[antlr-interest] Rewriting to Flat Tree Nodes for Associative Multiary Operators

Gavin Lambert antlr at mirality.co.nz
Fri Oct 3 03:02:02 PDT 2008


At 11:04 3/10/2008, Randall R Schulz wrote:
 >op790FormulaFlat
 >    :   (op780FormulaFlat -> op780FormulaFlat)
 >    (
 >        ( Or rDisjuncts = op790FormulaFlat) + )
 >    ->  ^(Or $op790FormulaFlat $rDisjuncts+)
 >    ) ?
 >    ;

That's a completely different form from what Jim suggested (for 
starters, it uses recursion within an iterative loop, which can 
cause complications).

Try this instead:

op790FormulaFlat
   :  (a=op780FormulaFlat -> op780FormulaFlat)
      ( (Or b+=op780FormulaFlat)+ -> ^(Or $a $b+) )?
   ;



More information about the antlr-interest mailing list