GATE / CS ARCHIVE

GATE CSE 2000 / QUESTION 1.19

Derivation used by a top-down parser

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

GATE 2000, Q1.19 1 mark · MCQ
Report issue

Parsing & Syntax Analysis

Question 1.19, GATE 2000: For input scanned left to right, does top-down parsing construct a leftmost derivation, its reverse, a rightmost derivation, or a reversed rightmost derivation?
Tap to enlarge
Your answer
Answer & solution

Answer: A (no official key was published)

Step 1: A top-down parser starts from the start symbol and expands grammar symbols to match the input prefix. It expands the leftmost unprocessed nonterminal to produce the next input symbols.

Step 2: These expansions run in the forward direction from start symbol to terminal string, giving a leftmost derivation, A.

A reversed rightmost derivation characterizes standard bottom-up shift-reduce parsing instead.

Original paper, page 3