- Data Structure
- Networking
- RDBMS
- Operating System
- Java
- MS Excel
- iOS
- HTML
- CSS
- Android
- Python
- C Programming
- C++
- C#
- MongoDB
- MySQL
- Javascript
- PHP
- Physics
- Chemistry
- Biology
- Mathematics
- English
- Economics
- Psychology
- Social Studies
- Fashion Studies
- Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Difference between Synthesized and Inherited Attributes
Both Synthesized and Inherited Attribute are the part of semantics of a language that provide meaning to its constructs, like tokens and syntax structure. Semantics help interpret symbols, their types, and their relations with each other and its analysis judges whether the syntax structure constructed in the source program derives any meaning or not. Now on the basis of features of attributes we can distinguish between Synthesized and Inherited Attributes
Following are the important differences between Synthesized and Inherited Attributes.
Sr. No. | Key | Synthesized Attribute | Inherited Attribute |
---|---|---|---|
1 | Definition | Synthesized attribute is an attribute whose parse tree node value is determined by the attribute value at child nodes.To illustrate, assume the following production S → ABC if S is taking values from its child nodes (A, B, C), then it is said to be a synthesized attribute, as the values of ABC are synthesized to S. | On other hand an attribute is said to be Inherited attribute if its parse tree node value is determined by the attribute value at parent and/or siblings node. In case of S → ABC if A can get values from S, B and C. B can take values from S, A, and C. Likewise, C can take values from S, A, and B then S is said to be Inherited Attribute. |
2 | Design | As mentioned above in case of Synthesized attribute the production must have non-terminal as its head. | On other hand in case of Inherited attribute the production must have non-terminal as a symbol in its body. |
3 | Evaluation | Synthesized attribute can be evaluated during a single bottom-up traversal of parse tree. | While on other hand Inherited attribute can be evaluated during a single top-down and sideways traversal of parse tree. |
4 | Terminal | Both terminal and Non terminals can contain the Synthesized attribute. | On other hand only Non terminals can contain the Inherited attribute. |
5 | Usage | Synthesized attribute is used by both S-attributed SDT and L-attributed STD. | On other hand Inherited attribute is used by only L-attributed SDT. |
Advertisements