Which of the following statements is/are FALSE?
GATE CSE 2024Compiler Design › Syntax-Directed Translation & Intermediate CodeVerified
GATE CSE 2024 PYQ: Which of the following statements is/are FALSE?
- AAn attribute grammar is a syntax-directed definition in which the functions in the semantic rules have no side effects
- BThe attributes in a -attributed definition cannot always be evaluated in a depth-first orderCorrect answer
- CSynthesized attributes can be evaluated by a bottom-up parser as the input is parsed
- DAll -attributed definitions based on grammar can be evaluated using a bottom-up parsing strategyCorrect answer
Answer
(B, D) The attributes in a L \text{L} L -attributed definition cannot always be evaluated in a depth-first order; All L \text{L} L -attributed definitions based on LR(1) \text{LR(1)} LR(1) grammar can be evaluated using a bottom-up parsing strategy
Approach
Use standard compiler-design definitions: attribute grammars are side-effect-free SDDs; L-attributed definitions are exactly those evaluable by a depth-first left-to-right traversal; synthesized attributes are handled by bottom-up parsers; and bottom-up evaluation of inherited attributes requires LR-attributed (not merely L-attributed) definitions.
The false statements are B and D. L-attributed definitions are evaluable in depth-first order, and bottom-up evaluation requires LR-attributed rather than arbitrary L-attributed definitions.
Reviewed by GateIQ Editorial Team: IIT & IISc Alumni.