[antlr-interest] How to define multi and div?

Bryan Ewbank ewbank at gmail.com
Sat Dec 10 11:35:46 PST 2005


Others have covered left-to-right tree construction pretty well - very
nice tutorial, too.

For completeness, right-to-left evaluation is handled by rule recursion, rather
than by a while-loop within the rule:

    left_to_right:  operand ( OPERATOR^ operand )* ;
    right_to_left:  operand ( OPERATOR^ right_to_left )? ;
    shared_l_to_r:  operand ( ( OPER1^ | OPER2^ ) operand )*;
    shared_r_to_l:  operand ( ( OPER1^ | OPER2^ ) shared_r_to_l )?;

Hope this helps,
- Bryan


More information about the antlr-interest mailing list