SlideShare a Scribd company logo
J. Bense Tony
Anna University
        Chennai
Acompiler is a program that reads a
program written in one language and
translates into equivalent target
language
                COMPILER
     Source-                   - Target
                      |
                      |
                      |
                Error Message
Compilers
   The Front end checks whether the
    program is correctly written in terms of the
    programming language syntax and
    semantics

   The back end is responsible for translating
    the source into assembly code.
Front End :

LexicalAnalysis
Preprocessing
Syntax Analysis
Semantic Analysis
Back End

 Analysis
 Optimization
 Code   generation
   Lexical Analyzer
   Syntax Analyzer
   Semantic Analyzer
   Intermediate code generator
   Code optimizer
   Code generator
Lexical



                  Syntax




                 Semantic
Symbol                                  Error
Table                                   Handler
manager
          Intermediate Code Generator




               Code Generator




                Code Optimizer
 Also called Linear Analysis
 Characters read from left to right and
  grouped into tokens that are a sequence of
  characters with a collective meaning
Scans Input
Removes White spaces and comments
Manufacture Tokens
Generate Error if Any
◦ Example

◦ A=B+C

◦ Variable tokens - A ,B, C
◦ Symbolic token -- = +
   Also called as Hierarchial Analysis
   A syntax tree[also called as parse tree] is generated
    where
    ◦ Operators  Interior nodes
    ◦ Operands  Children of node for operators.

                          =

                  A               +           Interior

                              B       C       Children
   Characters grouped as tokens in Lexical Analysis are
    recorded as Tables. Checks for semantic errors



   Collect TYPE information for the subsequent code
    generation phase
   Sophisticated compilers typically perform multiple
    passes over various intermediate forms.
   Many algorithms for code optimization are easier to
    apply one at a time
   The input to one optimization relies on the
    processing performed by another optimization
 Input : Concrete Syntax Tree[Parse Tree] or
           Abstract Syntax Tree
 The tree is converted into a linear sequence
  of instructions, usually in an intermediate
  language such as three address code.
 This is an Early stage of Code generation
Concrete Parse tree
             Abstract syntax tree



Converted into a linear sequence of instructions




       Results in 3AC [ 3 Address Code]
   This phase attempts to improve the intermediate
    code inorder to increase the running time

   Reduce the complexity of the code generated

   Leading to a faster execution of the program

   Increased Performance
   Platform Dependant/ Platform Independent
   Optimization can be automated by compilers or
    performed by programmers
   Usually, the most powerful optimization is to find
    a superior algorithm.
   Include activities like
    ◦ Optimization of LOOPS
    ◦ Optimization of Bottlenecks
 Succeeding step of Intermediate code
  optimizer
 Consists of re-locatable machine
  code/assembly code
 Intermediate instructions are converted
  into a a sequence of machine instructions
 One   pass compilers

 Multi   pass compilers

 Load    and go compilers

 Optimizing   compilers
One pass                            Multi pass

Passes through the source code of   Processes the source code of a
each compilation unit only once     program several times


Compilation time is faster          Compilation time is slower


Has limited scope of passes         Has wide scope of passes.


wide compilers                      Narrow compilers


Pascal                              Java
 Generates machine code and immediately
  executes it.

 Compilers usually produce either absolute
 code that is executed immediately upon
 conclusion of the compilation or object code that
 is transformed by a linking loader into absolute
 code.
   Loop optimization
   Data flow
   Code generation
   Functional language
   Interprocedural optimizations
   SSA [Static Single Assignment] based
    optimizations
