Shift/Reduce conflict in first state due to epsilon rule

308 views Asked by At

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?

1

There are 1 answers

0
SuzLy On BEST ANSWER

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.