The GATE Grind

GATE 2013 CS (CS1) – Question 50

Compiler Design · Parsing and Syntax Analysis · 2 marks · Multiple choice

Two LR(1) item sets share core {X→c·X, X→·cX, X→·d}. Their lookaheads are respectively {c,d} and {end-marker}. Which claims about their LALR merge are false? 1: Cannot merge because lookaheads differ. 2: Merge creates shift/reduce conflict. 3: Merge creates reduce/reduce conflict. 4: Cannot merge because goto on c leads to different sets.

  1. 1 only
  2. 2 only
  3. 1 and 4 only
  4. 1,2,3,4

Practise this question in The GATE Grind →

Show answer and explanation

Correct answer: (D) 1,2,3,4

Explanation

LALR merges equal LR(0) cores and unions their lookaheads, so differing lookaheads do not prevent merging. Neither set contains a completed item, so no reduction exists here to cause either conflict. Goto states with equal cores merge consistently as well. All four assertions are false, D.

More Parsing and Syntax Analysis questions

All Parsing and Syntax Analysis questions →