[antlr-interest] How do I use a custom token object?

Johannes Luber jaluber at gmx.de
Wed Jul 23 10:09:24 PDT 2008


Tom MacEllen schrieb:
> Hi there,
> 
> I have got a question about the wiki entry "How do I use a custom token object?" (found under http://www.antlr.org/wiki/pages/viewpage.action?pageId=1844).
> 
> In the example the custom token class is extended with the integer x.
> But the setting of the value of the field x is hard-coded in the emit method.
> 
> Is there a way to alter this value from the action in the grammar.
> Something like:
> ID : 'a'..'z'+  {/* set the integer x from here */};
> INT : '0'..'9'+ {/* and here */};
> 
> I am just curious if that is possible?

Doesn't ID.x or INT.x work?

Johannes
> 
> Thanks in advance
> Tom
> 



More information about the antlr-interest mailing list