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
Ad

More Related Content

What's hot (20)

Introduction to Compiler design
Introduction to Compiler design Introduction to Compiler design
Introduction to Compiler design
Dr. C.V. Suresh Babu
ย 
Code Optimization
Code OptimizationCode Optimization
Code Optimization
Akhil Kaushik
ย 
System calls
System callsSystem calls
System calls
Bernard Senam
ย 
Lecture 01 introduction to compiler
Lecture 01 introduction to compilerLecture 01 introduction to compiler
Lecture 01 introduction to compiler
Iffat Anjum
ย 
Fundamentals of Language Processing
Fundamentals of Language ProcessingFundamentals of Language Processing
Fundamentals of Language Processing
Hemant Sharma
ย 
1.Role lexical Analyzer
1.Role lexical Analyzer1.Role lexical Analyzer
1.Role lexical Analyzer
Radhakrishnan Chinnusamy
ย 
Lexical analysis - Compiler Design
Lexical analysis - Compiler DesignLexical analysis - Compiler Design
Lexical analysis - Compiler Design
Muhammed Afsal Villan
ย 
Assembler
AssemblerAssembler
Assembler
manpreetgrewal
ย 
Assembly Language
Assembly LanguageAssembly Language
Assembly Language
Ibrahimcommunication Al Ani
ย 
Introduction to system programming
Introduction to system programmingIntroduction to system programming
Introduction to system programming
sonalikharade3
ย 
Phases of compiler
Phases of compilerPhases of compiler
Phases of compiler
Akhil Kaushik
ย 
Compiler design
Compiler designCompiler design
Compiler design
Thakur Ganeshsingh Thakur
ย 
Type Checking(Compiler Design) #ShareThisIfYouLike
Type Checking(Compiler Design) #ShareThisIfYouLikeType Checking(Compiler Design) #ShareThisIfYouLike
Type Checking(Compiler Design) #ShareThisIfYouLike
United International University
ย 
Symbol table in compiler Design
Symbol table in compiler DesignSymbol table in compiler Design
Symbol table in compiler Design
Kuppusamy P
ย 
System software - macro expansion,nested macro calls
System software - macro expansion,nested macro callsSystem software - macro expansion,nested macro calls
System software - macro expansion,nested macro calls
SARASWATHI S
ย 
Input-Buffering
Input-BufferingInput-Buffering
Input-Buffering
Dattatray Gandhmal
ย 
Types of Compilers
Types of CompilersTypes of Compilers
Types of Compilers
Hemant Chetwani
ย 
Two pass Assembler
Two pass AssemblerTwo pass Assembler
Two pass Assembler
Satyamevjayte Haxor
ย 
Introduction to Compiler Construction
Introduction to Compiler Construction Introduction to Compiler Construction
Introduction to Compiler Construction
Sarmad Ali
ย 
Single pass assembler
Single pass assemblerSingle pass assembler
Single pass assembler
Bansari Shah
ย 
Introduction to Compiler design
Introduction to Compiler design Introduction to Compiler design
Introduction to Compiler design
Dr. C.V. Suresh Babu
ย 
Code Optimization
Code OptimizationCode Optimization
Code Optimization
Akhil Kaushik
ย 
System calls
System callsSystem calls
System calls
Bernard Senam
ย 
Lecture 01 introduction to compiler
Lecture 01 introduction to compilerLecture 01 introduction to compiler
Lecture 01 introduction to compiler
Iffat Anjum
ย 
Fundamentals of Language Processing
Fundamentals of Language ProcessingFundamentals of Language Processing
Fundamentals of Language Processing
Hemant Sharma
ย 
Lexical analysis - Compiler Design
Lexical analysis - Compiler DesignLexical analysis - Compiler Design
Lexical analysis - Compiler Design
Muhammed Afsal Villan
ย 
Introduction to system programming
Introduction to system programmingIntroduction to system programming
Introduction to system programming
sonalikharade3
ย 
Phases of compiler
Phases of compilerPhases of compiler
Phases of compiler
Akhil Kaushik
ย 
Type Checking(Compiler Design) #ShareThisIfYouLike
Type Checking(Compiler Design) #ShareThisIfYouLikeType Checking(Compiler Design) #ShareThisIfYouLike
Type Checking(Compiler Design) #ShareThisIfYouLike
United International University
ย 
Symbol table in compiler Design
Symbol table in compiler DesignSymbol table in compiler Design
Symbol table in compiler Design
Kuppusamy P
ย 
System software - macro expansion,nested macro calls
System software - macro expansion,nested macro callsSystem software - macro expansion,nested macro calls
System software - macro expansion,nested macro calls
SARASWATHI S
ย 
Types of Compilers
Types of CompilersTypes of Compilers
Types of Compilers
Hemant Chetwani
ย 
Introduction to Compiler Construction
Introduction to Compiler Construction Introduction to Compiler Construction
Introduction to Compiler Construction
Sarmad Ali
ย 
Single pass assembler
Single pass assemblerSingle pass assembler
Single pass assembler
Bansari Shah
ย 

