Re: if then else shift/reduce Syndrome

Michael Meissner <meissner@cygnus.com>
16 Feb 1996 01:24:27 -0500

          From comp.compilers

Related articles
if then else shift/reduce Syndrome tarnwb@holly.colostate.edu (Tarn Burton) (1996-02-13)
Re: if then else shift/reduce Syndrome solution@gate.net (1996-02-13)
Re: if then else shift/reduce Syndrome tim@franck.Princeton.EDU (1996-02-13)
Re: if then else shift/reduce Syndrome mab@wdl.loral.com (1996-02-14)
Re: if then else shift/reduce Syndrome theo@engr.mun.ca (1996-02-16)
Re: if then else shift/reduce Syndrome meissner@cygnus.com (Michael Meissner) (1996-02-16)
Re: if then else shift/reduce Syndrome solution@gate.net (1996-02-16)
Re: if then else shift/reduce Syndrome tarnwb@holly.colostate.edu (Tarn Burton) (1996-02-16)
Re: if then else shift/reduce Syndrome meissner@cygnus.com (Michael Meissner) (1996-02-21)
Re: if then else shift/reduce Syndrome henry@zoo.toronto.edu (Henry Spencer) (1996-02-27)
Re: if then else shift/reduce Syndrome neitzel@gaertner.de (1996-03-01)
Re: if then else shift/reduce Syndrome bakul@netcom.com (1996-03-03)
| List of all articles for this month |
From: Michael Meissner <meissner@cygnus.com>
Newsgroups: comp.compilers
Date: 16 Feb 1996 01:24:27 -0500
Organization: Compilers Central
References: 96-02-123 96-02-139
Keywords: parse, question

| Tarn Burton <tarnwb@holly.colostate.edu writes:
| >Does anyone know how to get rid of the bison shift/reduce conflict in
| >the C if then else.
|
| Yes, classify statements as open or closed.


...


| open-if : if-query open-statement
| | if-query closed-statement else open-statement
| closed-if : if-query closed-statement else closed-statement


I remember in the early days of the ANSI C committee (before it was
ISO-ized, probably about 10 years ago), when I tried doing this with
the then current ANSI grammer. It blew away the parser generator's
table size (probably V7 yacc if memory serves, since I didn't know
about GNU back then) in that it basically doubled the amount of states
for the statements. I decided to leave well enough alone, because as
somebody mentioned, almost all parser generators (ie, all usable ones)
will do what you want, in favoring the shift over the reduce.


--
Michael Meissner, Cygnus Support (East Coast)
Suite 105, 48 Grove Street, Somerville, MA 02144, USA
meissner@cygnus.com, 617-629-3016 (office), 617-629-3010 (fax)
--


Post a followup to this message

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