Threaded code compiler
 database lookup program.
 replaces given strings in the source with
  given binary code.

   Incremental compiler:
    ◦ Individual functions can be compiled in a run-time
      environment that also includes interpreted
      functions.
   Stage compiler
    That compiles to assembly language of a
    theoretical machine, like some Prolog
    implementations

   Just-in-time compiler
    ◦ Applications are delivered in byte code, which is
      compiled to native machine code just prior to
      execution
   A Retargetable compiler
    ◦ object code is frequently of lesser quality than that
      produced by a compiler developed specifically for a
      processor.
    ◦ Retargetable compilers are often also cross
      compilers
   A parallelizing compiler
    ◦ converts a serial input program into a form suitable
      for efficient execution on a parallel computer
      architecture.
 The compiler highlights all the possible
  errors which are obstacle in the
  program to provide a good meaning.
 Logical errors could be found only at
  Run time of the program.
   Array bound missing
   Array size too large
   Bad file name
   Call of on function
   Declaration missing
   Compound statement missing
   Illegal Accessions
   Not abstract
   Not accessible
   Not initialized
   Not found in “import”
   Scope related errors
   Cannot be inherited
   Overloading
   Overriding errors
   Program is free from lexical errors
   Program is free from syntax errors
   Program is free from semantic errors
   Even a complex program could be compiled in a
    small interval of time
   In programs related to database accessing,
    many risks are reduced.
THANK


YOU

More Related Content

PDF
Lecture 01 introduction to compiler
PPT
basics of compiler design
PPT
Introduction to Compiler design
PPT
Compiler Design Basics
PPT
Compiler Design
PPTX
Phases of Compiler
PPTX
Compiler design
PPTX
Phases of compiler
Lecture 01 introduction to compiler
basics of compiler design
Introduction to Compiler design
Compiler Design Basics
Compiler Design
Phases of Compiler
Compiler design
Phases of compiler

What's hot (20)

DOC
Time and space complexity
PPTX
Lexical Analysis - Compiler Design
PPT
1.Role lexical Analyzer
PPT
Intermediate code generation (Compiler Design)
PPTX
Algorithm Introduction
PDF
Algorithms Lecture 1: Introduction to Algorithms
PPTX
Assembly Language
PPTX
Lexical analysis - Compiler Design
PPTX
Compiler vs interpreter
PPTX
Ambiguous & Unambiguous Grammar
PDF
Syntax analysis
PPTX
Macro Processor
PPT
Lecture 1 - Lexical Analysis.ppt
PPTX
Peephole optimization techniques in compiler design
PPT
Time complexity
PPTX
Interfacing With High Level Programming Language
PPTX
Loop optimization
PPTX
Recognition-of-tokens
PPTX
Java package
PPTX
Loaders ( system programming )
Time and space complexity
Lexical Analysis - Compiler Design
1.Role lexical Analyzer
Intermediate code generation (Compiler Design)
Algorithm Introduction
Algorithms Lecture 1: Introduction to Algorithms
Assembly Language
Lexical analysis - Compiler Design
Compiler vs interpreter
Ambiguous & Unambiguous Grammar
Syntax analysis
Macro Processor
Lecture 1 - Lexical Analysis.ppt
Peephole optimization techniques in compiler design
Time complexity
Interfacing With High Level Programming Language
Loop optimization
Recognition-of-tokens
Java package
Loaders ( system programming )
Ad

Viewers also liked (14)

ODP
GCC, GNU compiler collection
PPTX
Difference Between Emulation & Simulation
PPTX
Simulation PowerPoint
PPTX
compiler and their types
PPTX
Emulation and simulation
PDF
Embedded Systems: Lecture 13: Introduction to GNU Toolchain (Build Tools)
PPT
Assembler
PPT
Introduction to compiler
PPT
Introduction to Simulation
PPT
PPTX
SIMULATION
PPTX
Assemblers
PPT
Assembler
PPTX
Two pass Assembler
GCC, GNU compiler collection
Difference Between Emulation & Simulation
Simulation PowerPoint
compiler and their types
Emulation and simulation
Embedded Systems: Lecture 13: Introduction to GNU Toolchain (Build Tools)
Assembler
Introduction to compiler
Introduction to Simulation
SIMULATION
Assemblers
Assembler
Two pass Assembler
Ad

Similar to Compilers (20)

