"easy" shift/reduce conflict

32 Views Asked by At

I'm writing a parser. My grammar includes a CLOSE verb for files, and takes as arguments any number of filenames separated by whitespace. Or, it would, if bison didn't complain, and it does.

close:          CLOSE filenames
                ;
filenames:      NAME
        |       filenames NAME
                ;

The report output says the problem is in State 124:

State 124

  232 close: CLOSE filenames .
  234 filenames: filenames . NAME

    NAME  shift, and go to state 198

    NAME      [reduce using rule 232 (close)]
    $default  reduce using rule 232 (close)

Here, "close" (lowercase) describes the syntax for CLOSE, one of several verbs in the language.

This looks to me like a textbook example of a recursive definition. It seems "obvious" to me that filenames should cause as many NAMES as appear to be shifted, and then reduced according to the "close" rule.

What am I missing?

0

There are 0 best solutions below