Next / Previous / Contents / Shipman's homepage

3.3. Principal classes

At the top level, these objects represent all the input files.

In general, then, the task of nomcompile3 is to read all the input files and incorporate them into these instances, and then use the instances to generate all the output files.

A background in the construction of compilers and assemblers will be useful in understanding this program. In particular, the structure of the .alt file has the classic forward reference problem: some of the codes refer to other codes that have not yet been seen.

The classic technique for solving the forward reference problem is to build a symbol table—a structure containing an entry for every name that has been used so far, even though some names have not yet been defined.

Once all the names have been processed, we must make a pass through the symbol table to insure that all referenced symbols have been defined.

The symbol table entries are instances of a class named AbSym. Each instance contains two attributes: .abbr, the bird code as a string, and .binding, which describes the definition of that bird code, if one has been encountered.

The .binding attribute is initially set to None. When a definition of that code is encountered, the .binding attribute is set to an instance derived from the abstract class AbBind. The various concrete classes derived from AbBind represent the different kinds of definitions of a bird code:

Here, then, is an entity-relationship diagram that depicts the relationships among these classes.