[antlr-interest] AST for repeated occurrences of binary operators
David-Sarah Hopwood
david-sarah at jacaranda.org
Tue Nov 24 20:24:29 PST 2009
Jim Idle wrote:
> David-Sarah Hopwood wrote:
>> Caetano Sauer wrote:
>>> What I want is (OR a b c).
>>
>> I think that will be produced by:
>>
>> orExpr : andExpr (^OR andExpr (OR! andExpr)*)?;
>
> expr : ae+=andExpr (OR ae+=andExpr)* -> ^(OR $ae+) ;
That isn't what the poster asked for: it will produce '(OR a)' when
the input is an andExpr, whereas what I posted above should produce
just 'a', if I haven't made a mistake.
> But usually that isn't the best way to organize the tree and:
>
> expr : andExpr (^OR andExpr)*;
>
> Is what is needed.
I agree. For binary operators, a binary AST is easier to deal with.
--
David-Sarah Hopwood ⚥ http://davidsarah.livejournal.com
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 292 bytes
Desc: OpenPGP digital signature
Url : http://www.antlr.org/pipermail/antlr-interest/attachments/20091125/24006c16/attachment.bin
More information about the antlr-interest
mailing list