Which one of the following is a top-down parser?
2007
Which one of the following is a top-down parser?
- A.
Recursive descent parser.
- B.
Operator precedence parser.
- C.
An LR(k) parser.
- D.
An LALR(k) parser
Attempted by 117 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.