Path: csiph.com!usenet.pasdenom.info!news.lightlink.com!news.iecc.com!.POSTED!nerds-end From: Kaz Kylheku Newsgroups: comp.compilers Subject: Re: Grammar with low-precedence postfix operator? Date: Mon, 9 Feb 2015 01:24:43 +0000 (UTC) Organization: Aioe.org NNTP Server Lines: 25 Sender: news@iecc.com Approved: comp.compilers@iecc.com Message-ID: <15-02-020@comp.compilers> References: <15-02-006@comp.compilers> <15-02-018@comp.compilers> NNTP-Posting-Host: news.iecc.com X-Trace: miucha.iecc.com 1423451329 7554 2001:470:1f07:1126:0:676f:7373:6970 (9 Feb 2015 03:08:49 GMT) X-Complaints-To: abuse@iecc.com NNTP-Posting-Date: Mon, 9 Feb 2015 03:08:49 +0000 (UTC) Keywords: parse, comment Posted-Date: 08 Feb 2015 22:08:49 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:1522 On 2015-02-08, Stefan Monnier wrote: >> term >> : INT >> | '(' expr ')' //parentheses >> | term '^' term //exponentiation >> | term term //implicit multiplication >> ; > >> expr >> : term >> | ('+' | '-') expr //unary plus/minus >> | expr ('/' | '*') expr //division and explicit multiplication >> | expr ('+' | '-') expr //addition/subtraction >> | expr '++' //increment >> ; > > This last production rule is wrong: "expr ++" should produce a "term", not > an "expr". If that is so, then ++ shall not have the desired low precedence. For instance a ^ b ++ be parsed as the exponentiation of two terms, a and b++, not as ++ applied to the expression a ^ b, as desired. [Oops, looks like you're right. -John]