GATE Computer ScienceModerateGATE CS (PYQ pattern)

For the production A → B C D (A.i, B.i, C.i, D.i inherited; A.s, B.s, C.s, D.s synthesised), which rule set makes the SDD L-attributed?

  1. A. B.i = A.i; C.i = D.s; A.s = C.s
  2. B. C.i = B.s; D.i = C.i + B.i; A.s = D.s
  3. C. B.i = A.i; D.i = A.s + C.s; A.s = B.s
  4. D. C.i = A.i; B.i = C.i; A.s = B.s + C.s

Correct answer: B. C.i = B.s; D.i = C.i + B.i; A.s = D.s

L-attributed: an inherited attribute of a child may use only the parent's inherited attributes and attributes of children to its left. C.i = B.s and D.i = C.i + B.i use left siblings only, and A.s may use anything. C.i = D.s uses a right sibling; D.i = A.s uses the parent's synthesised attribute (which is computed after D); B.i = C.i uses a right sibling.

More Compiler Design questions

Exams that ask this topic