GATE CS 2024 Set 2 — Question 29
MSQ+1 / -0MediumAttribute GrammarsSemantic AnalysisCompiler DesignS- & L-Attributed GrammarsSyntax-Directed Translation
Compiler Design → Semantic Analysis → Attribute Grammars
Last updated
Question
Which of the following statements is/are FALSE?
A.
An attribute grammar is a syntax-directed definition (SDD) in which the functions in the semantic rules have no side effects
B.
The attributes in a L-attributed definition cannot always be evaluated in a depth-first order
C.
Synthesized attributes can be evaluated by a bottom-up parser as the input is parsed
D.
All L-attributed definitions based on grammar can be evaluated using a bottom-up parsing strategy
Correct answer
(B) The attributes in a L-attributed definition cannot always be evaluated in a depth-first order; (D) All L-attributed definitions based on LR(1) grammar can be evaluated using a bottom-up parsing strategy
Solution
Statement (A) is true; it is the standard definition of an attribute grammar. Statement (B) is FALSE because L-attributed definitions are specifically defined such that their attributes can be evaluated in a single depth-first (left-to-right) traversal. Statement (C) is true because synthesized attributes depend only on children nodes, which are available during a bottom-up (post-order) traversal. Statement (D) is FALSE because not all L-attributed definitions can be evaluated during a single bottom-up pass; while techniques like marker non-terminals exist to handle inherited attributes, they can transform an grammar into one that is no longer .
More questions on Semantic Analysis
2024 Set 2 Q21Consider the following two sets: | Set X | Set Y | | :--- | :--- | | P. Lexical Analyzer | 1.…2024 Set 1 Q26Which of the following is/are Bottom-Up Parser(s)?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