The Symbol Table Module

A symbol table is a representation of the source code that provides a means to associate names with symbols, i.e. objects of a specific type. Such a symbol table is a graph composed of interconnected scopes, and the type of the scopes as well as the topology of the graph determine how the symbol lookup is performed.

Symbols are declared by the parser as soon as they are encountered, since the parser itself may need them later to disambiguate certain syntactic constructs.

SymbolTable::Display

As a way to inspect the constructed symbol table, the SymbolTable module provides a simple API to print the content of a Scope.

            SymbolTable::display(scope, std::cout);
          

will print the scope referred to by scope to std::cout.

Again, this API turned out to be rather useful, and so there is a stand-alone applet that just generates a symbol table and then prints it out using the above function.

            display-symbols [-d] <input>
          

The available options are:

-d

Print debug information (in particular traces) during the parsing.