Symbol Table
The symbol table is a data structure that is present in the compiler in order to keep a track of the semantic variables. It stores the information that is required in the program like the instances of variables, binding information about information, scope of variables, function names, classes etc.
The lexical and syntax analysis phase holds the symbol table. The analysis phase of the compiler collects the information, and the synthesis phase generates the code.
It is also used to increase the time efficiency of the compiler. The symbol table is used in almost all the phases of the compiler.
It is used in each phase for different purposes
- It creates new table entries in the lexical analysis phase, like for entering the tokens.
- It adds the information about the program in the syntax analysis phase.
- It refers to the table in the intermediate code generation phase to know the runtime allocated and also, it helps to add information about temporary variables.
- It uses the information present for machine-dependent optimization in the Code optimization phase.
- Uses the address information present in the table for generating the code in the Target Code Generator Phase.
Symbol Table