Problem
Multiline comments appear to not work correctly. Example:
/*
This is a multiline comment.
*/
<gpa> ::= "4.0" | <leading> "." <trailing>
<leading> ::= [0-3]
<trailing> ::= [0-9]
Output:
Uhoh, looks like you have an error: Error: Syntax error at line 2 col 0:
1 /*
2 This is a multiline comment.
^
Unexpected "\n". Instead, I was expecting to see one of the following:
A character matching /./ based on:
comment$ebnf$1 → ● /./ comment$ebnf$1
comment → comment$string$1 ● comment$ebnf$1 comment$string$2
rule → ● comment
bnf → ● rule
A "*" based on:
comment$string$2 → ● "*" "/"
comment → comment$string$1 comment$ebnf$1 ● comment$string$2
rule → ● comment
bnf → ● rule
Solution (maybe)
Presumably somewhere an incorrect assumption is made about whether some regex matches newlines. Here are a couple of possibilities.
It might be a case of the classic gotcha for the behavior of the . regex operator. The docs for JavaScript regexes say:
Note that the m multiline flag doesn't change the dot behavior. So to match a pattern across multiple lines, the character class [^] can be used — it will match any character including newlines.
The s "dotAll" flag allows the dot to also match line terminators.
Alternatively, often a regex for multiline comments has a subexpression similar to [^*] | \\[*] | [*][^/] | [*]$ | … somewhere. If you don't want to think too hard about it, just throw in another alternative matching a newline: [\n\r\f] | [^*] | \\[*] | [*][^/] | [*]$ | …
Problem
Multiline comments appear to not work correctly. Example:
Output:
Solution (maybe)
Presumably somewhere an incorrect assumption is made about whether some regex matches newlines. Here are a couple of possibilities.
It might be a case of the classic gotcha for the behavior of the
.regex operator. The docs for JavaScript regexes say:Alternatively, often a regex for multiline comments has a subexpression similar to
[^*] | \\[*] | [*][^/] | [*]$ | …somewhere. If you don't want to think too hard about it, just throw in another alternative matching a newline:[\n\r\f] | [^*] | \\[*] | [*][^/] | [*]$ | …