Inherited Attributes
An inherited attribute at a node in parse tree is defined using the attribute values at the parent or siblings. Inherited attributes are convenient for expressing 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 the right side of an assignment in order to decide whether the address or the value of the identifier is needed.
| Production rule | Semantic rule |
|---|---|
| S → T L | L.in:=T.type |
| T → int | T.type:=integer |
| T → float | T.type:=float |
| T → char | T.type:=char |
| T → double | T.type:=double |
| L → L1, id | L1.in=L.in
enter_type(id.entry, L.in) |
| L → id | enter_type(id.entry, L.in) |
Read more about this topic: Attribute Grammar
Famous quotes containing the words inherited and/or attributes:
“I rejoice that horses and steers have to be broken before they can be made the slaves of men, and that men themselves have some wild oats still left to sow before they become submissive members of society. Undoubtedly, all men are not equally fit subjects for civilization; and because the majority, like dogs and sheep, are tame by inherited disposition, this is no reason why the others should have their natures broken that they may be reduced to the same level.”
—Henry David Thoreau (18171862)
“God is the efficient cause not only of the existence of things, but also of their essence.
Corr. Individual things are nothing but modifications of the attributes of God, or modes by which the attributes of God are expressed in a fixed and definite manner.”
—Baruch (Benedict)