Using different tokens for the same grammar
1 posts in topic
Flat View  Flat View
TOPIC ACTIONS:
 

Posted By:   Daniel_Spiess
Posted On:   Wednesday, June 5, 2002 12:37 PM

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    More>>

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

   <<Less

Re: Using different tokens for the same grammar

Posted By:   Monty_Zukowski  
Posted On:   Monday, June 10, 2002 10:02 AM

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.
About | Sitemap | Contact