Computer Science, asked by Khirendra48651, 1 year ago

Difference between l attribute and s attribute in compiler design

Answers

Answered by mehtapayal2000
4

Answer:

S-attributed SDT :

If an SDT uses only synthesized attributes, it is called as S-attributed SDT.

S-attributed SDTs are evaluated in bottom-up parsing, as the values of the parent nodes depend upon the values of the child nodes.

Semantic actions are placed in rightmost place of RHS.

L-attributed SDT:

If an SDT uses both synthesized attributes and inherited attributes with a restriction that inherited attribute can inherit values from left siblings only, it is called as L-attributed SDT.

Attributes in L-attributed SDTs are evaluated by depth-first and left-to-right parsing manner.

Semantic actions are placed anywhere in RHS.

Note – If a definition is S-attributed, then it is also L-attributed but NOT vice-versa.

Answered by anvitanvar032
0

Answer:

The correct answer to this question is An attribute of the non-terminal on the left side of a production is called a synthesized attribute.  

Explanation:

Given - l attribute and s attribute in compiler design

To Find - Difference between l attribute and s attribute in compiler design

Synthesized characteristics – An attribute of the non-terminal on the left side of a production is called a synthesized attribute. The information that is passed up the parse tree is represented by synthesized attributes. Only its children can give the attribute value (Variables in the RHS of the production).

Let's use the example of the grammar A->BC. If an attribute of A depends on an attribute of B or C, it will be a synthesized attribute.

Inherited attributes: An inherited attribute is a property of a nonterminal on the right side of a production. The attribute can derive value from its siblings or from its parents (variables in the LHS or RHS of the production).

As an illustration, suppose A -> BC is a grammar production and B's attribute depends on A's attribute or C's attribute, in which case it is an inherited attribute.

#SPJ2

Similar questions