Login
OTIL Implementation Notes
Login

This page is dedicated to gathering useful information for designing the architecture of OTIL compilers.

Symbol Tables

In the following there will be extensive use of the term Symbol. This means anything that is referred to by a programmer decided name such as a variable or a function. This is a term of art in compiler construction rather than a language feature of OTIL as such. Likewise a Symbol Table is a collection of known symbols that the compiler is presently keeping track of.

OTIL draws heavily from the extremely rigid approach to declarations used in Pascal. There is limited support for local scope, limited places in which symbols maybe declared and everything must be declared prior to being used.

Scope

OTIL does not support arbitrarily nested scopes. Instead there are a fixed number of acceptable scopes as follows:

Locations and order of declarations

There are a handful of designated places for declaring symbols prior to their use:

All symbols must be declared prior to being invoked. To this end OTIL supports forward-declaration so that procedures and functions can be quickly listed without their lengthy definitions. In fact procedures and functions listed in the INTERFACE section of a module or library are required to be forward declarations.

Putting it all together

Because of the strictly limited number of scopes, strict rules regarding where things may be declared and requirement that everything is declared prior to use an OTIL compiler can do the entire task of building a symbol table prior to analysing the main body of a program or the body of a procedure/subroutine. There is no need for the symbol table to include entries with missing details. This markedly reduces how complex the compiler's middle-end needs to be.