Daily dose of nothing presents

Barely Even Structured Text (BEST)

When implementing a toy programming runtime, I tried to implement my “language” as a stack of simple layers.

Today, I'd like to describe the bottom of the stack, Barely Even Structured Text or BEST.

Intended as a lightweight (but not strictly minimal) layer, its design can be summarized in a few choices:

Here is the full description:

Spaces are separators outside of double quotes and escape sequences.

Strings are prefixed by ' or delimited by ".

The rest is symbols. They can be prefixed by \', or delimited by \" and ".

Quoting is preserved by parsers and printers, and meaningful in some circumstances (eg in STOR, [ starts a vector but \'[ does not).

\ can be used to escape:

For example, in:

A 'world \'of "dew"

A and of are symbols, the latter single-quoted. world and dew are strings, the latter double-quoted.

Here are 3 strings:

'A\ single\ string
"On each line"
"This one\nis two lines"

Single-quoted strings end before any unescaped space, whereas double-quoted strings only end before an unescaped double-quote, so this is a fine string too:

"A direct line
break works, so do
escaped quotes like \"!"

The naïve, probably bug-ridden implementation of parsing and printing fits in 200 lines of Nim code.

Looking forward to describing the layers above: