SlideShare a Scribd company logo
Compiler
By:Adil
no compiler
Not Getting (-.-)
//By:Adil
Code
Agenda of today presentation
• What is Compiler
• Brief History of compiler
• Task of compiler
• Phases of compiler
source code
Compiler
Machine code
What is Compiler
• Is a program that translates one language
to another
• Takes as input a source program typically
written in a high-level language
• Produces an equivalent target program
typically in assembly or machine language
• Reports error messages as part of the
translation process
Brief history of Compiler
• The term “compiler” was coined in the early
1950s by Grace Murray Hopper
• The first compiler of the high-level language
FORTRAN was developed between 1954 and
1957 at IBM
• The first FORTRAN compiler took 18 person-
years to create
Compiler tasks
A compiler must perform two tasks:
 analysis of source program: The analysis part breaks up the
source program into constituent pieces and imposes a
grammatical structure on them. It then uses this structure to
create an intermediate representation of the source program.
 synthesis of its corresponding program: constructs the
desired target program from the intermediate representation
and the information in the symbol table.
The analysis part is often called the front end of the compiler;
the synthesis part is the back end.
Compiler phases
• Lexical Analyzer
• Syntax Analyzer
• Semantic Analyzer
• Intermediate Code
Generator
• Code Optimizer
• Code Generation
Lexical Analysis (scanner): The
first phase of a compiler
• Lexical analyzer reads the stream of characters making up the source
program and groups the characters into meaningful sequences called
lexeme
• For each lexeme, the lexical analyzer produces a token of the form that it
passes on to the subsequent phase, syntax analysis(token-name, attribute-
value)
• Token-name: an abstract symbol is used during syntax analysis, an
• attribute-value: points to an entry in the symbol table for this token.
• Tokensrepresent basic program entities such as:
Identifiers, Literals, Reserved Words, Operators, Delimiters, etc.
Example:
1.”position” is a lexeme mapped into a token (id,
1), where id is an abstract symbol standing
for identifier and 1 points to the symbol table
entry for position. The symbol-table entry for
an identifier holds information about the
identifier, such as its name and type.
2. = is a lexeme that is mapped into the token (=).
Since this token needs no attribute-value, we
have omitted the second component. For
notational convenience, the lexeme itself is
used as the name of the abstract symbol.
3. “initial” is a lexeme that is mapped into the
token (id, 2), where 2 points to the symbol-
table entry for initial.
4. + is a lexeme that is mapped into the token (+).
5. “rate” is a lexeme mapped into the token (id,
3), where 3 points to the symbol-table entry
for rate.
6. * is a lexeme that is mapped into the token
(*) .
7. 60 is a lexeme that is mapped into the token
(60)
Blanks separating the lexemes would be discarded
by the lexical analyzer.
position = initial + 60
*
rate
Table
id 1
id 2
id 3
token lexem
Syntax Analysis (parser) : The second phase of the
compiler
• The parser uses the first components of the tokens produced by the lexical
analyzer to create a tree-like intermediate representation that depicts the
grammatical structure of the token stream.
• A typical representation is a syntax tree in which each interior node
represents an operation and the children of the node represent the
arguments of the operation
token is
id1 += *id3id2 60
Syntax Analysis Example
Pay = Base + Rate* 60
 The seven tokens are grouped into a parse tree
Assignment stmt
identifier
pay
= expression
expression expression
+
identifier
base
Rate*60
Semantic Analysis: Third phase of the compiler
The semantics of a program are its meaningas opposed to syntax or structure
The semantics consist of:
Runtime semantics
behavior of program at runtime
Static semantics–checked by the compile
Static semantics include:
Static semantics–checked by the compile
Declarations of variables and constants before use
Calling functions that exist (predefined in a library or defined by the user)
Passing parameters properly
Type checking.
Annotates the syntax tree with type information
Semantic Analysis: Third phase of the compiler
The semantics of a program are its meaningas
opposed to syntax or structure
The semantics consist of:
Runtime semantics
behavior of program at runtime
Static semantics–checked by the compile
Static semantics include:
Static semantics–checked by the compile
Declarations of variables and constants before
use
Calling functions that exist (predefined in a
library or defined by the user)
Passing parameters properly
Type checking.
Annotates the syntax tree with type information
Intermediate Code Generation: three-address code
After syntax and semantic analysis of the source program, many compilers
generate an explicit low-level or machine-like intermediate representation
(a program for an abstract machine). This intermediate representation
should have two important properties:
– it should be easy to produce and
– it should be easy to translate into the target machine.
The considered intermediate form called three-address code, which consists of
a sequence of assembly-like instructions with three operands per
instruction. Each operand can act like a register.
Code Optimization: to generate better target
code
• The machine-independent code-optimization phase attempts to improve the
intermediate code so that better target code will result.
• Usually better means:
– faster, shorter code, or target code that consumes less power.
• The optimizer can deduce that the conversion of 60 from integer to floating
point can be done once and for all at compile time, so the int to float
operation can be eliminated by replacing the integer 60 by the floating-point
number 60.0. Moreover, t3 is used only once
• There are simple optimizations that significantly improve the running time
of the target program without slowing down compilation too much.
Code Generation: takes as input an intermediate representation
of the source program and maps it into the target language
• If the target language is machine, code, registers or memory locations
are selected for each of the variables used by the program.
• Then, the intermediate instructions are translated into sequences of
machine instructions that perform the same task.
• A crucial aspect of code generation is the judicious assignment of
registers to hold variables.
Translation of an assignment
statement
Ad

