SlideShare a Scribd company logo
What is compiler?
 Compiler is a program which takes one language as input and translate
it into an equivalent another language.
 Compiler is divided into two parts: Analysis and Synthesis
 Basic model of compiler can be represented as follows:
 Conceptually, a compiler operates into phases, each of which
transform the source program from one representation to another.
 Each phase takes input from its previous stage, has its own representation of
source program, and feeds its output to the next phase of the compiler.
 The compiler has six phases called as lexical analyzer, syntax analyzer,
semantic analyzer, intermediate code generator, code optimizer and
code generator.
 Two other activities, symbol-table management and error handling,
are interacting with the six phases of compiler.
Phases of compiler
Phases of compiler
 To support the phases of compiler, symbol table is maintained. The
task of symbol table is to store identifiers used in program.
 Basically symbol table is a data structure used to store the
information about identifiers.
 The symbol table allows us to find the record for each identifier
quickly and to store or retrieve data from that record efficiently.
 While doing the semantic analysis and intermediate code
generation, we need to know what type of identifiers are.
 During code generation typically information about how much
storage is allocated to identifier is seen.
Symbol-table management
Error detection and reporting
 In compilation, each phase detects error. These errors must be reported
to error handler whose task is to handle the error so that the compilation
can proceed.
 Normally, the errors are reported in the form of message.
 Large number of error can be detected in syntax analysis phase. Such
error are known as syntax error.
 During semantic analysis, type mismatch kind of error is usually
detected.
Lexical analysis
 The lexical analysis is also known as scanning.
 It is the phase of compilation in which the complete source code is
scanned and source program is broken up into group of strings called
token.
 A token is sequence of character having a collective meaning.
 E.g. Total = count + rate
 After lexical analysis, the statement is broken up into series of tokens as
follows:
identifier total, assignment operator, identifier count, plus sign, identifier
rate
syntax analysis
 The syntax analysis is also known as parsing.
 In this phase token generated by lexical analysis are grouped together
to form a hierarchical structure known as syntax tree.
semantic analysis
 Once syntax is checked in the syntax analyzer phase the next phase i.e.
semantic analyzer determines the meaning of the source string.
 For example meaning of source string means matching parenthesis,
matching if…else statement, performing arithmetic operation of
expression that are type compatible or checking operation scope.
Intermediate code generation
 The intermediate code is a kind of code which is easy to generate and
this code can be easily converted to target code.
 This code is in variety of form such as three address code, quadruple,
triple, posix.
 For example, total = count + rate * 10
 Intermediate code using three address code method is
t1 := int_to_float(10)
t2 := rate * t1
t3 := count + t2
total := t3
Code optimization
 The code optimization phase attempt to improve the intermediate
code
 This is necessary to have a faster executing code or less consumption of
memory
 Thus, by optimizing the code the overall running time of the target
program can be improved.
Code generation
 In this phase, target code is generated.
 The intermediate code instructions are translated into sequence of
machine instruction
 For example, total = count + rate * 10
 Target code will be
MOV rate, R1
MUL #10.0, R1
MOV count, R2
ADD R2, R1
MOV R1, total
PPT
PPT

More Related Content

Similar to PPT

3.2
3.23.2
what is compiler and five phases of compiler
what is compiler and five phases of compilerwhat is compiler and five phases of compiler
what is compiler and five phases of compiler
adilmehmood93
 
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
 
System software module 4 presentation file
System software module 4 presentation fileSystem software module 4 presentation file
System software module 4 presentation file
jithujithin657
 
The Phases of a Compiler
The Phases of a CompilerThe Phases of a Compiler
The Phases of a Compiler
Radhika Talaviya
 
COMPILER CONSTRUCTION KU 1.pptx
COMPILER CONSTRUCTION KU 1.pptxCOMPILER CONSTRUCTION KU 1.pptx
COMPILER CONSTRUCTION KU 1.pptx
Rossy719186
 
Compiler design
Compiler designCompiler design
Compiler design
nazmul hoque
 
Introduction to Compilers
Introduction to CompilersIntroduction to Compilers
Introduction to Compilers
vijaya603274
 
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
 
1588147798Begining_ABUAD1.pdf
1588147798Begining_ABUAD1.pdf1588147798Begining_ABUAD1.pdf
1588147798Begining_ABUAD1.pdf
SemsemSameer1
 
