Syntax Tree OrganizationTopSymbol Table Organization Overview

Symbol Table Organization Overview

The symbol table maintained by your compiler will consist of two main components. The first is a collection of dynamically allocated structures containing one element for each distinct identifier used in the program. We will refer to this collection of structures as the identifier table and to its elements as identifier descriptors. Each of these elements will contain a pointer to the character string representation of the identifier with which it is associated and several other link fields. This table will be created by the scanner.

The second component is a collection of dynamically allocated structures including one element for each distinct declaration or definition in the program. We will refer to this collection of structures as the declaration table and its elements as declaration descriptors. These entries will be created and initialized by the semantic processing phase of your compiler. Each of these elements will include a pointer to the identifier descriptor for the identifier with which it is associated; attribute fields describing important characteristics of this declaration of the identifier (such as whether it is a function, a type or a variable); and several additional link fields.

In the syntax trees produced as output of the syntactic analysis phase, identifiers will be represented by pointers to their identifier descriptors. During the semantic processing phase, references to identifiers within the syntax tree will be modified so that references to identifier descriptors are either replaced by or augmented with references to declaration descriptors.

The construction of the symbol table will depend on two hash tables. The first of these hash tables is used by the scanner to locate the appropriate identifier descriptors as it encounters identifiers in the source program. You will not be concerned with the details of this hash table (I will provide you with the object code of a scanner including the hash table).

The second hash table is used to locate the declaration descriptors for structure component names. Given a component name and a pointer to the declaration descriptor for a structure type, this table will enable one to locate the declaration descriptor for the named component of the type if the named component is indeed a component of the specified structure type. This search structure will be created and maintained by the semantic processing phase of your compiler.

The format of the structures used to hold identifier and declaration descriptors is discussed below, after the specification of the syntax trees for Co.


Computer Science 434
Department of Computer Science
Williams College

Syntax Tree OrganizationTopSymbol Table Organization Overview