Unreducible production after conflict resolution incorrectly leading to further conflicts

Issue #4 resolved
Jesper Öqvist repo owner created an issue

NeoBeaver does not remove productions during conflict resolution which can lead to false positive errors when checking conflicts.

For example, when a shift/reduce conflict is resolved by choosing the SHIFT action, the reduce action should be removed from the transition table and not cause other conflicts.

Here is a small grammar with only one conflict but NeoBeaver reports two conflicts:

%goal expr;

%terminals LPAREN, RPAREN, ASTERISK, ID, INT;

expr =
    name
  | expr_nn
  ;
expr_nn =
    num
  | LPAREN expr RPAREN
  | LPAREN name RPAREN
  | LPAREN name ptr? RPAREN expr
  ;
ptr =
    ASTERISK
  | ptr ASTERISK
  ;
num = INT;
name = ID;

NeoBeaver reports these conflicts:

SHIFT/REDUCE:
  SHIFT RPAREN                          
  REDUCE expr -> name

REDUCE/REDUCE:
  REDUCE ptr$opt ->
  REDUCE expr -> name

If the SHIFT action is chosen in the SHIFT/REDUCE conflict, then the reduction expr -> name becomes unreachable and will not conflict with ptr$opt ->. In this case the REDUCE/REDUCE conflict is spurious and should not be reported.

Comments (3)

  1. Log in to comment