More Related Content

What's hot (20)

Loop invariant computation
Loop invariant computationLoop invariant computation
Loop invariant computation
ReachLocal Services India
 
Phases of compiler
Phases of compilerPhases of compiler
Phases of compiler
Karan Deopura
 
Basic Computer Organization and Design
Basic Computer Organization and DesignBasic Computer Organization and Design
Basic Computer Organization and Design
Kamal Acharya
 
Quadratic probing
Quadratic probingQuadratic probing
Quadratic probing
rajshreemuthiah
 
Real time operating system
Real time operating systemReal time operating system
Real time operating system
keshav khanal
 
Compilers
CompilersCompilers
Compilers
jayashri kolekar
 
Compilers and interpreters
Compilers and interpretersCompilers and interpreters
Compilers and interpreters
RAJU KATHI
 
phases of compiler-analysis phase
phases of compiler-analysis phasephases of compiler-analysis phase
phases of compiler-analysis phase
Suyash Srivastava
 
Applet Architecture - Introducing Java Applets
Applet Architecture - Introducing Java AppletsApplet Architecture - Introducing Java Applets
Applet Architecture - Introducing Java Applets
amitksaha
 
Java – lexical issues
Java – lexical issuesJava – lexical issues
Java – lexical issues
Pradeep Kumar TS
 
Symbol table in compiler Design
Symbol table in compiler DesignSymbol table in compiler Design
Symbol table in compiler Design
Kuppusamy P
 
Macro-processor
Macro-processorMacro-processor
Macro-processor
Temesgen Molla
 
Cache memory
Cache  memoryCache  memory
Cache memory
Prasenjit Dey
 
The Phases of a Compiler
The Phases of a CompilerThe Phases of a Compiler
The Phases of a Compiler
Radhika Talaviya
 
Parsing in Compiler Design
Parsing in Compiler DesignParsing in Compiler Design
Parsing in Compiler Design
Akhil Kaushik
 
debugging - system software
debugging - system softwaredebugging - system software
debugging - system software
Vicky Shan
 
04 cache memory
04 cache memory04 cache memory
04 cache memory
Sher Shah Merkhel
 
Unit 3
Unit 3Unit 3
Unit 3
pm_ghate
 
Cache Memory
Cache MemoryCache Memory
Cache Memory
sathish sak
 
Instruction Level Parallelism (ILP) Limitations
Instruction Level Parallelism (ILP) LimitationsInstruction Level Parallelism (ILP) Limitations
Instruction Level Parallelism (ILP) Limitations
Jose Pinilla
 
Basic Computer Organization and Design
Basic Computer Organization and DesignBasic Computer Organization and Design
Basic Computer Organization and Design
Kamal Acharya
 
Real time operating system
Real time operating systemReal time operating system
Real time operating system
keshav khanal
 
Compilers and interpreters
Compilers and interpretersCompilers and interpreters
Compilers and interpreters
RAJU KATHI
 
phases of compiler-analysis phase
phases of compiler-analysis phasephases of compiler-analysis phase
phases of compiler-analysis phase
Suyash Srivastava
 
Applet Architecture - Introducing Java Applets
Applet Architecture - Introducing Java AppletsApplet Architecture - Introducing Java Applets
Applet Architecture - Introducing Java Applets
amitksaha
 
