Problem solving shift/reduce conflict

"Ashwin" <>
4 Jan 2003 22:45:20 -0500

          From comp.compilers

Related articles
Problem solving shift/reduce conflict (Ashwin) (2003-01-04)
Re: Problem solving shift/reduce conflict (Chris Dodd) (2003-01-07)
Re: Problem solving shift/reduce conflict (2003-01-07)
| List of all articles for this month |

From: "Ashwin" <>
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


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.


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

  ReferenceType RankSpecifiers

  | ArrayType


  | RankSpecifiers RankSpecifier


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.