[antlr-interest] forcing parenthesis (no precedence)
David-Sarah Hopwood
david-sarah at jacaranda.org
Thu Jul 16 07:48:21 PDT 2009
hakan eryargi wrote:
> thank you but i can't get it. simply making AND's and OR's have same
> precedence doesnt force user to use parentheses.
Try this:
tokens {
OR = '|';
AND = '&';
LPAREN = '(';
RPAREN = ')';
}
expr
: primaryExpr ((OR^ primaryExpr)+ | (AND^ primaryExpr)+)?
;
primaryExpr
: LPAREN expr^ RPAREN
| simpleExpr
;
--
David-Sarah Hopwood ⚥ http://davidsarah.livejournal.com
More information about the antlr-interest
mailing list