. There is both a shift and a reduce entry in action[2,=]. Therefore state 2 has a shift-reduce conflict on symbol "=", However, the grammar is not ambiguous.
. Parse id=id assuming reduce action is taken in [2,=]
Stack |
input |
action
|
0 |
id=id |
shift 5
|
0 |
=id |
reduce by L id
|
0 L 2 |
=id |
reduce by R L
|
0 R 3 |
=id |
error
|
. if shift action is taken in [2,=]
Stack |
input |
action
|
0 |
id=id$ |
shift 5
|
0 id 5 |
=id$ |
reduce by L id
|
0 L 2 |
=id$ |
shift 6
|
0 L 2 = 6 |
id$ |
shift 5
|
0 L 2 = 6 id 5 |
$ |
reduce by L id
|
0 L 2 = 6 L 8 |
$ |
reduce by R L
|
0 L 2 = 6 R 9 |
$ |
reduce by S L=R
|
0 S 1 |
$ |
ACCEPT |
We can see that [2,=] has multiple entries, one shift and other reduce, which makes the given grammar ambiguous but it is not so.
'id = id' is a valid string in S' as
S '
S
L=R
L=L
L=id
id=id
but of the given two possible derivations, one of them accepts it if we use shift operation while if we use reduce at the same place, it gives error as in the other derivation.