[antlr-interest] Multiple Language Lexers - Single Parser

Jim Idle jimi at temporal-wave.com
Thu Aug 25 10:18:42 PDT 2011


You mean you want to switch languages on the fly or just use one or the other? If the latter just make a copy of the English one and change to german as you did below and call it another name. Then just invoke the one you want. 

To make the token numbers the same, generate the tokens with the English version then use the tokenVocab option in both levers. 

Jim

On Aug 25, 2011, at 6:00, Daniel Rippel <drippel at yahoo.com> wrote:

> 
> 
> I have a situation where I would like multiple lexers to feed the same parser.
> In particular I would like to have lexers that allow a user to write code in their native language.
> 
> For example, an English lexer would define
> IF : 'if' ;
> 
> WHILE : 'while' ;
> 
> A German lexer might have (and this is just a babefish lookup)
> 
> IF : 'wenn';
> WHILE : 'wahrend';
> 
> Ideally, these lexers should be able to feed the same parser.
> 
> I was wondering what the best approach would be in Antlr.  Any pointers or tips would be appreciated.
> 
> 
> This may be a newby question but I could not find answer in the FAQs or recent mail archives.
> 
> Thanks,
> Dan
> 
> List: http://www.antlr.org/mailman/listinfo/antlr-interest
> Unsubscribe: http://www.antlr.org/mailman/options/antlr-interest/your-email-address


More information about the antlr-interest mailing list