SlideShare a Scribd company logo
4
Most read
5
Most read
10
Most read
Made by: -
Deopura karan 130410107014
Submitted to: -
Nidhi shah
Phases of compiler
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

PPTX
The Phases of a Compiler
PPTX
Phases of compiler
PPTX
Issues in design_of_code_generator
PPT
basics of compiler design
PPT
Introduction to compiler
PPTX
Phases of Compiler
PPTX
Peephole optimization techniques in compiler design
PDF
COMPILER DESIGN- Syntax Directed Translation
The Phases of a Compiler
Phases of compiler
Issues in design_of_code_generator
basics of compiler design
Introduction to compiler
Phases of Compiler
Peephole optimization techniques in compiler design
COMPILER DESIGN- Syntax Directed Translation

What's hot (20)

PPTX
Unit 3 sp assembler
PPTX
Lexical Analysis - Compiler Design
PPTX
Parsing in Compiler Design
PPT
Introduction to Compiler design
PPTX
Assemblers
PPTX
Compiler construction tools
PDF
Token, Pattern and Lexeme
PPTX
Type checking in compiler design
PPTX
COMPILER DESIGN OPTIONS
PPTX
Symbol Table
PPTX
CLR AND LALR PARSER
PPTX
Code Optimization
PPTX
Compiler Chapter 1
PPTX
Basis path testing
PPTX
Structure of the compiler
PDF
Symbol table in compiler Design
PDF
Unit 2
PPTX
Compilers
PDF
Semaphores
PPTX
Code generation
Unit 3 sp assembler
Lexical Analysis - Compiler Design
Parsing in Compiler Design
Introduction to Compiler design
Assemblers
Compiler construction tools
Token, Pattern and Lexeme
Type checking in compiler design
COMPILER DESIGN OPTIONS
Symbol Table
CLR AND LALR PARSER
Code Optimization
Compiler Chapter 1
Basis path testing
Structure of the compiler
Symbol table in compiler Design
Unit 2
Compilers
Semaphores
Code generation
Ad

Viewers also liked (20)

PPTX
Decision tree
PPT
Compiler Design
PPTX
phases of compiler-analysis phase
PPTX
Mastering Python lesson 5a_lists_list_operations
PPTX
Six Degrees of Seperation: Using network theory to influence decision-making
PPTX
Lecture 4 (cen 309) IUBAT
PDF
Decision theory influence diagram
PPT
Simulated annealing
PPT
PPT
Language translator
PPTX
Simulated Annealing - A Optimisation Technique
PPTX
Simulated Annealing
PDF
Apply AHP in decision making
PPTX
Lexical analyzer
PPTX
Analytic hierarchy process
PDF
Ahp calculations
PPT
what is compiler and five phases of compiler
PPTX
Translators(Compiler, Assembler) and interpreter
PPTX
Compiler vs Interpreter-Compiler design ppt.
PPTX
Decision Tree Analysis
Decision tree
Compiler Design
phases of compiler-analysis phase
Mastering Python lesson 5a_lists_list_operations
Six Degrees of Seperation: Using network theory to influence decision-making
Lecture 4 (cen 309) IUBAT
Decision theory influence diagram
Simulated annealing
Language translator
Simulated Annealing - A Optimisation Technique
Simulated Annealing
Apply AHP in decision making
Lexical analyzer
Analytic hierarchy process
Ahp calculations
what is compiler and five phases of compiler
Translators(Compiler, Assembler) and interpreter
Compiler vs Interpreter-Compiler design ppt.
Decision Tree Analysis
Ad

Similar to Phases of compiler (20)

