GATE CS 2024 Set 1 — Question 26

MSQ+1 / -0EasySyntax AnalysisCompiler Design

Compiler Design → Syntax Analysis

Last updated

Question

Which of the following is/are Bottom-Up Parser(s)?
A.
Shift-reduce Parser
B.
Predictive Parser
C.
LL(1) Parser
D.
LR Parser

Correct answer

(A) Shift-reduce Parser; (D) LR Parser

Solution

Bottom-up parsing constructs the parse tree from the leaves (input string) up to the root (start symbol).
1.Shift-reduce Parser: This is a general style of bottom-up parsing where the parser shifts input symbols onto a stack and reduces a string of symbols on the top of the stack to a non-terminal according to the grammar rules. Thus, it is a bottom-up parser.
2.Predictive Parser: This is typically a recursive descent parser (top-down) that does not require backtracking. It predicts which production to use based on the lookahead. Thus, it is a top-down parser.
3.LL(1) Parser: LL parsers (Left-to-right scan, Leftmost derivation) are top-down parsers.
4.LR Parser: LR parsers (Left-to-right scan, Rightmost derivation in reverse) are a type of shift-reduce parser and are therefore bottom-up parsers.
Therefore, options (A) and (D) are correct.

More questions on Syntax Analysis

Practice GATE CS PYQs with adaptive difficulty

Timed practice, skill tracking, and AI explanations — free to start.

Start practicing free