Professional Documents
Culture Documents
Compiler Construction CS-4207: Lecture 1 & 2 Instructor Name: Atif Ishaq
Compiler Construction CS-4207: Lecture 1 & 2 Instructor Name: Atif Ishaq
Compiler Construction CS-4207: Lecture 1 & 2 Instructor Name: Atif Ishaq
CS-4207
Language Processor
Structure of Compiler
Phases of Compiler
2
Introduction
Course Objective
The course is intended to teach the students the basic techniques that underlie the
The course will introduce the theory and tools that can be standarly employed in
3
Introduction
Recommended Books
The Recommended book for this course
Other Material
4
Introduction
Marks Distribution
Mid Exam 20% (Min 2 Assignments)
5
Introduction
What is Compiler?
Programming Languages are notation for describing computation for both human
and machines
computer
6
Language Processors
What is Compiler?
Compiler is a program that can read a program in one language (source language)
What is Interpreter?
An interpreter directly execute the operations specified in the source program on
Source Code
Interpreter Outputs
Inputs
8
Language Processors
Compiler Vs Interpreter
Target Program generated by compiler is much faster that Interpreter
statement execution
9
Why Study Compiler Construction?
The study of compilers clarifies many deep issues in programming languages and
their execution, e.g. recursion, multithreading, object orientation. It may help you
design your own mini-language.
For example
10
Why Study Compiler Construction?
The compiler should be able to reconcile these two (sometimes conflicting) trends.
11
Why Study Compiler Construction?
12
Structure of Compiler
The analysis part breaks up the source program into constituent pieces and
impose a grammatical structure on them. The analysis part also collects
information about the source program and stores it in a data structure called
symbol table which is passed along with intermediate representation to the
synthesis part.
The synthesis part constructs the desired target program from the
intermediate representation and the information in the symbol table.
The analysis part is often called the front end of the compiler and the
synthesis part called the back end of compiler.
13
Context of a Compiler
14
Phases of a Compiler
15
Analysis of Source Program
16
Example Illustration (1/4)
(token-name , attribute-value)
18
Example Illustration (2/4)
19
Example Illustration (3/4)
20
Example Illustration (4/4)
21
Syntax Analysis
22
Semantic Analysis
24
Code Optimization
25
Code Generation
26
Symbol Table Management
27
Lecture Outcome
28
29