Chapter#01 cc
Chapter#01 ccChapter#01 cc
Chapter#01 cc
abdulbaki3
 
Compiler Construction introduction
Compiler Construction introductionCompiler Construction introduction
Compiler Construction introduction
Rana Ehtisham Ul Haq
 
Compiler Construction
Compiler ConstructionCompiler Construction
Compiler Construction
Sarmad Ali
 
phases of compiler-analysis phase
phases of compiler-analysis phasephases of compiler-analysis phase
phases of compiler-analysis phase
Suyash Srivastava
 
Compiler_Lecture1.pdf
Compiler_Lecture1.pdfCompiler_Lecture1.pdf
Compiler_Lecture1.pdf
AkarTaher
 
Compiler Design
Compiler DesignCompiler Design
Compiler Design
Dr. Jaydeep Patil
 
Ss ui lecture 2
Ss ui lecture 2Ss ui lecture 2
Ss ui lecture 2
Avinash Kapse
 
SSD Mod 2 -18CS61_Notes.pdf
SSD Mod 2 -18CS61_Notes.pdfSSD Mod 2 -18CS61_Notes.pdf
SSD Mod 2 -18CS61_Notes.pdf
JacobDragonette
 
Compiler
Compiler Compiler
Compiler
Md. Sumon Fakir
 

Similar to PPT (20)

3.2
3.23.2
3.2
 
what is compiler and five phases of compiler
what is compiler and five phases of compilerwhat is compiler and five phases of compiler
what is compiler and five phases of compiler
 
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
 
1._Introduction_.pptx
1._Introduction_.pptx1._Introduction_.pptx
1._Introduction_.pptx
 
System software module 4 presentation file
System software module 4 presentation fileSystem software module 4 presentation file
System software module 4 presentation file
 
The Phases of a Compiler
The Phases of a CompilerThe Phases of a Compiler
The Phases of a Compiler
 
COMPILER CONSTRUCTION KU 1.pptx
COMPILER CONSTRUCTION KU 1.pptxCOMPILER CONSTRUCTION KU 1.pptx
COMPILER CONSTRUCTION KU 1.pptx
 
Compiler design
Compiler designCompiler design
Compiler design
 
Introduction to Compilers
Introduction to CompilersIntroduction to Compilers
Introduction to Compilers
 
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
 
1588147798Begining_ABUAD1.pdf
1588147798Begining_ABUAD1.pdf1588147798Begining_ABUAD1.pdf
1588147798Begining_ABUAD1.pdf
 
Chapter#01 cc
Chapter#01 ccChapter#01 cc
Chapter#01 cc
 
Compiler Construction introduction
Compiler Construction introductionCompiler Construction introduction
Compiler Construction introduction
 
Compiler Construction
Compiler ConstructionCompiler Construction
Compiler Construction
 
phases of compiler-analysis phase
phases of compiler-analysis phasephases of compiler-analysis phase
phases of compiler-analysis phase
 
Compiler_Lecture1.pdf
Compiler_Lecture1.pdfCompiler_Lecture1.pdf
Compiler_Lecture1.pdf
 
Compiler Design
Compiler DesignCompiler Design
Compiler Design
 
Ss ui lecture 2
Ss ui lecture 2Ss ui lecture 2
Ss ui lecture 2
 
SSD Mod 2 -18CS61_Notes.pdf
SSD Mod 2 -18CS61_Notes.pdfSSD Mod 2 -18CS61_Notes.pdf
SSD Mod 2 -18CS61_Notes.pdf
 
Compiler
Compiler Compiler
Compiler
 

Recently uploaded

Software Engineering and Project Management - Introduction, Modeling Concepts...
Software Engineering and Project Management - Introduction, Modeling Concepts...Software Engineering and Project Management - Introduction, Modeling Concepts...
Software Engineering and Project Management - Introduction, Modeling Concepts...
Prakhyath Rai
 
一比一原版(uofo毕业证书)美国俄勒冈大学毕业证如何办理
一比一原版(uofo毕业证书)美国俄勒冈大学毕业证如何办理一比一原版(uofo毕业证书)美国俄勒冈大学毕业证如何办理
一比一原版(uofo毕业证书)美国俄勒冈大学毕业证如何办理
upoux
 
IEEE Aerospace and Electronic Systems Society as a Graduate Student Member
IEEE Aerospace and Electronic Systems Society as a Graduate Student MemberIEEE Aerospace and Electronic Systems Society as a Graduate Student Member
IEEE Aerospace and Electronic Systems Society as a Graduate Student Member
VICTOR MAESTRE RAMIREZ
 
