A syntax-directed definition is L-attributed if each inherited attribute of Xj for i between 1 and n, and on the right side of production A → X1X2…,Xn, depends only on:
-
The attributes (both inherited as well as synthesized) of the symbols X1,X2,…, Xj−1 (i.e., the symbols to the left of Xj in the production, and
-
The inherited attributes of A.
The syntax-directed definition above is an example of the L-attributed definition, because the inherited attribute L.type depends on T.type, and T is to the left of L in the production D → TL. Similarly, the inherited attribute L1.type depends on the inherited attribute L.type, and L is parent of L1 in the production L → L1,id.
When translations carried out during parsing, the order in which the semantic rules are evaluated by the parser must be explicitly specified. Hence, instead of using the syntax-directed definitions, we use syntax-directed translation schemes to specify the translations. Syntax-directed definitions are more abstract specifications for translations; therefore, they hide many implementation details, freeing the user from having to explicitly specify the order in which translation takes place. Whereas the syntax-directed translation schemes indicate the order in which semantic rules are evaluated, allowing some implementation details to be specified.