Re: ANSI C grammar without shift-reduce conflict on 'ELSE'

anton@mips.complang.tuwien.ac.at (Anton Ertl)
Mon, 10 Dec 2007 10:08:51 GMT

          From comp.compilers

Related articles
ANSI C grammar without shift-reduce conflict on 'ELSE' ggrares@yahoo.com (Rares GalaN) (2007-12-09)
Re: ANSI C grammar without shift-reduce conflict on 'ELSE' cbarron3@ix.netcom.com (2007-12-09)
Re: ANSI C grammar without shift-reduce conflict on 'ELSE' gah@ugcs.caltech.edu (glen herrmannsfeldt) (2007-12-09)
Re: ANSI C grammar without shift-reduce conflict on 'ELSE' anton@mips.complang.tuwien.ac.at (2007-12-10)
Re: ANSI C grammar without shift-reduce conflict on 'ELSE' anton@mips.complang.tuwien.ac.at (2007-12-10)
Re: ANSI C grammar without shift-reduce conflict on 'ELSE' monnier@iro.umontreal.ca (Stefan Monnier) (2007-12-12)
| List of all articles for this month |

From: anton@mips.complang.tuwien.ac.at (Anton Ertl)
Newsgroups: comp.compilers
Date: Mon, 10 Dec 2007 10:08:51 GMT
Organization: Institut fuer Computersprachen, Technische Universitaet Wien
References: 07-12-021 07-12-022
Keywords: C, yacc
Posted-Date: 10 Dec 2007 10:43:01 EST

cbarron3@ix.netcom.com (Carl Barron) writes:
>See bison.info-3.
>--quote--
[...]
> But if the parser chose to reduce when possible rather than shift,
>the result would be to attach the else-clause to the outermost
>if-statement, making these two inputs equivalent:
>
> if x then if y then win (); else lose;
>
> if x then do; if y then win (); end; else lose;
>--end quote


I believe that this is incorrect: If the parser chose to reduce, it
would never shift an ELSE, and therefore would report a syntax error
when confronted with an IF statement containing an ELSE clause.


- anton
--
M. Anton Ertl
anton@mips.complang.tuwien.ac.at
http://www.complang.tuwien.ac.at/anton/



Post a followup to this message

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