[antlr-interest] How the get the token value of 'ONEOF'

chain one chainone at gmail.com
Tue Dec 2 05:52:11 PST 2008


Hello:
I have a question about the token value, the question is :

In the generated Java file, the token values are defined in this way:
 public static final String[] tokenNames = new String[] {
        "<invalid>", "<EOR>", "<DOWN>", "<UP>","ENTITY_VAR_IDENT",
"RULE_ID","INTERVAL_ITEM","'ONEOF'"
    };
    public static final int ENTITY_VAR_IDENT=4;
    public static final int RULE_ID=5;
    public static final int INTERVAL_ITEM=6;
    public static final int T__7=7;



if I want to identify a token , I can type this:

Grammar:
{ input.LA(1)== ENTITY_VAR_IDENT}?

Generated Code:
int LA1_0 = input.LA(1);
if ( (LA1_0==ENTITY_VAR_IDENT) )
{
   alt1=1;
}


that is OK

But what if I want to check if the token is 'ONEOF'?
How could I know T__7 stands for 'ONEOF' and its value is 7?

Thanks for your help!
Best Regards,
chainone
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.antlr.org/pipermail/antlr-interest/attachments/20081202/d37d693e/attachment.html 


More information about the antlr-interest mailing list