In
http://www.antlr.org/wiki/display/ANTLR3/1.+Lexer we have predicate:
TAG_START_OPEN : '<' { tagMode = true; } ;
TAG_END_OPEN : '</' { tagMode = true; } ;
TAG_CLOSE : { tagMode }?=> '>' { tagMode = false; } ;
TAG_EMPTY_CLOSE : { tagMode }?=> '/>' { tagMode = false; } ;
Variable
tagMode is set when detect lexical symbol. It is possible to set variable
in syntax or even semantic level and use this variable on lexical level?
Is two problems:
First: It not works in multiprocessing compiler: first pass lexical, second syntax, third semantics
If even all will be in one pass, it is second problem: lookahead, compiler looks for example 6 symbols ahead to distinguish between two productions, if look ahead it can't apply predicates which depends on symbols close to ahead.