A compiler operates in phases, each of which transform the source program from one representation to another. Generally, these are six types of phases in compiler. These are -
- Lexical Analysis
- Syntax Analysis
- Semantic Analysis
- Intermediate code generation
- Code Optimization
- Code Generation
Lexical Analysis : Linear Analysis is called lexical analysis or scanning. Linear analysis reads the character in the source program & groups them into tokens in which each token represents a logically cohesive sequence of characters such as identifier. A key words(if, while etc.). A punctuation character or multi-character operator like : =.
Syntax Analysis : Hierarchical analysis is called syntax analysis or parsing. in the syntax analysis, the character or tokens are grouped hierarchically into nested collection with collective meaning.
Semantic Analysis : The semantic analysis phase checks the source program for semantic errors & gathers type information for the sub-sequent code generation phase. It uses the hierarchical structure determined by the syntax - analysis phase to identify the operators & operands of expression & statements. An important component of semantic analysis is type checking.
0 comments:
Post a Comment