Thanks Jim

In order to get the right tree I ended up with this:

rhs
        : a=rhs_alt (OR b=rhs)*
        ;


Sorry to labor the point here but what I keep failing to see is how you 
spec a rewrite rule for this kind of expression. I know the default gets 
me what I need but that's not quite the same as knowing :)

I do not want to use the list idiom Ter mentions in the book. Are 
sub-rules the only way to do it?

On 07/03/2011 15:25, Jim Idle wrote:
> rhs : rhs_alt ( OR^ rhs_alt )*;
>
>
>
>> -----Original Message-----
>> From: [email protected] [mailto:antlr-interest-
>> [email protected]] On Behalf Of [email protected]
>> Sent: Monday, March 07, 2011 6:33 AM
>> To: ANTLR Interest
>> Subject: [antlr-interest] V2 ->  V3 rules
>>
>> I've checked the Migration Wiki and it's a little unclear on how handle
>> the following. The general form is taken from bison.g:
>>
>> V2:
>>
>> rhs : rhs_alt
>>       { ## = #( [ALT, "alt"], #rhs ); }
>>       ( OR^ rhs_alt )*;
>>
>> V3:
>>
>> rhs : (a=rhs_alt ->  $rhs ) (OR b=rhs)*
>>       ;
>>
>> error(132) reference $rhs is ambiguous; rule rhs is enclosing rule and
>> referenced in the production (assuming enclosing rule)
>>
>> V3 - not even sure if this form is legal ...
>>
>> rhs : rhs_alt
>>           { $$ = $([OR,"or"],$rhs); }
>>         (OR^ rhs_alt)*
>>       ;
>>
>> error(117): missing attribute access on rule scope: rhs
>>
>> Thx++
>>
>> Jerry.
>>
>>
>>
>>
>> List: http://www.antlr.org/mailman/listinfo/antlr-interest
>> Unsubscribe: http://www.antlr.org/mailman/options/antlr-interest/your-
>> email-address
>
> List: http://www.antlr.org/mailman/listinfo/antlr-interest
> Unsubscribe: 
> http://www.antlr.org/mailman/options/antlr-interest/your-email-address
>



List: http://www.antlr.org/mailman/listinfo/antlr-interest
Unsubscribe: 
http://www.antlr.org/mailman/options/antlr-interest/your-email-address

-- 
You received this message because you are subscribed to the Google Groups 
"il-antlr-interest" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/il-antlr-interest?hl=en.

Reply via email to