SlideShare a Scribd company logo
Compilers
       Group #4
Independent studies and
        seminar
       CST 477-1
 Computer Science and
      Technology
 Uva Wellassa University
Introduction

What is translator
  A Translator is a computer program that translates one
  programming language instruction(s) into another
  programming language instruction(s) without the loss
  of original meaning.
What is a compiler?

If the translator translates a high level language into an
   assembly or machine language it is called a compiler.




Functionalities of a Compiler

• recognize legal (and illegal) programs
• generate correct code
• manage storage of all variables and code
• agree on format for object (or assembly) code
                                      3
History

1952: First compiler (linker/loader) written by Grace Hopper
for A-0 programming language

1957: First complete compiler for FORTRAN by John Backus
and team

1960: COBOL compilers for multiple architectures

1962: First self-hosting compiler for LISP
Some examples for compilers

Compiler       Author        Windows   Unix-like   Other OSs      IDE

GNU Java       GNU Project      No        Yes           No         No

               Sun
               Microsystem
Javac                           Yes       Yes           Yes        No
               s (Owned by
               Oracle)

C++ Builder    Embarcadero      Yes       No            OS X       Yes

                                                      Yes IBM
                                                     mainframe,
GCC C          GNU Project      Yes       Yes        AmigaOS,      No
                                                     VAX/VMS,
                                                      RTEMS
Visual Basic   Microsoft        Yes       No            DOS        Yes
Structure of a compiler




• intermediate representation (IR)
• front end maps legal code into IR
• back end maps IR onto target machine
• simplify retargeting
• allows multiple front ends
• multiple passes better code
Intermediate representation

Suppose we wish to build compilers for n source
  languages and m target machines.

  Case 1: no IR
     Need separate compiler for each source language/target
    machine combination.
     A total of n ∗ m compilers necessary.
     Front-end becomes cluttered with machine specific
    details, back-end becomes cluttered with source
    language specific details.
  Case 2: IR present
    Need just n front-ends, m back ends.
Front end




•Line reconstruction.
•Lexical analysis
•Preprocessing
•Syntax analysis
•Semantic analysis
Scanner




• Lexical analysis breaks the source code text into small pieces called
  tokens.
• Each token is a single atomic unit of the language, for instance a
  keyword, identifier or symbol name
• This phase is also called lexing or scanning
Parser




• recognize context-free syntax
• guide context-sensitive analysis
• produce meaningful error messages
• attempt error correction
Back end




 Analysis
        This is the gathering of program information from the intermediate
        representation derived from the input.
 Optimization
        the intermediate language representation is transformed into functionally
        equivalent but faster (or smaller) forms.
 Code generation
        the transformed intermediate language is translated into the output
        language, usually the native machine language of the system.
Instruction selection




• produce compact, fast code
• use available addressing modes
• pattern matching problem
    —   ad hoc techniques
    —   tree pattern matching
    —   string pattern matching
    —   dynamic programming
Register allocation




• have value in a register when used
• limited resources
• changes instruction choices
• can move loads and stores
• optimal allocation is difficult
Other types of compilers

source-to-source compiler
  a type of compiler that takes a high level language as its
  input and outputs a high level language.
Stage compiler
  compiles to assembly language of a theoretical
  machine, like some Prolog implementations
    This Prolog machine is also known as the Warren Abstract
    Machine (or WAM).
    Bytecode compilers for Java, Python, and many more are also a
    subtype of this.
Just-in-time compiler
  Applications are delivered in bytecode, which is compiled to
  native machine code just prior to execution.
Issues Driving Compiler Design

 Advantage:
   Self-Contained and Efficient
   Hardware Optimization

 Disadvantage:
   Compiled programs are targeted towards a particular
   platform and hence are platform dependent.
   Compile Times
   They are slower in execution than assembly programs.
   Compiled programs do not allow security to be implemented
   with in the code - e.g. a compiled program can access any area of the
   memory, and can do whatever it wants with your PC (most of the viruses are made
   in compiled languages).

                                      15
Reference

http://lambda.uta.edu/cse5317/notes/node5.html
http://dragonbook.stanford.edu/lecture-
notes/Stanford-CS143/16-Intermediate-Rep.pdf
http://en.wikipedia.org/wiki/Compiler
http://www.personal.kent.edu/~rmuhamma/Compiler
s/MyCompiler/phase.htm
Group members


UWU/CST/08/0019   LANKATHILAKA B.A.R.
UWU/CST/08/0020   LIYANAGE C.J.V.
UWU/CST/08/0021   MAHANAMA A.C.
UWU/CST/08/0023   MUTUNAYAKE M.N.A.
UWU/CST/08/0024   NASHAN M.H.M.
UWU/CST/08/0025   NAYANATHARA J.A.J.U.
Thank You

