Skip to main content

GATE CSE 2024Compiler Design › Syntax-Directed Translation & Intermediate CodeVerified

GATE CSE 2024 PYQ: ​​​​​Which of the following statements is/are FALSE?

​​​​​Which of the following statements is/are FALSE?

  1. A
    An attribute grammar is a syntax-directed definition (SDD)\text{(SDD)} in which the functions in the semantic rules have no side effects
  2. B
    The attributes in a L\text{L}-attributed definition cannot always be evaluated in a depth-first order
    Correct answer
  3. C
    Synthesized attributes can be evaluated by a bottom-up parser as the input is parsed
  4. D
    All L\text{L}-attributed definitions based on LR(1)\text{LR(1)} grammar can be evaluated using a bottom-up parsing strategy
    Correct 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.