About
Semantic analysis is the phase in which the compiler:
- adds semantic information to the parse tree
- builds the symbol table.
This phase performs semantic checks such as:
- type checking (checking for type errors),
- or object binding (associating variable and function references with their definitions),
- or definite assignment (requiring all local variables to be initialized before use), rejecting incorrect programs or issuing warnings.
Semantic analysis usually requires a complete parse tree, meaning that this phase logically follows the parsing phase, and logically precedes the code generation phase.