GATE / CS ARCHIVE

GATE CSE 2008 / QUESTION 11

Handle in LR parsing

Compiler Design · Parsing & Syntax Analysis · Full GATE CSE 2008 paper

GATE 2008, Q11 1 mark · MCQ
Report issue

Parsing & Syntax Analysis

Question 11, GATE 2008: Which describes a handle in LR parsing?

(A) A position in a sentential form for the next shift or reduce operation
(B) A nonterminal whose production is used for the next reduction
(C) A production possibly used for a future reduction and the position of the next shift or reduce operation
(D) The production used in the next reduction and the position of its right-hand side in the sentential form
Tap to enlarge
Your answer
Answer & solution

Answer: D (no official key was published)

1. Bottom-up LR parsing reverses a rightmost derivation: it replaces a production’s right-hand side by its left-hand-side nonterminal.
2. A handle must specify both which production to reduce and which occurrence of its right-hand side is the correct next one. Merely naming a position or a nonterminal is insufficient.
3. D gives exactly this production-and-position pair. A possible future reduction, as in C, is not necessarily the next handle.

Original paper, page 3