In: Computer Science
---------This question is related to Compiler Design----------
What are the different phases of a compiler. How can we group these phases into two
major groups. What are some of the advantages of this grouping.
Compiler is a special program that converts high level language to machine level or low level.
There are 6 phases in a compiler. They are
1) Lexical Analysis
2) Syntax Analysis
3) Semantic Analysis
4) Intermediate Code Generation
5) Code Optimization
6) Code Generation.
The above 6 phases are divided into 2 groups Analysis Phase and Synthesis Phase.
The first 3 components constitute Analysis Phase(Lexical Analysis, Syntax Analysis, Semantic Analysis)
The last 3 components constitute Synthesis Phase(Intermediate Code Generation, Code Optimization, Code Generation)
Advantages of this Grouping
1) Reduced time as when the code is perfectly parsed then only it will be processed by the next group.
2) Redundancy is minimized. Each group works on its own and no task is carried out redundantly.
3) Improves efficiency. The output of one group will be sent to the other meanwhile if any left over instructions will be carried out by the first group.
4) Accountability will be more and ease of debugging errors by the programmer if any is easy.