SlideShare uma empresa Scribd logo
1 de 15
Made by: -
Deopura karan 130410107014
Submitted to: -
Nidhi shah
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
Phases of compiler
Phases of compiler

Mais conteúdo relacionado

Mais procurados

Assembler design options
Assembler design optionsAssembler design options
Assembler design options
Mohd Arif
 

Mais procurados (20)

Phases of compiler
Phases of compilerPhases of compiler
Phases of compiler
 
Three Address code
Three Address code Three Address code
Three Address code
 
loaders and linkers
 loaders and linkers loaders and linkers
loaders and linkers
 
Assembler design options
Assembler design optionsAssembler design options
Assembler design options
 
Bootstrapping in Compiler
Bootstrapping in CompilerBootstrapping in Compiler
Bootstrapping in Compiler
 
Compiler Design Basics
Compiler Design BasicsCompiler Design Basics
Compiler Design Basics
 
System Programming Overview
System Programming OverviewSystem Programming Overview
System Programming Overview
 
Principle source of optimazation
Principle source of optimazationPrinciple source of optimazation
Principle source of optimazation
 
phases of a compiler
 phases of a compiler phases of a compiler
phases of a compiler
 
Code optimization in compiler design
Code optimization in compiler designCode optimization in compiler design
Code optimization in compiler design
 
Structure of the compiler
Structure of the compilerStructure of the compiler
Structure of the compiler
 
Compiler construction tools
Compiler construction toolsCompiler construction tools
Compiler construction tools
 
MACRO PROCESSOR
MACRO PROCESSORMACRO PROCESSOR
MACRO PROCESSOR
 
Implicit and explicit sequence control with exception handling
Implicit and explicit sequence control with exception handlingImplicit and explicit sequence control with exception handling
Implicit and explicit sequence control with exception handling
 
Lexical analysis - Compiler Design
Lexical analysis - Compiler DesignLexical analysis - Compiler Design
Lexical analysis - Compiler Design
 
The role of the parser and Error recovery strategies ppt in compiler design
The role of the parser and Error recovery strategies ppt in compiler designThe role of the parser and Error recovery strategies ppt in compiler design
The role of the parser and Error recovery strategies ppt in compiler design
 
Introduction to Compiler Construction
Introduction to Compiler Construction Introduction to Compiler Construction
Introduction to Compiler Construction
 
Compiler design
Compiler designCompiler design
Compiler design
 
Compilers
CompilersCompilers
Compilers
 
Type Checking(Compiler Design) #ShareThisIfYouLike
Type Checking(Compiler Design) #ShareThisIfYouLikeType Checking(Compiler Design) #ShareThisIfYouLike
Type Checking(Compiler Design) #ShareThisIfYouLike
 

Destaque

Compiler Design
Compiler DesignCompiler Design
Compiler Design
Mir Majid
 
Analytic hierarchy process
Analytic hierarchy processAnalytic hierarchy process
Analytic hierarchy process
Ujjwal 'Shanu'
 

Destaque (20)

Decision tree
Decision treeDecision tree
Decision tree
 
Compiler Design
Compiler DesignCompiler Design
Compiler Design
 
phases of compiler-analysis phase
phases of compiler-analysis phasephases of compiler-analysis phase
phases of compiler-analysis phase
 
Mastering Python lesson 5a_lists_list_operations
Mastering Python lesson 5a_lists_list_operationsMastering Python lesson 5a_lists_list_operations
Mastering Python lesson 5a_lists_list_operations
 
Six Degrees of Seperation: Using network theory to influence decision-making
Six Degrees of Seperation: Using network theory to influence decision-makingSix Degrees of Seperation: Using network theory to influence decision-making
Six Degrees of Seperation: Using network theory to influence decision-making
 
Lecture 4 (cen 309) IUBAT
Lecture 4 (cen 309) IUBATLecture 4 (cen 309) IUBAT
Lecture 4 (cen 309) IUBAT
 
Decision theory influence diagram
Decision theory   influence diagramDecision theory   influence diagram
Decision theory influence diagram
 
Simulated annealing
Simulated annealingSimulated annealing
Simulated annealing
 
Ahp
AhpAhp
Ahp
 
Language translator
Language translatorLanguage translator
Language translator
 
Simulated Annealing - A Optimisation Technique
Simulated Annealing - A Optimisation TechniqueSimulated Annealing - A Optimisation Technique
Simulated Annealing - A Optimisation Technique
 
Simulated Annealing
Simulated AnnealingSimulated Annealing
Simulated Annealing
 
Apply AHP in decision making
Apply AHP in decision makingApply AHP in decision making
Apply AHP in decision making
 
Lexical analyzer
Lexical analyzerLexical analyzer
Lexical analyzer
 
