CS331 Compiler Project
Phase 3

SYMBOL TABLES



Our compiler will require three different symbol tables: a constant table, into which constants are inserted when encountered during lexical analysis; a global symbol table, which contains names known throughout all scopes of the Pascal program; and a local symbol table, which contains names known in the block currently being parsed. The constant and global tables will be set up at the very outset of compilation, before the first token is scanned, and will not be deleted until the compilation process terminates. The global table will initially contain names of all built-in functions (in our case, read and write) and may also contain all keywords (if you use the symbol table for determining keywords). The constant table is initally empty. Local tables are instantiated when the compiler begins to parse a procedure or function and deleted when parsing of that procedure or function ends. All of the information in each of the symbol tables will be accessed using hashing. Each symbol table object will have the capability to insert a new entry and lookup an entry.