Escolar Documentos
Profissional Documentos
Cultura Documentos
Adnan Ferdous Ashrafi CSI 411 - Compiler Lecture 1 - Introduction to Compiler September 20, 2020 1 / 14
1 Introduction
Course Details
Marks Distribution
Adnan Ferdous Ashrafi CSI 411 - Compiler Lecture 1 - Introduction to Compiler September 20, 2020 2 / 14
Introduction
Adnan Ferdous Ashrafi CSI 411 - Compiler Lecture 1 - Introduction to Compiler September 20, 2020 3 / 14
Marks Distribution
Attendance : 10%
Class Tests : 30% (Best 3 will be counted)
Midterm : 30%
Final : 30%
Total : 100%
Adnan Ferdous Ashrafi CSI 411 - Compiler Lecture 1 - Introduction to Compiler September 20, 2020 4 / 14
What is a Compiler?
Definition of a Compiler
Programming languages are notations for describing computations to people
and to machines. The world as we know it depends on programming lan-
guages, because all the software running on all the computers was written
in some programming language. But, before a program can be run, it first
must be translated into a form in which it can be executed by a computer.
The software systems that do this translation are called compilers.
Adnan Ferdous Ashrafi CSI 411 - Compiler Lecture 1 - Introduction to Compiler September 20, 2020 5 / 14
Compiled Languages Vs. Interpreted Languages
Figure 2: An Interpreter
Adnan Ferdous Ashrafi CSI 411 - Compiler Lecture 1 - Introduction to Compiler September 20, 2020 7 / 14
Structure of a typical Compiler
1 Lexical Analyzer
x = a + b × c;
⇓
id = id + id × id ;
id a
Symbol Table id b
id c
id x
Adnan Ferdous Ashrafi CSI 411 - Compiler Lecture 1 - Introduction to Compiler September 20, 2020 9 / 14
An Example - Part II
2 Syntax Analyzer
id = id + id × id ;
⇓
E → E+T I T
T → T×F I F
F → id
3 Semantics Analyzer
Adnan Ferdous Ashrafi CSI 411 - Compiler Lecture 1 - Introduction to CompilerSeptember 20, 2020 11 / 14
An Example - Part IV
t1 = b×c;
t2 = a+t1 ;
x = t2 ;
5 Code Optimizer
Table 3: Optimized Code
t1 = b×c;
x = a+t1 ;
Adnan Ferdous Ashrafi CSI 411 - Compiler Lecture 1 - Introduction to CompilerSeptember 20, 2020 12 / 14
An Example - Part V
MUL R1,R2
ADD R2,R0
MOV x,R2
R0 a
R1 b
R2 c
Adnan Ferdous Ashrafi CSI 411 - Compiler Lecture 1 - Introduction to CompilerSeptember 20, 2020 13 / 14
Thank you.
Any Questions?
Adnan Ferdous Ashrafi CSI 411 - Compiler Lecture 1 - Introduction to CompilerSeptember 20, 2020 14 / 14