sexp-grammar icon indicating copy to clipboard operation
sexp-grammar copied to clipboard

Add support for block comments and datum comments

Open lortabac opened this issue 2 years ago • 2 comments

Really amazing library!

The only feature that is missing for me is support for the other two comment syntaxes. From the Chez Scheme documentation at https://scheme.com/tspl4/intro.html#./intro:h1

Block comments are delimited by #| and |# pairs, and may be nested. A datum comment consists of a #; prefix and the datum (printed data value) that follows it. Datum comments are typically used to comment out individual definitions or expressions. For example, (three #;(not four) element list) is just what it says. Datum comments may also be nested, though #;#;(a)(b) has the somewhat nonobvious effect of commenting out both (a) and (b).

What do you think?

lortabac avatar May 14 '22 13:05 lortabac

Thanks!

I am a bit betwixt and between -- supporting block and datum comments definitely add convenience but on the other hand, it seems like it might add some complexity.

Would you like to play around with alex and happy to enable such comments? If the implementation turns out to be simple enough, I'd be happy to merge it.

For datum comments we'd need a new type of lexeme and a parser production that matches that lexeme followed by an S-expression producing nothing. But for block comments, we'd have to modify the lexer in a slightly more intricate way, adding some state for counting nested blocks, etc.

esmolanka avatar May 16 '22 23:05 esmolanka

Closed by accident, reopened since there's also block comments part that is not yet addressed.

esmolanka avatar May 22 '22 20:05 esmolanka