next up previous
Next: Name spaces and scopes Up: An Analyzer for ANSI Previous: Tree.map


Name Analysis

Name analysis establishes a meaning (possibly ``no meaning'', if certain errors have been made) for each identifier in the program. In the process, it decorates the nodes of the abstract syntax tree with attributes and stores properties of entities in the definition table. These attributes and properties provide the basis for constraint checking, and can also be used to guide a translation of the program.

Every identifier occurrence requires an integer-valued Sym attribute specifying its string table index. The string table index is provided by the lexical analyzer as the value of the terminal symbol identifer (see Section 1.1.3). IdentOcc defines a computation setting the Sym attribute from the terminal symbol value; that computation can be inherited by any nonterminal representing an identifier occurrence:

Name.lido[1]:

CLASS SYMBOL IdentOcc COMPUTE SYNT.Sym=TERM; END;

Regions of text encompassing identifier scopes[4]
Identifier occurrences[5]
Checking for definition errors[8]
This macro is attached to a product file.

Many of the computations used during semantic analysis are common to many trees, and have been captured in library modules. Modules actually used in the semantic analysis of C programs must be instantiated:

Name.specs[2]:

Instantiate modules[3]
This macro is attached to a product file.



Subsections
next up previous
Next: Name spaces and scopes Up: An Analyzer for ANSI Previous: Tree.map
2008-08-30