Advanced control scheme of doubly fed induction generator for wind turbine us...
Advanced control scheme of doubly fed induction generator for wind turbine us...Advanced control scheme of doubly fed induction generator for wind turbine us...
Advanced control scheme of doubly fed induction generator for wind turbine us...
IJECEIAES
 
Gas agency management system project report.pdf
Gas agency management system project report.pdfGas agency management system project report.pdf
Gas agency management system project report.pdf
Kamal Acharya
 
Null Bangalore | Pentesters Approach to AWS IAM
Null Bangalore | Pentesters Approach to AWS IAMNull Bangalore | Pentesters Approach to AWS IAM
Null Bangalore | Pentesters Approach to AWS IAM
Divyanshu
 
ITSM Integration with MuleSoft.pptx
ITSM  Integration with MuleSoft.pptxITSM  Integration with MuleSoft.pptx
ITSM Integration with MuleSoft.pptx
VANDANAMOHANGOUDA
 
Design and optimization of ion propulsion drone
Design and optimization of ion propulsion droneDesign and optimization of ion propulsion drone
Design and optimization of ion propulsion drone
bjmsejournal
 
Optimizing Gradle Builds - Gradle DPE Tour Berlin 2024
Optimizing Gradle Builds - Gradle DPE Tour Berlin 2024Optimizing Gradle Builds - Gradle DPE Tour Berlin 2024
Optimizing Gradle Builds - Gradle DPE Tour Berlin 2024
Sinan KOZAK
 
Rainfall intensity duration frequency curve statistical analysis and modeling...
Rainfall intensity duration frequency curve statistical analysis and modeling...Rainfall intensity duration frequency curve statistical analysis and modeling...
Rainfall intensity duration frequency curve statistical analysis and modeling...
bijceesjournal
 
SCALING OF MOS CIRCUITS m .pptx
SCALING OF MOS CIRCUITS m                 .pptxSCALING OF MOS CIRCUITS m                 .pptx
SCALING OF MOS CIRCUITS m .pptx
harshapolam10
 
一比一原版(CalArts毕业证)加利福尼亚艺术学院毕业证如何办理
一比一原版(CalArts毕业证)加利福尼亚艺术学院毕业证如何办理一比一原版(CalArts毕业证)加利福尼亚艺术学院毕业证如何办理
一比一原版(CalArts毕业证)加利福尼亚艺术学院毕业证如何办理
ecqow
 
Curve Fitting in Numerical Methods Regression
Curve Fitting in Numerical Methods RegressionCurve Fitting in Numerical Methods Regression
Curve Fitting in Numerical Methods Regression
Nada Hikmah
 
TIME TABLE MANAGEMENT SYSTEM testing.pptx
TIME TABLE MANAGEMENT SYSTEM testing.pptxTIME TABLE MANAGEMENT SYSTEM testing.pptx
TIME TABLE MANAGEMENT SYSTEM testing.pptx
CVCSOfficial
 
Engineering Standards Wiring methods.pdf
Engineering Standards Wiring methods.pdfEngineering Standards Wiring methods.pdf
Engineering Standards Wiring methods.pdf
edwin408357
 
Computational Engineering IITH Presentation
Computational Engineering IITH PresentationComputational Engineering IITH Presentation
Computational Engineering IITH Presentation
co23btech11018
 
Software Engineering and Project Management - Software Testing + Agile Method...
Software Engineering and Project Management - Software Testing + Agile Method...Software Engineering and Project Management - Software Testing + Agile Method...
Software Engineering and Project Management - Software Testing + Agile Method...
Prakhyath Rai
 
1FIDIC-CONSTRUCTION-CONTRACT-2ND-ED-2017-RED-BOOK.pdf
1FIDIC-CONSTRUCTION-CONTRACT-2ND-ED-2017-RED-BOOK.pdf1FIDIC-CONSTRUCTION-CONTRACT-2ND-ED-2017-RED-BOOK.pdf
1FIDIC-CONSTRUCTION-CONTRACT-2ND-ED-2017-RED-BOOK.pdf
MadhavJungKarki
 