Symbol table in compiler Design
Symbol table in compiler DesignSymbol table in compiler Design
Symbol table in compiler Design
Kuppusamy P
 
Parsing in Compiler Design
Parsing in Compiler DesignParsing in Compiler Design
Parsing in Compiler Design
Akhil Kaushik
 
debugging - system software
debugging - system softwaredebugging - system software
debugging - system software
Vicky Shan
 
Instruction Level Parallelism (ILP) Limitations
Instruction Level Parallelism (ILP) LimitationsInstruction Level Parallelism (ILP) Limitations
Instruction Level Parallelism (ILP) Limitations
Jose Pinilla
 

Viewers also liked (20)

Phases of Compiler
Phases of CompilerPhases of Compiler
Phases of Compiler
Tanzeela_Hussain
 
Compiler Design
Compiler DesignCompiler Design
Compiler Design
Mir Majid
 
Compiler Chapter 1
Compiler Chapter 1Compiler Chapter 1
Compiler Chapter 1
Huawei Technologies
 
Different phases of a compiler
Different phases of a compilerDifferent phases of a compiler
Different phases of a compiler
Sumit Sinha
 
Lexical analyzer
Lexical analyzerLexical analyzer
Lexical analyzer
Ashwini Sonawane
 
Lexical analyzer
Lexical analyzerLexical analyzer
Lexical analyzer
kiran acharya
 
Compiler Construction
Compiler ConstructionCompiler Construction
Compiler Construction
Army Public School and College -Faisal
 
Compiler Design - Introduction to Compiler
Compiler Design - Introduction to CompilerCompiler Design - Introduction to Compiler
Compiler Design - Introduction to Compiler
Iffat Anjum
 
What is Compiler?
What is Compiler?What is Compiler?
What is Compiler?
Huawei Technologies
 
Compiler vs Interpreter-Compiler design ppt.
Compiler vs Interpreter-Compiler design ppt.Compiler vs Interpreter-Compiler design ppt.
Compiler vs Interpreter-Compiler design ppt.
Md Hossen
 
Compilers
CompilersCompilers
Compilers
Bense Tony
 
Lex (lexical analyzer)
Lex (lexical analyzer)Lex (lexical analyzer)
Lex (lexical analyzer)
Sami Said
 
Compiler Design(NANTHU NOTES)
Compiler Design(NANTHU NOTES)Compiler Design(NANTHU NOTES)
Compiler Design(NANTHU NOTES)
guest251d9a
 
Compiler Design Basics
Compiler Design BasicsCompiler Design Basics
Compiler Design Basics
Akhil Kaushik
 
Code generation
Code generationCode generation
Code generation
Aparna Nayak
 
The analysis synthesis model of compilation
The analysis synthesis model of compilationThe analysis synthesis model of compilation
The analysis synthesis model of compilation
Huawei Technologies
 
Role-of-lexical-analysis
Role-of-lexical-analysisRole-of-lexical-analysis
Role-of-lexical-analysis
Dattatray Gandhmal
 
Phases of a Compiler
Phases of a CompilerPhases of a Compiler
Phases of a Compiler
University of Saskatchewan
 
compiler and their types
compiler and their typescompiler and their types
compiler and their types
patchamounika7
 
About Tokens and Lexemes
About Tokens and LexemesAbout Tokens and Lexemes
About Tokens and Lexemes
Ben Scholzen
 
Ad

Similar to what is compiler and five phases of compiler (20)

Lecture 2.1 - Phase of a Commmmpiler.pdf
Lecture 2.1 - Phase of a Commmmpiler.pdfLecture 2.1 - Phase of a Commmmpiler.pdf
Lecture 2.1 - Phase of a Commmmpiler.pdf
AbuZahed5
 
Chapter 1.pptx
Chapter 1.pptxChapter 1.pptx
Chapter 1.pptx
NesredinTeshome1
 
Concept of compiler in details
Concept of compiler in detailsConcept of compiler in details
Concept of compiler in details
kazi_aihtesham
 
Compiler Construction
Compiler ConstructionCompiler Construction
Compiler Construction
Sarmad Ali
 
Compiler Construction-2 for bs computer science.pptx
Compiler Construction-2 for bs computer science.pptxCompiler Construction-2 for bs computer science.pptx
Compiler Construction-2 for bs computer science.pptx
DailyReminder1
 
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
 
1._Introduction_.pptx
1._Introduction_.pptx1._Introduction_.pptx
1._Introduction_.pptx
Anbarasan Radhakrishnan R
 
