Open rljacobson opened 10 months ago
Presumably somewhere an incorrect assumption is made about whether some regex matches newlines... It might be a case of the classic gotcha for the behavior of the
.
regex operator.
https://github.com/paul-kline/bnf-playground/blob/main/ts/bnf.ne#L38C12-L38C25
often a regex for multiline comments has a subexpression similar to
[^*] | \\[*] | [*][^/] | [*]$ | …
somewhere
https://github.com/kach/nearley/issues/42#issuecomment-63849550
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] | [^*] | \\[*] | [*][^/] | [*]$ | …