[antlr-interest] How to assign diff ids to same literal when importing grammars?

Prashant Deva prashant.deva at gmail.com
Wed Mar 16 02:39:49 PST 2005


I got 2 lexers which contain the keyword 'public' in the literals
section. i import the grammar of lexer B into A. Now the problem is
that the token id assigned to the 'public' keyword in the generated
'ATokenTypes' is the same.
eg -
Literal_public = 14;
But while runtime i will be switching between the 2 lexers while
lexing. So i want the parser to see a different id when the 'public'
comes from lexer A and when it comes from lexer B.
So i want it to be something like this is the generated ATokenTypes file - 
Key_A_Public =15;
Key_B_Public = 16;

How do i do this?


More information about the antlr-interest mailing list