Which one of the following is a top-down parser?
View worked solution
Answer: A
Parsers are broadly classified into two categories based on how they construct the parse tree:
- Top-Down Parsers: These parsers construct the parse tree starting from the root (the start symbol) and proceed downwards to the leaves (the input terminals). Examples include:
- Recursive Descent Parser (which uses recursive procedures to parse the input, with or without backtracking)
- LL(k) parsers
- Bottom-Up Parsers: These parsers construct the parse tree starting from the leaves (the input terminals) and proceed upwards to the root (the start symbol) using shift-reduce operations. Examples include:
- Operator Precedence Parser
- LR(k) parsers (including SLR, LALR, and CLR)
Among the given options, only the Recursive descent parser is a top-down parser. The others (Operator precedence, LR(k), and LALR(k)) are bottom-up parsers.
Free practice · Your answers on this page are not saved.