Chapter-1.pptx compiler Design Course Material
Chapter-1.pptx compiler Design Course MaterialChapter-1.pptx compiler Design Course Material
Chapter-1.pptx compiler Design Course Material
gadisaAdamu
 
A basic introduction to compiler design.ppt
A basic introduction to compiler design.pptA basic introduction to compiler design.ppt
A basic introduction to compiler design.ppt
pandaashirbad9
 
A basic introduction to compiler design.ppt
A basic introduction to compiler design.pptA basic introduction to compiler design.ppt
A basic introduction to compiler design.ppt
pandaashirbad9
 
COMPILER CONSTRUCTION KU 1.pptx
COMPILER CONSTRUCTION KU 1.pptxCOMPILER CONSTRUCTION KU 1.pptx
COMPILER CONSTRUCTION KU 1.pptx
Rossy719186
 
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
 
Compier Design_Unit I.ppt
Compier Design_Unit I.pptCompier Design_Unit I.ppt
Compier Design_Unit I.ppt
sivaganesh293
 
Compier Design_Unit I.ppt
Compier Design_Unit I.pptCompier Design_Unit I.ppt
Compier Design_Unit I.ppt
sivaganesh293
 
Unit 1.pptx
Unit 1.pptxUnit 1.pptx
Unit 1.pptx
NISHASOMSCS113
 
System software module 4 presentation file
System software module 4 presentation fileSystem software module 4 presentation file
System software module 4 presentation file
jithujithin657
 
Compiler Design Material
Compiler Design MaterialCompiler Design Material
Compiler Design Material
Dr. C.V. Suresh Babu
 
Introduction to compiler
Introduction to compilerIntroduction to compiler
Introduction to compiler
Abha Damani
 
2-Design Issues, Patterns, Lexemes, Tokens-28-04-2023.docx
2-Design Issues, Patterns, Lexemes, Tokens-28-04-2023.docx2-Design Issues, Patterns, Lexemes, Tokens-28-04-2023.docx
2-Design Issues, Patterns, Lexemes, Tokens-28-04-2023.docx
venkatapranaykumarGa
 
Introduction to Compilers
Introduction to CompilersIntroduction to Compilers
Introduction to Compilers
vijaya603274
 
Lecture 2.1 - Phase of a Commmmpiler.pdf
Lecture 2.1 - Phase of a Commmmpiler.pdfLecture 2.1 - Phase of a Commmmpiler.pdf
Lecture 2.1 - Phase of a Commmmpiler.pdf
AbuZahed5
 
Concept of compiler in details
Concept of compiler in detailsConcept of compiler in details
Concept of compiler in details
kazi_aihtesham
 
Compiler Construction
Compiler ConstructionCompiler Construction
Compiler Construction
Sarmad Ali
 
Compiler Construction-2 for bs computer science.pptx
Compiler Construction-2 for bs computer science.pptxCompiler Construction-2 for bs computer science.pptx
Compiler Construction-2 for bs computer science.pptx
DailyReminder1
 
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
 
Chapter-1.pptx compiler Design Course Material
Chapter-1.pptx compiler Design Course MaterialChapter-1.pptx compiler Design Course Material
Chapter-1.pptx compiler Design Course Material
gadisaAdamu
 
A basic introduction to compiler design.ppt
A basic introduction to compiler design.pptA basic introduction to compiler design.ppt
A basic introduction to compiler design.ppt
pandaashirbad9
 
A basic introduction to compiler design.ppt
A basic introduction to compiler design.pptA basic introduction to compiler design.ppt
A basic introduction to compiler design.ppt
pandaashirbad9
 
COMPILER CONSTRUCTION KU 1.pptx
COMPILER CONSTRUCTION KU 1.pptxCOMPILER CONSTRUCTION KU 1.pptx
COMPILER CONSTRUCTION KU 1.pptx
Rossy719186
 
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
 
Compier Design_Unit I.ppt
Compier Design_Unit I.pptCompier Design_Unit I.ppt
Compier Design_Unit I.ppt
sivaganesh293
 
Compier Design_Unit I.ppt
Compier Design_Unit I.pptCompier Design_Unit I.ppt
Compier Design_Unit I.ppt
sivaganesh293
 
System software module 4 presentation file
System software module 4 presentation fileSystem software module 4 presentation file
System software module 4 presentation file
jithujithin657
 
Introduction to compiler
Introduction to compilerIntroduction to compiler
Introduction to compiler
Abha Damani
 