PDF
PDF
Principles of Compiler Design
PPTX
phase of compiler
PPT
phases of a compiler
DOCX
2-Design Issues, Patterns, Lexemes, Tokens-28-04-2023.docx
PPT
Compiler Construction
PPTX
System software module 4 presentation file
PDF
Phases of Compiler.pdf
PDF
Phases of compiler
PDF
Lecture 2.1 - Phase of a Commmmpiler.pdf
PPTX
Phases of Compiler.pptx
PPSX
Spr ch-05-compilers
PPTX
Chapter 1.pptx
PPTX
Basic of compiler
PPTX
1-Phases of compiler-26-04-2023.pptx
DOCX
Dineshmaterial1 091225091539-phpapp02
PPTX
16 compiler-151129060845-lva1-app6892-converted.pptx
DOCX
Compiler Design Material
PPTX
1 cc
PDF
Phases of the Compiler - Systems Programming
Principles of Compiler Design
phase of compiler
phases of a compiler
2-Design Issues, Patterns, Lexemes, Tokens-28-04-2023.docx
Compiler Construction
System software module 4 presentation file
Phases of Compiler.pdf
Phases of compiler
Lecture 2.1 - Phase of a Commmmpiler.pdf
Phases of Compiler.pptx
Spr ch-05-compilers
Chapter 1.pptx
Basic of compiler
1-Phases of compiler-26-04-2023.pptx
Dineshmaterial1 091225091539-phpapp02
16 compiler-151129060845-lva1-app6892-converted.pptx
Compiler Design Material
1 cc
Phases of the Compiler - Systems Programming

Recently uploaded (20)

PDF
Abrasive, erosive and cavitation wear.pdf
PPTX
Current and future trends in Computer Vision.pptx
PPTX
Software Engineering and software moduleing
PPTX
introduction to high performance computing
PDF
August 2025 - Top 10 Read Articles in Network Security & Its Applications
PDF
III.4.1.2_The_Space_Environment.p pdffdf
PDF
BIO-INSPIRED ARCHITECTURE FOR PARSIMONIOUS CONVERSATIONAL INTELLIGENCE : THE ...
PPTX
Module 8- Technological and Communication Skills.pptx
PDF
Human-AI Collaboration: Balancing Agentic AI and Autonomy in Hybrid Systems
PPTX
Amdahl’s law is explained in the above power point presentations
PPTX
Management Information system : MIS-e-Business Systems.pptx
PDF
737-MAX_SRG.pdf student reference guides
PDF
UNIT no 1 INTRODUCTION TO DBMS NOTES.pdf
PDF
A SYSTEMATIC REVIEW OF APPLICATIONS IN FRAUD DETECTION
PPTX
6ME3A-Unit-II-Sensors and Actuators_Handouts.pptx
PPTX
ASME PCC-02 TRAINING -DESKTOP-NLE5HNP.pptx
PDF
PREDICTION OF DIABETES FROM ELECTRONIC HEALTH RECORDS
PPTX
tack Data Structure with Array and Linked List Implementation, Push and Pop O...
PDF
Level 2 – IBM Data and AI Fundamentals (1)_v1.1.PDF
PDF
Accra-Kumasi Expressway - Prefeasibility Report Volume 1 of 7.11.2018.pdf
Abrasive, erosive and cavitation wear.pdf
Current and future trends in Computer Vision.pptx
Software Engineering and software moduleing
introduction to high performance computing
August 2025 - Top 10 Read Articles in Network Security & Its Applications
III.4.1.2_The_Space_Environment.p pdffdf
BIO-INSPIRED ARCHITECTURE FOR PARSIMONIOUS CONVERSATIONAL INTELLIGENCE : THE ...
Module 8- Technological and Communication Skills.pptx
Human-AI Collaboration: Balancing Agentic AI and Autonomy in Hybrid Systems
Amdahl’s law is explained in the above power point presentations
Management Information system : MIS-e-Business Systems.pptx
737-MAX_SRG.pdf student reference guides
UNIT no 1 INTRODUCTION TO DBMS NOTES.pdf
A SYSTEMATIC REVIEW OF APPLICATIONS IN FRAUD DETECTION
6ME3A-Unit-II-Sensors and Actuators_Handouts.pptx
ASME PCC-02 TRAINING -DESKTOP-NLE5HNP.pptx
PREDICTION OF DIABETES FROM ELECTRONIC HEALTH RECORDS
tack Data Structure with Array and Linked List Implementation, Push and Pop O...
Level 2 – IBM Data and AI Fundamentals (1)_v1.1.PDF
Accra-Kumasi Expressway - Prefeasibility Report Volume 1 of 7.11.2018.pdf

Phases of compiler

  • 1. Made by: - Deopura karan 130410107014 Submitted to: - Nidhi shah
  • 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