PPTX
1-Phases of compiler-26-04-2023.pptx
PPT
Cpcs302 1
PPTX
1 cc
PPTX
The Phases of a Compiler
DOCX
Dineshmaterial1 091225091539-phpapp02
PPTX
Unit1.pptx of compiler design students subjects
PPTX
16 compiler-151129060845-lva1-app6892-converted.pptx
PPT
phases of a compiler
PPTX
role of lexical anaysis
DOC
Compilerdesignnew 091219090526-phpapp02
DOC
Compiler Design(Nanthu)
DOC
Compiler Design(NANTHU NOTES)
DOCX
Compiler Design Material
PPTX
Compiler Design Unit1 PPT Phases of Compiler.pptx
PPT
Compiler Construction introduction
PPT
Phases of compiler
PPTX
Chapter 1.pptx
PPTX
Lecture 1 introduction to language processors
PDF
unit1pdf__2021_12_14_12_37_34.pdf
PDF
Phases of compiler
1-Phases of compiler-26-04-2023.pptx
Cpcs302 1
1 cc
The Phases of a Compiler
Dineshmaterial1 091225091539-phpapp02
Unit1.pptx of compiler design students subjects
16 compiler-151129060845-lva1-app6892-converted.pptx
phases of a compiler
role of lexical anaysis
Compilerdesignnew 091219090526-phpapp02
Compiler Design(Nanthu)
Compiler Design(NANTHU NOTES)
Compiler Design Material
Compiler Design Unit1 PPT Phases of Compiler.pptx
Compiler Construction introduction
Phases of compiler
Chapter 1.pptx
Lecture 1 introduction to language processors
unit1pdf__2021_12_14_12_37_34.pdf
Phases of compiler

Recently uploaded (20)

PDF
How UI/UX Design Impacts User Retention in Mobile Apps.pdf
PDF
Unlocking AI with Model Context Protocol (MCP)
PDF
Dropbox Q2 2025 Financial Results & Investor Presentation
PPTX
Cloud computing and distributed systems.
PDF
cuic standard and advanced reporting.pdf
PPTX
ACSFv1EN-58255 AWS Academy Cloud Security Foundations.pptx
PPTX
Spectroscopy.pptx food analysis technology
PPTX
Big Data Technologies - Introduction.pptx
PPT
“AI and Expert System Decision Support & Business Intelligence Systems”
PPTX
Effective Security Operations Center (SOC) A Modern, Strategic, and Threat-In...
PPTX
20250228 LYD VKU AI Blended-Learning.pptx
PDF
Diabetes mellitus diagnosis method based random forest with bat algorithm
PDF
Reach Out and Touch Someone: Haptics and Empathic Computing
PPTX
sap open course for s4hana steps from ECC to s4
PDF
Advanced methodologies resolving dimensionality complications for autism neur...
PDF
Profit Center Accounting in SAP S/4HANA, S4F28 Col11
PDF
Agricultural_Statistics_at_a_Glance_2022_0.pdf
PPTX
Digital-Transformation-Roadmap-for-Companies.pptx
PPT
Teaching material agriculture food technology
PDF
Encapsulation theory and applications.pdf
How UI/UX Design Impacts User Retention in Mobile Apps.pdf
Unlocking AI with Model Context Protocol (MCP)
Dropbox Q2 2025 Financial Results & Investor Presentation
Cloud computing and distributed systems.
cuic standard and advanced reporting.pdf
ACSFv1EN-58255 AWS Academy Cloud Security Foundations.pptx
Spectroscopy.pptx food analysis technology
Big Data Technologies - Introduction.pptx
“AI and Expert System Decision Support & Business Intelligence Systems”
Effective Security Operations Center (SOC) A Modern, Strategic, and Threat-In...
20250228 LYD VKU AI Blended-Learning.pptx
Diabetes mellitus diagnosis method based random forest with bat algorithm
Reach Out and Touch Someone: Haptics and Empathic Computing
sap open course for s4hana steps from ECC to s4
Advanced methodologies resolving dimensionality complications for autism neur...
Profit Center Accounting in SAP S/4HANA, S4F28 Col11
Agricultural_Statistics_at_a_Glance_2022_0.pdf
Digital-Transformation-Roadmap-for-Companies.pptx
Teaching material agriculture food technology
Encapsulation theory and applications.pdf

