Which of the following is/are Bottom-Up Parser(s)?
2024
Which of the following is/are Bottom-Up Parser(s)?
- A.
Shift-reduce Parser
- B.
Predictive Parser
- C.
LL(1) Parser
- D.
LR Parser
Attempted by 166 students.
Show answer & explanation
Correct answer: A, D
Answer: Shift-reduce Parser and LR Parser are bottom-up parsers.
Short explanation:
Bottom-up parsers construct the parse tree starting from the input symbols (the leaves) and work upward by reducing substrings to nonterminals until the start symbol is reached.
Shift-reduce Parser: Uses a stack to shift input tokens and apply reductions; this process builds the parse tree from the bottom up.
LR Parser: A family of bottom-up parsers (LR(0), SLR, LALR, LR(1)) that use states and parsing tables to decide shift/reduce actions and handle a wide class of grammars.
Why the other choices are not bottom-up:
Predictive Parser: This is a top-down approach that predicts which production to use based on lookahead, expanding from the start symbol rather than reducing input substrings.
LL(1) Parser: A specific top-down parser using one-token lookahead; it constructs the parse tree by choosing productions and expanding nodes from the top down.
Final selection:
Select the shift-reduce parser and the LR parser as bottom-up parsers.
A video solution is available for this question — log in and enroll to watch it.