Skip to main content

GATE CSE 2026Compiler Design › Grammars & ParsingVerified

GATE CSE 2026 PYQ: Consider the canonical L R ( 0 ) L R(0) L R ( 0 ) parsing of the grammar below using terminals { a , b , c }…

Consider the canonical LR(0)L R(0) parsing of the grammar below using terminals {a,b,c}\{a, b, c\} and non-terminals {A,B,C,S}\{A, B, C, S\} with SS as the start symbol.

S→ACBA→aA∣ϵC→cC∣ϵB→bB∣b \begin{array}{l} S \rightarrow A C B \\ A \rightarrow a A \mid \epsilon \\ C \rightarrow c C \mid \epsilon \\ B \rightarrow b B \mid b \end{array}
Which one of the following options gives the number of shift-reduce conflicts that will occur in the LR(0)L R(0) ACTION table?

  1. A
    2
  2. B
    3
  3. C
    4
  4. D
    5
    Correct answer

Answer

(D) 5 5 5

Approach

Construct the canonical LR(0) collection for the augmented grammar and mark every state where a completed item (reduce) and an item with a terminal after the dot (shift) coexist. Count each conflicting terminal action.

The canonical LR(0) collection has five states with a shift-reduce conflict: I0, I1, I2, I4, and I7. Counting the conflicting terminal actions gives 5, so option D is correct.

Reviewed by GateIQ Editorial Team: IIT & IISc Alumni.