Answer: C
To determine the parsing class of the grammar G, we analyze the LR(0) and LR(1) states.
1. SLR(1) Analysis:
First, let's compute the Follow set of the non-terminal A:
Follow(A)={a,c}
Consider the LR(0) state I reached after scanning the terminal d from the start state:
I={S→d.c,A→d.}
In this state:
- There is a shift action on terminal c (from S→d.c).
- There is a reduce action for A→d on any terminal in Follow(A)={a,c}.
Since c∈Follow(A), we have a Shift-Reduce conflict on terminal c. Thus, the grammar is not SLR(1).
2. LR(1) and LALR(1) Analysis:
Let's construct the corresponding LR(1) states to see if lookaheads resolve the conflict:
- From the path S→dc, we get the state:
I1={S→d.c,[$],A→d.,[a]}
Here, the shift is on c and the reduce is on a. There is no conflict.
- From the path S→bda, we get the state:
I2={S→bd.a,[$],A→d.,[c]}
Here, the shift is on a and the reduce is on c. There is no conflict.
Since these two states have different cores (core(I1)={S→d.c,A→d.} and core(I2)={S→bd.a,A→d.}), they are not merged during LALR(1) construction. Thus, the grammar is LALR(1).
Therefore, G is LALR(1) but not SLR(1).