More Related Content

PPTX
Types of Compilers
Hemant Chetwani
 
PPT
Capability Maturity Model (CMM) in Software Engineering
FaizanAhmad340414
 
PPTX
Compilers
Bense Tony
 
PPTX
Designing Techniques in Software Engineering
kirupasuchi1996
 
PPT
4 evolution-of-programming-languages
Rohit Shrivastava
 
PPT
Software Engineering (Project Scheduling)
ShudipPal
 
PPTX
Staffing level estimation
kavitha muneeshwaran
 
PPT
Passes of compilers
Vairavel C
 
Types of Compilers
Hemant Chetwani
 
Capability Maturity Model (CMM) in Software Engineering
FaizanAhmad340414
 
Compilers
Bense Tony
 
Designing Techniques in Software Engineering
kirupasuchi1996
 
4 evolution-of-programming-languages
Rohit Shrivastava
 
Software Engineering (Project Scheduling)
ShudipPal
 
Staffing level estimation
kavitha muneeshwaran
 
Passes of compilers
Vairavel C
 

What's hot (20)

PPTX
Assembly and Machine Code
Project Student
 
PPTX
Operating system architecture
Sabin dumre
 
PPTX
Real time Scheduling in Operating System for Msc CS
Thanveen
 
PDF
software engineering
Azad public school
 
PPTX
Software Measurement and Metrics.pptx
ubaidullah75790
 
PPTX
Real Time OS For Embedded Systems
Himanshu Ghetia
 
PPTX
introduction to programming languages
NaqashAhmad14
 
PPTX
Estimating Software Maintenance Costs
lalithambiga kamaraj
 
PPT
Introduction to programming with c,
Hossain Md Shakhawat
 
PPTX
Translators(Compiler, Assembler) and interpreter
baabtra.com - No. 1 supplier of quality freshers
 
PPTX
Fundamental design concepts
srijavel
 
PPTX
Software Configuration Management (SCM)
Er. Shiva K. Shrestha
 
PPT
1.1 The nature of software.ppt
JAYAPRIYAR7
 
PPTX
Programming Language
Education Front
 
PPTX
Design notation
ramya marichamy
 
PPT
Introduction to Compiler Construction
Sarmad Ali
 
PPTX
Chapter 1 2 - some size factors
NancyBeaulah_R
 
PPTX
System software - macro expansion,nested macro calls
SARASWATHI S
 
PPT
Flynns classification
Yasir Khan
 
PPTX
evolution of operating system
Amir Khan
 
Assembly and Machine Code
Project Student
 
Operating system architecture
Sabin dumre
 
Real time Scheduling in Operating System for Msc CS
Thanveen
 
software engineering
Azad public school
 
Software Measurement and Metrics.pptx
ubaidullah75790
 
Real Time OS For Embedded Systems
Himanshu Ghetia
 
introduction to programming languages
NaqashAhmad14
 
Estimating Software Maintenance Costs
lalithambiga kamaraj
 
Introduction to programming with c,
Hossain Md Shakhawat
 
Translators(Compiler, Assembler) and interpreter
baabtra.com - No. 1 supplier of quality freshers
 
Fundamental design concepts
srijavel
 
Software Configuration Management (SCM)
Er. Shiva K. Shrestha
 
1.1 The nature of software.ppt
JAYAPRIYAR7
 
Programming Language
Education Front
 
Design notation
ramya marichamy
 
Introduction to Compiler Construction
Sarmad Ali
 
Chapter 1 2 - some size factors
NancyBeaulah_R
 
System software - macro expansion,nested macro calls
SARASWATHI S
 
Flynns classification
Yasir Khan
 
evolution of operating system
Amir Khan
 
Ad

Similar to Compilers (20)

DOCX
COMPILER DESIGN.docx
Revathiparamanathan
 
PPT
Chapter One
bolovv
 
PPTX
Chapter 2 Program language translation.pptx
dawod yimer
 
PPTX
Lecture 1 introduction to language processors
Rebaz Najeeb
 
PDF
Chapter1.pdf
tharwatabdulhmed
 
PPTX
Introduction to Compilers
Akhil Kaushik
 
PDF
Compiler design
negussie tirfe78
 
PPT
Introduction to compiler design, PPT-1, MODULE 1
ROSHNI PRADHAN
 
PPTX
Pros and cons of c as a compiler language
Ashok Raj
 
PPTX
Compiler Design Introduction
Thapar Institute
 
DOC
compiler vs interpreter
Faculty of Science , portsaid Univeristy
 
PDF
2 Programming Language.pdf
KINGZzofYouTube
 
PPT
System software
Senthil Kanth
 
PPT
A basic introduction to compiler design.ppt
pandaashirbad9
 
PPT
A basic introduction to compiler design.ppt
pandaashirbad9
 
