Synthesized vs Inherited Attributes
Synthesized Attribute: An attribute that gets its values from the attributes attached to the children of its non-terminal.
Inherited Attribute: An attribute that gets its values from the attributes attached to the parent (or siblings) of its non-terminal.
**PRODUCTION** **SEMANTIC RULES**
T->FT’ T’.inh=F.val
T.val=T’.syn
T’->*FT1’ T1’.inh=T’.inh*F.val
T’.syn=T1’.syn
T’->Ɛ T’.syn=T’.inh
F->id F.val=id.lexval
As you can see from the given grammar rules(productions), inh is an inherited attribute and syn is a synthesized attribute.
Further Read: Attribute Grammars.
The attribute which takes data values from its child nodes is called a synthesized attribute.
These are also called s-attributed production. The attribute which takes values from parents or sibling nodes is called inherited attributes. The production rule having inherited attribute(Each inherited attributes is restricted to inherit either from a parent or left sibling only) are called L-attributed productions.