Symbol tables
Introduction / Definition
A symbol table maps names to information such as type, value, scope, or memory location. Compilers and interpreters use symbol tables during declaration and reference processing. Common operations include insert and lookup. Hash tables and balanced trees are typical implementations.
Syntax / Structure / Formula
lookup(name) → information
Detailed Explanation
When a compiler sees a variable declaration, it records the symbol. Later references perform a lookup to obtain its associated information.
Example
Example: count → \{type:int, scope:local\}.
Output / Result
The compiler can retrieve count's type and scope.
Important Points / Notes
- Used heavily in language tools.
- Scope may require nested tables.
Mini Practice Question
What information can a symbol-table entry store?