[antlr-interest] ANTLR 3 Lexical States

Bertalan Fodor lilypondtool at organum.hu
Fri Jan 25 12:06:23 PST 2008



> What is it you are trying
> to parse?
It is the LilyPond grammar.

I think this example will explain:

In 'initial' state the \w+ words mean variables, so if you read var, there should be a 'var' variable defined.
However, in an other state, let's call it 'markup' everything is allowed and interpreted as string literals: 
\markup { everything can go here, even +- and whatever 
In this mode you can switch to another mode with a command like this: \normalMode { var },  }

So lexical states can be nested.

I'm going to be afraid that antlr 3 won't really suit.

Bert


More information about the antlr-interest mailing list