Not that I'm aware of. However, I have found that having all of my tokens in one place has been very helpful for debugging and refactoring, as well as simply presenting a clear picture of the grammar.
-Jared chain one wrote: > Hi Jared Bunting: > > Thanks for your quick response. > Your suggestion must work. But there are so many tokens just like > 'ONEOF' in my grammar right now, to explicitly define all of this > kind of tokens is quiet a bit boring. > I am wondering if there is another way to do this? If not, I will > define them : ) > > > 2008/12/2 Jared Bunting <[EMAIL PROTECTED] > <mailto:[EMAIL PROTECTED]>> > > I can't see your grammar, but I believe that the "T__N" tokens are > generated when you define lexical tokens directly in your parser > rules. So basically, define it explicitly in the tokens section > rather than in a parser rule. Then, it will have a name. > -Jared > > chain one wrote: > > 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 > > ------------------------------------------------------------------------ > > > List: http://www.antlr.org:8080/mailman/listinfo/antlr-interest > Unsubscribe: > > http://www.antlr.org:8080/mailman/options/antlr-interest/your-email-address > > > > List: http://www.antlr.org:8080/mailman/listinfo/antlr-interest Unsubscribe: http://www.antlr.org:8080/mailman/options/antlr-interest/your-email-address --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "il-antlr-interest" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/il-antlr-interest?hl=en -~----------~----~----~----~------~----~------~--~---
