bison/yacc: shift/reduce conflict using %prec for composition

longjonathan@comcast.net (J Long)
25 Jun 2004 01:52:06 -0400

          From comp.compilers

Related articles
bison/yacc: shift/reduce conflict using %prec for composition longjonathan@comcast.net (2004-06-25)
Re: bison/yacc: shift/reduce conflict using %prec for composition cdodd@acm.org (Chris Dodd) (2004-06-28)
| List of all articles for this month |
From: longjonathan@comcast.net (J Long)
Newsgroups: comp.compilers
Date: 25 Jun 2004 01:52:06 -0400
Organization: http://groups.google.com
Keywords: yacc, parse
Posted-Date: 25 Jun 2004 01:52:06 EDT

Would someone explain why a simple grammar such as this:


%left FUNCTION


%%


expr: 'A'
        | expr expr %prec FUNCTION
;


causes a shift/reduce conflict in bison/yacc? Here is how I understand
my generated parser will work: all input must consist of a series of
the terminal 'A', which will be identified as an expr; when two exprs
are found adjacent, i.e., two 'A's, they will be reduced by the
left-to-right precedence declared by the %prec modifier. I thus see no
reason for a shift/reduce conflict.
[It's because precedences are attached to tokens, and there's no tokens
in that rule. -John]



Post a followup to this message

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