Which one of the following is a top-down parser?
2015
Which one of the following is a top-down parser?
- A.
Recursive descent parser
- B.
Shift left associative parser
- C.
SLR(k) parser
- D.
LR(k) parser
Attempted by 149 students.
Show answer & explanation
Correct answer: A
A recursive descent parser is a top-down parsing technique that builds the parse tree starting from the root node and working down to the leaves. It uses a set of mutually recursive procedures, where each procedure corresponds to one non-terminal symbol in the grammar. This approach attempts to predict which production rule to apply based on the current input token, making it inherently top-down.\nIn contrast, SLR(k) and LR(k) parsers are bottom-up parsing methods. They construct the parse tree from the leaves up to the root by shifting input symbols onto a stack and reducing them according to grammar rules. These parsers analyze the input from left to right but build the tree in reverse order.\
A video solution is available for this question — log in and enroll to watch it.