Picolab / pico-engine

An implementation of the pico-engine hosted on node.js
http://picolabs.io/
MIT License
43 stars 8 forks source link

The compiler ought to handle an ambiguous closing chevron quote differently #588

Closed b1conrad closed 2 years ago

b1conrad commented 2 years ago

Chevron-quoted strings are particularly useful in generating HTML, or other language which contain double quote characters. Some examples:

<<<option#{e==el => " selected" | ""}>#{e}</option>
>>

Notice that the closing chevron quote is on a new line. This is because the compiler handles the ambiguous >>> as closing the quote and then seeing a > instead of including the > at the end of the quote and then closing it.

b1conrad commented 2 years ago

Currently, the KRL programmer has to disambiguate as either

>> >

or

> >>

as the compiler will choose the former interpretation if there is no white space in a sequence of three (or more) greater than signs.

We would like the compiler to close the quote on the last two of three or more contiguous greater than signs.

b1conrad commented 2 years ago

Doh. The language already provides a way to specify the case that I was worried about.

<< ... \>>>

Escaping a trailing greater than sign will include it as the last character of a chevron quoted string.

See the Extended Quoting page in the Escaping section.

b1conrad commented 2 years ago

Closing this, as there is the backslash to escape the inner closing angle bracket.