Compiler: Compiler is a translation Software , used to translate high level language program in to it equivalent machine code.Also error are reported at the end of compilation process.- A compiler compile as a whole program.
- A compiler detect the error at the end after compilation.
- A compiler generate an object code.
- Mainly used in C, C++, & Fortaan etc
- Analysis phase
- Synthesis phase
In this phase the source program is analysed each, Statement etc are checked Syntactically and Semantically according to rule of the language binge used.
What is Synthesis phase?
It perform conversion of source program (Syntactically & Semantically )in to a target/ machine code.
LOGICAL DECOMPOSITION OF COMPILER
As we have study that a compiler is divided in to two phase , now these two phase are further sub divided in three phases.
Analysis phase is divided into following three phases.
- Lexical analysis phase
- Syntax analysis phase
- Semantic analysis phase
This is a very first phase of compiler it take source program as input and divided it in to smaller and meaning full parts , this small and meaning full parts are called Tokens, There are five parts which the program/ code are divided
- Constant
- Identifiers
- Operators
- punctuators
- Reserved Words
*. The module which perform lexical phase are called Scanner / lexical analyseer.
*. Lexical analysis phase takes source program as input and give token as output.
Syntax analysis phase?
This phase takes the token as input and generates a hierarchical structure called parse/ syntax tree, in order to syntactically check each and every statement written in source program according to the rule defined by the language being used.
Syntax analysis is a process and module that operate syntax analysis is called parser / syntax analyseer.
The error detect in this phase is called syntax error.
Semantic analysis phase?
This phase takes the parse/syntax tree as input and generate semantic parse tree. This phase is responsible to perform operation like type conversion , operators compatibility and array abound checking etc.
Module which performs this phase called semantic analyseer.
The error detected in this phase are called Semantic Error.
What is Synthesis phases?
1. Intermediate code Generation phase:
This phase is responsible to convert the source program in to three-Address code format which is normally called as intermediate code.
Why Three-Address code format?
Source code is converted in to three-address format, because Assembly language is three-address language, So the conversion of three-address code to assembly code is easier and simple.
The module that perform this phase is called "Intermediate code Generation"
Code Optimization phase:
In this phase,the intermediate code generated in previous phase is reduced to minimum number of statement if possible.
The module of compiler that perform code optimization is called code optimizer.
Code Generation phase:
The last phase of compiler that converts the optimized code into a machine/ target code.

No comments:
Post a Comment