Can lexer depends on the syntax?

18 views
Skip to first unread message

Andrzej Borucki

unread,
Jan 4, 2013, 3:58:33 AM1/4/13
to antlr-di...@googlegroups.com
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.

Reply all
Reply to author
Forward
0 new messages