[antlr-interest] AST for repeated occurrences of binary operators

David-Sarah Hopwood david-sarah at jacaranda.org
Tue Nov 24 12:37:40 PST 2009


Jim Idle wrote:
> expr : ^(OR expr expr)
>      | ^(AND expr expr)
>      | atoms
>      ;

That's not equivalent; you want just

  expr : andExpr (^OR andExpr)*;

> The important thing here is that I want it to skip straight to andExpr in case there is no OR token.

The above syntax will do that.

-- 
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/20091124/4c06c02d/attachment.bin 


More information about the antlr-interest mailing list