VOOZH about

URL: https://www.geeksforgeeks.org/compiler-design/differences-between-synthesized-and-inherited-attributes/

⇱ Differences between Synthesized and Inherited Attributes - GeeksforGeeks


  • Courses
  • Tutorials
  • Interview Prep

Differences between Synthesized and Inherited Attributes

Last Updated : 9 Mar, 2026

In Syntax Directed Definition, attributes are used to store and pass semantic information during parsing. These attributes help in evaluating expressions, checking types, and generating intermediate code in a compiler.
Based on how their values are computed and how information flows in the parse tree, attributes are classified into Synthesized Attributes and Inherited Attributes.

Synthesized AttributesInherited Attributes
An attribute is synthesized if its value at a parse tree node is determined from the attribute values of its child nodes.An attribute is inherited if its value at a parse tree node is determined from the attribute values of its parent and/or sibling nodes.
The production must have a non-terminal as its head.The production must have a non-terminal in its body.
A synthesized attribute at node n is defined using attribute values of the children of n.An inherited attribute at node n is defined using attribute values of the parent, node itself, and siblings.
Evaluated using a bottom-up traversal of the parse tree.Evaluated using a top-down or sideways traversal of the parse tree.
Can be associated with both terminals and non-terminals.Associated only with non-terminals.
Used in S-attributed SDT and L-attributed SDT.Used only in L-attributed SDT.
Comment
Article Tags:

Explore