[antlr-interest] (newbie problem)reference to rewrite element name without re...

Randall R Schulz rschulz at sonic.net
Mon Jul 9 16:53:00 PDT 2007


On Monday 09 July 2007 16:43, ali azimi wrote:
> Hi,
>
>   I apologize for my grammar being cluttered. I will try to use
> underscore more often.

That's soooo 1980s! Get with the interCap / camelCase program!!


>   Do I have to write different rewrite rules for each sub-rule like
> the followings?
>
>   signal_list_item
>               :signal_identifier-> ^(signal_identifier)
>               |signal_list_identifier-> ^(signal_list_identifier)
>               |timer_identifier-> ^(timer_identifier)
>               ;
>
>   Or this one is correct? (what is the difference?)
>
>   Rule2 signal_list_item
>
>               :( signal_identifier
>                |signal_list_identifier|timer_identifier)
>               -> ^(SLIST[$signal_list_item.start ] signalidentifier signal_list_identifier
>                    timer_identifier)

The answer depends on the rewrite you need to perform, but it looks like
the answer is probably "yes," in this case. Offhand, my guess would be
that in most cases, you'll be creating a separate rewrite for each distinct
right-hand side.


>   Thanks,
>
>   Al


Randall Schulz


More information about the antlr-interest mailing list