[antlr-interest] Switching between different lexers from within parser

Remi Koutcherawy remi.koutcherawy at wanadoo.fr
Sat Jan 26 02:17:15 PST 2002


Hi, sorry this text seems to have been cancelled from my preceding mail.

> is there a possibility to switch in a clean and deterministic way
> beetween different lexers from within the *parser*?

I am doing that. (Maybe not so clean as expected and intented)
I join a short working example.

A main_parser switches in its grammar to a B_parser with a B_lexer.
This B_parser returns to the main_parser when it gets an unexpected token.

My main problem was to return from the B_lexer,
*without* consuming the unrecognized tokens.

By the way, I had a look at the generated code, and add some "missing" code in the grammar.
 parse_AST = (AST)currentAST.root;
These variables are not declared in the .g they come from the generated code, so they look like a
hack in the grammar ;-)
This line lacks in the generated code (only for this use, no rush to correct the generator).

Rémi



 

Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/ 



More information about the antlr-interest mailing list