SlideShare a Scribd company logo
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

More Related Content

What's hot

Phases of compiler
Phases of compilerPhases of compiler
Phases of compiler
Akhil Kaushik
 
Peephole Optimization
Peephole OptimizationPeephole Optimization
Peephole Optimization
United International University
 
Process in operating system
Process in operating systemProcess in operating system
Process in operating system
Chetan Mahawar
 
Code Optimization
Code OptimizationCode Optimization
Code Optimization
Akhil Kaushik
 
Need of object oriented programming
Need of object oriented programmingNeed of object oriented programming
Need of object oriented programming
Amar Jukuntla
 
Threads (operating System)
Threads (operating System)Threads (operating System)
Threads (operating System)
Prakhar Maurya
 
Syntax Analysis in Compiler Design
Syntax Analysis in Compiler Design Syntax Analysis in Compiler Design
Syntax Analysis in Compiler Design
MAHASREEM
 
Structure of the compiler
Structure of the compilerStructure of the compiler
Structure of the compiler
Sudhaa Ravi
 
Operator precedence
Operator precedenceOperator precedence
Operator precedence
Akshaya Arunan
 
Lexical Analysis - Compiler Design
Lexical Analysis - Compiler DesignLexical Analysis - Compiler Design
Lexical Analysis - Compiler Design
Akhil Kaushik
 
Recognition-of-tokens
Recognition-of-tokensRecognition-of-tokens
Recognition-of-tokens
Dattatray Gandhmal
 
Paging and segmentation
Paging and segmentationPaging and segmentation
Paging and segmentation
Piyush Rochwani
 
Code optimization
Code optimizationCode optimization
Code optimization
veena venugopal
 
Java Exception handling
Java Exception handlingJava Exception handling
Java Exception handling
kamal kotecha
 
Little o and little omega
Little o and little omegaLittle o and little omega
Little o and little omega
Rajesh K Shukla
 
loaders and linkers
 loaders and linkers loaders and linkers
loaders and linkers
Temesgen Molla
 
System calls
System callsSystem calls
System calls
Bernard Senam
 
Loop optimization
Loop optimizationLoop optimization
Loop optimization
Vivek Gandhi
 
Introduction to Compiler design
Introduction to Compiler design Introduction to Compiler design
Introduction to Compiler design
Dr. C.V. Suresh Babu
 
Process synchronization in Operating Systems
Process synchronization in Operating SystemsProcess synchronization in Operating Systems
Process synchronization in Operating Systems
Ritu Ranjan Shrivastwa
 

What's hot (20)

Phases of compiler
Phases of compilerPhases of compiler
Phases of compiler
 
Peephole Optimization
Peephole OptimizationPeephole Optimization
Peephole Optimization
 
Process in operating system
Process in operating systemProcess in operating system
Process in operating system
 
Code Optimization
Code OptimizationCode Optimization
Code Optimization
 
Need of object oriented programming
Need of object oriented programmingNeed of object oriented programming
Need of object oriented programming
 
Threads (operating System)
Threads (operating System)Threads (operating System)
Threads (operating System)
 
Syntax Analysis in Compiler Design
Syntax Analysis in Compiler Design Syntax Analysis in Compiler Design
Syntax Analysis in Compiler Design
 
Structure of the compiler
Structure of the compilerStructure of the compiler
Structure of the compiler
 
Operator precedence
Operator precedenceOperator precedence
Operator precedence
 
Lexical Analysis - Compiler Design
Lexical Analysis - Compiler DesignLexical Analysis - Compiler Design
Lexical Analysis - Compiler Design
 
Recognition-of-tokens
Recognition-of-tokensRecognition-of-tokens
Recognition-of-tokens
 
Paging and segmentation
Paging and segmentationPaging and segmentation
Paging and segmentation
 
Code optimization
Code optimizationCode optimization
Code optimization
 
Java Exception handling
Java Exception handlingJava Exception handling
Java Exception handling
 
Little o and little omega
Little o and little omegaLittle o and little omega
Little o and little omega
 
loaders and linkers
 loaders and linkers loaders and linkers
loaders and linkers
 
System calls
System callsSystem calls
System calls
 
Loop optimization
Loop optimizationLoop optimization
Loop optimization
 
Introduction to Compiler design
Introduction to Compiler design Introduction to Compiler design
Introduction to Compiler design
 
Process synchronization in Operating Systems
Process synchronization in Operating SystemsProcess synchronization in Operating Systems
Process synchronization in Operating Systems
 

Viewers also liked

