[antlr-interest] Rewrite rule question

Jim Idle jimi at temporal-wave.com
Mon Feb 18 13:37:39 PST 2008


> -----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





More information about the antlr-interest mailing list