Which one of the following options gives the number of shift-reduce conflicts that will occur in the ACTION table?
C
Step-by-Step Solution
Insight: Epsilon productions in LR(0) immediately create reduce items in the initial state, which clash with any shift items for the same non-terminal, causing shift-reduce conflicts.
Exam route: Construct the LR(0) items state by state. Count the exact (state, terminal) pairs where both a shift and a reduce action are valid in the ACTION table.
Learning route:
- State I0: Contains
S' -> .S,S -> .ACB,A -> .aA, andA -> .(from ). The dot is before A, not C, so C productions are not yet in I0.
A -> .is a reduce item (places reduce in all columns).A -> .aAis a shift item on 'a'.- Result: 1 SR conflict (on 'a').
- State I1 = GOTO(I0, a): Contains
A -> a.A,A -> .aA,A -> ..
- Shift on 'a', reduce A. Result: 1 SR conflict (on 'a').
- State I2 = GOTO(I0, A): Contains
S -> A.CB,C -> .cC,C -> ..
- Shift on 'c', reduce C. Result: 1 SR conflict (on 'c').
- State I3 = GOTO(I2, c): Contains
C -> c.C,C -> .cC,C -> ..
- Shift on 'c', reduce C. Result: 1 SR conflict (on 'c').
- State I4 = GOTO(I2, C): Contains
S -> AC.B,B -> .bB,B -> .b.
- Only shift items (on 'b'). Result: 0 conflicts.
- All other states (like GOTO on S, B) have only reduce items or only shift items, yielding 0 SR conflicts.
- Total SR conflicts = 1 + 1 + 1 + 1 = 4.