Re: Shift/reduce conflict in Yacc C grammar

corbett@lupa.Eng.Sun.COM (Robert Corbett)
23 Jan 1998 00:16:36 -0500

          From comp.compilers

Related articles
Shift/reduce conflict in Yacc C grammar hajnal@eik.bme.hu (HAJNAL Akos) (1998-01-11)
Re: Shift/reduce conflict in Yacc C grammar thetick@magelang.com (Scott Stanchfield) (1998-01-14)
Re: Shift/reduce conflict in Yacc C grammar clark@quarry.zk3.dec.com (Chris Clark USG) (1998-01-20)
Re: Shift/reduce conflict in Yacc C grammar Bronikov@inreach.com (Dmitri&Nina Bronnikov) (1998-01-21)
Re: Shift/reduce conflict in Yacc C grammar corbett@lupa.Eng.Sun.COM (1998-01-23)
Re: Shift/reduce conflict in Yacc C grammar khays@sequent.com (1998-01-23)
Re: Shift/reduce conflict in Yacc C grammar cfc@world.std.com (Chris F Clark) (1998-01-24)
Re: Shift/reduce conflict in Yacc C grammar thetick@magelang.com (Scott Stanchfield) (1998-01-24)
| List of all articles for this month |

From: corbett@lupa.Eng.Sun.COM (Robert Corbett)
Newsgroups: comp.compilers
Date: 23 Jan 1998 00:16:36 -0500
Organization: Sun Microsystems Computer Corporation
References: 98-01-035
Keywords: C, parse, yacc

HAJNAL Akos <hajnal@eik.bme.hu> wrote:
>My question is that, there is available a C grammar in lex/yacc
>that does not contain any shift/reduce conflict?
>Can such grammar exsist?


Try to find a copy of the 1st edition of C: A Reference Manual by
Harbison and Steele. They give an LALR(1) grammar for C that handles
if-then-else without conflicts. The LALR(1) grammar does not appear
in the latest edition.


It is possible to write an LALR(1) grammar for C, assuming a lexical
analyzer that distinguishes typedef-names from identifiers. It is a
pain to do so, and the resulting parser will be slower than a parser
for a grammar with some well-chosen and properly handled conflicts.


Sincerely,
Bob Corbett
--


Post a followup to this message

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