Viewers also liked (12)

GCC, GNU compiler collection
GCC, GNU compiler collectionGCC, GNU compiler collection
GCC, GNU compiler collection
Alberto Bustamante Reyes
ย 
Difference Between Emulation & Simulation
Difference Between Emulation & SimulationDifference Between Emulation & Simulation
Difference Between Emulation & Simulation
catchanil1989
ย 
Simulation PowerPoint
Simulation PowerPointSimulation PowerPoint
Simulation PowerPoint
Melissa Wilson
ย 
compiler and their types
compiler and their typescompiler and their types
compiler and their types
patchamounika7
ย 
Emulation and simulation
Emulation and simulationEmulation and simulation
Emulation and simulation
NebalAlJamal
ย 
Embedded Systems: Lecture 13: Introduction to GNU Toolchain (Build Tools)
Embedded Systems: Lecture 13: Introduction to GNU Toolchain (Build Tools)Embedded Systems: Lecture 13: Introduction to GNU Toolchain (Build Tools)
Embedded Systems: Lecture 13: Introduction to GNU Toolchain (Build Tools)
Ahmed El-Arabawy
ย 
Introduction to compiler
Introduction to compilerIntroduction to compiler
Introduction to compiler
Abha Damani
ย 
Introduction to Simulation
Introduction to SimulationIntroduction to Simulation
Introduction to Simulation
chimco.net
ย 
Debugging
DebuggingDebugging
Debugging
Indu Sharma Bhardwaj
ย 
SIMULATION
SIMULATIONSIMULATION
SIMULATION
Eminent Planners
ย 
Assemblers
AssemblersAssemblers
Assemblers
Dattatray Gandhmal
ย 
Assembler
AssemblerAssembler
Assembler
Maha Lakshmi
ย 
Difference Between Emulation & Simulation
Difference Between Emulation & SimulationDifference Between Emulation & Simulation
Difference Between Emulation & Simulation
catchanil1989
ย 
Simulation PowerPoint
Simulation PowerPointSimulation PowerPoint
Simulation PowerPoint
Melissa Wilson
ย 
compiler and their types
compiler and their typescompiler and their types
compiler and their types
patchamounika7
ย 
Emulation and simulation
Emulation and simulationEmulation and simulation
Emulation and simulation
NebalAlJamal
ย 
Embedded Systems: Lecture 13: Introduction to GNU Toolchain (Build Tools)
Embedded Systems: Lecture 13: Introduction to GNU Toolchain (Build Tools)Embedded Systems: Lecture 13: Introduction to GNU Toolchain (Build Tools)
Embedded Systems: Lecture 13: Introduction to GNU Toolchain (Build Tools)
Ahmed El-Arabawy
ย 
Introduction to compiler
Introduction to compilerIntroduction to compiler
Introduction to compiler
Abha Damani
ย 
Introduction to Simulation
Introduction to SimulationIntroduction to Simulation
Introduction to Simulation
chimco.net
ย 
Assembler
AssemblerAssembler
Assembler
Maha Lakshmi
ย 
Ad

Similar to Compilers (20)

