BenjaminSchaaf / sbnf

A BNF-style language for writing sublime-syntax files
MIT License
58 stars 6 forks source link

Preserve newlines in whitespace-insensitive regexes #43

Closed eugenesvk closed 1 year ago

eugenesvk commented 1 year ago

I was trying to use a whitespace insensitive mode to comment regexes (which is especially needed since some rules don't compose properly, so long literal regexes are required)

VAR='(?x)
some  # regex
with # comments
'

But then on compilation when Sbnf automatically lookahead regex (?=(?x)some #regex...) for some of its rules, it doesn't preserve newlines, so the regex becomes invalid due to # comments, and the syntax becomes invalid as well

Or removing the comments is also fine

BenjaminSchaaf commented 1 year ago

Seems I misunderstood this issue. The newlines are being preserved, but because we're writing the regex as a string into yaml the comment becomes part of the yaml string and thus breaks.