|
Slide 5.1: Synthesized attributes Slide 5.3: A translational-semantics example Home |
|
B at a parse-tree node N is defined by a semantic rule associated with the production at the parent of N.
An inherited attribute at node N is defined only in terms of attribute values at N's parent, N itself, and N's siblings.
The following syntax-directed definitions takes a simple declaration <D> consisting of a basic type <T> followed by a list L of identifiers.
<T> can be int or float.
For each identifier on the list, the type is entered into the symbol-table entry for the identifier.
The function addType is called with two arguments:
|
|
Entry(id), a lexical value that points to a symbol-table object, and
Inh(<L>)], the type being assigned to every identifier on the list.
Inh(<L>) as the type of the represented identifier id.
The following figure shows a dependency graph for the input string “float id1, id2, id3”.