Re: Grammar with low-precedence postfix operator?

Kaz Kylheku <kaz@kylheku.com>
Mon, 9 Feb 2015 01:24:43 +0000 (UTC)

          From comp.compilers

Related articles
Grammar with low-precedence postfix operator? rljacobson@gmail.com (Robert Jacobson) (2015-02-05)
Re: Grammar with low-precedence postfix operator? kaz@kylheku.com (Kaz Kylheku) (2015-02-05)
Re: Grammar with low-precedence postfix operator? anton@mips.complang.tuwien.ac.at (2015-02-07)
Re: Grammar with low-precedence postfix operator? rljacobson@gmail.com (Robert Jacobson) (2015-02-07)
Re: Grammar with low-precedence postfix operator? monnier@iro.umontreal.ca (Stefan Monnier) (2015-02-08)
Re: Grammar with low-precedence postfix operator? kaz@kylheku.com (Kaz Kylheku) (2015-02-09)
Re: Grammar with low-precedence postfix operator? DrDiettrich1@netscape.net (Hans-Peter Diettrich) (2015-02-09)
Re: Grammar with low-precedence postfix operator? jgk@panix.com (2015-02-10)
Re: Grammar with low-precedence postfix operator? kaz@kylheku.com (Kaz Kylheku) (2015-02-11)
Re: Grammar with low-precedence postfix operator? rljacobson@gmail.com (Robert Jacobson) (2015-02-21)
| List of all articles for this month |
From: Kaz Kylheku <kaz@kylheku.com>
Newsgroups: comp.compilers
Date: Mon, 9 Feb 2015 01:24:43 +0000 (UTC)
Organization: Aioe.org NNTP Server
References: 15-02-006 15-02-018
Keywords: parse, comment
Posted-Date: 08 Feb 2015 22:08:49 EST

On 2015-02-08, Stefan Monnier <monnier@iro.umontreal.ca> wrote:
>> term
>> : INT
>> | '(' expr ')' //parentheses
>> | <assoc=right> 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]


Post a followup to this message

Return to the comp.compilers page.
Search the comp.compilers archives again.