Hi All,
While writing a grammar for programs written in the Racket language, I have stumbled upon a problem.
In Racket #| starts a multiline comment and |# ends it.
The problem is that multiline comments can be nested:
#| a comment #| still a comment |# even more comment |#
Here is my non-working attempt:
repository: multilinecomment: begin: #| end: |# name: comment contentName: comment patterns: - include: "#multilinecomment" name: comment - match: ([^|]||(?=[^#]))* name: comment
The intent of the match patterns are:
"#multilinecomment" A multiline comment can contain another multiline comment.
([^|]||(?=[^#]))* The meaning of the subexpressions:
[^|] any characters not an `|` |(?=[^#]) an `|` followed by a non-`#`
The entire expression thus matches a string not containg |#
Is it possible to match nested multiline comments correctly?
-- Jens Axel Søgaard