2-Design Issues, Patterns, Lexemes, Tokens-28-04-2023.docx
2-Design Issues, Patterns, Lexemes, Tokens-28-04-2023.docx2-Design Issues, Patterns, Lexemes, Tokens-28-04-2023.docx
2-Design Issues, Patterns, Lexemes, Tokens-28-04-2023.docx
venkatapranaykumarGa
 
Introduction to Compilers
Introduction to CompilersIntroduction to Compilers
Introduction to Compilers
vijaya603274
 
Ad

Recently uploaded (20)

Odoo Inventory Rules and Routes v17 - Odoo Slides
Odoo Inventory Rules and Routes v17 - Odoo SlidesOdoo Inventory Rules and Routes v17 - Odoo Slides
Odoo Inventory Rules and Routes v17 - Odoo Slides
Celine George
 
Michelle Rumley & Mairéad Mooney, Boole Library, University College Cork. Tra...
Michelle Rumley & Mairéad Mooney, Boole Library, University College Cork. Tra...Michelle Rumley & Mairéad Mooney, Boole Library, University College Cork. Tra...
Michelle Rumley & Mairéad Mooney, Boole Library, University College Cork. Tra...
Library Association of Ireland
 
Quality Contril Analysis of Containers.pdf
Quality Contril Analysis of Containers.pdfQuality Contril Analysis of Containers.pdf
Quality Contril Analysis of Containers.pdf
Dr. Bindiya Chauhan
 
Metamorphosis: Life's Transformative Journey
Metamorphosis: Life's Transformative JourneyMetamorphosis: Life's Transformative Journey
Metamorphosis: Life's Transformative Journey
Arshad Shaikh
 
Presentation on Tourism Product Development By Md Shaifullar Rabbi
Presentation on Tourism Product Development By Md Shaifullar RabbiPresentation on Tourism Product Development By Md Shaifullar Rabbi
Presentation on Tourism Product Development By Md Shaifullar Rabbi
Md Shaifullar Rabbi
 
apa-style-referencing-visual-guide-2025.pdf
apa-style-referencing-visual-guide-2025.pdfapa-style-referencing-visual-guide-2025.pdf
apa-style-referencing-visual-guide-2025.pdf
Ishika Ghosh
 
Presentation of the MIPLM subject matter expert Erdem Kaya
Presentation of the MIPLM subject matter expert Erdem KayaPresentation of the MIPLM subject matter expert Erdem Kaya
Presentation of the MIPLM subject matter expert Erdem Kaya
MIPLM
 
Operations Management (Dr. Abdulfatah Salem).pdf
Operations Management (Dr. Abdulfatah Salem).pdfOperations Management (Dr. Abdulfatah Salem).pdf
Operations Management (Dr. Abdulfatah Salem).pdf
Arab Academy for Science, Technology and Maritime Transport
 
Introduction to Vibe Coding and Vibe Engineering
Introduction to Vibe Coding and Vibe EngineeringIntroduction to Vibe Coding and Vibe Engineering
Introduction to Vibe Coding and Vibe Engineering
Damian T. Gordon
 
SCI BIZ TECH QUIZ (OPEN) PRELIMS XTASY 2025.pptx
SCI BIZ TECH QUIZ (OPEN) PRELIMS XTASY 2025.pptxSCI BIZ TECH QUIZ (OPEN) PRELIMS XTASY 2025.pptx
SCI BIZ TECH QUIZ (OPEN) PRELIMS XTASY 2025.pptx
Ronisha Das
 
YSPH VMOC Special Report - Measles Outbreak Southwest US 5-3-2025.pptx
YSPH VMOC Special Report - Measles Outbreak  Southwest US 5-3-2025.pptxYSPH VMOC Special Report - Measles Outbreak  Southwest US 5-3-2025.pptx
YSPH VMOC Special Report - Measles Outbreak Southwest US 5-3-2025.pptx
Yale School of Public Health - The Virtual Medical Operations Center (VMOC)
 
UNIT 3 NATIONAL HEALTH PROGRAMMEE. SOCIAL AND PREVENTIVE PHARMACY
UNIT 3 NATIONAL HEALTH PROGRAMMEE. SOCIAL AND PREVENTIVE PHARMACYUNIT 3 NATIONAL HEALTH PROGRAMMEE. SOCIAL AND PREVENTIVE PHARMACY
UNIT 3 NATIONAL HEALTH PROGRAMMEE. SOCIAL AND PREVENTIVE PHARMACY
DR.PRISCILLA MARY J
 
