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 LR(1)LR(1) 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 LR(1)LR(1) grammar into one that is no longer LR(1)LR(1).

More questions on Semantic Analysis

Practice GATE CS PYQs with adaptive difficulty

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

Start practicing free