Problem solving shift/reduce conflict

"Ashwin" <ashwin21_99@hotmail.com>
4 Jan 2003 22:45:20 -0500

          From comp.compilers

Related articles
Problem solving shift/reduce conflict ashwin21_99@hotmail.com (Ashwin) (2003-01-04)
Re: Problem solving shift/reduce conflict cdodd@acm.org (Chris Dodd) (2003-01-07)
Re: Problem solving shift/reduce conflict lars@bearnip.com (2003-01-07)
| List of all articles for this month |
From: "Ashwin" <ashwin21_99@hotmail.com>
Newsgroups: comp.compilers
Date: 4 Jan 2003 22:45:20 -0500
Organization: Compilers Central
Keywords: parse, yacc
Posted-Date: 04 Jan 2003 22:45:20 EST

Hi,


I am trying to remove all the shift/reduce, reduce/reduce
problems from my C# grammar. There is one shift/reduce
problem I am stumped on. I would appreciate if someone
can tell me how to fix the problem. I don't even understand
why bison says that there is a shift/reduce problem.


The grammar (just four simple rules) and the
partial bison output follows.


Thank you in advance for your help.


Ashwin
-----------------------------------------


The following is my (simplified) grammar. The
starting point is ArrayType.


ArrayType:
  ReferenceType RankSpecifiers
  ;


ReferenceType:
    ClassType
  | ArrayType
  ;


ClassType:
  OBJECT
  |STRING
  ;




RankSpecifiers:
  RankSpecifier
  | RankSpecifiers RankSpecifier
  ;


RankSpecifier:
  LEFTBRACKET RIGHTBRACKET
  ;


The following is my partial listing using -v option of bison where the
shift/reduce conflict is listed


state 7


        ArrayType -> ReferenceType RankSpecifiers . (rule 26)
        RankSpecifiers -> RankSpecifiers . RankSpecifier (rule 28)


        LEFTBRACKET shift, and go to state 6


        LEFTBRACKET [reduce using rule 26 (ArrayType)]
        $default reduce using rule 26 (ArrayType)


        RankSpecifier go to state 10


state 6


        RankSpecifier -> LEFTBRACKET . RIGHTBRACKET (rule 29)


        RIGHTBRACKET shift, and go to state 9



Post a followup to this message

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