[antlr-interest] grammar for boolean expressions

Gary Miller gary at sumwise.com
Tue Apr 12 00:06:15 PDT 2011


My two cents worth.
I prefer rewrites as I can create virtual tokens.

Regards
Gary

expr
    : or -> ^(EXPR or)
;

or : (and -> and)
    (
        OR b=and    -> ^( LOGICAL_OR $or $b )
    )*
;

and  : (atom -> atom)
    (
      AND b=atom -> ^(LOGICAL_AND $and $b)
    )*
;

atom
    : id
;

id        : ID;

ID : 'a'..'z';
AND : '&';
OR  : '|';


More information about the antlr-interest mailing list