GATE Computer ScienceModerateGATE CS (PYQ pattern)

Which of the following is/are true? I. Every S-attributed definition is L-attributed. II. Every L-attributed definition can be evaluated in one depth-first left-to-right traversal of the parse tree. III. An SDD whose dependency graph has a cycle for some parse tree can be L-attributed. IV. For an S-attributed definition, attributes can be evaluated on each reduce move of an LR parser using the attribute values kept on the stack.

  1. A. I, II and III only
  2. B. II, III and IV only
  3. C. I and IV only
  4. D. I, II and IV only

Correct answer: D. I, II and IV only

I: no inherited attributes, so the L-rules hold. II: that is the defining property of L-attributed. III: an L-attributed definition cannot have a cycle, since each attribute depends only on attributes already available in left-to-right order. IV: standard bottom-up evaluation with a value stack.

More Compiler Design questions

Exams that ask this topic