Compiler design and lexical analyser
Compiler design and lexical analyserCompiler design and lexical analyser
Compiler design and lexical analyser
abhishek gupta
ย 
Chapter1pdf__2021_11_23_10_53_20.pdf
Chapter1pdf__2021_11_23_10_53_20.pdfChapter1pdf__2021_11_23_10_53_20.pdf
Chapter1pdf__2021_11_23_10_53_20.pdf
DrIsikoIsaac
ย 
unit1pdf__2021_12_14_12_37_34.pdf
unit1pdf__2021_12_14_12_37_34.pdfunit1pdf__2021_12_14_12_37_34.pdf
unit1pdf__2021_12_14_12_37_34.pdf
DrIsikoIsaac
ย 
Compiler_Lecture1.pdf
Compiler_Lecture1.pdfCompiler_Lecture1.pdf
Compiler_Lecture1.pdf
AkarTaher
ย 
Phases of Compiler
Phases of CompilerPhases of Compiler
Phases of Compiler
A. S. M. Shafi
ย 
Unit 1 part1 Introduction of Compiler Design.pptx
Unit 1 part1 Introduction of Compiler Design.pptxUnit 1 part1 Introduction of Compiler Design.pptx
Unit 1 part1 Introduction of Compiler Design.pptx
Neelkaranbind
ย 
Lecture 1 introduction to language processors
Lecture 1  introduction to language processorsLecture 1  introduction to language processors
Lecture 1 introduction to language processors
Rebaz Najeeb
ย 
aditya malkani compiler.pptx
aditya malkani compiler.pptxaditya malkani compiler.pptx
aditya malkani compiler.pptx
WildVenomOP
ย 
Phases of Compiler.pptx
Phases of Compiler.pptxPhases of Compiler.pptx
Phases of Compiler.pptx
ssuser3b4934
ย 
Chapter#01 cc
Chapter#01 ccChapter#01 cc
Chapter#01 cc
abdulbaki3
ย 
Compiler_Presentation important one. .pptx
Compiler_Presentation important one. .pptxCompiler_Presentation important one. .pptx
Compiler_Presentation important one. .pptx
SiddarthaBANDARI
ย 
Compiler Construction introduction
Compiler Construction introductionCompiler Construction introduction
Compiler Construction introduction
Rana Ehtisham Ul Haq
ย 
Language translators
Language translatorsLanguage translators
Language translators
Aditya Sharat
ย 
Compiler Construction
Compiler ConstructionCompiler Construction
Compiler Construction
Ahmed Raza
ย 
COMPILER CONSTRUCTION KU 1.pptx
COMPILER CONSTRUCTION KU 1.pptxCOMPILER CONSTRUCTION KU 1.pptx
COMPILER CONSTRUCTION KU 1.pptx
Rossy719186
ย 
LANGUAGE TRANSLATOR
LANGUAGE TRANSLATORLANGUAGE TRANSLATOR
LANGUAGE TRANSLATOR
PUNE VIDYARTHI GRIHA'S COLLEGE OF ENGINEERING, NASHIK
ย 
Chapter 1.pptx
Chapter 1.pptxChapter 1.pptx
Chapter 1.pptx
NesredinTeshome1
ย 
Compiler Construction from very basic start
Compiler Construction from very basic startCompiler Construction from very basic start
Compiler Construction from very basic start
voyoc79528
ย 
1._Introduction_.pptx
1._Introduction_.pptx1._Introduction_.pptx
1._Introduction_.pptx
Anbarasan Radhakrishnan R
ย 
Compiler design
Compiler designCompiler design
Compiler design
nazmul hoque
ย 
Compiler design and lexical analyser
Compiler design and lexical analyserCompiler design and lexical analyser
Compiler design and lexical analyser
abhishek gupta
ย 
Chapter1pdf__2021_11_23_10_53_20.pdf
Chapter1pdf__2021_11_23_10_53_20.pdfChapter1pdf__2021_11_23_10_53_20.pdf
Chapter1pdf__2021_11_23_10_53_20.pdf
DrIsikoIsaac
ย 
unit1pdf__2021_12_14_12_37_34.pdf
unit1pdf__2021_12_14_12_37_34.pdfunit1pdf__2021_12_14_12_37_34.pdf
unit1pdf__2021_12_14_12_37_34.pdf
DrIsikoIsaac
ย 
Compiler_Lecture1.pdf
Compiler_Lecture1.pdfCompiler_Lecture1.pdf
Compiler_Lecture1.pdf
AkarTaher
ย 
Phases of Compiler
Phases of CompilerPhases of Compiler
Phases of Compiler
A. S. M. Shafi
ย 
Unit 1 part1 Introduction of Compiler Design.pptx
Unit 1 part1 Introduction of Compiler Design.pptxUnit 1 part1 Introduction of Compiler Design.pptx
Unit 1 part1 Introduction of Compiler Design.pptx
Neelkaranbind
ย 
Lecture 1 introduction to language processors
Lecture 1  introduction to language processorsLecture 1  introduction to language processors
Lecture 1 introduction to language processors
Rebaz Najeeb
ย 
aditya malkani compiler.pptx
aditya malkani compiler.pptxaditya malkani compiler.pptx
aditya malkani compiler.pptx
WildVenomOP
ย 
Phases of Compiler.pptx
Phases of Compiler.pptxPhases of Compiler.pptx
Phases of Compiler.pptx
ssuser3b4934
ย 
Chapter#01 cc
Chapter#01 ccChapter#01 cc
Chapter#01 cc
abdulbaki3
ย 
Compiler_Presentation important one. .pptx
Compiler_Presentation important one. .pptxCompiler_Presentation important one. .pptx
Compiler_Presentation important one. .pptx
SiddarthaBANDARI
ย 
Compiler Construction introduction
Compiler Construction introductionCompiler Construction introduction
Compiler Construction introduction
Rana Ehtisham Ul Haq
ย 
Language translators
Language translatorsLanguage translators
Language translators
Aditya Sharat
ย 
Compiler Construction
Compiler ConstructionCompiler Construction
Compiler Construction
Ahmed Raza
ย 
COMPILER CONSTRUCTION KU 1.pptx
COMPILER CONSTRUCTION KU 1.pptxCOMPILER CONSTRUCTION KU 1.pptx
COMPILER CONSTRUCTION KU 1.pptx
Rossy719186
ย 
Compiler Construction from very basic start
Compiler Construction from very basic startCompiler Construction from very basic start
Compiler Construction from very basic start
voyoc79528
ย 
Compiler design
Compiler designCompiler design
Compiler design
nazmul hoque
ย 
Ad

