The Symbol Table stores the following items:
- Variable names
- Constants
- Procedure / Function names
- Strings
- Compiler generated temporaries
- Labels in source language
- Parameters
- Array and files
Compiler uses following types of information from symbol table:
- Data type
- Name
- Declaring procedures
- Storage
- If structure or record, then pointer to structure table
- For parameters, whether parameter passing is by value or reference?
- Number and type of arguments passed to the function
- Base address
Symbol Table Operations:
Major operations required of a symbol table are:
- Insertion
- Search
- Deletions which are ‘Purely Logical’ depending scope and visibility and ‘not physical’
Symbol Table and its relations with various phases of Compiler
- Symbol Table is accessed at every stage of the compilation process
$\triangleright $Scanning includes insertion of new identifiers
$\triangleright $Parsing access to the symbol table to ensure that an operand exists (declaration before use)
$\triangleright $Semantic analysis includes,
$\triangleright $Determination of types of identifiers from declarations
$\triangleright $Type Checking to ensure that operands are used in type valid contexts
$\triangleright $Checking scope, visibility notations
Intermediate generation, memory allocation and for relative address (i.e., relative to a base address that is known only at run time) calculation
Optimization, all memory accesses through symbol table
Target code, translation of relative addresses to absolute address in terms of word length, word boundary etc.
0 comments:
Post a Comment