S→𝐴𝐶𝐵
A→𝑎𝐴 | 𝜖
C→𝑐𝐶 | 𝜖
B→𝑏𝐵 | 𝑏
Which one of the following options gives the number of shift-reduce conflicts that will occur in the 𝐿𝑅(0) ACTION table?
Correct : d
The correct answer is Option D — 5 shift-reduce conflicts.
A shift-reduce conflict in an LR(0) state occurs when the state contains both a complete item (dot at the end → reduce) and an item with the dot before a terminal (→ shift). The grammar has ε-productions for A and C, which introduce complete items into states alongside shift items, creating conflicts.
State I0 contains A→• (reduce A→ε) and A→•aA (shift ''''a'''') → Conflict 1.
State I1 = GOTO(I0, A) contains C→• (reduce C→ε) and C→•cC (shift ''''c'''') → Conflict 2.
State I2 = GOTO(I0, a) contains A→• (reduce A→ε) and A→•aA (shift ''''a'''') → Conflict 3.
State I5 = GOTO(I1, c) contains C→• (reduce C→ε) and C→•cC (shift ''''c'''') → Conflict 4.
State I8 = GOTO(I4, b) contains B→b• (reduce) and B→b•B (shift ''''b'''') → Conflict 5.
No other states produce shift-reduce conflicts. The B production B→bB|b causes a conflict because both B→b• and B→b•B appear in the same state. The ε-productions of A and C each cause conflicts in two states — one at the initial state and one in the recursive state.
Similar Questions
Total Unique Visitors