Analytic hierarchy process
Analytic hierarchy processAnalytic hierarchy process
Analytic hierarchy process
 
Ahp calculations
Ahp calculationsAhp calculations
Ahp calculations
 
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
 
Translators(Compiler, Assembler) and interpreter
Translators(Compiler, Assembler) and interpreterTranslators(Compiler, Assembler) and interpreter
Translators(Compiler, Assembler) and interpreter
 
Compiler vs Interpreter-Compiler design ppt.
Compiler vs Interpreter-Compiler design ppt.Compiler vs Interpreter-Compiler design ppt.
Compiler vs Interpreter-Compiler design ppt.
 
Decision Tree Analysis
Decision Tree AnalysisDecision Tree Analysis
Decision Tree Analysis
 

Semelhante a Phases of compiler

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
 

Semelhante a Phases of compiler (20)

PPT
PPTPPT
PPT
 
phase of compiler
phase of compilerphase of compiler
phase of compiler
 
Assignment1
Assignment1Assignment1
Assignment1
 
role of lexical anaysis
role of lexical anaysisrole of lexical anaysis
role of lexical anaysis
 
Compiler Design Material
Compiler Design MaterialCompiler Design Material
Compiler Design Material
 
How a Compiler Works ?
How a Compiler Works ?How a Compiler Works ?
How a Compiler Works ?
 
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
 
The Phases of a Compiler
The Phases of a CompilerThe Phases of a Compiler
The Phases of a Compiler
 
3.2
3.23.2
3.2
 
1._Introduction_.pptx
1._Introduction_.pptx1._Introduction_.pptx
1._Introduction_.pptx
 
Dineshmaterial1 091225091539-phpapp02
Dineshmaterial1 091225091539-phpapp02Dineshmaterial1 091225091539-phpapp02
Dineshmaterial1 091225091539-phpapp02
 
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
 
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
 
COMPILER CONSTRUCTION KU 1.pptx
COMPILER CONSTRUCTION KU 1.pptxCOMPILER CONSTRUCTION KU 1.pptx
COMPILER CONSTRUCTION KU 1.pptx
 
System software module 4 presentation file
System software module 4 presentation fileSystem software module 4 presentation file
System software module 4 presentation file
 
Compiler design
Compiler designCompiler design
Compiler design
 
Compiler Construction introduction
Compiler Construction introductionCompiler Construction introduction
Compiler Construction introduction
 
Introduction to Compilers
Introduction to CompilersIntroduction to Compilers
Introduction to Compilers
 
Compiler Design
Compiler DesignCompiler Design
Compiler Design
 
Chapter#01 cc
Chapter#01 ccChapter#01 cc
Chapter#01 cc
 

Último

Standard vs Custom Battery Packs - Decoding the Power Play
Standard vs Custom Battery Packs - Decoding the Power PlayStandard vs Custom Battery Packs - Decoding the Power Play
Standard vs Custom Battery Packs - Decoding the Power Play
Epec Engineered Technologies
 
1_Introduction + EAM Vocabulary + how to navigate in EAM.pdf
1_Introduction + EAM Vocabulary + how to navigate in EAM.pdf1_Introduction + EAM Vocabulary + how to navigate in EAM.pdf
1_Introduction + EAM Vocabulary + how to navigate in EAM.pdf
AldoGarca30
 
"Lesotho Leaps Forward: A Chronicle of Transformative Developments"
"Lesotho Leaps Forward: A Chronicle of Transformative Developments""Lesotho Leaps Forward: A Chronicle of Transformative Developments"
"Lesotho Leaps Forward: A Chronicle of Transformative Developments"
mphochane1998
 

Último (20)

A CASE STUDY ON CERAMIC INDUSTRY OF BANGLADESH.pptx
A CASE STUDY ON CERAMIC INDUSTRY OF BANGLADESH.pptxA CASE STUDY ON CERAMIC INDUSTRY OF BANGLADESH.pptx
A CASE STUDY ON CERAMIC INDUSTRY OF BANGLADESH.pptx
 
Standard vs Custom Battery Packs - Decoding the Power Play
Standard vs Custom Battery Packs - Decoding the Power PlayStandard vs Custom Battery Packs - Decoding the Power Play
Standard vs Custom Battery Packs - Decoding the Power Play
 
Unleashing the Power of the SORA AI lastest leap
Unleashing the Power of the SORA AI lastest leapUnleashing the Power of the SORA AI lastest leap
Unleashing the Power of the SORA AI lastest leap
 
Design For Accessibility: Getting it right from the start
Design For Accessibility: Getting it right from the startDesign For Accessibility: Getting it right from the start
Design For Accessibility: Getting it right from the start
 
