GATE / CS ARCHIVE

GATE CSE 2014 SET 1 / QUESTION 34

GATE CSE 2014 Set 1 Q34

Compiler Design · Parsing & Syntax Analysis · Full GATE CSE 2014 Set 1 paper

GATE 2014 Set 1, Q34 2 marks · MCQ
Report issue

Parsing & Syntax Analysis

Question 34, GATE 2014: An LR item set contains S→L·>R and Q→R·. On lookahead/input symbol <, does it contain a conflict? A: both shift-reduce and reduce-reduce. B: shift-reduce only. C: reduce-reduce only. D: neither. The symbol after the first dot is >, while the queried input is <.
Tap to enlarge
Your answer
Answer & solution

Official answer: D

1. Method and setup. A shift is possible only for a terminal immediately after a dot, and a reduction only for a completed item, subject to the parser’s lookahead rules. Do not confuse the literal terminals < and >. There is only one completed item, so no pair of competing reductions is present.

2. Work through the result and its assumptions. The first item has its dot before >, not before <. Thus no shift is enabled on <. Only Q→R. is completed, so at most one reduction is possible on that symbol. There is neither a shift-reduce nor reduce-reduce conflict, D.

Original paper, page 15 · Answer key