Related articles |
---|
yacc priorities and reduce-reduce conflicts Frederic.Tendeau@xrce.xerox.com (Frederic Tendeau) (1997-11-23) |
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:
%token PRIORITY_BOTTOM TILDE
(...)
%nonassoc PRIORITY_BOTTOM
%nonassoc TILDE
(...)
a : b %prec PRIORITY_BOTTOM
| TILDE b
;
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
PRIORITY_BOTTOM.
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,
--Frederic
[Precedences only solve shift/reduce conflicts. You need to flatten
your grammar, see chapter 8 of our book. -John]
--
Return to the
comp.compilers page.
Search the
comp.compilers archives again.