[antlr-interest] Rewriting a list of tokens to a list of custom tokens

Jim Idle jimi at temporal-wave.com
Wed Oct 19 08:40:51 PDT 2011


t1+='void' (t2+='*')* -> ^(LIST TYPE[$t1]+ TYPE[$t2]+)

By interpolating from your question. At least, that should get you on the
right track.


Jim

> -----Original Message-----
> From: antlr-interest-bounces at antlr.org [mailto:antlr-interest-
> bounces at antlr.org] On Behalf Of Christian
> Sent: Wednesday, October 19, 2011 5:40 AM
> To: antlr-interest at antlr.org
> Subject: [antlr-interest] Rewriting a list of tokens to a list of
> custom tokens
>
> Hello ANTLR community,
>
> I want to get
>
>     t+='void' (t+='*')*
>
> to a list of a custom token type, say TYPE. That is, each element/token
> of the list should change its original type to the type TYPE.
> The following approach does not work because invalid java code is
> generated:
>
>     t+='void' (t+='*')* -> ^(TYPE[$t]+)
>
> The following implicit list generation works fine, however each element
> retains its original type:
>
>     t+='void' (t+='*')* -> ^($t+)
>
> Can anyone tell me, whether and how this could be done?
>
> Thanks in advance,
> Christian
>
> List: http://www.antlr.org/mailman/listinfo/antlr-interest
> Unsubscribe: http://www.antlr.org/mailman/options/antlr-interest/your-
> email-address


More information about the antlr-interest mailing list