2008 BUILDING CONSTRUCTION Illustrated - Ching Chapter 02 The Building.pdf
2008 BUILDING CONSTRUCTION Illustrated - Ching Chapter 02 The Building.pdf2008 BUILDING CONSTRUCTION Illustrated - Ching Chapter 02 The Building.pdf
2008 BUILDING CONSTRUCTION Illustrated - Ching Chapter 02 The Building.pdf
Yasser Mahgoub
 
Data Driven Maintenance | UReason Webinar
Data Driven Maintenance | UReason WebinarData Driven Maintenance | UReason Webinar
Data Driven Maintenance | UReason Webinar
UReason
 

Recently uploaded (20)

Software Engineering and Project Management - Introduction, Modeling Concepts...
Software Engineering and Project Management - Introduction, Modeling Concepts...Software Engineering and Project Management - Introduction, Modeling Concepts...
Software Engineering and Project Management - Introduction, Modeling Concepts...
 
一比一原版(uofo毕业证书)美国俄勒冈大学毕业证如何办理
一比一原版(uofo毕业证书)美国俄勒冈大学毕业证如何办理一比一原版(uofo毕业证书)美国俄勒冈大学毕业证如何办理
一比一原版(uofo毕业证书)美国俄勒冈大学毕业证如何办理
 
IEEE Aerospace and Electronic Systems Society as a Graduate Student Member
IEEE Aerospace and Electronic Systems Society as a Graduate Student MemberIEEE Aerospace and Electronic Systems Society as a Graduate Student Member
IEEE Aerospace and Electronic Systems Society as a Graduate Student Member
 
Advanced control scheme of doubly fed induction generator for wind turbine us...
Advanced control scheme of doubly fed induction generator for wind turbine us...Advanced control scheme of doubly fed induction generator for wind turbine us...
Advanced control scheme of doubly fed induction generator for wind turbine us...
 
Gas agency management system project report.pdf
Gas agency management system project report.pdfGas agency management system project report.pdf
Gas agency management system project report.pdf
 
Null Bangalore | Pentesters Approach to AWS IAM
Null Bangalore | Pentesters Approach to AWS IAMNull Bangalore | Pentesters Approach to AWS IAM
Null Bangalore | Pentesters Approach to AWS IAM
 
ITSM Integration with MuleSoft.pptx
ITSM  Integration with MuleSoft.pptxITSM  Integration with MuleSoft.pptx
ITSM Integration with MuleSoft.pptx
 
Design and optimization of ion propulsion drone
Design and optimization of ion propulsion droneDesign and optimization of ion propulsion drone
Design and optimization of ion propulsion drone
 
Optimizing Gradle Builds - Gradle DPE Tour Berlin 2024
Optimizing Gradle Builds - Gradle DPE Tour Berlin 2024Optimizing Gradle Builds - Gradle DPE Tour Berlin 2024
Optimizing Gradle Builds - Gradle DPE Tour Berlin 2024
 
Rainfall intensity duration frequency curve statistical analysis and modeling...
Rainfall intensity duration frequency curve statistical analysis and modeling...Rainfall intensity duration frequency curve statistical analysis and modeling...
Rainfall intensity duration frequency curve statistical analysis and modeling...
 
SCALING OF MOS CIRCUITS m .pptx
SCALING OF MOS CIRCUITS m                 .pptxSCALING OF MOS CIRCUITS m                 .pptx
SCALING OF MOS CIRCUITS m .pptx
 
一比一原版(CalArts毕业证)加利福尼亚艺术学院毕业证如何办理
一比一原版(CalArts毕业证)加利福尼亚艺术学院毕业证如何办理一比一原版(CalArts毕业证)加利福尼亚艺术学院毕业证如何办理
一比一原版(CalArts毕业证)加利福尼亚艺术学院毕业证如何办理
 
Curve Fitting in Numerical Methods Regression
Curve Fitting in Numerical Methods RegressionCurve Fitting in Numerical Methods Regression
Curve Fitting in Numerical Methods Regression
 
TIME TABLE MANAGEMENT SYSTEM testing.pptx
TIME TABLE MANAGEMENT SYSTEM testing.pptxTIME TABLE MANAGEMENT SYSTEM testing.pptx
TIME TABLE MANAGEMENT SYSTEM testing.pptx
 
Engineering Standards Wiring methods.pdf
Engineering Standards Wiring methods.pdfEngineering Standards Wiring methods.pdf
Engineering Standards Wiring methods.pdf
 
Computational Engineering IITH Presentation
Computational Engineering IITH PresentationComputational Engineering IITH Presentation
Computational Engineering IITH Presentation
 