Block diagram reduction techniques in control systems.ppt
Block diagram reduction techniques in control systems.pptBlock diagram reduction techniques in control systems.ppt
Block diagram reduction techniques in control systems.ppt
 
Moment Distribution Method For Btech Civil
Moment Distribution Method For Btech CivilMoment Distribution Method For Btech Civil
Moment Distribution Method For Btech Civil
 
Engineering Drawing focus on projection of planes
Engineering Drawing focus on projection of planesEngineering Drawing focus on projection of planes
Engineering Drawing focus on projection of planes
 
HAND TOOLS USED AT ELECTRONICS WORK PRESENTED BY KOUSTAV SARKAR
HAND TOOLS USED AT ELECTRONICS WORK PRESENTED BY KOUSTAV SARKARHAND TOOLS USED AT ELECTRONICS WORK PRESENTED BY KOUSTAV SARKAR
HAND TOOLS USED AT ELECTRONICS WORK PRESENTED BY KOUSTAV SARKAR
 
Bhubaneswar🌹Call Girls Bhubaneswar ❤Komal 9777949614 💟 Full Trusted CALL GIRL...
Bhubaneswar🌹Call Girls Bhubaneswar ❤Komal 9777949614 💟 Full Trusted CALL GIRL...Bhubaneswar🌹Call Girls Bhubaneswar ❤Komal 9777949614 💟 Full Trusted CALL GIRL...
Bhubaneswar🌹Call Girls Bhubaneswar ❤Komal 9777949614 💟 Full Trusted CALL GIRL...
 
Wadi Rum luxhotel lodge Analysis case study.pptx
Wadi Rum luxhotel lodge Analysis case study.pptxWadi Rum luxhotel lodge Analysis case study.pptx
Wadi Rum luxhotel lodge Analysis case study.pptx
 
COST-EFFETIVE and Energy Efficient BUILDINGS ptx
COST-EFFETIVE  and Energy Efficient BUILDINGS ptxCOST-EFFETIVE  and Energy Efficient BUILDINGS ptx
COST-EFFETIVE and Energy Efficient BUILDINGS ptx
 
DC MACHINE-Motoring and generation, Armature circuit equation
DC MACHINE-Motoring and generation, Armature circuit equationDC MACHINE-Motoring and generation, Armature circuit equation
DC MACHINE-Motoring and generation, Armature circuit equation
 
Online food ordering system project report.pdf
Online food ordering system project report.pdfOnline food ordering system project report.pdf
Online food ordering system project report.pdf
 
kiln thermal load.pptx kiln tgermal load
kiln thermal load.pptx kiln tgermal loadkiln thermal load.pptx kiln tgermal load
kiln thermal load.pptx kiln tgermal load
 
School management system project Report.pdf
School management system project Report.pdfSchool management system project Report.pdf
School management system project Report.pdf
 
1_Introduction + EAM Vocabulary + how to navigate in EAM.pdf
1_Introduction + EAM Vocabulary + how to navigate in EAM.pdf1_Introduction + EAM Vocabulary + how to navigate in EAM.pdf
1_Introduction + EAM Vocabulary + how to navigate in EAM.pdf
 
"Lesotho Leaps Forward: A Chronicle of Transformative Developments"
"Lesotho Leaps Forward: A Chronicle of Transformative Developments""Lesotho Leaps Forward: A Chronicle of Transformative Developments"
"Lesotho Leaps Forward: A Chronicle of Transformative Developments"
 
S1S2 B.Arch MGU - HOA1&2 Module 3 -Temple Architecture of Kerala.pptx
S1S2 B.Arch MGU - HOA1&2 Module 3 -Temple Architecture of Kerala.pptxS1S2 B.Arch MGU - HOA1&2 Module 3 -Temple Architecture of Kerala.pptx
S1S2 B.Arch MGU - HOA1&2 Module 3 -Temple Architecture of Kerala.pptx
 
Thermal Engineering-R & A / C - unit - V
Thermal Engineering-R & A / C - unit - VThermal Engineering-R & A / C - unit - V
Thermal Engineering-R & A / C - unit - V
 
Navigating Complexity: The Role of Trusted Partners and VIAS3D in Dassault Sy...
Navigating Complexity: The Role of Trusted Partners and VIAS3D in Dassault Sy...Navigating Complexity: The Role of Trusted Partners and VIAS3D in Dassault Sy...
Navigating Complexity: The Role of Trusted Partners and VIAS3D in Dassault Sy...
 

Phases of compiler

  • 1. Made by: - Deopura karan 130410107014 Submitted to: - Nidhi shah
  • 2.
  • 3. 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:
  • 4.  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
  • 6.  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
  • 7. 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.
  • 8. 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
  • 9. 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.
  • 10. 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.
  • 11. 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
  • 12. 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.
  • 13. 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