📜  综合属性和继承属性的区别

📅  最后修改于: 2021-09-27 22:43:12             🧑  作者: Mango

在语法定向定义中,使用了两个属性,一个是合成属性,另一个是继承属性。如果一个属性的解析树节点值由子节点的属性值确定,则称该属性为合成属性,而如果其解析树节点值由父节点和/或兄弟节点的属性值确定,则称该属性为继承属性节点。

现在,我们将看到综合属性和继承属性之间的比较。
下面给出这两个属性之间的比较:

S.NO Synthesized Attributes Inherited Attributes
1. An attribute is said to be Synthesized attribute if its parse tree node value is determined by the attribute value at child nodes. 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.
2. The production must have non-terminal as its head. The production must have non-terminal as a symbol in its body.
3. A synthesized attribute at node n is defined only in terms of attribute values at the children of n itself. A Inherited attribute at node n is defined only in terms of attribute values of n’s parent, n itself, and n’s siblings.
4. It can be evaluated during a single bottom-up traversal of parse tree. It can be evaluated during a single top-down and sideways traversal of parse tree.
5. Synthesized attributes can be contained by both the terminals or non-terminals. Inherited attributes can’t be contained by both, It is only contained by non-terminals.
6. Synthesized attribute is used by both S-attributed SDT and L-attributed STD. Inherited attribute is used by only L-attributed SDT.
7.