Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Switching Antlr lexer modes from parser

Tags:

antlr

antlr4

How to control switching Antlr lexer modes from parser actions? I extended the generated Parser and Lexer so I can call pushMode and popMode from parser witch in turn call suitable pushMode and popMode of lexer but with no effect. Is there any thing I can do to activate this functionality?

like image 368
Angie Avatar asked Sep 25 '13 06:09

Angie


1 Answers

Your lexer should be written such that the input can be completely tokenized before the parser is even created. Even though the token stream is lazily filled, ANTLR 4 is not guaranteed to correctly parse the input if your lexer does not meet this requirement.

like image 68
Sam Harwell Avatar answered Oct 10 '22 03:10

Sam Harwell