3
votes

My C#-ish toy grammar now has its first reduce-reduce conflicts! I'm so proud of me.

It seems all right to me, however (I switched off to a GLR parser for the occasion). The problem is, while I know the %expect directive can shut up Bison about shift/reduce conflicts, I can't find the equivalent for reduce/reduce conflicts. So what should I use to make it silent about my 3 shift/reduces and my 2 reduce/reduces?

1
If you can, grab the Dragon book "Compilers: Principles, Tools & Techniques" by Aho et al and "Modern Compiler Implementation in C"Aiden Bell
Well, the Dragon Book's kind of expensive for my poor student status. :/ Especially since I'm doing it purely as a hobby, and I certainly won't have classes about compilers before several years.zneak

1 Answers

4
votes

From the GNU Bison documentation, found here

For normal LALR(1) parsers, reduce/reduce conflicts are more serious, and should be eliminated entirely. Bison will always report reduce/reduce conflicts for these parsers. With GLR parsers, however, both kinds of conflicts are routine; otherwise, there would be no need to use GLR parsing. Therefore, it is also possible to specify an expected number of reduce/reduce conflicts in GLR parsers, using the declaration:

 %expect-rr n