Recently uploaded (20)

Electronic_Mail_Attacks-1-35.pdf by xploit
Electronic_Mail_Attacks-1-35.pdf by xploitElectronic_Mail_Attacks-1-35.pdf by xploit
Electronic_Mail_Attacks-1-35.pdf by xploit
niftliyevhuseyn
ย 
The Evolution of Meme Coins A New Era for Digital Currency ppt.pdf
The Evolution of Meme Coins A New Era for Digital Currency ppt.pdfThe Evolution of Meme Coins A New Era for Digital Currency ppt.pdf
The Evolution of Meme Coins A New Era for Digital Currency ppt.pdf
Abi john
ย 
What is Model Context Protocol(MCP) - The new technology for communication bw...
What is Model Context Protocol(MCP) - The new technology for communication bw...What is Model Context Protocol(MCP) - The new technology for communication bw...
What is Model Context Protocol(MCP) - The new technology for communication bw...
Vishnu Singh Chundawat
ย 
2025-05-Q4-2024-Investor-Presentation.pptx
2025-05-Q4-2024-Investor-Presentation.pptx2025-05-Q4-2024-Investor-Presentation.pptx
2025-05-Q4-2024-Investor-Presentation.pptx
Samuele Fogagnolo
ย 
AI Changes Everything โ€“ Talk at Cardiff Metropolitan University, 29th April 2...
AI Changes Everything โ€“ Talk at Cardiff Metropolitan University, 29th April 2...AI Changes Everything โ€“ Talk at Cardiff Metropolitan University, 29th April 2...
AI Changes Everything โ€“ Talk at Cardiff Metropolitan University, 29th April 2...
Alan Dix
ย 
AI EngineHost Review: Revolutionary USA Datacenter-Based Hosting with NVIDIA ...
AI EngineHost Review: Revolutionary USA Datacenter-Based Hosting with NVIDIA ...AI EngineHost Review: Revolutionary USA Datacenter-Based Hosting with NVIDIA ...
AI EngineHost Review: Revolutionary USA Datacenter-Based Hosting with NVIDIA ...
SOFTTECHHUB
ย 
Automation Hour 1/28/2022: Capture User Feedback from Anywhere
Automation Hour 1/28/2022: Capture User Feedback from AnywhereAutomation Hour 1/28/2022: Capture User Feedback from Anywhere
Automation Hour 1/28/2022: Capture User Feedback from Anywhere
Lynda Kane
ย 
Leading AI Innovation As A Product Manager - Michael Jidael
Leading AI Innovation As A Product Manager - Michael JidaelLeading AI Innovation As A Product Manager - Michael Jidael
Leading AI Innovation As A Product Manager - Michael Jidael
Michael Jidael
ย 
"PHP and MySQL CRUD Operations for Student Management System"
"PHP and MySQL CRUD Operations for Student Management System""PHP and MySQL CRUD Operations for Student Management System"
"PHP and MySQL CRUD Operations for Student Management System"
Jainul Musani
ย 
Buckeye Dreamin 2024: Assessing and Resolving Technical Debt
Buckeye Dreamin 2024: Assessing and Resolving Technical DebtBuckeye Dreamin 2024: Assessing and Resolving Technical Debt
Buckeye Dreamin 2024: Assessing and Resolving Technical Debt
Lynda Kane
ย 
Automation Dreamin': Capture User Feedback From Anywhere
Automation Dreamin': Capture User Feedback From AnywhereAutomation Dreamin': Capture User Feedback From Anywhere
Automation Dreamin': Capture User Feedback From Anywhere
Lynda Kane
ย 
Dev Dives: Automate and orchestrate your processes with UiPath Maestro
Dev Dives: Automate and orchestrate your processes with UiPath MaestroDev Dives: Automate and orchestrate your processes with UiPath Maestro
Dev Dives: Automate and orchestrate your processes with UiPath Maestro
UiPathCommunity
ย 
AI and Data Privacy in 2025: Global Trends
AI and Data Privacy in 2025: Global TrendsAI and Data Privacy in 2025: Global Trends
AI and Data Privacy in 2025: Global Trends
InData Labs
ย 
Splunk Security Update | Public Sector Summit Germany 2025
Splunk Security Update | Public Sector Summit Germany 2025Splunk Security Update | Public Sector Summit Germany 2025
Splunk Security Update | Public Sector Summit Germany 2025
Splunk
ย 
How Can I use the AI Hype in my Business Context?
How Can I use the AI Hype in my Business Context?How Can I use the AI Hype in my Business Context?
How Can I use the AI Hype in my Business Context?
Daniel Lehner
ย 
Rusty Waters: Elevating Lakehouses Beyond Spark
Rusty Waters: Elevating Lakehouses Beyond SparkRusty Waters: Elevating Lakehouses Beyond Spark
Rusty Waters: Elevating Lakehouses Beyond Spark
carlyakerly1
ย 
Manifest Pre-Seed Update | A Humanoid OEM Deeptech In France
Manifest Pre-Seed Update | A Humanoid OEM Deeptech In FranceManifest Pre-Seed Update | A Humanoid OEM Deeptech In France
Manifest Pre-Seed Update | A Humanoid OEM Deeptech In France
chb3
ย 
Drupalcamp Finland โ€“ Measuring Front-end Energy Consumption
Drupalcamp Finland โ€“ Measuring Front-end Energy ConsumptionDrupalcamp Finland โ€“ Measuring Front-end Energy Consumption
Drupalcamp Finland โ€“ Measuring Front-end Energy Consumption
Exove
ย 
Cyber Awareness overview for 2025 month of security
Cyber Awareness overview for 2025 month of securityCyber Awareness overview for 2025 month of security
Cyber Awareness overview for 2025 month of security
riccardosl1
ย 
Procurement Insights Cost To Value Guide.pptx
Procurement Insights Cost To Value Guide.pptxProcurement Insights Cost To Value Guide.pptx
Procurement Insights Cost To Value Guide.pptx
Jon Hansen
ย 
Electronic_Mail_Attacks-1-35.pdf by xploit
Electronic_Mail_Attacks-1-35.pdf by xploitElectronic_Mail_Attacks-1-35.pdf by xploit
Electronic_Mail_Attacks-1-35.pdf by xploit
niftliyevhuseyn
ย 
The Evolution of Meme Coins A New Era for Digital Currency ppt.pdf
The Evolution of Meme Coins A New Era for Digital Currency ppt.pdfThe Evolution of Meme Coins A New Era for Digital Currency ppt.pdf
The Evolution of Meme Coins A New Era for Digital Currency ppt.pdf
Abi john
ย 
What is Model Context Protocol(MCP) - The new technology for communication bw...
What is Model Context Protocol(MCP) - The new technology for communication bw...What is Model Context Protocol(MCP) - The new technology for communication bw...
What is Model Context Protocol(MCP) - The new technology for communication bw...
Vishnu Singh Chundawat
ย 
2025-05-Q4-2024-Investor-Presentation.pptx
2025-05-Q4-2024-Investor-Presentation.pptx2025-05-Q4-2024-Investor-Presentation.pptx
2025-05-Q4-2024-Investor-Presentation.pptx
Samuele Fogagnolo
ย 
AI Changes Everything โ€“ Talk at Cardiff Metropolitan University, 29th April 2...
AI Changes Everything โ€“ Talk at Cardiff Metropolitan University, 29th April 2...AI Changes Everything โ€“ Talk at Cardiff Metropolitan University, 29th April 2...
AI Changes Everything โ€“ Talk at Cardiff Metropolitan University, 29th April 2...
Alan Dix
ย 
AI EngineHost Review: Revolutionary USA Datacenter-Based Hosting with NVIDIA ...
AI EngineHost Review: Revolutionary USA Datacenter-Based Hosting with NVIDIA ...AI EngineHost Review: Revolutionary USA Datacenter-Based Hosting with NVIDIA ...
AI EngineHost Review: Revolutionary USA Datacenter-Based Hosting with NVIDIA ...
SOFTTECHHUB
ย 
Automation Hour 1/28/2022: Capture User Feedback from Anywhere
Automation Hour 1/28/2022: Capture User Feedback from AnywhereAutomation Hour 1/28/2022: Capture User Feedback from Anywhere
Automation Hour 1/28/2022: Capture User Feedback from Anywhere
Lynda Kane
ย 
Leading AI Innovation As A Product Manager - Michael Jidael
Leading AI Innovation As A Product Manager - Michael JidaelLeading AI Innovation As A Product Manager - Michael Jidael
Leading AI Innovation As A Product Manager - Michael Jidael
Michael Jidael
ย 
"PHP and MySQL CRUD Operations for Student Management System"
"PHP and MySQL CRUD Operations for Student Management System""PHP and MySQL CRUD Operations for Student Management System"
"PHP and MySQL CRUD Operations for Student Management System"
Jainul Musani
ย 
Buckeye Dreamin 2024: Assessing and Resolving Technical Debt
Buckeye Dreamin 2024: Assessing and Resolving Technical DebtBuckeye Dreamin 2024: Assessing and Resolving Technical Debt
Buckeye Dreamin 2024: Assessing and Resolving Technical Debt
Lynda Kane
ย 
Automation Dreamin': Capture User Feedback From Anywhere
Automation Dreamin': Capture User Feedback From AnywhereAutomation Dreamin': Capture User Feedback From Anywhere
Automation Dreamin': Capture User Feedback From Anywhere
Lynda Kane
ย 
Dev Dives: Automate and orchestrate your processes with UiPath Maestro
Dev Dives: Automate and orchestrate your processes with UiPath MaestroDev Dives: Automate and orchestrate your processes with UiPath Maestro
Dev Dives: Automate and orchestrate your processes with UiPath Maestro
UiPathCommunity
ย 
AI and Data Privacy in 2025: Global Trends
AI and Data Privacy in 2025: Global TrendsAI and Data Privacy in 2025: Global Trends
AI and Data Privacy in 2025: Global Trends
InData Labs
ย 
Splunk Security Update | Public Sector Summit Germany 2025
Splunk Security Update | Public Sector Summit Germany 2025Splunk Security Update | Public Sector Summit Germany 2025
Splunk Security Update | Public Sector Summit Germany 2025
Splunk
ย 
How Can I use the AI Hype in my Business Context?
How Can I use the AI Hype in my Business Context?How Can I use the AI Hype in my Business Context?
How Can I use the AI Hype in my Business Context?
Daniel Lehner
ย 
Rusty Waters: Elevating Lakehouses Beyond Spark
Rusty Waters: Elevating Lakehouses Beyond SparkRusty Waters: Elevating Lakehouses Beyond Spark
Rusty Waters: Elevating Lakehouses Beyond Spark
carlyakerly1
ย 
Manifest Pre-Seed Update | A Humanoid OEM Deeptech In France
Manifest Pre-Seed Update | A Humanoid OEM Deeptech In FranceManifest Pre-Seed Update | A Humanoid OEM Deeptech In France
Manifest Pre-Seed Update | A Humanoid OEM Deeptech In France
chb3
ย 
Drupalcamp Finland โ€“ Measuring Front-end Energy Consumption
Drupalcamp Finland โ€“ Measuring Front-end Energy ConsumptionDrupalcamp Finland โ€“ Measuring Front-end Energy Consumption
Drupalcamp Finland โ€“ Measuring Front-end Energy Consumption
Exove
ย 
Cyber Awareness overview for 2025 month of security
Cyber Awareness overview for 2025 month of securityCyber Awareness overview for 2025 month of security
Cyber Awareness overview for 2025 month of security
riccardosl1
ย 
Procurement Insights Cost To Value Guide.pptx
Procurement Insights Cost To Value Guide.pptxProcurement Insights Cost To Value Guide.pptx
Procurement Insights Cost To Value Guide.pptx
Jon Hansen
ย 

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.