Given the following syntax directed translation rules:
- Rule 1:
- Rule 2:
- Rule 3:
GATE CSE 2025Compiler Design › Syntax-Directed Translation & Intermediate CodeVerified
(C) Rule 1 1 1 is neither S S S -attributed nor L L L -attributed; Rule 2 2 2 is not S S S -attributed and is L L L -attributed; Rule 3 3 3 is S S S -attributed and L L L -attributed.
Classify each semantic rule by checking whether it uses only synthesized attributes or whether any inherited attribute depends only on the parent/left siblings. An attribute defined using child attributes is synthesized; one defined from the parent or a sibling is inherited. S-attributed requires all attributes to be synthesized. L-attributed allows inherited attributes only if they depend on parent inherited attributes or attributes of left siblings, never right siblings.
Rule 1 violates L-attributedness because A.i uses right sibling B.i, and it also has inherited attributes, so it is neither S- nor L-attributed. Rule 2 has inherited D.i from left sibling C, making it L-attributed but not S-attributed. Rule 3 computes only synthesized attributes, making it both S- and L-attributed. Therefore option C is correct.
Reviewed by GateIQ Editorial Team: IIT & IISc Alumni.