Symbol Tables

Symbol tables are core part of every compiler. Turbo Pascal uses linked lists and hasing to effectively store and retrieve identifiers. Functions in this unit take care for data storing, identifier searching and various symbol table management.

This function checks for identifier that should be already declared.

Every compiler stores data in different symbol tables. Symbol table is a special data structure that is designed for easy insertion of new symbol with associated data and quick search through all elements in the table.

Each identifier symbol table must be created before it can be used. Turbo Pascal uses diferent parameters (number of linked lists) for different identifier symbol tables.

Storing identifiers into symbol table is simple because of the way how Turbo Pascal organizes symbol tables.

This function searches for current identifier in specified symbol table. The speed of this function and the design of symbol tables (hash function) have a significant impact on the speed of the compiler. Hash function splits identifiers into several linked lists so only one list is checked when searching for identifier. However, all the identifiers …

After each module is compiled the symbol tables are compacted to remove unused space.

Turbo Pascal calculates a checksum of public identifiers for every unit to quickly check if something has been changed.

All Turbo Pascal reserved words are stored in a dedicated symbol table.