SlideShare a Scribd company logo
Compiler
Prepared By:
Safeen Dlshad
Bafreen Amjad
Darya Mahdi
Harikar mikail
University of Zakho
College of Engineering
Petroleum Engineering Department
Content
 Introduction
 The Structure of a Compiler
 The Phases of a Compiler
 The Grouping of Phases
 Interpreters & Compilers
Introduction
• A compiler translates (or Compiler) is a software which
converts a program written in high level language (Source
Language) to low level language (Object/Target/Machine
Language).
Compiler
Compilation Error
High Level
Language
Low Level
Language
• Read and analyze entire program
• The compiler can spot some obvious programming
mistakes.
• There are thousands of source languages, ranging from
traditional programming languages such as FORTRAN and
Pascal to specialized languages.
Introduction
• The basic tasks that any compiler must perform are essentially the same.
• By understanding these tasks, we can construct compilers for a wide
variety of source languages and target machines using the same basic
techniques.
• The first real compiler
– Throughout the 1950’s, compilers were considered notoriously difficult
programs to write.
– The first FORTRAN compiler, for example, took 18 staff-years to implement.
Introduction
Any compiler must perform two major tasks
 Analysis an intermediate representation is created from the given source program.
– Lexical Analyzer, Syntax Analyzer and Semantic Analyzer are the parts of this phase.
 Synthesis of takes the tree structure and translates the operations therein into the