Anti-Depressants pharmacology 1slide.pptx
Anti-Depressants pharmacology 1slide.pptxAnti-Depressants pharmacology 1slide.pptx
Anti-Depressants pharmacology 1slide.pptx
Mayuri Chavan
 
pulse ppt.pptx Types of pulse , characteristics of pulse , Alteration of pulse
pulse  ppt.pptx Types of pulse , characteristics of pulse , Alteration of pulsepulse  ppt.pptx Types of pulse , characteristics of pulse , Alteration of pulse
pulse ppt.pptx Types of pulse , characteristics of pulse , Alteration of pulse
sushreesangita003
 
Stein, Hunt, Green letter to Congress April 2025
Stein, Hunt, Green letter to Congress April 2025Stein, Hunt, Green letter to Congress April 2025
Stein, Hunt, Green letter to Congress April 2025
Mebane Rash
 
How to track Cost and Revenue using Analytic Accounts in odoo Accounting, App...
How to track Cost and Revenue using Analytic Accounts in odoo Accounting, App...How to track Cost and Revenue using Analytic Accounts in odoo Accounting, App...
How to track Cost and Revenue using Analytic Accounts in odoo Accounting, App...
Celine George
 
Marie Boran Special Collections Librarian Hardiman Library, University of Gal...
Marie Boran Special Collections Librarian Hardiman Library, University of Gal...Marie Boran Special Collections Librarian Hardiman Library, University of Gal...
Marie Boran Special Collections Librarian Hardiman Library, University of Gal...
Library Association of Ireland
 
Exploring-Substances-Acidic-Basic-and-Neutral.pdf
Exploring-Substances-Acidic-Basic-and-Neutral.pdfExploring-Substances-Acidic-Basic-and-Neutral.pdf
Exploring-Substances-Acidic-Basic-and-Neutral.pdf
Sandeep Swamy
 
One Hot encoding a revolution in Machine learning
One Hot encoding a revolution in Machine learningOne Hot encoding a revolution in Machine learning
One Hot encoding a revolution in Machine learning
momer9505
 
How to Manage Opening & Closing Controls in Odoo 17 POS
How to Manage Opening & Closing Controls in Odoo 17 POSHow to Manage Opening & Closing Controls in Odoo 17 POS
How to Manage Opening & Closing Controls in Odoo 17 POS
Celine George
 
Odoo Inventory Rules and Routes v17 - Odoo Slides
Odoo Inventory Rules and Routes v17 - Odoo SlidesOdoo Inventory Rules and Routes v17 - Odoo Slides
Odoo Inventory Rules and Routes v17 - Odoo Slides
Celine George
 
Michelle Rumley & Mairéad Mooney, Boole Library, University College Cork. Tra...
Michelle Rumley & Mairéad Mooney, Boole Library, University College Cork. Tra...Michelle Rumley & Mairéad Mooney, Boole Library, University College Cork. Tra...
Michelle Rumley & Mairéad Mooney, Boole Library, University College Cork. Tra...
Library Association of Ireland
 
Quality Contril Analysis of Containers.pdf
Quality Contril Analysis of Containers.pdfQuality Contril Analysis of Containers.pdf
Quality Contril Analysis of Containers.pdf
Dr. Bindiya Chauhan
 
Metamorphosis: Life's Transformative Journey
Metamorphosis: Life's Transformative JourneyMetamorphosis: Life's Transformative Journey
Metamorphosis: Life's Transformative Journey
Arshad Shaikh
 
Presentation on Tourism Product Development By Md Shaifullar Rabbi
Presentation on Tourism Product Development By Md Shaifullar RabbiPresentation on Tourism Product Development By Md Shaifullar Rabbi
Presentation on Tourism Product Development By Md Shaifullar Rabbi
Md Shaifullar Rabbi
 
apa-style-referencing-visual-guide-2025.pdf
apa-style-referencing-visual-guide-2025.pdfapa-style-referencing-visual-guide-2025.pdf
apa-style-referencing-visual-guide-2025.pdf
Ishika Ghosh
 
Presentation of the MIPLM subject matter expert Erdem Kaya
Presentation of the MIPLM subject matter expert Erdem KayaPresentation of the MIPLM subject matter expert Erdem Kaya
Presentation of the MIPLM subject matter expert Erdem Kaya
MIPLM
 
