Attribute Grammar - Inherited Attributes

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:

    It is not an era of repose. We have used up all our inherited freedom. If we would save our lives, we must fight for them.
    Henry David Thoreau (1817–1862)

    The world of the egotist is, inevitably, a narrow world, and the boundaries of self are limited to the close horizon of personality.... But, within this horizon, there is room for many attributes that are excellent....
    Ellen Glasgow (1873–1945)