Which of the following statements is/are FALSE?

2024

Which of the following statements is/are FALSE?

  1. A.

    An attribute grammar is a syntax-directed definition (SDD) in which the functions in the semantic rules have no side effects

  2. B.

    The attributes in a L-attributed definition cannot always be evaluated in a depthfirst order

  3. C.

    Synthesized attributes can be evaluated by a bottom-up parser as the input is parsed

  4. D.

    All L-attributed definitions based on LR(1) grammar can be evaluated using a bottom-up parsing strategy

Attempted by 92 students.

Show answer & explanation

Correct answer: B, D

Answer: The false statement is the one that claims an attribute grammar's semantic-rule functions "have no side effects."

Why this is false: An attribute grammar is a formal way to attach attributes and semantic rules to grammar productions and to specify dependencies among attribute values. Saying the semantic functions have no side effects overstates the formal requirement — the core requirement is well-defined attribute dependencies; implementations may use semantic actions that have side effects, so the absolute claim is incorrect.

  • Synthesized attributes: depend only on children and can be computed during bottom-up parsing as reductions happen.

  • L-attributed definitions: are structured to allow left-to-right evaluation (useful for top-down parsing). With proper scheduling of semantic actions, L-attributed SDDs based on LR(1) grammars can also be evaluated in bottom-up parsers.

Bottom line: The overly absolute claim about "no side effects" is false; the other statements describe standard, usable properties of synthesized attributes, L-attributed definitions, and bottom-up evaluation.

A video solution is available for this question — log in and enroll to watch it.

Explore the full course: Gate Guidance By Sanchit Sir