Semantic analysis (compilers)

This is an old revision of this page, as edited by Jan Hidders (talk | contribs) at 15:29, 8 February 2004 (remove 'see also', improve style). The present address (URL) is a permanent link to this revision, which may differ significantly from the current revision.

In computer science, semantic analysis is a pass by a compiler that adds semantical information to the parse tree and performs certain checks based on this information. It follows the parsing phase, in which the parse tree is generated, and precedes the code generation phase, in which executable code is generated. Typical examples of semantical information that is added and checked is typing information (type checking) and the binding of variables and function names to their definitions (object binding). Sometimes also some early code optimization is done in this phase.

For this phase the compiler usually maintains socalled symbolic tables in which it stores what each symbol (variable names, function names, etc.) refers to.