[antlr-interest] Re: Using different tokens for the same grammar

mzukowski at yci.com mzukowski at yci.com
Fri Jun 14 10:14:40 PDT 2002


Antlr looks up literals in a hash map called literals in the lexer.  It
would be pretty easy for you to add an initialization routine that loaded in
more entries, say for French and Spanish.  The easiest way would probably be
to re-use the *TokenTypes.txt file, translated to whatever language, and
just parse it and load it into the table.

Monty

> -----Original Message-----
> From: dspiess_mk [mailto:dj at gamethingy.com]
> Sent: Thursday, June 06, 2002 2:01 PM
> To: antlr-interest at yahoogroups.com
> Subject: [antlr-interest] Using different tokens for the same grammar
> 
> 
> Hi, 
> I've inhierted a project that uses antlr, and I am trying to localize 
> the application. Is there an easy way to swap out what the valid 
> tokens are, but keep the grammar the same? 
> 
> For example our application builds mathematical expressions for 
> evaluation. The English version has a function called average(i, 
> i2, ...) where the user specifies the function average and several 
> parameters. In French, this needs to be moyenne(i, 12, ...). The 
> parsing is the same, just the keyword is different. 
> 
> Is there a way to specify the tokens at runtime instead of compile 
> time? I really don't want to have to support different compiles for 
> each localized version of our java app. 
> 
> Thanks for any help! 
> 
> Daniel Spiess
> 
> 
> 
> 
> 
>  
> 
> Your use of Yahoo! Groups is subject to 
> http://docs.yahoo.com/info/terms/ 
> 
> 
> 

 

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



More information about the antlr-interest mailing list