Which of the following is/are Bottom-Up Parser(s)?
- (A)
Shift-reduce Parser
- (B)
Predictive Parser
- (C)
LL(1) Parser
- (D)
LR Parser
Which of the following is/are Bottom-Up Parser(s)?
Shift-reduce Parser
Predictive Parser
LL(1) Parser
LR Parser
ANSWER
The bottom-up parsers are (A) Shift-reduce Parser and (D) LR Parser.
Official answer: A, DSource: Official answer key, GATE 2024 CS1 (IISc Bengaluru)
Bottom-up parsing builds the parse tree from the leaves (the input tokens) up to the start symbol, tracing a rightmost derivation in reverse.
(A) A shift-reduce parser shifts tokens onto a stack and reduces handles to non-terminals. This is the general bottom-up method, so it qualifies.
(B) A predictive parser is a recursive-descent or table-driven parser that chooses a production from the lookahead. It expands from the start symbol, so it is top-down.
(C) An LL(1) parser is the table-driven predictive parser: Left-to-right scan, Leftmost derivation, 1 lookahead. It is top-down.
(D) An LR parser (LR(0), SLR, LALR, CLR) is a shift-reduce parser driven by an automaton of items . It is bottom-up.
So the bottom-up parsers are (A) and (D).
KEY IDEA
Bottom-up parsers (shift-reduce, and the LR family built on it) reduce the input to the start symbol. Top-down parsers (predictive, recursive descent, LL(1)) expand from the start symbol.
WATCH OUT FOR
Choosing the predictive or LL(1) parser because it is table-driven and uses a stack. Both build the tree from the root downwards, so they are top-down.
From the GATE 2024 CS1 paper. Every question of this paper · Download the full paper · All 13 Parsing questions, with notes