SlideShare a Scribd company logo
Date :- 16,jan,2015
Compiler
Presented to: Sir Khalid Mehmood
Group Name: Tech Routers
Members:
Muhammad Ahtisham 2813
Nouman Chudhary 2463
Waqas Ahmad 2481
Junaid Pervaiz 2468
Umair Ilyas 2809
Jawad Mian 2490
Sohaib Raza 2497
Muhammad Waqas 2803
What Do Compilers Do (1)
2
 A compiler acts as a translator,
transforming human-oriented programming languages
into computer-oriented machine languages.
 Ignore machine-dependent details for programmer
Programming
Language
(Source)
Compiler
Machine
Language
(Target)
3
 Any compiler must perform two major tasks
 Analysis of the source program
 Synthesis of a machine-language program
The Structure of a Compiler (1)
Compiler
Analysis Synthesis
Preprocessors, Compilers, Assemblers,
and Linkers
Preprocessor
Compiler
Assembler
Linker
Skeletal Source Program
Source Program
Target Assembly Program
Relocatable Object Code
Absolute Machine Code
Libraries and
Relocatable Object Files
Try for example:
gcc -v myprog.c
The Structure of a Compiler (2)
5
Scanner Parser
Semantic
Routines
Code
Generator
Optimizer
Source
Program Tokens Syntactic
Structure
Symbol and
Attribute
Tables
(Used by all Phases of The
Compiler)
(Character
Stream)
Intermediate
Representation
Target machine code
The Structure of a Compiler (3)
6
Scanner Parser
Semantic
Routines
Code
Generator
Optimizer
Source
Program Tokens Syntactic
Structure
Symbol and
Attribute
Tables
(Used by all
Phases of
The Compiler)
Scanner
 The scanner begins the analysis of the source program by
reading the input, character by character, and grouping
characters into individual words and symbols (tokens)
 RE ( Regular expression )
 NFA ( Non-deterministic Finite Automata )
 DFA ( Deterministic Finite Automata )
(Character
Stream)
Intermediate
Representation
Target machine code
The Structure of a Compiler (4)
7
Scanner Parser
Semantic
Routines
Code
Generator
Optimizer
Source
Program Tokens Syntactic
Structure
Symbol and
Attribute
Tables
(Used by all
Phases of
The Compiler)
Parser
 Given a formal syntax specification (typically as a context-
free grammar [CFG] ), the parse reads tokens and groups
them into units as specified by the productions of the CFG
being used.
 As syntactic structure is recognized, the parser either calls
corresponding semantic routines directly or builds a
syntax tree.
 CFG ( Context-Free Grammar )
 GAA ( Grammar Analysis Algorithms )
(Character
Stream)
Intermediate
Representation
Target machine code
The Structure of a Compiler (5)
8
Scanner Parser
Semantic
Routines
Code
Generator
Optimizer
Source
Program
(Character
Stream)
Tokens Syntactic
Structure
Intermediate
Representation
Symbol and
Attribute
Tables
(Used by all
Phases of
The Compiler)
Semantic Routines
 Perform two functions
 Check the static semantics of each construct
 Do the actual translation
 The heart of a compiler
 Syntax Directed Translation
 Semantic Processing Techniques
 IR (Intermediate Representation)
Target machine code
The Structure of a Compiler (6)
9
Scanner Parser
Semantic
Routines
Code
Generator
Optimizer
Source
Program Tokens Syntactic
Structure
Symbol and
Attribute
Tables
(Used by all
Phases of
The Compiler)
Optimizer
 The IR code generated by the semantic routines is
analyzed and transformed into functionally equivalent but
improved IR code
 This phase can be very complex and slow
 loop optimization, register allocation, code scheduling
 Register and Temporary Management
(Character
Stream)
Intermediate
Representation
Target machine code
The Structure of a Compiler (7)
10
Source
Program
(Character
Stream)
Scanner
Tokens
Parser
Syntactic
Structure
Semantic
Routines
Intermediate
Representation
Optimizer
Code
Generator
Code Generator
 Interpretive Code Generation
 Generating Code from Tree/Dag
 Grammar-Based Code Generator
Target machine code
The Structure of a Compiler (8)
11
Scanner
[Lexical Analyzer]
Parser
[Syntax Analyzer]
Semantic Process
[Semantic analyzer]
Code Generator
[Intermediate Code Generator]
Code Optimizer
Tokens
Parse
tree
Abstract Syntax Tree w/
Attributes
Non-optimized Intermediate
Code
Optimized Intermediate Code
Code Optimizer
Target machine code

