Computer Sciences > GATE 2024 Set-2 > Compiler Design
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 an LR(1) grammar can be evaluated using a bottom-up parsing strategy

Correct : b,d

  • a) An attribute grammar is an SDD with no side effects:
    By formal definition, an attribute grammar is a Syntax-Directed Definition (SDD) that uses semantic functions without any side effects (such as directly printing values or updating global tables). It strictly computes values of attributes from other attributes.
    This statement is TRUE.

  • b) The attributes in an L-attributed definition cannot always be evaluated in a depth-first order:
    L-attributed definitions are explicitly structured to allow attribute evaluation via a natural depth-first, left-to-right traversal. Because dependency graphs for L-attributed definitions are guaranteed to have no cycles, they can always be evaluated in a depth-first sequence.
    This statement is FALSE.

  • c) Synthesized attributes can be evaluated by a bottom-up parser as the input is parsed:
    A bottom-up parser (like an LR parser) naturally reduces children nodes into parent nodes. Since a synthesized attribute computes its value based on the values of its children nodes, its evaluation perfectly aligns with the shift-reduce actions of a bottom-up parser.
    This statement is TRUE.

  • d) All L-attributed definitions based on an LR(1) grammar can be evaluated using a bottom-up parsing strategy:
    While L-attributed definitions can always be evaluated during top-down parsing, they cannot all be evaluated during a single-pass bottom-up parsing run. For a bottom-up parser to evaluate an inherited attribute, the value must be available before the parent or siblings are fully reduced, which often requires introducing marker non-terminals. If these markers break the underlying LR(1) nature of the grammar, a single-pass bottom-up evaluation becomes impossible.
    This statement is FALSE.

Conclusion: The incorrect statements are b and d.

Similar Questions

Match the following according to input(from the left column) to the compiler phase(in the right column) that process it: (P)Syntax Tree (i)...
#168 MCQ
Consider the following code segment. x = u - t; y = x * v; x = y + w; y = t - z; y = x * y; The minimum number of total variables required to convert the abo...
#575 Fill in the Blanks
Consider the following grammar: stmt -> if expr then else expr; stmt | ε expr -> term relop term | term term -> id | number id -> a | b | c number -> [...
#594 Fill in the Blanks

Related Topics

No tags found

Unique Visitor Count

Total Unique Visitors

Loading......