1 Compiler Phases
1 Compiler Phases
College of science
Department of Computer Science
Compiler
The Structure of the Compiler
Lecture One
2023-2024
Mzhda Hiwa
Complier
• A compiler is a computer program that translates a program
written in a high-level programming language that is suitable
for human programmers into the low-level machine language
that is required by computers.
Source Code
Executable Code
Interpreter and its Differences with Compiler
Interpreters also convert high level language into machine
readable binary equivalents.
• There are some differences between compiler and
interpreter:
After Preprocessing
int main (){
int x=10;
}
Assembler
Assembly Machine
Source Compiler Assembler
Language code
program
program
Linker
• Usually a longer program is divided into smaller subprograms
called modules. And these modules must be combined to
execute the program. The process of combining the modules is
done by the linker.
• Linkers links the libraries and functions which are essential for
executing a program.
t1 = inttofloat(60)
t2 = id3 * t1
t3 = id2 + t2
id1 = t3
• Ex:
LDF R2, id3
MULF R2, R2, #60.0
LDF Rl, id2
ADDF Rl, Rl, R2
STF idl, Rl
• The phases of a compiler are collected into front end and back end.
• The FRONT END consists of those phases that depend primarily on the
source program. These normally include Lexical and Syntactic analysis,
Semantic analysis ,and the generation of intermediate code.
• The BACK END includes the code optimization phase and final code
generation phase, along with the necessary error handling and symbol
table operations.
• The front end Analyses the source program and produces intermediate
code while the back end Synthesis the target program from the
intermediate code.
Middle End