Compiler
Compiler
Cross Compiler
Runs on one machine and generates assembly code for another machine.
C-compiler works in 2 passes where pass 1 performs Analysis and pass 2
performs synthesis.
C- Compiler is written 80% in C-Language and 20 % in ALP Language.
Writing Compiler in its own language is called as boot strapping.
C-Compiler uses combination of recursive recent parser and operator
precedence parser.
Syntax Analysis
Semantic Analysis
Semantic analysis checks whether the parse tree constructed follows the
rules of language.
For example, assignment of values is between compatible data types, and
adding string to an integer.
Also, the semantic analyzer keeps track of identifiers, their types and
expressions; whether identifiers are declared before use or not etc. The
semantic analyzer produces an annotated syntax tree as an output.
Code Optimization
Code Generation
In this phase, the code generator takes the optimized representation of the
intermediate code and maps it to the target machine language.
The code generator translates the intermediate code into a sequence of
(generally) re-locatable machine code.
Sequence of instructions of machine code performs the task as the
intermediate code would do.
Symbol Table
Error handling
It is responsible for handling of the errors which can occur in any of the
compilation.