Which one of the following is a top-down parser?

2007

Which one of the following is a top-down parser?

Answer: A. Recursive descent parser.Answer: Recursive descent parser. Explanation: Why this is correct and why the others are not. Top-down parsing starts from the grammar's start symbol and…

  1. A.

    Recursive descent parser.

  2. B.

    Operator precedence parser.

  3. C.

    An LR(k) parser.

  4. D.

    An LALR(k) parser

Attempted by 208 students.

Show answer & explanation

Correct answer: A

Answer: Recursive descent parser.

Explanation: Why this is correct and why the others are not.

  • Top-down parsing starts from the grammar's start symbol and expands nonterminals to generate the input (producing leftmost derivations).

  • Recursive descent parser: a direct implementation of top-down parsing using mutually recursive procedures for nonterminals; predictive versions use lookahead to select productions without backtracking.

  • Operator precedence parser: a bottom-up shift-reduce approach that reduces tokens according to operator precedence, so it is not a top-down parser.

  • LR(k) and LALR(k) parsers: bottom-up (shift-reduce) parsers that build a rightmost derivation in reverse; they do not perform top-down expansion.

A video solution is available for this question — log in and enroll to watch it.

Explore the full course: Iocl Engineers Officers Grade A Paper 2

Loading lesson…