Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!usenet.blueworldhosting.com!feeder01.blueworldhosting.com!border2.nntp.dca1.giganews.com!nntp.giganews.com!news.iecc.com!.POSTED!nerds-end From: Robert Jacobson Newsgroups: comp.compilers Subject: Re: Grammar with low-precedence postfix operator? Date: Sat, 21 Feb 2015 12:55:52 -0800 (PST) Organization: Compilers Central Lines: 21 Sender: news@iecc.com Approved: comp.compilers@iecc.com Message-ID: <15-02-032@comp.compilers> References: <15-02-006@comp.compilers> NNTP-Posting-Host: news.iecc.com Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 8bit X-Trace: miucha.iecc.com 1424576248 9034 2001:470:1f07:1126:0:676f:7373:6970 (22 Feb 2015 03:37:28 GMT) X-Complaints-To: abuse@iecc.com NNTP-Posting-Date: Sun, 22 Feb 2015 03:37:28 +0000 (UTC) Keywords: parse Posted-Date: 21 Feb 2015 22:37:28 EST X-submission-address: compilers@iecc.com X-moderator-address: compilers-request@iecc.com X-FAQ-and-archives: http://compilers.iecc.com Xref: csiph.com comp.compilers:1534 Thank you everyone for your help. The solution I found for solving my language ambiguity uses ANTLR's semantic predicates feature which can turn off production alternatives at parse time. I use a predicate (below) to suppress implicit multiplication in the presence of a binary plus operator. expr : LEAF | LPAREN expr RPAREN //parentheses | expr POWER expr | (PLUS | MINUS) expr //unary plus/minus | expr { _input.LT(1).getType() != PLUS && _input.LT(1).getType() != MINUS}? expr //implicit multiplication | expr (DIV | MUL) expr //division and explicit multiplication | expr (PLUS | MINUS) expr //addition/subtraction | expr '&' //postfix parenthesization. ; Best regards, Robert