Help with Yacc reduce/reduce conflict

Warren <warren.toomey@gmail.com>
Mon, 21 Jun 2010 20:10:33 -0700 (PDT)

          From comp.compilers

Related articles
Help with Yacc reduce/reduce conflict warren.toomey@gmail.com (Warren) (2010-06-21)
Re: Help with Yacc reduce/reduce conflict gah@ugcs.caltech.edu (glen herrmannsfeldt) (2010-06-23)
Re: Help with Yacc reduce/reduce conflict kym@sdf.lonestar.org (russell kym horsell) (2010-06-24)
Re: Help with Yacc reduce/reduce conflict paul@paulbmann.com (Paul Mann) (2010-07-01)
| List of all articles for this month |
From: Warren <warren.toomey@gmail.com>
Newsgroups: comp.compilers
Date: Mon, 21 Jun 2010 20:10:33 -0700 (PDT)
Organization: Compilers Central
Keywords: yacc, question
Posted-Date: 23 Jun 2010 09:53:46 EDT

I'm writing a tool for novice Java students to submit their programs
on-line and get back warnings about common mistakes, e.g. if (x = y),
and assignments where the == operator is used instead of =.


I've started with the Yacc-based Java grammar at
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/java/parse.y and pruned
it down to this: http://minnie.tuhs.org/Z/java.y


I'm modifying the grammar to accept illegal Java constructs, so that
they can be identified as mistakes. Right now I am trying to add the
'==' operator to assignments, but I am getting 4 reduce/reduce
conflicts. The specific added rule causing the problem is:


assignment:
                left_hand_side assignment_operator assignment_expression
| left_hand_side '==' assignment_expression /* This one!*/
| left_hand_side assignment_operator error
;


I can see the conflicts in y.output, but after trying all day to fix
them, I'm stuck. I have read several on-line tips for solving this,
e.g. A Quick Introduction to Handling Conflicts in Yacc Parsers by
Saumya Debray, but still no luck.


Any suggestions on how to restructure the grammar to resolve this
would be most appreciated!


Thanks, Warren


Post a followup to this message

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