[antlr-interest] Rewrite rule question
Jamie Penney
jpen054 at ec.auckland.ac.nz
Mon Feb 18 14:07:17 PST 2008
Jim Idle wrote:
>> -----Original Message-----
>> From: Jamie Penney [mailto:jpen054 at ec.auckland.ac.nz]
>> Sent: Monday, February 18, 2008 1:32 PM
>> I have a set of rewrite rules like so:
>> primary_expression :
>> (literal | simple_name | ... )
>> (DOT IDENTIFIER some_rule -> ^(PRIMARY_EXPRESSION
>>
> $primary_expression DOT IDENTIFIER type_argument_list_handler)
>
>> | ... )*
>>
>> If there are none of the last group, then no rewrite rule is
>>
> triggered.
>
>> If I specify a rewrite rule on the first group, will the rewrite rules
>> in the second group overwrite the ones from the first if they are
>> triggered (this is the behaviour I want)?
>>
>
> Yes. But you may find that you have to supply rewrites for the other
> alts when you supply a rewrite for one of them. You could place that in
> a subrule if you want to avoid having to do that.
>
> Jim
That should be fine. I am trying to preserve the existing rewrite rules
if I can.
Thanks,
Jamie Penney
More information about the antlr-interest
mailing list