Inherited attributes

From eplmediawiki
This is the approved revision of this page, as well as being the most recent.
Jump to: navigation, search

An inherited attribute is one whose value at a node in a parse tree is defined in terms of attributes at the parent and/or sibling of that node. Inherited attributes are convenient for express the dependence of a programming language construct on the context in which it appears. For example, we can use an inherited attribute to keep track of whether an identifier appears on the left or right side of an assignment in order to decide whether the adress or the value of the identifier is needed. Although it is always possible to rewrite a syntax-directed definition to use only synthesized attributes, it is often more natural to use syntax-directed definitions with inherited attributes.

in "Compilers: Principles, Techniques and Tools"
Alfred V. Aho, Ravi Sethi, Jeffrey D. Ullman

See also: Synthesized attributes

Personal tools