More Related Content

What's hot (20)

PPT
Phases of compiler
PANKAJKUMAR2519
 
PPTX
Phases of Compiler
Tanzeela_Hussain
 
PPT
Compiler Construction introduction
Rana Ehtisham Ul Haq
 
PPTX
Compilers
Satyamevjayte Haxor
 
PPTX
Compilers
Bense Tony
 
PPT
Classification of Compilers
Sarmad Ali
 
PPTX
Compiler design
Thakur Ganeshsingh Thakur
 
PPT
Compiler Design
Mir Majid
 
DOC
Compiler Design(NANTHU NOTES)
guest251d9a
 
PPTX
compiler and their types
patchamounika7
 
DOCX
Techniques & applications of Compiler
Preethi AKNR
 
PDF
COMPILER DESIGN- Introduction & Lexical Analysis:
Jyothishmathi Institute of Technology and Science Karimnagar
 
PPTX
Compiler design
nazmul hoque
 
PDF
Phases of Compiler
A. S. M. Shafi
 
PPT
Compiler1
Natish Kumar
 
PDF
Lecture 01 introduction to compiler
Iffat Anjum
 
PPTX
Basic of compiler
Abhishek Singh
 
PPT
phases of a compiler
Ms.SHANTHI.S CSE
 
PPTX
COMPILER DESIGN OPTIONS
sonalikharade3
 
PPSX
Spr ch-05-compilers
Vasim Pathan
 
Phases of compiler
PANKAJKUMAR2519
 
Phases of Compiler
Tanzeela_Hussain
 
Compiler Construction introduction
Rana Ehtisham Ul Haq
 
Compilers
Bense Tony
 
Classification of Compilers
Sarmad Ali
 
Compiler design
Thakur Ganeshsingh Thakur
 
Compiler Design
Mir Majid
 
Compiler Design(NANTHU NOTES)
guest251d9a
 
compiler and their types
patchamounika7
 
Techniques & applications of Compiler
Preethi AKNR
 
COMPILER DESIGN- Introduction & Lexical Analysis:
Jyothishmathi Institute of Technology and Science Karimnagar
 
Compiler design
nazmul hoque
 
Phases of Compiler
A. S. M. Shafi
 
Compiler1
Natish Kumar
 
Lecture 01 introduction to compiler
Iffat Anjum
 
Basic of compiler
Abhishek Singh
 
phases of a compiler
Ms.SHANTHI.S CSE
 
COMPILER DESIGN OPTIONS
sonalikharade3
 
Spr ch-05-compilers
Vasim Pathan
 

Viewers also liked (9)

PPTX
GCC
Kir Chou
 
PPT
Principles of compiler design
Janani Parthiban
 
PDF
Preprocessor
Learn By Watch
 
PPTX
Yacc (yet another compiler compiler)
omercomail
 
PPT
Assembler
Mohd Arif
 
PDF
Compression: Images (JPEG)
danishrafiq
 
PPTX
Translators(Compiler, Assembler) and interpreter
baabtra.com - No. 1 supplier of quality freshers
 
PPTX
JPEG Image Compression
Aishwarya K. M.
 
PPTX
Compiler Chapter 1
Huawei Technologies
 
Principles of compiler design
Janani Parthiban
 
Preprocessor
Learn By Watch
 
Yacc (yet another compiler compiler)
omercomail
 
Assembler
Mohd Arif
 
Compression: Images (JPEG)
danishrafiq
 
Translators(Compiler, Assembler) and interpreter
baabtra.com - No. 1 supplier of quality freshers
 
JPEG Image Compression
Aishwarya K. M.
 
Compiler Chapter 1
Huawei Technologies
 
Ad

Similar to Compiler (20)

PPT
cd-greeshma (1).ppt compiler design unit 1
vrawat4
 
PPT
cd-greeshma.ppt online downloaded for study
yashashreeg2307
 
PPT
Cd unit i
Abhimanyu Mishra
 
PPTX
Presentation compiler design
Md. Touhidur Rahman
 
PDF
1 introduction to compiler
BarwarBadradin
 
PPTX
Introduction to Compilers | Phases & Structure
International Institute of Information Technology (I²IT)
 
PPTX
Compiler Design Slides for Third Year Computer Science and Engineering
DrRajurkarArchanaMil
 
