Re: Grammar with low-precedence postfix operator?

jgk@panix.com (Joe keane)
Tue, 10 Feb 2015 21:03:24 +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: jgk@panix.com (Joe keane)
Newsgroups: comp.compilers
Date: Tue, 10 Feb 2015 21:03:24 +0000 (UTC)
Organization: Public Access Networks Corp.
References: 15-02-006 15-02-014
Keywords: parse, design
Posted-Date: 10 Feb 2015 20:47:30 EST

Anton Ertl <anton@mips.complang.tuwien.ac.at> wrote:
>For your example involving ^ and ++, I think that one should use
>parentheses explicitly in most cases, e.g. (a^b)++^c or a^(b++)^c.
>You can leave away the parentheses if there is no ambiguity, as in
>your 2++^3, but that's not straightforward to express in BNF.


gcc does something like this


You can say:


if (x & y == 0)


probable error, warn or reject


if ((x & y) == 0)


OK


if (x & (y == 0))


OK, if that's what you want


I don't know how it is implemented.


if (x == 1 && y == 2)


fine IMHO


if ((x == 1) && (y == 2))


too many parens


if (((x >= 1) && (x <= 2)) || ((y >= 1) && (y <= 2)))


way too many parens IMHO, but shouldn't reject


The reason you don't want to reject these is that,
besides that it's style, they could come from macros.


If you color parens in macros, you could also look out for macros:


#define SUM(X, Y) (X)+(Y)


probable error


#define DOUBLE(X) (2*X)


probable error


Post a followup to this message

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