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

Tom MacEllen tt.slot at mail.ru
Wed Jul 23 08:09:35 PDT 2008


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?

Thanks in advance
Tom


More information about the antlr-interest mailing list