Re: Shift/reduce conflict in Yacc C grammar

"Scott Stanchfield" <thetick@magelang.com>
14 Jan 1998 14:46:54 -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: "Scott Stanchfield" <thetick@magelang.com>
Newsgroups: comp.compilers
Date: 14 Jan 1998 14:46:54 -0500
Organization: MageLang Institute - http://www.MageLang.com
References: 98-01-035
Keywords: C, parse, yacc

Can't you use the precedence trick?


You know (if I recall properly)


%nonassoc ELSE
%nonassoc LOWER_THEN_ELSE


...


ifStatement
    : IF expr THEN statement %prec LOWER_THAN_ELSE
    | IF expr THEN statement ELSE statement
    ;


Or does it still give a problem?


(Or have I been away from yacc that long???)


-- Scott


Scott Stanchfield - http://www.scruz.net/~thetick
MageLang Institute - http://www.MageLang.com


HAJNAL Akos wrote...
>I downloaded the ANSI C grammar from
>The above grammar contains a shift/reduce conflict at
>the definitions if-then, if-then-else.
>For this reason I can not put actions within these rules,
>i.e. for example after parsing the condition part.


[I believe he wants to put in embedded actions, which you can't do because
it forces yacc to look more than one token ahead. -John]








--


Post a followup to this message

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