Assignment 1
Assignment 1
Assignment 1
MATRIC NO:15/69/0072
LEVEL: HND II PT
Question 1
Write a short note on Compiler Writing tools.
A compiler is a computer program which helps you transform source code written in a high-level
language into low-level machine language. It translates the code written in one programming language
to some other language without changing the meaning of the code. The compiler also makes the end
code efficient which is optimized for execution time and memory space.
The compiling process includes basic translation mechanisms and error detection. Compiler process
goes through lexical, syntax, and semantic analysis at the front end, and code generation and
optimization at a back-end.
Question 2
Explain briefly on the two parts of compilation.
The analysis part breaks up the source program into constituent pieces and creates an intermediate
representation of the source program.
The synthesis part constructs the desired target program from the intermediate representation.
Question 3
Explain briefly on the phases of compilation process.
Here, the character stream from the source program is grouped in meaningful sequences by identifying
the tokens. It makes the entry of the corresponding tickets into the symbol table and passes that token
to next phase.
Semantic Analyzer will check for Type mismatches, incompatible operands, a function called with
improper arguments, an undeclared variable, etc.
I. Helps you to store type information gathered and save it in symbol table or syntax tree
II. Allows you to perform type checking
In the case of type mismatch, where there are no exact type correction rules which satisfy the desired
operation a semantic error is shown.
Intermediate code is between the high-level and machine level language. This intermediate code needs
to be generated in such a manner that makes it easy to translate it into the target machine code.
The phases of a compiler are collected into front end and back end. The front end includes all analysis
phases end the intermediate code generator. The back end includes the code optimization phase and
final code generation phase.