Decision tree
Decision treeDecision tree
Decision tree
Karan Deopura
 
Compiler Design
Compiler DesignCompiler Design
Compiler Design
Mir Majid
 
phases of compiler-analysis phase
phases of compiler-analysis phasephases of compiler-analysis phase
phases of compiler-analysis phase
Suyash Srivastava
 
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
Ruth Marvin
 
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
International Water Management Institute (IWMI)
 
Lecture 4 (cen 309) IUBAT
Lecture 4 (cen 309) IUBATLecture 4 (cen 309) IUBAT
Lecture 4 (cen 309) IUBAT
emdad bhuiyan
 
Decision theory influence diagram
Decision theory   influence diagramDecision theory   influence diagram
Decision theory influence diagram
Edgar Mata
 
Simulated annealing
Simulated annealingSimulated annealing
Simulated annealing
Kirill Netreba
 
Ahp
AhpAhp
Language translator
Language translatorLanguage translator
Language translator
asmakh89
 
Simulated Annealing - A Optimisation Technique
Simulated Annealing - A Optimisation TechniqueSimulated Annealing - A Optimisation Technique
Simulated Annealing - A Optimisation Technique
AUSTIN MOSES
 
Simulated Annealing
Simulated AnnealingSimulated Annealing
Simulated Annealing
Joy Dutta
 
Apply AHP in decision making
Apply AHP in decision makingApply AHP in decision making
Apply AHP in decision making
Mohd Farid Awang
 
Lexical analyzer
Lexical analyzerLexical analyzer
Lexical analyzer
kiran acharya
 
Analytic hierarchy process
Analytic hierarchy processAnalytic hierarchy process
Analytic hierarchy process
Ujjwal 'Shanu'
 
Ahp calculations
Ahp calculationsAhp calculations
Ahp calculations
Lakshna Suresh
 
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
 
Translators(Compiler, Assembler) and interpreter
Translators(Compiler, Assembler) and interpreterTranslators(Compiler, Assembler) and interpreter
Translators(Compiler, Assembler) and interpreter
baabtra.com - No. 1 supplier of quality freshers
 
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
 
Decision Tree Analysis
Decision Tree AnalysisDecision Tree Analysis
Decision Tree Analysis
Anand Arora
 

