yacc priorities and reduce-reduce conflicts

Frederic Tendeau <Frederic.Tendeau@xrce.xerox.com>
23 Nov 1997 19:47:43 -0500

          From comp.compilers

Related articles
yacc priorities and reduce-reduce conflicts Frederic.Tendeau@xrce.xerox.com (Frederic Tendeau) (1997-11-23)
| List of all articles for this month |

From: Frederic Tendeau <Frederic.Tendeau@xrce.xerox.com>
Newsgroups: comp.compilers
Date: 23 Nov 1997 19:47:43 -0500
Organization: Xerox Research Center Europe
Keywords: yacc, parse

Say you have in some lang.y file:
%nonassoc TILDE

and say that these 2 rules create a red-red conflict in some state:
a : b_ (n)
a : TILDE b_ (n+1)

I thought that the priority declarations could solve the conflict in
favour of the rule (n+1) because its priority is the priority of
TILDE, wheras the priority of the rule (n) is the one of

But this is wrong. yacc considers that these priorities do not solve
the conflict. This seems to mean that when a rule is reduced, its
priority is not infered from its terminals ---which is surprising.

I did not find any documentation concerning this issue. Neither with
`man yacc`, nor in (my version of) O'Reilly lex&yacc book.

Could anyone help?

Thanks in advance,
[Precedences only solve shift/reduce conflicts. You need to flatten
your grammar, see chapter 8 of our book. -John]


Post a followup to this message

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