[antlr-interest] Rewrite Rules, inline to right side.
John Ridgway
john at jacelridge.com
Sun Mar 9 14:10:41 PDT 2008
Try it like this:
rule
: (b1=boolops -> $b1) (firstops b2=boolops -> ^(firstops $rule
$b2) )*
;
i.e., with parentheses around the first two things. I believe that
otherwise it treats the entire rest of the line as being what it's
going to output for the initial boolops.
I think you also ought to be able to simplify it to:
rule
: (boolops -> boolops) ( firstops b2=boolops -> ^(firstops
$rule $b2) )
;
Peace
- John
On Mar 9, 2008, at 4:17 PM, Shaun Bogan wrote:
> Thanks for the help.
> Unfortunately, Antlr returns an error when I use the rule you
> provided. It appears to not
> like the second = sign. Says unexpected token '='. I pasted exactly
> what you had and changed rule to the name of my rule (which is
> assignops).
>
> Shaun
>
>
> On Sun, Mar 9, 2008 at 1:56 PM, Johannes Luber <jaluber at gmx.de> wrote:
>> Shaun Bogan schrieb:
>>> Could someone tell me how to rewrite the following on the right-
>>> hand side:
>>> boolops (firstops^ boolops)*
>>>
>>
>> rule
>> : b1=boolops -> $b1 (firstops b2=boolops -> ^(firstops $rule
>> $b2) )*
>> ;
>>
>> should solve this.
>>
>> Johannes
>>
More information about the antlr-interest
mailing list