PDF
Language translators
Aditya Sharat
 
PPTX
Compiler Construction
Ahmed Raza
 
PDF
Lecture 01 introduction to compiler
Iffat Anjum
 
PPT
Compiler Construction
Army Public School and College -Faisal
 
PPTX
compiler and their types
patchamounika7
 
COMPILER DESIGN.docx
Revathiparamanathan
 
Chapter One
bolovv
 
Chapter 2 Program language translation.pptx
dawod yimer
 
Lecture 1 introduction to language processors
Rebaz Najeeb
 
Chapter1.pdf
tharwatabdulhmed
 
Introduction to Compilers
Akhil Kaushik
 
Compiler design
negussie tirfe78
 
Introduction to compiler design, PPT-1, MODULE 1
ROSHNI PRADHAN
 
Pros and cons of c as a compiler language
Ashok Raj
 
Compiler Design Introduction
Thapar Institute
 
2 Programming Language.pdf
KINGZzofYouTube
 
System software
Senthil Kanth
 
A basic introduction to compiler design.ppt
pandaashirbad9
 
A basic introduction to compiler design.ppt
pandaashirbad9
 
Language translators
Aditya Sharat
 
Compiler Construction
Ahmed Raza
 
Lecture 01 introduction to compiler
Iffat Anjum
 
compiler and their types
patchamounika7
 
Ad

Recently uploaded (20)

PPTX
Command Palatte in Odoo 18.1 Spreadsheet - Odoo Slides
Celine George
 
PPTX
Measures_of_location_-_Averages_and__percentiles_by_DR SURYA K.pptx
Surya Ganesh
 
PPTX
Artificial-Intelligence-in-Drug-Discovery by R D Jawarkar.pptx
Rahul Jawarkar
 
PPTX
Care of patients with elImination deviation.pptx
AneetaSharma15
 
PPTX
Sonnet 130_ My Mistress’ Eyes Are Nothing Like the Sun By William Shakespear...
DhatriParmar
 
PDF
The-Invisible-Living-World-Beyond-Our-Naked-Eye chapter 2.pdf/8th science cur...
Sandeep Swamy
 
PDF
Health-The-Ultimate-Treasure (1).pdf/8th class science curiosity /samyans edu...
Sandeep Swamy
 
PPTX
CDH. pptx
AneetaSharma15
 
PDF
Module 2: Public Health History [Tutorial Slides]
JonathanHallett4
 
PPTX
Introduction to pediatric nursing in 5th Sem..pptx
AneetaSharma15
 
PPTX
Continental Accounting in Odoo 18 - Odoo Slides
Celine George
 
PPTX
Kanban Cards _ Mass Action in Odoo 18.2 - Odoo Slides
Celine George
 
PDF
Antianginal agents, Definition, Classification, MOA.pdf
Prerana Jadhav
 
PPTX
Basics and rules of probability with real-life uses
ravatkaran694
 
PPTX
CARE OF UNCONSCIOUS PATIENTS .pptx
AneetaSharma15
 
DOCX
SAROCES Action-Plan FOR ARAL PROGRAM IN DEPED
Levenmartlacuna1
 
PDF
Virat Kohli- the Pride of Indian cricket
kushpar147
 
PPTX
Python-Application-in-Drug-Design by R D Jawarkar.pptx
Rahul Jawarkar
 
PPTX
Cleaning Validation Ppt Pharmaceutical validation
Ms. Ashatai Patil
 
PPTX
PROTIEN ENERGY MALNUTRITION: NURSING MANAGEMENT.pptx
PRADEEP ABOTHU
 
Command Palatte in Odoo 18.1 Spreadsheet - Odoo Slides
Celine George
 
Measures_of_location_-_Averages_and__percentiles_by_DR SURYA K.pptx
Surya Ganesh
 
Artificial-Intelligence-in-Drug-Discovery by R D Jawarkar.pptx
Rahul Jawarkar
 
Care of patients with elImination deviation.pptx
AneetaSharma15
 
Sonnet 130_ My Mistress’ Eyes Are Nothing Like the Sun By William Shakespear...
DhatriParmar
 
The-Invisible-Living-World-Beyond-Our-Naked-Eye chapter 2.pdf/8th science cur...
Sandeep Swamy
 
Health-The-Ultimate-Treasure (1).pdf/8th class science curiosity /samyans edu...
Sandeep Swamy
 
CDH. pptx
AneetaSharma15
 
Module 2: Public Health History [Tutorial Slides]
JonathanHallett4
 
Introduction to pediatric nursing in 5th Sem..pptx
AneetaSharma15
 
Continental Accounting in Odoo 18 - Odoo Slides
Celine George
 
Kanban Cards _ Mass Action in Odoo 18.2 - Odoo Slides
Celine George
 
