Skip to content
Official PYQ · 1992

GATE CS 1992 Q02 — Parsing (LL, LR)

Explain with AI

Consider the SLR(1)\text{SLR(1)} and LALR (1)\text{LALR (1)}  parsing tables for a context free grammar. Which of the following statement is/are true?

Select all correct options
View worked solution

Answer: B;C;D

To compare the SLR(1)\text{SLR(1)} and LALR(1)\text{LALR(1)} parsing tables, we analyze their underlying state machines and construction rules:

  1. State Machine Structure: Both SLR(1)\text{SLR(1)} and LALR(1)\text{LALR(1)} parsers are based on the same set of states as the LR(0)\text{LR(0)} parser. Since the states and the transitions between them are identical:
    • The goto transitions (on non-terminals) are identical in both tables. Thus, statement (A) is false.
    • The shift actions (transitions on terminals) are identical in both tables. Thus, statement (B) is true.
  2. Reduce Actions:
    • In SLR(1)\text{SLR(1)}, for a state containing the item A→α⋅A \to \alpha \cdot, a reduce action is placed under all terminals in Follow(A)\text{Follow}(A).
    • In LALR(1)\text{LALR(1)}, the reduce action is placed only under the specific lookahead terminals associated with that item in the merged LR(1)\text{LR(1)} state. Since these lookaheads are a subset of Follow(A)\text{Follow}(A), the reduce entries can be different. Thus, statement (C) is true.
  3. Error Entries: Since the reduce entries can differ between the two tables, the blank cells (which represent error entries) will also differ. Thus, statement (D) is true.

Therefore, the correct statements are B, C, and D.

Free practice · Your answers on this page are not saved.

Published
Report a correction
Keep exploringMore Parsing (LL, LR) questions