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.

Symbol Tables and Hash Functions
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.
Symbol Table Management
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
Storing identifiers into symbol table is simple because of the way how Turbo Pascal organizes symbol tables.
Searching in Symbol Table
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.
Searching For Identifiers
This function checks for identifier that should be already declared. If Token is Token_Identifier it checks if identifier is declared under current scope. If not the error is reported.
Compacting Symbol Tables
After each module is compiled the symbol tables are compacted to remove unused space.
Checking Public Identifiers
Turbo Pascal calculates a checksum of public identifiers for every unit to quickly check if something has been changed.
Reserved Words
All Turbo Pascal reserved words are stored in a dedicated symbol table.

© 2021 Turbo Pascal | Privacy Policy