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

Helmut Neukirchen neukirchen at itm.mu-luebeck.de
Mon Jan 28 09:54:17 PST 2002


Remi Koutcherawy wrote:

> Hi,
> 
> 
>>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.


What about a Main_Parser with a larger lookahead or syntactic predicates
which makes the Main_Lexer consume characters which were intended for B_Lexer?
Wouldn't you also need some mechanisms to prevent the Main_Lexer from
consuming B_lexer tokens? I.e. add your exception stuff also to the
Main_Lexer. (For my problem this wouldn't help anyway since there might be
an overlap of tokens between the different lexers.)

Helmut
-- 
Helmut Neukirchen                   mailto:neukirchen at itm.mu-luebeck.de
Institute for Telematics                   http://www.itm.mu-luebeck.de
Medical University of Luebeck                   phone: +49 451 500 4867
Ratzeburger Allee 160, D-23538 Luebeck, Germany   fax: +49 451 500 3722


 

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



More information about the antlr-interest mailing list