Compilers

  • 1. J. Bense Tony Anna University Chennai
  • 2. Acompiler is a program that reads a program written in one language and translates into equivalent target language COMPILER Source- - Target | | | Error Message
  • 4. The Front end checks whether the program is correctly written in terms of the programming language syntax and semantics  The back end is responsible for translating the source into assembly code.
  • 6. Back End  Analysis  Optimization  Code generation
  • 7. Lexical Analyzer  Syntax Analyzer  Semantic Analyzer  Intermediate code generator  Code optimizer  Code generator
  • 8. Lexical Syntax Semantic Symbol Error Table Handler manager Intermediate Code Generator Code Generator Code Optimizer
  • 9.  Also called Linear Analysis  Characters read from left to right and grouped into tokens that are a sequence of characters with a collective meaning Scans Input Removes White spaces and comments Manufacture Tokens Generate Error if Any
  • 10. ◦ Example ◦ A=B+C ◦ Variable tokens - A ,B, C ◦ Symbolic token -- = +
  • 11. Also called as Hierarchial Analysis  A syntax tree[also called as parse tree] is generated where ◦ Operators  Interior nodes ◦ Operands  Children of node for operators. = A + Interior B C Children
  • 12. Characters grouped as tokens in Lexical Analysis are recorded as Tables. Checks for semantic errors  Collect TYPE information for the subsequent code generation phase
  • 13. Sophisticated compilers typically perform multiple passes over various intermediate forms.  Many algorithms for code optimization are easier to apply one at a time  The input to one optimization relies on the processing performed by another optimization
  • 14.  Input : Concrete Syntax Tree[Parse Tree] or Abstract Syntax Tree  The tree is converted into a linear sequence of instructions, usually in an intermediate language such as three address code.  This is an Early stage of Code generation
  • 15. Concrete Parse tree Abstract syntax tree Converted into a linear sequence of instructions Results in 3AC [ 3 Address Code]
  • 16. This phase attempts to improve the intermediate code inorder to increase the running time  Reduce the complexity of the code generated  Leading to a faster execution of the program  Increased Performance
  • 17. Platform Dependant/ Platform Independent  Optimization can be automated by compilers or performed by programmers  Usually, the most powerful optimization is to find a superior algorithm.  Include activities like ◦ Optimization of LOOPS ◦ Optimization of Bottlenecks
  • 18.  Succeeding step of Intermediate code optimizer  Consists of re-locatable machine code/assembly code  Intermediate instructions are converted into a a sequence of machine instructions
  • 19.  One pass compilers  Multi pass compilers  Load and go compilers  Optimizing compilers
  • 20. One pass Multi pass Passes through the source code of Processes the source code of a each compilation unit only once program several times Compilation time is faster Compilation time is slower Has limited scope of passes Has wide scope of passes. wide compilers Narrow compilers Pascal Java
  • 21.  Generates machine code and immediately executes it.  Compilers usually produce either absolute code that is executed immediately upon conclusion of the compilation or object code that is transformed by a linking loader into absolute code.
  • 22. Loop optimization  Data flow  Code generation  Functional language  Interprocedural optimizations  SSA [Static Single Assignment] based optimizations
  • 23. Threaded code compiler  database lookup program.  replaces given strings in the source with given binary code.  Incremental compiler: ◦ Individual functions can be compiled in a run-time environment that also includes interpreted functions.
  • 24. Stage compiler That compiles to assembly language of a theoretical machine, like some Prolog implementations  Just-in-time compiler ◦ Applications are delivered in byte code, which is compiled to native machine code just prior to execution
  • 25. A Retargetable compiler ◦ object code is frequently of lesser quality than that produced by a compiler developed specifically for a processor. ◦ Retargetable compilers are often also cross compilers  A parallelizing compiler ◦ converts a serial input program into a form suitable for efficient execution on a parallel computer architecture.
  • 26.  The compiler highlights all the possible errors which are obstacle in the program to provide a good meaning.  Logical errors could be found only at Run time of the program.
  • 27. Array bound missing  Array size too large  Bad file name  Call of on function  Declaration missing  Compound statement missing  Illegal Accessions
  • 28. Not abstract  Not accessible  Not initialized  Not found in “import”  Scope related errors  Cannot be inherited  Overloading  Overriding errors
  • 29. Program is free from lexical errors  Program is free from syntax errors  Program is free from semantic errors  Even a complex program could be compiled in a small interval of time  In programs related to database accessing, many risks are reduced.