Switching Antlr lexer modes from the parser

How to control the switching of Antlr modes to parser actions? I expanded the created Parser and Lexer so that I could call pushMode and popMode from the parser, which in turn calls the appropriate pushMode and popMode dictionary, but without effect. Is there anything I can do to activate this functionality?

+6
source share
1 answer

Your lexer should be written in such a way that the input can be completely marked before the parser is even created. Despite the fact that the token stream is lazily full, ANTLR 4 does not guarantee a correct input analysis if your lexer does not meet this requirement.

+7
source

Source: https://habr.com/ru/post/954556/


All Articles