I have had a shift-reduce conflict and reduced it to a couple of lines:
start : instruction_A;
instruction_A : instruction_A instruction
|
;
instruction : RETURN 'X'
| RETURN
| 'X' '!'
;
3: shift/reduce conflict (shift 6, reduce 5) on 'X'
state 3
instruction : RETURN . 'X' (4)
instruction : RETURN . (5)
'X' shift 6
$end reduce 5
RETURN reduce 5
My guess is that the expression X! RETURN X!
cannot be parsed because when the parser reaches the 'X' token, it does not know if it should continue the instruction or start another one.
Basically, the expected arrangements are:
{X! RETURN} {X!}
{X! RETURN X}
How to solve this? It seems like reading an extra token would solve the problem, but this must be done with LALR(1).