[antlr-interest] Modifying token type within parser
Jeff Dahl
jddahl at micron.com
Wed Jul 13 07:48:31 PDT 2005
Ric Klaren wrote:
>On 7/12/05, Jeff Dahl <jddahl at micron.com> wrote:
>
>
>>Is it possible to modify the token type within the parser?
>>
>>I tried:
>>
>> parser_rule: t:TOKEN {t.setType(OTHER_TOKEN);}
>>
>>but, the actual token passed up is still of type TOKEN.
>>
>>
>
>If you're trying to build a tree with a different token type just use
>the AST construction syntax to add the appropriate token to the AST
>(might have to turn automatic construction of for the rule).
>
>
Good point! Thanks for the help. Your solution works perfectly.
Jeff
More information about the antlr-interest
mailing list