Introduction to Vibe Coding and Vibe Engineering
Introduction to Vibe Coding and Vibe EngineeringIntroduction to Vibe Coding and Vibe Engineering
Introduction to Vibe Coding and Vibe Engineering
Damian T. Gordon
 
SCI BIZ TECH QUIZ (OPEN) PRELIMS XTASY 2025.pptx
SCI BIZ TECH QUIZ (OPEN) PRELIMS XTASY 2025.pptxSCI BIZ TECH QUIZ (OPEN) PRELIMS XTASY 2025.pptx
SCI BIZ TECH QUIZ (OPEN) PRELIMS XTASY 2025.pptx
Ronisha Das
 
UNIT 3 NATIONAL HEALTH PROGRAMMEE. SOCIAL AND PREVENTIVE PHARMACY
UNIT 3 NATIONAL HEALTH PROGRAMMEE. SOCIAL AND PREVENTIVE PHARMACYUNIT 3 NATIONAL HEALTH PROGRAMMEE. SOCIAL AND PREVENTIVE PHARMACY
UNIT 3 NATIONAL HEALTH PROGRAMMEE. SOCIAL AND PREVENTIVE PHARMACY
DR.PRISCILLA MARY J
 
Anti-Depressants pharmacology 1slide.pptx
Anti-Depressants pharmacology 1slide.pptxAnti-Depressants pharmacology 1slide.pptx
Anti-Depressants pharmacology 1slide.pptx
Mayuri Chavan
 
pulse ppt.pptx Types of pulse , characteristics of pulse , Alteration of pulse
pulse  ppt.pptx Types of pulse , characteristics of pulse , Alteration of pulsepulse  ppt.pptx Types of pulse , characteristics of pulse , Alteration of pulse
pulse ppt.pptx Types of pulse , characteristics of pulse , Alteration of pulse
sushreesangita003
 
Stein, Hunt, Green letter to Congress April 2025
Stein, Hunt, Green letter to Congress April 2025Stein, Hunt, Green letter to Congress April 2025
Stein, Hunt, Green letter to Congress April 2025
Mebane Rash
 
How to track Cost and Revenue using Analytic Accounts in odoo Accounting, App...
How to track Cost and Revenue using Analytic Accounts in odoo Accounting, App...How to track Cost and Revenue using Analytic Accounts in odoo Accounting, App...
How to track Cost and Revenue using Analytic Accounts in odoo Accounting, App...
Celine George
 
Marie Boran Special Collections Librarian Hardiman Library, University of Gal...
Marie Boran Special Collections Librarian Hardiman Library, University of Gal...Marie Boran Special Collections Librarian Hardiman Library, University of Gal...
Marie Boran Special Collections Librarian Hardiman Library, University of Gal...
Library Association of Ireland
 
Exploring-Substances-Acidic-Basic-and-Neutral.pdf
Exploring-Substances-Acidic-Basic-and-Neutral.pdfExploring-Substances-Acidic-Basic-and-Neutral.pdf
Exploring-Substances-Acidic-Basic-and-Neutral.pdf
Sandeep Swamy
 
One Hot encoding a revolution in Machine learning
One Hot encoding a revolution in Machine learningOne Hot encoding a revolution in Machine learning
One Hot encoding a revolution in Machine learning
momer9505
 
How to Manage Opening & Closing Controls in Odoo 17 POS
How to Manage Opening & Closing Controls in Odoo 17 POSHow to Manage Opening & Closing Controls in Odoo 17 POS
How to Manage Opening & Closing Controls in Odoo 17 POS
Celine George
 

