bisonshift-reduce-conflictshift-reduce

Shift/Reduce conflict in first state due to epsilon rule


I have shift/reduce conflict in bison.

I checked the parser.output file:

State 0

0 $accept: . Prog $end

STRUCT  shift, and go to state 1

$default  reduce using rule 6 (Structs)

Prog        go to state 2
Structs     go to state 3
StructDec   go to state 4

I have the rules:

Prog    :   Structs Funcs {};
Structs :   StructDec Structs | {};
StructDec : STRUCT ID LB StrctMmLst RB SC{};

And Prog is the start symbole.

%start Prog

I assume the reason is the epsilon rule of structs. How can I resolve it without changing the meaning?


Solution

  • The solution actualy was to look at the beginning of the file. there you can see the numbers of the conflictiong states. The one I was looking at was not a conflict at all.