WS : [ \t]+ -> skip ; // skip spaces, tabs
Works well to ignore white space by preventing those characters from reaching the parser. I want to do the same thing with character pair of '/' and newline. That is, backslash-newline are removed like other white space allowing a single statement to have embedded newlines.
I am trying variations of
ESC_NEWLINE : '\\'NEWLINE ; NEWLINE : '\r'? '\n'; WS : ([ \t]+ | ESC_NEWLINE) -> skip ;
but this does not skip ESC_NEWLINE. I don't know what other approach to take.
When you do:
the
WSrule will never match aESC_NEWLINE. Lexer rules are matched in the following way:This means that the input
\\n(slash + new line) will always be matched as aESC_NEWLINErule, never as aWSrule.The solution: let
ESC_NEWLINEskip itself:Or remove
ESC_NEWLINE: