I have an ANTLR JavaScript grammar (taken from the Internet), which seem to support everything except for regex literals.

The problem with a regex literal is that you have two rules, essentially:

multiplicativeExpression
    : unaryExpression (LT!* ('*' | '/' | '%')^ LT!* unaryExpression)*

and

regexLiteral
    : '/' RegexLiteralChar* '/'

where the rule RegexLiteralChar uses different lexer rules than a normal expression (eg. a double quote does not terminate it).

This means that I need to, in some way, change some kind of lexer state from my parser. How can I do this? Is it even possible?

Edit
Report