[antlr-interest] ANTLR 3 Lexical States

Bertalan Fodor (LilyPondTool) lilypondtool at organum.hu
Fri Jan 25 02:21:06 PST 2008


My Antlr grammar I'm migrating to Antlr 3 heavily uses lexical states, 
that is, the Lexer has lots of semantic predicates to distinguish 
between alternatives like this
STRING: {inState(States.NORMAL)}? LETTER+
SPECIAL_STRING: {inState(States.SPECIAL)}? LETTER+

The states are set during the parse process, like this
special_handling: "\special" { setState(States.SPECIAL); } SPECIAL_STRING;

It worked perfectly well in Anltr 2. However, now I'm a bit afraid that 
the Antlr 3 style lexing will make this not work.

What do you think?

Thank you,

Bertalan Fodor

-- 
LilyPondTool is the editor for LilyPond files.
See http://lilypondtool.organum.hu



More information about the antlr-interest mailing list