Antianginal agents, Definition, Classification, MOA.pdf
Prerana Jadhav
 
Basics and rules of probability with real-life uses
ravatkaran694
 
CARE OF UNCONSCIOUS PATIENTS .pptx
AneetaSharma15
 
SAROCES Action-Plan FOR ARAL PROGRAM IN DEPED
Levenmartlacuna1
 
Virat Kohli- the Pride of Indian cricket
kushpar147
 
Python-Application-in-Drug-Design by R D Jawarkar.pptx
Rahul Jawarkar
 
Cleaning Validation Ppt Pharmaceutical validation
Ms. Ashatai Patil
 
PROTIEN ENERGY MALNUTRITION: NURSING MANAGEMENT.pptx
PRADEEP ABOTHU
 

Compilers

  • 1. Compilers Group #4 Independent studies and seminar CST 477-1 Computer Science and Technology Uva Wellassa University
  • 2. Introduction What is translator A Translator is a computer program that translates one programming language instruction(s) into another programming language instruction(s) without the loss of original meaning.
  • 3. What is a compiler? If the translator translates a high level language into an assembly or machine language it is called a compiler. Functionalities of a Compiler • recognize legal (and illegal) programs • generate correct code • manage storage of all variables and code • agree on format for object (or assembly) code 3
  • 4. History 1952: First compiler (linker/loader) written by Grace Hopper for A-0 programming language 1957: First complete compiler for FORTRAN by John Backus and team 1960: COBOL compilers for multiple architectures 1962: First self-hosting compiler for LISP
  • 5. Some examples for compilers Compiler Author Windows Unix-like Other OSs IDE GNU Java GNU Project No Yes No No Sun Microsystem Javac Yes Yes Yes No s (Owned by Oracle) C++ Builder Embarcadero Yes No OS X Yes Yes IBM mainframe, GCC C GNU Project Yes Yes AmigaOS, No VAX/VMS, RTEMS Visual Basic Microsoft Yes No DOS Yes
  • 6. Structure of a compiler • intermediate representation (IR) • front end maps legal code into IR • back end maps IR onto target machine • simplify retargeting • allows multiple front ends • multiple passes better code
  • 7. Intermediate representation Suppose we wish to build compilers for n source languages and m target machines. Case 1: no IR Need separate compiler for each source language/target machine combination. A total of n ∗ m compilers necessary. Front-end becomes cluttered with machine specific details, back-end becomes cluttered with source language specific details. Case 2: IR present Need just n front-ends, m back ends.
  • 8. Front end •Line reconstruction. •Lexical analysis •Preprocessing •Syntax analysis •Semantic analysis
  • 9. Scanner • Lexical analysis breaks the source code text into small pieces called tokens. • Each token is a single atomic unit of the language, for instance a keyword, identifier or symbol name • This phase is also called lexing or scanning
  • 10. Parser • recognize context-free syntax • guide context-sensitive analysis • produce meaningful error messages • attempt error correction
  • 11. Back end  Analysis This is the gathering of program information from the intermediate representation derived from the input.  Optimization the intermediate language representation is transformed into functionally equivalent but faster (or smaller) forms.  Code generation the transformed intermediate language is translated into the output language, usually the native machine language of the system.
  • 12. Instruction selection • produce compact, fast code • use available addressing modes • pattern matching problem — ad hoc techniques — tree pattern matching — string pattern matching — dynamic programming
  • 13. Register allocation • have value in a register when used • limited resources • changes instruction choices • can move loads and stores • optimal allocation is difficult
  • 14. Other types of compilers source-to-source compiler a type of compiler that takes a high level language as its input and outputs a high level language. Stage compiler compiles to assembly language of a theoretical machine, like some Prolog implementations This Prolog machine is also known as the Warren Abstract Machine (or WAM). Bytecode compilers for Java, Python, and many more are also a subtype of this. Just-in-time compiler Applications are delivered in bytecode, which is compiled to native machine code just prior to execution.
  • 15. Issues Driving Compiler Design Advantage: Self-Contained and Efficient Hardware Optimization Disadvantage: Compiled programs are targeted towards a particular platform and hence are platform dependent. Compile Times They are slower in execution than assembly programs. Compiled programs do not allow security to be implemented with in the code - e.g. a compiled program can access any area of the memory, and can do whatever it wants with your PC (most of the viruses are made in compiled languages). 15
  • 17. Group members UWU/CST/08/0019 LANKATHILAKA B.A.R. UWU/CST/08/0020 LIYANAGE C.J.V. UWU/CST/08/0021 MAHANAMA A.C. UWU/CST/08/0023 MUTUNAYAKE M.N.A. UWU/CST/08/0024 NASHAN M.H.M. UWU/CST/08/0025 NAYANATHARA J.A.J.U.