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:
“The scientific mind is atrophied, and suffers under inherited cerebral weakness, when it comes in contact with the eternal womanAstarte, Isis, Demeter, Aphrodite, and the last and greatest deity of all, the Virgin.”
—Henry Brooks Adams (18381918)
“True and false are attributes of speech not of things. And where speech is not, there is neither truth nor falsehood. Error there may be, as when we expect that which shall not be; or suspect what has not been: but in neither case can a man be charged with untruth.”
—Thomas Hobbes (15881679)