The compilation can be done in two parts : Analysis and synthesis, In analysis part the source program is read and broken down into constituent pieces, The syntax and the meaning of the source string is detenruned and then an intermediate code is created from the input source program. In synthesis put this internediate form of the source language is taken and converted into an equivalent target program.
When compiler is built it should possess following properties .
1. The compiler itself must be bug free.
2. It must generate correct machine code.
3. The generated machine code must run fast.
4. The compiler itself must run fast (compilation time must be proportional to program size).
5. The compiler must be portable (i.e. modular supporting separate compilation).
6. It must give good diagnostics and error messages.
7. The generated code must work well with existing debuggers.
8. It must have consistent optimization.
Analysis of Source Program
The source program can be analysed in three phases .
1) Linear Analysis. : In this type of analysis the source string is read from left to right and grouped into tokens. For example· Tokens for a language can be identifiers, constants, relational operators, keywords.
2) Hierarchical Analysis : In this analysis, characters or tokens are grouped hierarchically into nested collections for checking them syntactically.
3) Semantic Analysis: This kind of anaIysis ensures the correctness of meaning of the program.