[antlr-interest] Re: Adding parenthesis to the calc grammer

Bryan Ewbank ewbank at gmail.com
Tue Mar 1 09:57:51 PST 2005


Eran pointed out that my code didn't work.  I'd missed part of the
discussion of semantic predicates.

To accept the tree, but not evaluate it, you must provide an alternate
that eats the tree but bypasses evaluation of that tree:

eval returns [bool result]
    :
        #(AND
            result = eval
            (
                {result==true}? result=eval
            |
                . // skip processing
            )
        )
    |
        #(OR
            result = eval
            (
                {result==false}? result=eval
            |
                . // skip processing
            )
        )
    | TRUE_  {result = 1;}
    | FALSE_ {result = 0;}
    ;


More information about the antlr-interest mailing list