Semantic analysis or context sensitive analysis is a process in
compiler
In computing, a compiler is a computer program that Translator (computing), translates computer code written in one programming language (the ''source'' language) into another language (the ''target'' language). The name "compiler" is primaril ...
construction, usually after
parsing
Parsing, syntax analysis, or syntactic analysis is a process of analyzing a String (computer science), string of Symbol (formal), symbols, either in natural language, computer languages or data structures, conforming to the rules of a formal gramm ...
, to gather necessary semantic information from the
source code
In computing, source code, or simply code or source, is a plain text computer program written in a programming language. A programmer writes the human readable source code to control the behavior of a computer.
Since a computer, at base, only ...
.
It usually includes
type checking
In computer programming, a type system is a logical system comprising a set of rules that assigns a property called a ''type'' (for example, integer, floating point, string) to every '' term'' (a word, phrase, or other set of symbols). Usu ...
, or makes sure a variable is declared before use which is impossible to describe in the
extended Backus–Naur form
Extension, extend or extended may refer to:
Mathematics
Logic or set theory
* Axiom of extensionality
* Extensible cardinal
* Extension (model theory)
* Extension (proof theory)
* Extension (predicate logic), the set of tuples of values ...
and thus not easily detected during parsing.
See also
*
Attribute grammar
*
Context-sensitive language
*
Semantic analysis (computer science)
References
Compiler construction
Program analysis
{{plt-stub