what is compiler and five phases of compiler

  • 2. no compiler Not Getting (-.-) //By:Adil Code
  • 3. Agenda of today presentation • What is Compiler • Brief History of compiler • Task of compiler • Phases of compiler source code Compiler Machine code
  • 4. What is Compiler • Is a program that translates one language to another • Takes as input a source program typically written in a high-level language • Produces an equivalent target program typically in assembly or machine language • Reports error messages as part of the translation process
  • 5. Brief history of Compiler • The term “compiler” was coined in the early 1950s by Grace Murray Hopper • The first compiler of the high-level language FORTRAN was developed between 1954 and 1957 at IBM • The first FORTRAN compiler took 18 person- years to create
  • 6. Compiler tasks A compiler must perform two tasks:  analysis of source program: The analysis part breaks up the source program into constituent pieces and imposes a grammatical structure on them. It then uses this structure to create an intermediate representation of the source program.  synthesis of its corresponding program: constructs the desired target program from the intermediate representation and the information in the symbol table. The analysis part is often called the front end of the compiler; the synthesis part is the back end.
  • 7. Compiler phases • Lexical Analyzer • Syntax Analyzer • Semantic Analyzer • Intermediate Code Generator • Code Optimizer • Code Generation
  • 8. Lexical Analysis (scanner): The first phase of a compiler • Lexical analyzer reads the stream of characters making up the source program and groups the characters into meaningful sequences called lexeme • For each lexeme, the lexical analyzer produces a token of the form that it passes on to the subsequent phase, syntax analysis(token-name, attribute- value) • Token-name: an abstract symbol is used during syntax analysis, an • attribute-value: points to an entry in the symbol table for this token. • Tokensrepresent basic program entities such as: Identifiers, Literals, Reserved Words, Operators, Delimiters, etc.
  • 9. Example: 1.”position” is a lexeme mapped into a token (id, 1), where id is an abstract symbol standing for identifier and 1 points to the symbol table entry for position. The symbol-table entry for an identifier holds information about the identifier, such as its name and type. 2. = is a lexeme that is mapped into the token (=). Since this token needs no attribute-value, we have omitted the second component. For notational convenience, the lexeme itself is used as the name of the abstract symbol. 3. “initial” is a lexeme that is mapped into the token (id, 2), where 2 points to the symbol- table entry for initial. 4. + is a lexeme that is mapped into the token (+). 5. “rate” is a lexeme mapped into the token (id, 3), where 3 points to the symbol-table entry for rate. 6. * is a lexeme that is mapped into the token (*) . 7. 60 is a lexeme that is mapped into the token (60) Blanks separating the lexemes would be discarded by the lexical analyzer. position = initial + 60 * rate Table id 1 id 2 id 3 token lexem
  • 10. Syntax Analysis (parser) : The second phase of the compiler • The parser uses the first components of the tokens produced by the lexical analyzer to create a tree-like intermediate representation that depicts the grammatical structure of the token stream. • A typical representation is a syntax tree in which each interior node represents an operation and the children of the node represent the arguments of the operation token is id1 += *id3id2 60
  • 11. Syntax Analysis Example Pay = Base + Rate* 60  The seven tokens are grouped into a parse tree Assignment stmt identifier pay = expression expression expression + identifier base Rate*60
  • 12. Semantic Analysis: Third phase of the compiler The semantics of a program are its meaningas opposed to syntax or structure The semantics consist of: Runtime semantics behavior of program at runtime Static semantics–checked by the compile Static semantics include: Static semantics–checked by the compile Declarations of variables and constants before use Calling functions that exist (predefined in a library or defined by the user) Passing parameters properly Type checking. Annotates the syntax tree with type information
  • 13. Semantic Analysis: Third phase of the compiler The semantics of a program are its meaningas opposed to syntax or structure The semantics consist of: Runtime semantics behavior of program at runtime Static semantics–checked by the compile Static semantics include: Static semantics–checked by the compile Declarations of variables and constants before use Calling functions that exist (predefined in a library or defined by the user) Passing parameters properly Type checking. Annotates the syntax tree with type information
  • 14. Intermediate Code Generation: three-address code After syntax and semantic analysis of the source program, many compilers generate an explicit low-level or machine-like intermediate representation (a program for an abstract machine). This intermediate representation should have two important properties: – it should be easy to produce and – it should be easy to translate into the target machine. The considered intermediate form called three-address code, which consists of a sequence of assembly-like instructions with three operands per instruction. Each operand can act like a register.
  • 15. Code Optimization: to generate better target code • The machine-independent code-optimization phase attempts to improve the intermediate code so that better target code will result. • Usually better means: – faster, shorter code, or target code that consumes less power. • The optimizer can deduce that the conversion of 60 from integer to floating point can be done once and for all at compile time, so the int to float operation can be eliminated by replacing the integer 60 by the floating-point number 60.0. Moreover, t3 is used only once • There are simple optimizations that significantly improve the running time of the target program without slowing down compilation too much.
  • 16. Code Generation: takes as input an intermediate representation of the source program and maps it into the target language • If the target language is machine, code, registers or memory locations are selected for each of the variables used by the program. • Then, the intermediate instructions are translated into sequences of machine instructions that perform the same task. • A crucial aspect of code generation is the judicious assignment of registers to hold variables.
  • 17. Translation of an assignment statement