Viewers also liked (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
 

Similar to Phases of compiler

PPT
PPTPPT
phase of compiler
phase of compilerphase of compiler
phase of compiler
TECHNICALGYANIBABUAA
 
Assignment1
Assignment1Assignment1
Assignment1
Sunita Milind Dol
 
role of lexical anaysis
role of lexical anaysisrole of lexical anaysis
role of lexical anaysis
Sudhaa Ravi
 
Compiler Design Material
Compiler Design MaterialCompiler Design Material
Compiler Design Material
Dr. C.V. Suresh Babu
 
How a Compiler Works ?
How a Compiler Works ?How a Compiler Works ?
How a Compiler Works ?
Hirdesh Vishwdewa
 
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
 
3.2
3.23.2
1._Introduction_.pptx
1._Introduction_.pptx1._Introduction_.pptx
1._Introduction_.pptx
Anbarasan Radhakrishnan R
 
Dineshmaterial1 091225091539-phpapp02
Dineshmaterial1 091225091539-phpapp02Dineshmaterial1 091225091539-phpapp02
Dineshmaterial1 091225091539-phpapp02
Tirumala Rao
 
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
 
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
 
COMPILER CONSTRUCTION KU 1.pptx
COMPILER CONSTRUCTION KU 1.pptxCOMPILER CONSTRUCTION KU 1.pptx
COMPILER CONSTRUCTION KU 1.pptx
Rossy719186
 
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
Compiler designCompiler design
Compiler design
nazmul hoque
 
Compiler Construction introduction
Compiler Construction introductionCompiler Construction introduction
Compiler Construction introduction
Rana Ehtisham Ul Haq
 
Introduction to Compilers
Introduction to CompilersIntroduction to Compilers
Introduction to Compilers
vijaya603274
 
Compiler Design
Compiler DesignCompiler Design
Compiler Design
Dr. Jaydeep Patil
 
Chapter#01 cc
Chapter#01 ccChapter#01 cc
Chapter#01 cc
abdulbaki3
 
Compiler_Lecture1.pdf
Compiler_Lecture1.pdfCompiler_Lecture1.pdf
Compiler_Lecture1.pdf
AkarTaher
 

Similar to 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
 
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
 
Compiler_Lecture1.pdf
Compiler_Lecture1.pdfCompiler_Lecture1.pdf
Compiler_Lecture1.pdf
 

Recently uploaded

Generative AI Use cases applications solutions and implementation.pdf
Generative AI Use cases applications solutions and implementation.pdfGenerative AI Use cases applications solutions and implementation.pdf
Generative AI Use cases applications solutions and implementation.pdf
mahaffeycheryld
 
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
 
CompEx~Manual~1210 (2).pdf COMPEX GAS AND VAPOURS
CompEx~Manual~1210 (2).pdf COMPEX GAS AND VAPOURSCompEx~Manual~1210 (2).pdf COMPEX GAS AND VAPOURS
CompEx~Manual~1210 (2).pdf COMPEX GAS AND VAPOURS
RamonNovais6
 
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
 
Applications of artificial Intelligence in Mechanical Engineering.pdf
Applications of artificial Intelligence in Mechanical Engineering.pdfApplications of artificial Intelligence in Mechanical Engineering.pdf
Applications of artificial Intelligence in Mechanical Engineering.pdf
Atif Razi
 
morris_worm_intro_and_source_code_analysis_.pdf
morris_worm_intro_and_source_code_analysis_.pdfmorris_worm_intro_and_source_code_analysis_.pdf
morris_worm_intro_and_source_code_analysis_.pdf
ycwu0509
 
Prediction of Electrical Energy Efficiency Using Information on Consumer's Ac...
Prediction of Electrical Energy Efficiency Using Information on Consumer's Ac...Prediction of Electrical Energy Efficiency Using Information on Consumer's Ac...
Prediction of Electrical Energy Efficiency Using Information on Consumer's Ac...
PriyankaKilaniya
 
一比一原版(爱大毕业证书)爱荷华大学毕业证如何办理
一比一原版(爱大毕业证书)爱荷华大学毕业证如何办理一比一原版(爱大毕业证书)爱荷华大学毕业证如何办理
一比一原版(爱大毕业证书)爱荷华大学毕业证如何办理
nedcocy
 
AI + Data Community Tour - Build the Next Generation of Apps with the Einstei...
AI + Data Community Tour - Build the Next Generation of Apps with the Einstei...AI + Data Community Tour - Build the Next Generation of Apps with the Einstei...
AI + Data Community Tour - Build the Next Generation of Apps with the Einstei...
Paris Salesforce Developer Group
 
SCALING OF MOS CIRCUITS m .pptx
SCALING OF MOS CIRCUITS m                 .pptxSCALING OF MOS CIRCUITS m                 .pptx
SCALING OF MOS CIRCUITS m .pptx
harshapolam10
 
Engineering Standards Wiring methods.pdf
Engineering Standards Wiring methods.pdfEngineering Standards Wiring methods.pdf
Engineering Standards Wiring methods.pdf
edwin408357
 
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
 
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
 
22CYT12-Unit-V-E Waste and its Management.ppt
22CYT12-Unit-V-E Waste and its Management.ppt22CYT12-Unit-V-E Waste and its Management.ppt
22CYT12-Unit-V-E Waste and its Management.ppt
KrishnaveniKrishnara1
 
Object Oriented Analysis and Design - OOAD
Object Oriented Analysis and Design - OOADObject Oriented Analysis and Design - OOAD
Object Oriented Analysis and Design - OOAD
PreethaV16
 
Embedded machine learning-based road conditions and driving behavior monitoring
Embedded machine learning-based road conditions and driving behavior monitoringEmbedded machine learning-based road conditions and driving behavior monitoring
Embedded machine learning-based road conditions and driving behavior monitoring
IJECEIAES
 
Use PyCharm for remote debugging of WSL on a Windo cf5c162d672e4e58b4dde5d797...
Use PyCharm for remote debugging of WSL on a Windo cf5c162d672e4e58b4dde5d797...Use PyCharm for remote debugging of WSL on a Windo cf5c162d672e4e58b4dde5d797...
Use PyCharm for remote debugging of WSL on a Windo cf5c162d672e4e58b4dde5d797...
shadow0702a
 
Electric vehicle and photovoltaic advanced roles in enhancing the financial p...
Electric vehicle and photovoltaic advanced roles in enhancing the financial p...Electric vehicle and photovoltaic advanced roles in enhancing the financial p...
Electric vehicle and photovoltaic advanced roles in enhancing the financial p...
IJECEIAES
 
LLM Fine Tuning with QLoRA Cassandra Lunch 4, presented by Anant
LLM Fine Tuning with QLoRA Cassandra Lunch 4, presented by AnantLLM Fine Tuning with QLoRA Cassandra Lunch 4, presented by Anant
LLM Fine Tuning with QLoRA Cassandra Lunch 4, presented by Anant
Anant Corporation
 
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
 

Recently uploaded (20)

Generative AI Use cases applications solutions and implementation.pdf
Generative AI Use cases applications solutions and implementation.pdfGenerative AI Use cases applications solutions and implementation.pdf
Generative AI Use cases applications solutions and implementation.pdf
 
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...
 
CompEx~Manual~1210 (2).pdf COMPEX GAS AND VAPOURS
CompEx~Manual~1210 (2).pdf COMPEX GAS AND VAPOURSCompEx~Manual~1210 (2).pdf COMPEX GAS AND VAPOURS
CompEx~Manual~1210 (2).pdf COMPEX GAS AND VAPOURS
 
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
 
Applications of artificial Intelligence in Mechanical Engineering.pdf
Applications of artificial Intelligence in Mechanical Engineering.pdfApplications of artificial Intelligence in Mechanical Engineering.pdf
Applications of artificial Intelligence in Mechanical Engineering.pdf
 
morris_worm_intro_and_source_code_analysis_.pdf
morris_worm_intro_and_source_code_analysis_.pdfmorris_worm_intro_and_source_code_analysis_.pdf
morris_worm_intro_and_source_code_analysis_.pdf
 
Prediction of Electrical Energy Efficiency Using Information on Consumer's Ac...
Prediction of Electrical Energy Efficiency Using Information on Consumer's Ac...Prediction of Electrical Energy Efficiency Using Information on Consumer's Ac...
Prediction of Electrical Energy Efficiency Using Information on Consumer's Ac...
 
一比一原版(爱大毕业证书)爱荷华大学毕业证如何办理
一比一原版(爱大毕业证书)爱荷华大学毕业证如何办理一比一原版(爱大毕业证书)爱荷华大学毕业证如何办理
一比一原版(爱大毕业证书)爱荷华大学毕业证如何办理
 
AI + Data Community Tour - Build the Next Generation of Apps with the Einstei...
AI + Data Community Tour - Build the Next Generation of Apps with the Einstei...AI + Data Community Tour - Build the Next Generation of Apps with the Einstei...
AI + Data Community Tour - Build the Next Generation of Apps with the Einstei...
 
SCALING OF MOS CIRCUITS m .pptx
SCALING OF MOS CIRCUITS m                 .pptxSCALING OF MOS CIRCUITS m                 .pptx
SCALING OF MOS CIRCUITS m .pptx
 
Engineering Standards Wiring methods.pdf
Engineering Standards Wiring methods.pdfEngineering Standards Wiring methods.pdf
Engineering Standards Wiring methods.pdf
 
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
 
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...
 
22CYT12-Unit-V-E Waste and its Management.ppt
22CYT12-Unit-V-E Waste and its Management.ppt22CYT12-Unit-V-E Waste and its Management.ppt
22CYT12-Unit-V-E Waste and its Management.ppt
 
Object Oriented Analysis and Design - OOAD
Object Oriented Analysis and Design - OOADObject Oriented Analysis and Design - OOAD
Object Oriented Analysis and Design - OOAD
 
Embedded machine learning-based road conditions and driving behavior monitoring
Embedded machine learning-based road conditions and driving behavior monitoringEmbedded machine learning-based road conditions and driving behavior monitoring
Embedded machine learning-based road conditions and driving behavior monitoring
 
Use PyCharm for remote debugging of WSL on a Windo cf5c162d672e4e58b4dde5d797...
Use PyCharm for remote debugging of WSL on a Windo cf5c162d672e4e58b4dde5d797...Use PyCharm for remote debugging of WSL on a Windo cf5c162d672e4e58b4dde5d797...
Use PyCharm for remote debugging of WSL on a Windo cf5c162d672e4e58b4dde5d797...
 
Electric vehicle and photovoltaic advanced roles in enhancing the financial p...
Electric vehicle and photovoltaic advanced roles in enhancing the financial p...Electric vehicle and photovoltaic advanced roles in enhancing the financial p...
Electric vehicle and photovoltaic advanced roles in enhancing the financial p...
 
LLM Fine Tuning with QLoRA Cassandra Lunch 4, presented by Anant
LLM Fine Tuning with QLoRA Cassandra Lunch 4, presented by AnantLLM Fine Tuning with QLoRA Cassandra Lunch 4, presented by Anant
LLM Fine Tuning with QLoRA Cassandra Lunch 4, presented by Anant
 
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
 

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