target program.
– Intermediate Code Generator, Code Generator, and Code Optimizer are the parts of this phase.
The Structure of a Compiler
Compile
r
Analysis
Synthesi
s
The Structure of a Compiler
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 Phases of a Compiler
• Lexical Analyzer
• Syntax Analyzer
• Semantic Analyzer
• Intermediate code generator
• Code optimizer
• Code generator
The Grouping of Phases
• Compiler front and back ends:
– Front end: analysis (machine independent)
– Back end: synthesis (machine
• Compiler passes:
– A collection of phases is done only once (single pass) or
multiple times (multi pass)
 Single pass: usually requires everything to be defined
before being used in source program
 Multi pass: compiler may have to keep entire program
representation in memory
Interpreters & Compilers
Compilers
 A program that translates a program from one language (the source) to another
(the target)
 Typical Implementations
– FORTRAN, C, C++, Java, COBOL, etc. etc.
– Strong need for optimization
Compiler
Error messages
Source
Program
Target
Program
Input
Output
Interpreters & Compilers
Interpreters
 A program that reads a source program and produces the results of executing
that program.
 Typical Implementations
– PERL, Python, awk, sed, sh, csh, postscript printer, Java VM
– Effective if interpreter overhead is low relative to execution cost of language
statements
Interpreter
Source
Program
Input
Output
Error messages
Interpreters & Compilers
• An interpreter may need to process the same piece of the syntax tree (for
example, the body of a loop) many times  interpretation is slower than
executing a compiled program.
• An interpreter executes the source program statement by statement  it can
usually give better error diagnostics than a compiler.
• Compilers and interpreters both must read the input – a stream of characters –
and “understand” it; analysis
w h i l e ( k < l e n g t h ) { <nl> <tab> i f ( a [ k ] > 0
) <nl> <tab> <tab>{ n P o s + + ; } <nl> <tab> }
Thanks for watching and
listening we wish you all the
best

More Related Content

What's hot

Compilers and interpreters
Compilers and interpretersCompilers and interpreters
Compilers and interpreters
RAJU KATHI
 
Introduction to compiler
Introduction to compilerIntroduction to compiler
Introduction to compiler
Abha Damani
 

What's hot (20)

Introduction to Compiler design
Introduction to Compiler design Introduction to Compiler design
Introduction to Compiler design
 
Introduction to Compiler
Introduction to CompilerIntroduction to Compiler
Introduction to Compiler
 
Introduction to Compiler Construction
Introduction to Compiler Construction Introduction to Compiler Construction
Introduction to Compiler Construction
 
COMPILER DESIGN- Introduction & Lexical Analysis:
COMPILER DESIGN- Introduction & Lexical Analysis: COMPILER DESIGN- Introduction & Lexical Analysis:
COMPILER DESIGN- Introduction & Lexical Analysis:
 
compiler and their types
compiler and their typescompiler and their types
compiler and their types
 
Interpreted and compiled language
Interpreted and compiled languageInterpreted and compiled language
Interpreted and compiled language
 
Types of Compilers
Types of CompilersTypes of Compilers
Types of Compilers
 
compiler vs interpreter
compiler vs interpretercompiler vs interpreter
compiler vs interpreter
 
Compilation v. interpretation
Compilation v. interpretationCompilation v. interpretation
Compilation v. interpretation
 
Compiler vs interpreter
Compiler vs interpreterCompiler vs interpreter
Compiler vs interpreter
 
Language translator
Language translatorLanguage translator
Language translator
 
Compilers and interpreters
Compilers and interpretersCompilers and interpreters
Compilers and interpreters
 
Compiler vs interpreter
Compiler vs interpreterCompiler vs interpreter
Compiler vs interpreter
 
Compiler design
Compiler designCompiler design
Compiler design
 
Classification of Compilers
Classification of CompilersClassification of Compilers
Classification of Compilers
 
basics of compiler design
basics of compiler designbasics of compiler design
basics of compiler design
 
Interpreter
InterpreterInterpreter
Interpreter
 
Introduction to compiler
Introduction to compilerIntroduction to compiler
Introduction to compiler
 
Cf&oa
Cf&oaCf&oa
Cf&oa
 
Chapter 5
Chapter 5Chapter 5
Chapter 5
 

Similar to Compiler - Computer Programming - UOZ

Compiler Construction Lecture One .pptx
Compiler Construction Lecture One  .pptxCompiler Construction Lecture One  .pptx
Compiler Construction Lecture One .pptx
انشال عارف
 

Similar to Compiler - Computer Programming - UOZ (20)

CD - CH1 - Introduction to compiler design.pptx
CD - CH1 - Introduction to compiler design.pptxCD - CH1 - Introduction to compiler design.pptx
CD - CH1 - Introduction to compiler design.pptx
 
Cd ch1 - introduction
Cd   ch1 - introductionCd   ch1 - introduction
Cd ch1 - introduction
 
4_5802928814682016556.pptx
4_5802928814682016556.pptx4_5802928814682016556.pptx
4_5802928814682016556.pptx
 
Introduction to Compilers
Introduction to CompilersIntroduction to Compilers
Introduction to Compilers
 
Compiler Design Basics
Compiler Design BasicsCompiler Design Basics
Compiler Design Basics
 
Compiler lecture 01
Compiler lecture 01Compiler lecture 01
Compiler lecture 01
 
lce1 مترجمات.pptx
lce1 مترجمات.pptxlce1 مترجمات.pptx
lce1 مترجمات.pptx
 
Compiler Construction Lecture One .pptx
Compiler Construction Lecture One  .pptxCompiler Construction Lecture One  .pptx
Compiler Construction Lecture One .pptx
 
Life cycle of a computer program
Life cycle of a computer programLife cycle of a computer program
Life cycle of a computer program
 
COMPILER DESIGN.docx
COMPILER DESIGN.docxCOMPILER DESIGN.docx
COMPILER DESIGN.docx
 
Transpilers(Source-to-Source Compilers)
Transpilers(Source-to-Source Compilers)Transpilers(Source-to-Source Compilers)
Transpilers(Source-to-Source Compilers)
 
Chapter1.pdf
Chapter1.pdfChapter1.pdf
Chapter1.pdf
 
Assembler
AssemblerAssembler
Assembler
 
Session01 basics programming
Session01 basics programmingSession01 basics programming
Session01 basics programming
 
Compiler Design Introduction
Compiler Design Introduction Compiler Design Introduction
Compiler Design Introduction
 
Introduction to computer programming
Introduction to computer programmingIntroduction to computer programming
Introduction to computer programming
 
Week 08_Basics of Compiler Construction.pdf
Week 08_Basics of Compiler Construction.pdfWeek 08_Basics of Compiler Construction.pdf
Week 08_Basics of Compiler Construction.pdf
 
Lecture1 compilers
Lecture1 compilersLecture1 compilers
Lecture1 compilers
 
Embedded c c++ programming fundamentals master
Embedded c c++ programming fundamentals masterEmbedded c c++ programming fundamentals master
Embedded c c++ programming fundamentals master
 
Lecture 1 introduction to language processors
Lecture 1  introduction to language processorsLecture 1  introduction to language processors
Lecture 1 introduction to language processors
 

More from Safen D Taha

More from Safen D Taha (7)

Gas plant unit process
Gas plant unit processGas plant unit process
Gas plant unit process
 
Drilling economics drilling engineering
Drilling economics drilling engineeringDrilling economics drilling engineering
Drilling economics drilling engineering
 
Integration - Mathematics - UoZ
Integration - Mathematics - UoZ Integration - Mathematics - UoZ
Integration - Mathematics - UoZ
 
magnetic field - electricity - UOZ
magnetic field - electricity - UOZmagnetic field - electricity - UOZ
magnetic field - electricity - UOZ
 
Earth is Flat ? or Round ?
Earth is Flat ? or Round ?Earth is Flat ? or Round ?
Earth is Flat ? or Round ?
 
health & safety at work
health & safety at work health & safety at work
health & safety at work
 
Fluid Dynamics (Continuity Equation - Bernoulli Equation - head loss - Appli...
Fluid Dynamics  (Continuity Equation - Bernoulli Equation - head loss - Appli...Fluid Dynamics  (Continuity Equation - Bernoulli Equation - head loss - Appli...
Fluid Dynamics (Continuity Equation - Bernoulli Equation - head loss - Appli...
 

Recently uploaded

Automobile Management System Project Report.pdf
Automobile Management System Project Report.pdfAutomobile Management System Project Report.pdf
Automobile Management System Project Report.pdf
Kamal Acharya
 
Laundry management system project report.pdf
Laundry management system project report.pdfLaundry management system project report.pdf
Laundry management system project report.pdf
Kamal Acharya
 
CFD Simulation of By-pass Flow in a HRSG module by R&R Consult.pptx
CFD Simulation of By-pass Flow in a HRSG module by R&R Consult.pptxCFD Simulation of By-pass Flow in a HRSG module by R&R Consult.pptx
CFD Simulation of By-pass Flow in a HRSG module by R&R Consult.pptx
R&R Consult
 
Fruit shop management system project report.pdf
Fruit shop management system project report.pdfFruit shop management system project report.pdf
Fruit shop management system project report.pdf
Kamal Acharya
 

Recently uploaded (20)

BRAKING SYSTEM IN INDIAN RAILWAY AutoCAD DRAWING
BRAKING SYSTEM IN INDIAN RAILWAY AutoCAD DRAWINGBRAKING SYSTEM IN INDIAN RAILWAY AutoCAD DRAWING
BRAKING SYSTEM IN INDIAN RAILWAY AutoCAD DRAWING
 
Furniture showroom management system project.pdf
Furniture showroom management system project.pdfFurniture showroom management system project.pdf
Furniture showroom management system project.pdf
 
KIT-601 Lecture Notes-UNIT-3.pdf Mining Data Stream
KIT-601 Lecture Notes-UNIT-3.pdf Mining Data StreamKIT-601 Lecture Notes-UNIT-3.pdf Mining Data Stream
KIT-601 Lecture Notes-UNIT-3.pdf Mining Data Stream
 
The Ultimate Guide to External Floating Roofs for Oil Storage Tanks.docx
The Ultimate Guide to External Floating Roofs for Oil Storage Tanks.docxThe Ultimate Guide to External Floating Roofs for Oil Storage Tanks.docx
The Ultimate Guide to External Floating Roofs for Oil Storage Tanks.docx
 
NO1 Pandit Amil Baba In Bahawalpur, Sargodha, Sialkot, Sheikhupura, Rahim Yar...
NO1 Pandit Amil Baba In Bahawalpur, Sargodha, Sialkot, Sheikhupura, Rahim Yar...NO1 Pandit Amil Baba In Bahawalpur, Sargodha, Sialkot, Sheikhupura, Rahim Yar...
NO1 Pandit Amil Baba In Bahawalpur, Sargodha, Sialkot, Sheikhupura, Rahim Yar...
 
KIT-601 Lecture Notes-UNIT-5.pdf Frame Works and Visualization
KIT-601 Lecture Notes-UNIT-5.pdf Frame Works and VisualizationKIT-601 Lecture Notes-UNIT-5.pdf Frame Works and Visualization
KIT-601 Lecture Notes-UNIT-5.pdf Frame Works and Visualization
 
Automobile Management System Project Report.pdf
Automobile Management System Project Report.pdfAutomobile Management System Project Report.pdf
Automobile Management System Project Report.pdf
 
Laundry management system project report.pdf
Laundry management system project report.pdfLaundry management system project report.pdf
Laundry management system project report.pdf
 
Construction method of steel structure space frame .pptx
Construction method of steel structure space frame .pptxConstruction method of steel structure space frame .pptx
Construction method of steel structure space frame .pptx
 
A CASE STUDY ON ONLINE TICKET BOOKING SYSTEM PROJECT.pdf
A CASE STUDY ON ONLINE TICKET BOOKING SYSTEM PROJECT.pdfA CASE STUDY ON ONLINE TICKET BOOKING SYSTEM PROJECT.pdf
A CASE STUDY ON ONLINE TICKET BOOKING SYSTEM PROJECT.pdf
 
fundamentals of drawing and isometric and orthographic projection
fundamentals of drawing and isometric and orthographic projectionfundamentals of drawing and isometric and orthographic projection
fundamentals of drawing and isometric and orthographic projection
 
CFD Simulation of By-pass Flow in a HRSG module by R&R Consult.pptx
CFD Simulation of By-pass Flow in a HRSG module by R&R Consult.pptxCFD Simulation of By-pass Flow in a HRSG module by R&R Consult.pptx
CFD Simulation of By-pass Flow in a HRSG module by R&R Consult.pptx
 
Fruit shop management system project report.pdf
Fruit shop management system project report.pdfFruit shop management system project report.pdf
Fruit shop management system project report.pdf
 
The Benefits and Techniques of Trenchless Pipe Repair.pdf
The Benefits and Techniques of Trenchless Pipe Repair.pdfThe Benefits and Techniques of Trenchless Pipe Repair.pdf
The Benefits and Techniques of Trenchless Pipe Repair.pdf
 
Immunizing Image Classifiers Against Localized Adversary Attacks
Immunizing Image Classifiers Against Localized Adversary AttacksImmunizing Image Classifiers Against Localized Adversary Attacks
Immunizing Image Classifiers Against Localized Adversary Attacks
 
Top 13 Famous Civil Engineering Scientist
Top 13 Famous Civil Engineering ScientistTop 13 Famous Civil Engineering Scientist
Top 13 Famous Civil Engineering Scientist
 
Online resume builder management system project report.pdf
Online resume builder management system project report.pdfOnline resume builder management system project report.pdf
Online resume builder management system project report.pdf
 
Event Management System Vb Net Project Report.pdf
Event Management System Vb Net  Project Report.pdfEvent Management System Vb Net  Project Report.pdf
Event Management System Vb Net Project Report.pdf
 
Quality defects in TMT Bars, Possible causes and Potential Solutions.
Quality defects in TMT Bars, Possible causes and Potential Solutions.Quality defects in TMT Bars, Possible causes and Potential Solutions.
Quality defects in TMT Bars, Possible causes and Potential Solutions.
 
ENERGY STORAGE DEVICES INTRODUCTION UNIT-I
ENERGY STORAGE DEVICES  INTRODUCTION UNIT-IENERGY STORAGE DEVICES  INTRODUCTION UNIT-I
ENERGY STORAGE DEVICES INTRODUCTION UNIT-I
 

Compiler - Computer Programming - UOZ

  • 1. Compiler Prepared By: Safeen Dlshad Bafreen Amjad Darya Mahdi Harikar mikail University of Zakho College of Engineering Petroleum Engineering Department
  • 2. Content  Introduction  The Structure of a Compiler  The Phases of a Compiler  The Grouping of Phases  Interpreters & Compilers
  • 3. Introduction • A compiler translates (or Compiler) is a software which converts a program written in high level language (Source Language) to low level language (Object/Target/Machine Language). Compiler Compilation Error High Level Language Low Level Language
  • 4.
  • 5. • Read and analyze entire program • The compiler can spot some obvious programming mistakes. • There are thousands of source languages, ranging from traditional programming languages such as FORTRAN and Pascal to specialized languages. Introduction
  • 6. • The basic tasks that any compiler must perform are essentially the same. • By understanding these tasks, we can construct compilers for a wide variety of source languages and target machines using the same basic techniques. • The first real compiler – Throughout the 1950’s, compilers were considered notoriously difficult programs to write. – The first FORTRAN compiler, for example, took 18 staff-years to implement. Introduction
  • 7. Any compiler must perform two major tasks  Analysis an intermediate representation is created from the given source program. – Lexical Analyzer, Syntax Analyzer and Semantic Analyzer are the parts of this phase.  Synthesis of takes the tree structure and translates the operations therein into the target program. – Intermediate Code Generator, Code Generator, and Code Optimizer are the parts of this phase. The Structure of a Compiler Compile r Analysis Synthesi s
  • 8. The Structure of a Compiler 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
  • 9. The Phases of a Compiler • Lexical Analyzer • Syntax Analyzer • Semantic Analyzer • Intermediate code generator • Code optimizer • Code generator
  • 10. The Grouping of Phases • Compiler front and back ends: – Front end: analysis (machine independent) – Back end: synthesis (machine • Compiler passes: – A collection of phases is done only once (single pass) or multiple times (multi pass)  Single pass: usually requires everything to be defined before being used in source program  Multi pass: compiler may have to keep entire program representation in memory
  • 11. Interpreters & Compilers Compilers  A program that translates a program from one language (the source) to another (the target)  Typical Implementations – FORTRAN, C, C++, Java, COBOL, etc. etc. – Strong need for optimization Compiler Error messages Source Program Target Program Input Output
  • 12. Interpreters & Compilers Interpreters  A program that reads a source program and produces the results of executing that program.  Typical Implementations – PERL, Python, awk, sed, sh, csh, postscript printer, Java VM – Effective if interpreter overhead is low relative to execution cost of language statements Interpreter Source Program Input Output Error messages
  • 13. Interpreters & Compilers • An interpreter may need to process the same piece of the syntax tree (for example, the body of a loop) many times  interpretation is slower than executing a compiled program. • An interpreter executes the source program statement by statement  it can usually give better error diagnostics than a compiler. • Compilers and interpreters both must read the input – a stream of characters – and “understand” it; analysis w h i l e ( k < l e n g t h ) { <nl> <tab> i f ( a [ k ] > 0 ) <nl> <tab> <tab>{ n P o s + + ; } <nl> <tab> }
  • 14. Thanks for watching and listening we wish you all the best