Consider the SDD given below: C → DC1 { D.val = CDval } /*Production 1*/ C2…
Consider the SDD given below:
C → DC1 { D.val = CDval } /*Production 1*/
C2 →*DC3 { C2 .val = C3 .val × D.val} /*Production 2*/
Which of the given option is correct w.r.t the above SDD?
Answer: C. This SDD follows only L-attributed definition but not S-attributed definition. — Summary: concise classification of attributes in each production. Production 1 (C → D C1 { D.val = CDval }): D.val is assigned by the semantic rule and…
- A.
Production 2 follows S-attributed definition but not L-attributed definition.
- B.
Production 1 has only inherited attribute.
- C.
This SDD follows only L-attributed definition but not S-attributed definition.
- D.
None of the above.
Attempted by 88 students.
Show answer & explanation
Correct answer: C
Summary: concise classification of attributes in each production.
Production 1 (C → D C1 { D.val = CDval }): D.val is assigned by the semantic rule and belongs to the child symbol D, so D.val is an inherited attribute. Because an inherited attribute appears, the SDD cannot be purely S-attributed (S-attributed definitions allow only synthesized attributes).
Production 2 (C2 → * D C3 { C2.val = C3.val × D.val }): C2.val is computed from attributes of the right-hand side symbols (C3.val and D.val), so C2.val is a synthesized attribute. This production is S-attributed (only synthesized attributes are computed) and is also valid under L-attributed rules, since L-attributed definitions permit synthesized attributes.
Conclusion: The correct, concise observation is that Production 1 has an inherited attribute (D.val). Therefore the statement that Production 1 has only an inherited attribute is accurate. As a result, the SDD is not S-attributed; Production 2 is synthesized and compatible with L-attributed definitions.