PPTX
CD U1-5.pptx
Himajanaidu2
 
PPT
A basic introduction to compiler design.ppt
pandaashirbad9
 
PPT
A basic introduction to compiler design.ppt
pandaashirbad9
 
PDF
Compilers Principles, Practice & Tools Compilers
ssuser964532
 
PDF
unit1pdf__2021_12_14_12_37_34.pdf
DrIsikoIsaac
 
PDF
Compiler construction lecture 01 .pptx.pdf
zamanjktiktok
 
PPT
Chap01-Intro.ppt
AhmadAbubaker16
 
PPTX
Introduction to Compiler Design Structutre, Phases
Vanitha Alagesan
 
PDF
Chapter1pdf__2021_11_23_10_53_20.pdf
DrIsikoIsaac
 
PPT
1 - Introduction to Compilers.ppt
Rakesh Kumar
 
PDF
Lecture 2.1 - Phase of a Commmmpiler.pdf
AbuZahed5
 
PPTX
Ch 1.pptx
woldu2
 
cd-greeshma (1).ppt compiler design unit 1
vrawat4
 
cd-greeshma.ppt online downloaded for study
yashashreeg2307
 
Cd unit i
Abhimanyu Mishra
 
Presentation compiler design
Md. Touhidur Rahman
 
1 introduction to compiler
BarwarBadradin
 
Introduction to Compilers | Phases & Structure
International Institute of Information Technology (I²IT)
 
Compiler Design Slides for Third Year Computer Science and Engineering
DrRajurkarArchanaMil
 
CD U1-5.pptx
Himajanaidu2
 
A basic introduction to compiler design.ppt
pandaashirbad9
 
A basic introduction to compiler design.ppt
pandaashirbad9
 
Compilers Principles, Practice & Tools Compilers
ssuser964532
 
unit1pdf__2021_12_14_12_37_34.pdf
DrIsikoIsaac
 
Compiler construction lecture 01 .pptx.pdf
zamanjktiktok
 
Chap01-Intro.ppt
AhmadAbubaker16
 
Introduction to Compiler Design Structutre, Phases
Vanitha Alagesan
 
Chapter1pdf__2021_11_23_10_53_20.pdf
DrIsikoIsaac
 
1 - Introduction to Compilers.ppt
Rakesh Kumar
 
Lecture 2.1 - Phase of a Commmmpiler.pdf
AbuZahed5
 
Ch 1.pptx
woldu2
 
Ad

More from IGZ Software house (20)

PPT
Window server 2008
IGZ Software house
 
PPTX
Types of server
IGZ Software house
 
DOCX
Types of network
IGZ Software house
 
PPT
Ip address and subnetting
IGZ Software house
 
PPTX
Group policy management window server 2008r2
IGZ Software house
 
PPT
Active directory domain services
IGZ Software house
 
PPTX
17 roles of window server 2008 r2
IGZ Software house
 
PPTX
Raid and its levels
IGZ Software house
 
PPT
Introduction Network security
IGZ Software house
 
PPT
Firewalls
IGZ Software house
 
PPT
Encryption
IGZ Software house
 
PPT
Cryptography
IGZ Software house
 
PDF
Authentication techniques
IGZ Software house
 
PPTX
X86 Architecture
IGZ Software house
 
PPTX
Window architecture
IGZ Software house
 
PPTX
What is-32-bit-and-64-bit
IGZ Software house
 
PPTX
Virtual machine
IGZ Software house
 
PPTX
Interpreter
IGZ Software house
 
PPTX
Competitor analaysis
IGZ Software house
 
Window server 2008
IGZ Software house
 
Types of server
IGZ Software house
 
Types of network
IGZ Software house
 
Ip address and subnetting
IGZ Software house
 
Group policy management window server 2008r2
IGZ Software house
 
Active directory domain services
IGZ Software house
 
17 roles of window server 2008 r2
IGZ Software house
 
Raid and its levels
IGZ Software house
 
Introduction Network security
IGZ Software house
 
Encryption
IGZ Software house
 
Cryptography
IGZ Software house
 
Authentication techniques
IGZ Software house
 
X86 Architecture
IGZ Software house
 
Window architecture
IGZ Software house
 
What is-32-bit-and-64-bit
IGZ Software house
 
Virtual machine
IGZ Software house
 
Interpreter
IGZ Software house
 
Competitor analaysis
IGZ Software house
 

Recently uploaded (20)