Software Engineering and Project Management - Software Testing + Agile Method...
Software Engineering and Project Management - Software Testing + Agile Method...Software Engineering and Project Management - Software Testing + Agile Method...
Software Engineering and Project Management - Software Testing + Agile Method...
 
1FIDIC-CONSTRUCTION-CONTRACT-2ND-ED-2017-RED-BOOK.pdf
1FIDIC-CONSTRUCTION-CONTRACT-2ND-ED-2017-RED-BOOK.pdf1FIDIC-CONSTRUCTION-CONTRACT-2ND-ED-2017-RED-BOOK.pdf
1FIDIC-CONSTRUCTION-CONTRACT-2ND-ED-2017-RED-BOOK.pdf
 
2008 BUILDING CONSTRUCTION Illustrated - Ching Chapter 02 The Building.pdf
2008 BUILDING CONSTRUCTION Illustrated - Ching Chapter 02 The Building.pdf2008 BUILDING CONSTRUCTION Illustrated - Ching Chapter 02 The Building.pdf
2008 BUILDING CONSTRUCTION Illustrated - Ching Chapter 02 The Building.pdf
 
Data Driven Maintenance | UReason Webinar
Data Driven Maintenance | UReason WebinarData Driven Maintenance | UReason Webinar
Data Driven Maintenance | UReason Webinar
 

PPT

  • 1.
  • 2. What is compiler?  Compiler is a program which takes one language as input and translate it into an equivalent another language.  Compiler is divided into two parts: Analysis and Synthesis  Basic model of compiler can be represented as follows:
  • 3.  Conceptually, a compiler operates into phases, each of which transform the source program from one representation to another.  Each phase takes input from its previous stage, has its own representation of source program, and feeds its output to the next phase of the compiler.  The compiler has six phases called as lexical analyzer, syntax analyzer, semantic analyzer, intermediate code generator, code optimizer and code generator.  Two other activities, symbol-table management and error handling, are interacting with the six phases of compiler. Phases of compiler
  • 5.  To support the phases of compiler, symbol table is maintained. The task of symbol table is to store identifiers used in program.  Basically symbol table is a data structure used to store the information about identifiers.  The symbol table allows us to find the record for each identifier quickly and to store or retrieve data from that record efficiently.  While doing the semantic analysis and intermediate code generation, we need to know what type of identifiers are.  During code generation typically information about how much storage is allocated to identifier is seen. Symbol-table management
  • 6. Error detection and reporting  In compilation, each phase detects error. These errors must be reported to error handler whose task is to handle the error so that the compilation can proceed.  Normally, the errors are reported in the form of message.  Large number of error can be detected in syntax analysis phase. Such error are known as syntax error.  During semantic analysis, type mismatch kind of error is usually detected.
  • 7. Lexical analysis  The lexical analysis is also known as scanning.  It is the phase of compilation in which the complete source code is scanned and source program is broken up into group of strings called token.  A token is sequence of character having a collective meaning.  E.g. Total = count + rate  After lexical analysis, the statement is broken up into series of tokens as follows: identifier total, assignment operator, identifier count, plus sign, identifier rate
  • 8. syntax analysis  The syntax analysis is also known as parsing.  In this phase token generated by lexical analysis are grouped together to form a hierarchical structure known as syntax tree.
  • 9. semantic analysis  Once syntax is checked in the syntax analyzer phase the next phase i.e. semantic analyzer determines the meaning of the source string.  For example meaning of source string means matching parenthesis, matching if…else statement, performing arithmetic operation of expression that are type compatible or checking operation scope.
  • 10. Intermediate code generation  The intermediate code is a kind of code which is easy to generate and this code can be easily converted to target code.  This code is in variety of form such as three address code, quadruple, triple, posix.  For example, total = count + rate * 10  Intermediate code using three address code method is t1 := int_to_float(10) t2 := rate * t1 t3 := count + t2 total := t3
  • 11. Code optimization  The code optimization phase attempt to improve the intermediate code  This is necessary to have a faster executing code or less consumption of memory  Thus, by optimizing the code the overall running time of the target program can be improved.
  • 12. Code generation  In this phase, target code is generated.  The intermediate code instructions are translated into sequence of machine instruction  For example, total = count + rate * 10  Target code will be MOV rate, R1 MUL #10.0, R1 MOV count, R2 ADD R2, R1 MOV R1, total