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
2024 Set 2 Q21Consider the following two sets: | Set X | Set Y | | :--- | :--- | | P. Lexical Analyzer | 1.…2024 Set 2 Q29Which of the following statements is/are FALSE?2024 Set 1 Q37Consider the following syntax-directed definition (SDD). | Production | Semantic Rules | | ------ |…2024 Set 1 Q38Consider the following grammar , with as the start symbol. The grammar has three…2024 Set 1 Q39Consider the following pseudo-code. [code] Which one of the following options CORRECTLY specifies…
Practice GATE CS PYQs with adaptive difficulty
Timed practice, skill tracking, and AI explanations — free to start.
Start practicing free