PDF
The Different Types of Non-Experimental Research
Thelma Villaflores
 
PPTX
2025 Winter SWAYAM NPTEL & A Student.pptx
Utsav Yagnik
 
PDF
BÀI TẬP BỔ TRỢ TIẾNG ANH 8 - GLOBAL SUCCESS - CẢ NĂM - NĂM 2024 (VOCABULARY, ...
Nguyen Thanh Tu Collection
 
PDF
ARAL_Orientation_Day-2-Sessions_ARAL-Readung ARAL-Mathematics ARAL-Sciencev2.pdf
JoelVilloso1
 
PPTX
Unit 2 COMMERCIAL BANKING, Corporate banking.pptx
AnubalaSuresh1
 
PDF
CONCURSO DE POESIA “POETUFAS – PASSOS SUAVES PELO VERSO.pdf
Colégio Santa Teresinha
 
PDF
Isharyanti-2025-Cross Language Communication in Indonesian Language
Neny Isharyanti
 
PDF
LAW OF CONTRACT ( 5 YEAR LLB & UNITARY LLB)- MODULE-3 - LEARN THROUGH PICTURE
APARNA T SHAIL KUMAR
 
PPTX
I AM MALALA The Girl Who Stood Up for Education and was Shot by the Taliban...
Beena E S
 
PDF
Lesson 2 - WATER,pH, BUFFERS, AND ACID-BASE.pdf
marvinnbustamante1
 
PDF
community health nursing question paper 2.pdf
Prince kumar
 
PPTX
Growth and development and milestones, factors
BHUVANESHWARI BADIGER
 
PPTX
Neurodivergent Friendly Schools - Slides from training session
Pooky Knightsmith
 
PPTX
Universal immunization Programme (UIP).pptx
Vishal Chanalia
 
PPTX
A PPT on Alfred Lord Tennyson's Ulysses.
Beena E S
 
PDF
Dimensions of Societal Planning in Commonism
StefanMz
 
PDF
Generative AI: it's STILL not a robot (CIJ Summer 2025)
Paul Bradshaw
 
PPTX
How to Set Up Tags in Odoo 18 - Odoo Slides
Celine George
 
PDF
The-Ever-Evolving-World-of-Science (1).pdf/7TH CLASS CURIOSITY /1ST CHAPTER/B...
Sandeep Swamy
 
PDF
The History of Phone Numbers in Stoke Newington by Billy Thomas
History of Stoke Newington
 
The Different Types of Non-Experimental Research
Thelma Villaflores
 
2025 Winter SWAYAM NPTEL & A Student.pptx
Utsav Yagnik
 
BÀI TẬP BỔ TRỢ TIẾNG ANH 8 - GLOBAL SUCCESS - CẢ NĂM - NĂM 2024 (VOCABULARY, ...
Nguyen Thanh Tu Collection
 
ARAL_Orientation_Day-2-Sessions_ARAL-Readung ARAL-Mathematics ARAL-Sciencev2.pdf
JoelVilloso1
 
Unit 2 COMMERCIAL BANKING, Corporate banking.pptx
AnubalaSuresh1
 
CONCURSO DE POESIA “POETUFAS – PASSOS SUAVES PELO VERSO.pdf
Colégio Santa Teresinha
 
Isharyanti-2025-Cross Language Communication in Indonesian Language
Neny Isharyanti
 
LAW OF CONTRACT ( 5 YEAR LLB & UNITARY LLB)- MODULE-3 - LEARN THROUGH PICTURE
APARNA T SHAIL KUMAR
 
I AM MALALA The Girl Who Stood Up for Education and was Shot by the Taliban...
Beena E S
 
Lesson 2 - WATER,pH, BUFFERS, AND ACID-BASE.pdf
marvinnbustamante1
 
community health nursing question paper 2.pdf
Prince kumar
 
Growth and development and milestones, factors
BHUVANESHWARI BADIGER
 
Neurodivergent Friendly Schools - Slides from training session
Pooky Knightsmith
 
Universal immunization Programme (UIP).pptx
Vishal Chanalia
 
A PPT on Alfred Lord Tennyson's Ulysses.
Beena E S
 
Dimensions of Societal Planning in Commonism
StefanMz
 
Generative AI: it's STILL not a robot (CIJ Summer 2025)
Paul Bradshaw
 
How to Set Up Tags in Odoo 18 - Odoo Slides
Celine George
 
The-Ever-Evolving-World-of-Science (1).pdf/7TH CLASS CURIOSITY /1ST CHAPTER/B...
Sandeep Swamy
 
The History of Phone Numbers in Stoke Newington by Billy Thomas
History of Stoke Newington
 

Compiler

  • 1. Date :- 16,jan,2015 Compiler Presented to: Sir Khalid Mehmood Group Name: Tech Routers Members: Muhammad Ahtisham 2813 Nouman Chudhary 2463 Waqas Ahmad 2481 Junaid Pervaiz 2468 Umair Ilyas 2809 Jawad Mian 2490 Sohaib Raza 2497 Muhammad Waqas 2803
  • 2. What Do Compilers Do (1) 2  A compiler acts as a translator, transforming human-oriented programming languages into computer-oriented machine languages.  Ignore machine-dependent details for programmer Programming Language (Source) Compiler Machine Language (Target)
  • 3. 3  Any compiler must perform two major tasks  Analysis of the source program  Synthesis of a machine-language program The Structure of a Compiler (1) Compiler Analysis Synthesis
  • 4. Preprocessors, Compilers, Assemblers, and Linkers Preprocessor Compiler Assembler Linker Skeletal Source Program Source Program Target Assembly Program Relocatable Object Code Absolute Machine Code Libraries and Relocatable Object Files Try for example: gcc -v myprog.c
  • 5. The Structure of a Compiler (2) 5 Scanner Parser Semantic Routines Code Generator Optimizer Source Program Tokens Syntactic Structure Symbol and Attribute Tables (Used by all Phases of The Compiler) (Character Stream) Intermediate Representation Target machine code
  • 6. The Structure of a Compiler (3) 6 Scanner Parser Semantic Routines Code Generator Optimizer Source Program Tokens Syntactic Structure Symbol and Attribute Tables (Used by all Phases of The Compiler) Scanner  The scanner begins the analysis of the source program by reading the input, character by character, and grouping characters into individual words and symbols (tokens)  RE ( Regular expression )  NFA ( Non-deterministic Finite Automata )  DFA ( Deterministic Finite Automata ) (Character Stream) Intermediate Representation Target machine code
  • 7. The Structure of a Compiler (4) 7 Scanner Parser Semantic Routines Code Generator Optimizer Source Program Tokens Syntactic Structure Symbol and Attribute Tables (Used by all Phases of The Compiler) Parser  Given a formal syntax specification (typically as a context- free grammar [CFG] ), the parse reads tokens and groups them into units as specified by the productions of the CFG being used.  As syntactic structure is recognized, the parser either calls corresponding semantic routines directly or builds a syntax tree.  CFG ( Context-Free Grammar )  GAA ( Grammar Analysis Algorithms ) (Character Stream) Intermediate Representation Target machine code
  • 8. The Structure of a Compiler (5) 8 Scanner Parser Semantic Routines Code Generator Optimizer Source Program (Character Stream) Tokens Syntactic Structure Intermediate Representation Symbol and Attribute Tables (Used by all Phases of The Compiler) Semantic Routines  Perform two functions  Check the static semantics of each construct  Do the actual translation  The heart of a compiler  Syntax Directed Translation  Semantic Processing Techniques  IR (Intermediate Representation) Target machine code
  • 9. The Structure of a Compiler (6) 9 Scanner Parser Semantic Routines Code Generator Optimizer Source Program Tokens Syntactic Structure Symbol and Attribute Tables (Used by all Phases of The Compiler) Optimizer  The IR code generated by the semantic routines is analyzed and transformed into functionally equivalent but improved IR code  This phase can be very complex and slow  loop optimization, register allocation, code scheduling  Register and Temporary Management (Character Stream) Intermediate Representation Target machine code
  • 10. The Structure of a Compiler (7) 10 Source Program (Character Stream) Scanner Tokens Parser Syntactic Structure Semantic Routines Intermediate Representation Optimizer Code Generator Code Generator  Interpretive Code Generation  Generating Code from Tree/Dag  Grammar-Based Code Generator Target machine code
  • 11. The Structure of a Compiler (8) 11 Scanner [Lexical Analyzer] Parser [Syntax Analyzer] Semantic Process [Semantic analyzer] Code Generator [Intermediate Code Generator] Code Optimizer Tokens Parse tree Abstract Syntax Tree w/ Attributes Non-optimized Intermediate Code Optimized Intermediate Code Code Optimizer Target machine code