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)

    “Why does not the kitten betray some of the attributes common to the adult puss? A puppy is but a dog, plus high spirits, and minus common sense. We never hear our friends say they love puppies, but cannot bear dogs. A kitten is a thing apart; and many people who lack the discriminating enthusiasm for cats, who regard these beautiful beasts with aversion and mistrust, are won over easily, and cajoled out of their prejudices, by the deceitful wiles of kittenhood.”
    —Agnes Repplier (1858–1950)