SlideShare a Scribd company logo
Compiler
SUBMITTED BY:
MD:SUMON FAKIR
ID:173002024
Dept of CSE
SUBMITTED TO:
Md. Jahidul Islam
Lecturer of CSE
Green university of Bangladesh
Table of Contents
Introduction
The structure of Compiler(All phases)
All Phases of Compiler
1
Compiler & its Application
Compiler vs Interpreter
Symbol Table Management
Table of Contents cont..
Derivations (with Examples)
2
Reference
Conclusion
Introduction
3
A compiler translates the code written in one
language to some other language without
changing the meaning of the program. It is
also expected that a compiler should make
the target code efficient and optimized in
terms of time and space
Compiler & its Application
4
A compiler is a program that reads a
program written in one language and
translates is into an equivalent program
in another language.
What is compiler ?
Compiler & its Application cont..
5
Application of compiler
 Implementation of High-Level Programming
Optimizations for Computer Architectures
Design of New Computer Architectures
Program Translations
Software Productivity Tools
Compiler vs Interpreter
6
1.Compiler scans the entire program and
translate the whole it into machine code.
1.Interpreter translates just one statement
of the program at time into machine code
2.Compiler takes a lot of time to anaylize the
source code .however , the overall time
taken to execute the process is much faster.
2.An interpreter takes vary less time to
anaylize the source code .however, overall
time to execute the process is much slower.
3.Compiler are used by program language
like C and C++ for example
3.Interpreter are used by programming
language like Ruby and python for example
The Structure of Compiler (all phase )
7
Lexical Analyzer
Syntax Tree
Semantic Analyzer
Character stream
Intermediate code
generation
Code Optimizer
Code Generator
Symbol Table
manager
Error Handler
Lexical analysis coverts source program into a stream of
valid word of the language, known as token.
Lexical analyzer also known as(Lexer ,Scanner,Tokening )
8
Lexical Analyzer
Function of lexical
Analyzer
Convert the source code into stream of token.
Removing white space , comments
Recognizing keyword , identifier, Contents
Show error when then lexeme doesn’t match of
patten
All phase of Compiler
Syntax of a language refers to the structure of valid program or
statement of the language.
Specified using certain rules known as Productions
Collection of such productions(rules) is known as grammar.
Syntax Tree
9
Function of syntax
tree
Syntax analysis to verified that a string of token valid or not.
 report syntactic error.
recovery from such error so as to continuous to execution
process
All phase of Compiler (cont..)
Semantic Analysis makes sure that declarations and statements
of program are semantically correct. It is a collection of
procedures which is called by syntax tree as and when required by
grammar. Both syntax tree and symbol table are used to check
the consistency of the given code.
Semantic Analyzer
10
Function of syntax
tree  Semantic error :Type mismatch, Undeclared variables,
Reserved identifier.
 Type Checking: Ensures that data types are used in a way
consistent with their definition.
 Label Checking –A program should contain labels
references.
All phase of Compiler (cont..)
Semantic Analysis makes sure that declarations and statements
of program are semantically correct. It is a collection of
procedures which is called by syntax tree as and when required
by grammar. Both syntax tree and symbol table are used to
check the consistency of the given code.
Intermediate code generation
11
 Postfix Notation
 Three-Address Code
 Syntax
Intermediate code representation
All phase of Compiler (cont..)
Optimization is a program transformation technique, which tries
to improve the code by making it consume less resources example
CPU, Memory and deliver high speed. In optimization, high-level
general programming constructs are replaced by very efficient
low-level programming codes
Code Optimizer
12
Code generation can be considered as the final phase
of compilation. Through post code generation,
optimization process can be applied on the code
Code Generator
All phase of Compiler (cont..)
1
13
Symbol Table Manager
Symbol table is an important data structure created and maintained
by compilers in order to store information about the occurrence of
various entities such as variable names, function names, objects,
classes, interfaces, etc. Symbol table is used by both the analysis
and the synthesis parts of a compiler.
1
14
Derivation
derivation is used to find whether the string
belongs to a given grammar.
Type of Derivation
1. Leftmost derivation.
2. Rightmost derivation
1
15
Derivation cont..
Leftmost derivation
Example
A XYZ
B  a
Y b
Z c
SOLUTION
A XYZ
A aYZ
A abZ
A abc
Rightmost derivation
Example
A XYZ
B  a
Y b
Z c
SOLUTION
A XYZ
A XYc
A Xbc
A abc
1
16
A compiler translates the code written in one language to some other
language without changing the meaning of the program. It is also
expected that a compiler should make the target code efficient and
optimized in terms of time and space. Compiler design principles provide
an in-depth view of translation and optimization process.
Conclusion
1
17
1.https://www.tutorialspoint.com/compiler_design/index.htm
2.https://www.youtube.com/watch?v=KRx-
BPR4bbs&list=PLV8vIYTIdSnaeEO7C3elIV9u-
Vj5G5CRF&index=13
3.https://www.youtube.com/watch?v=9e-
ksSoVvG8&list=PLgH5QX0i9K3oWTwTgILA7v9oysoDgkJDg&ind
ex=7
References
1
18

More Related Content

What's hot

phases of a compiler
 phases of a compiler phases of a compiler
phases of a compiler
Ms.SHANTHI.S CSE
 
Spr ch-05-compilers
Spr ch-05-compilersSpr ch-05-compilers
Spr ch-05-compilersVasim Pathan
 
Phases of compiler
Phases of compilerPhases of compiler
Phases of compiler
Karan Deopura
 
Compiler Design(Nanthu)
Compiler Design(Nanthu)Compiler Design(Nanthu)
Compiler Design(Nanthu)
guest91cc85
 
Compiler Construction
Compiler ConstructionCompiler Construction
Compiler Construction
Sarmad Ali
 
Error detection recovery
Error detection recoveryError detection recovery
Error detection recoveryTech_MX
 
basics of compiler design
basics of compiler designbasics of compiler design
basics of compiler design
Preeti Katiyar
 
Phases of-compiler
Phases of-compilerPhases of-compiler
Phases of-compiler
Zahidul Islam Razu
 
Concept of compiler in details
Concept of compiler in detailsConcept of compiler in details
Concept of compiler in details
kazi_aihtesham
 
Phases of Compiler
Phases of CompilerPhases of Compiler
Phases of Compiler
Tanzeela_Hussain
 
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
 
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 One
Chapter OneChapter One
Chapter Onebolovv
 
Techniques & applications of Compiler
Techniques & applications of CompilerTechniques & applications of Compiler
Techniques & applications of Compiler
Preethi AKNR
 
Compiler Design
Compiler DesignCompiler Design
Compiler DesignMir Majid
 
Compiler Design
Compiler DesignCompiler Design
Compiler Design
Dr. Jaydeep Patil
 
Compiler Design(NANTHU NOTES)
Compiler Design(NANTHU NOTES)Compiler Design(NANTHU NOTES)
Compiler Design(NANTHU NOTES)
guest251d9a
 
Introduction to Compiler Construction
Introduction to Compiler Construction Introduction to Compiler Construction
Introduction to Compiler Construction
Sarmad Ali
 

What's hot (20)

phases of a compiler
 phases of a compiler phases of a compiler
phases of a compiler
 
Spr ch-05-compilers
Spr ch-05-compilersSpr ch-05-compilers
Spr ch-05-compilers
 
Phases of compiler
Phases of compilerPhases of compiler
Phases of compiler
 
Compiler Design(Nanthu)
Compiler Design(Nanthu)Compiler Design(Nanthu)
Compiler Design(Nanthu)
 
Compiler Construction
Compiler ConstructionCompiler Construction
Compiler Construction
 
Error detection recovery
Error detection recoveryError detection recovery
Error detection recovery
 
basics of compiler design
basics of compiler designbasics of compiler design
basics of compiler design
 
Phases of-compiler
Phases of-compilerPhases of-compiler
Phases of-compiler
 
Concept of compiler in details
Concept of compiler in detailsConcept of compiler in details
Concept of compiler in details
 
Phases of Compiler
Phases of CompilerPhases of Compiler
Phases of Compiler
 
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
 
Compiler1
Compiler1Compiler1
Compiler1
 
Compiler Design Material
Compiler Design MaterialCompiler Design Material
Compiler Design Material
 
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
 
Chapter One
Chapter OneChapter One
Chapter One
 
Techniques & applications of Compiler
Techniques & applications of CompilerTechniques & applications of Compiler
Techniques & applications of Compiler
 
Compiler Design
Compiler DesignCompiler Design
Compiler Design
 
Compiler Design
Compiler DesignCompiler Design
Compiler Design
 
Compiler Design(NANTHU NOTES)
Compiler Design(NANTHU NOTES)Compiler Design(NANTHU NOTES)
Compiler Design(NANTHU NOTES)
 
Introduction to Compiler Construction
Introduction to Compiler Construction Introduction to Compiler Construction
Introduction to Compiler Construction
 

Similar to Compiler

Ch 1.pptx
Ch 1.pptxCh 1.pptx
Ch 1.pptx
woldu2
 
Chapter#01 cc
Chapter#01 ccChapter#01 cc
Chapter#01 cc
abdulbaki3
 
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 Construction introduction
Compiler Construction introductionCompiler Construction introduction
Compiler Construction introduction
Rana Ehtisham Ul Haq
 
Assignment1
Assignment1Assignment1
Assignment1
Sunita Milind Dol
 
Compiler_Lecture1.pdf
Compiler_Lecture1.pdfCompiler_Lecture1.pdf
Compiler_Lecture1.pdf
AkarTaher
 
SOFTWARE TOOL FOR TRANSLATING PSEUDOCODE TO A PROGRAMMING LANGUAGE
SOFTWARE TOOL FOR TRANSLATING PSEUDOCODE TO A PROGRAMMING LANGUAGESOFTWARE TOOL FOR TRANSLATING PSEUDOCODE TO A PROGRAMMING LANGUAGE
SOFTWARE TOOL FOR TRANSLATING PSEUDOCODE TO A PROGRAMMING LANGUAGE
IJCI JOURNAL
 
SOFTWARE TOOL FOR TRANSLATING PSEUDOCODE TO A PROGRAMMING LANGUAGE
SOFTWARE TOOL FOR TRANSLATING PSEUDOCODE TO A PROGRAMMING LANGUAGESOFTWARE TOOL FOR TRANSLATING PSEUDOCODE TO A PROGRAMMING LANGUAGE
SOFTWARE TOOL FOR TRANSLATING PSEUDOCODE TO A PROGRAMMING LANGUAGE
IJCI JOURNAL
 
design intoduction of_COMPILER_DESIGN.pdf
design intoduction of_COMPILER_DESIGN.pdfdesign intoduction of_COMPILER_DESIGN.pdf
design intoduction of_COMPILER_DESIGN.pdf
advRajatSharma
 
Code generation errors and recovery
Code generation errors and recoveryCode generation errors and recovery
Code generation errors and recovery
Momina Idrees
 
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
 
lec00-Introduction.pdf
lec00-Introduction.pdflec00-Introduction.pdf
lec00-Introduction.pdf
wigewej294
 
Chapter 2 Program language translation.pptx
Chapter 2 Program language translation.pptxChapter 2 Program language translation.pptx
Chapter 2 Program language translation.pptx
dawod yimer
 
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
 
Lexical analyzer
Lexical analyzerLexical analyzer
Lexical analyzer
Ashwini Sonawane
 
Cd unit i
Cd unit iCd unit i
Cd unit i
Abhimanyu Mishra
 
PSEUDOCODE TO SOURCE PROGRAMMING LANGUAGE TRANSLATOR
PSEUDOCODE TO SOURCE PROGRAMMING LANGUAGE TRANSLATORPSEUDOCODE TO SOURCE PROGRAMMING LANGUAGE TRANSLATOR
PSEUDOCODE TO SOURCE PROGRAMMING LANGUAGE TRANSLATOR
ijistjournal
 
Phases of Compiler.pptx
Phases of Compiler.pptxPhases of Compiler.pptx
Phases of Compiler.pptx
ssuser3b4934
 

Similar to Compiler (20)

Ch 1.pptx
Ch 1.pptxCh 1.pptx
Ch 1.pptx
 
Chapter#01 cc
Chapter#01 ccChapter#01 cc
Chapter#01 cc
 
SSD Mod 2 -18CS61_Notes.pdf
SSD Mod 2 -18CS61_Notes.pdfSSD Mod 2 -18CS61_Notes.pdf
SSD Mod 2 -18CS61_Notes.pdf
 
Compiler Construction introduction
Compiler Construction introductionCompiler Construction introduction
Compiler Construction introduction
 
3.2
3.23.2
3.2
 
Assignment1
Assignment1Assignment1
Assignment1
 
Compiler_Lecture1.pdf
Compiler_Lecture1.pdfCompiler_Lecture1.pdf
Compiler_Lecture1.pdf
 
SOFTWARE TOOL FOR TRANSLATING PSEUDOCODE TO A PROGRAMMING LANGUAGE
SOFTWARE TOOL FOR TRANSLATING PSEUDOCODE TO A PROGRAMMING LANGUAGESOFTWARE TOOL FOR TRANSLATING PSEUDOCODE TO A PROGRAMMING LANGUAGE
SOFTWARE TOOL FOR TRANSLATING PSEUDOCODE TO A PROGRAMMING LANGUAGE
 
SOFTWARE TOOL FOR TRANSLATING PSEUDOCODE TO A PROGRAMMING LANGUAGE
SOFTWARE TOOL FOR TRANSLATING PSEUDOCODE TO A PROGRAMMING LANGUAGESOFTWARE TOOL FOR TRANSLATING PSEUDOCODE TO A PROGRAMMING LANGUAGE
SOFTWARE TOOL FOR TRANSLATING PSEUDOCODE TO A PROGRAMMING LANGUAGE
 
design intoduction of_COMPILER_DESIGN.pdf
design intoduction of_COMPILER_DESIGN.pdfdesign intoduction of_COMPILER_DESIGN.pdf
design intoduction of_COMPILER_DESIGN.pdf
 
Code generation errors and recovery
Code generation errors and recoveryCode generation errors and recovery
Code generation errors and recovery
 
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
 
lec00-Introduction.pdf
lec00-Introduction.pdflec00-Introduction.pdf
lec00-Introduction.pdf
 
Chapter 2 Program language translation.pptx
Chapter 2 Program language translation.pptxChapter 2 Program language translation.pptx
Chapter 2 Program language translation.pptx
 
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
 
Lexical analyzer
Lexical analyzerLexical analyzer
Lexical analyzer
 
How a Compiler Works ?
How a Compiler Works ?How a Compiler Works ?
How a Compiler Works ?
 
Cd unit i
Cd unit iCd unit i
Cd unit i
 
PSEUDOCODE TO SOURCE PROGRAMMING LANGUAGE TRANSLATOR
PSEUDOCODE TO SOURCE PROGRAMMING LANGUAGE TRANSLATORPSEUDOCODE TO SOURCE PROGRAMMING LANGUAGE TRANSLATOR
PSEUDOCODE TO SOURCE PROGRAMMING LANGUAGE TRANSLATOR
 
Phases of Compiler.pptx
Phases of Compiler.pptxPhases of Compiler.pptx
Phases of Compiler.pptx
 

Recently uploaded

addressing modes in computer architecture
addressing modes  in computer architectureaddressing modes  in computer architecture
addressing modes in computer architecture
ShahidSultan24
 
CME397 Surface Engineering- Professional Elective
CME397 Surface Engineering- Professional ElectiveCME397 Surface Engineering- Professional Elective
CME397 Surface Engineering- Professional Elective
karthi keyan
 
HYDROPOWER - Hydroelectric power generation
HYDROPOWER - Hydroelectric power generationHYDROPOWER - Hydroelectric power generation
HYDROPOWER - Hydroelectric power generation
Robbie Edward Sayers
 
Water Industry Process Automation and Control Monthly - May 2024.pdf
Water Industry Process Automation and Control Monthly - May 2024.pdfWater Industry Process Automation and Control Monthly - May 2024.pdf
Water Industry Process Automation and Control Monthly - May 2024.pdf
Water Industry Process Automation & Control
 
Cosmetic shop management system project report.pdf
Cosmetic shop management system project report.pdfCosmetic shop management system project report.pdf
Cosmetic shop management system project report.pdf
Kamal Acharya
 
Courier management system project report.pdf
Courier management system project report.pdfCourier management system project report.pdf
Courier management system project report.pdf
Kamal Acharya
 
Automobile Management System Project Report.pdf
Automobile Management System Project Report.pdfAutomobile Management System Project Report.pdf
Automobile Management System Project Report.pdf
Kamal Acharya
 
Democratizing Fuzzing at Scale by Abhishek Arya
Democratizing Fuzzing at Scale by Abhishek AryaDemocratizing Fuzzing at Scale by Abhishek Arya
Democratizing Fuzzing at Scale by Abhishek Arya
abh.arya
 
J.Yang, ICLR 2024, MLILAB, KAIST AI.pdf
J.Yang,  ICLR 2024, MLILAB, KAIST AI.pdfJ.Yang,  ICLR 2024, MLILAB, KAIST AI.pdf
J.Yang, ICLR 2024, MLILAB, KAIST AI.pdf
MLILAB
 
Student information management system project report ii.pdf
Student information management system project report ii.pdfStudent information management system project report ii.pdf
Student information management system project report ii.pdf
Kamal Acharya
 
ethical hacking in wireless-hacking1.ppt
ethical hacking in wireless-hacking1.pptethical hacking in wireless-hacking1.ppt
ethical hacking in wireless-hacking1.ppt
Jayaprasanna4
 
Hybrid optimization of pumped hydro system and solar- Engr. Abdul-Azeez.pdf
Hybrid optimization of pumped hydro system and solar- Engr. Abdul-Azeez.pdfHybrid optimization of pumped hydro system and solar- Engr. Abdul-Azeez.pdf
Hybrid optimization of pumped hydro system and solar- Engr. Abdul-Azeez.pdf
fxintegritypublishin
 
Architectural Portfolio Sean Lockwood
Architectural Portfolio Sean LockwoodArchitectural Portfolio Sean Lockwood
Architectural Portfolio Sean Lockwood
seandesed
 
Vaccine management system project report documentation..pdf
Vaccine management system project report documentation..pdfVaccine management system project report documentation..pdf
Vaccine management system project report documentation..pdf
Kamal Acharya
 
Halogenation process of chemical process industries
Halogenation process of chemical process industriesHalogenation process of chemical process industries
Halogenation process of chemical process industries
MuhammadTufail242431
 
TECHNICAL TRAINING MANUAL GENERAL FAMILIARIZATION COURSE
TECHNICAL TRAINING MANUAL   GENERAL FAMILIARIZATION COURSETECHNICAL TRAINING MANUAL   GENERAL FAMILIARIZATION COURSE
TECHNICAL TRAINING MANUAL GENERAL FAMILIARIZATION COURSE
DuvanRamosGarzon1
 
Top 10 Oil and Gas Projects in Saudi Arabia 2024.pdf
Top 10 Oil and Gas Projects in Saudi Arabia 2024.pdfTop 10 Oil and Gas Projects in Saudi Arabia 2024.pdf
Top 10 Oil and Gas Projects in Saudi Arabia 2024.pdf
Teleport Manpower Consultant
 
Gen AI Study Jams _ For the GDSC Leads in India.pdf
Gen AI Study Jams _ For the GDSC Leads in India.pdfGen AI Study Jams _ For the GDSC Leads in India.pdf
Gen AI Study Jams _ For the GDSC Leads in India.pdf
gdsczhcet
 
WATER CRISIS and its solutions-pptx 1234
WATER CRISIS and its solutions-pptx 1234WATER CRISIS and its solutions-pptx 1234
WATER CRISIS and its solutions-pptx 1234
AafreenAbuthahir2
 
Planning Of Procurement o different goods and services
Planning Of Procurement o different goods and servicesPlanning Of Procurement o different goods and services
Planning Of Procurement o different goods and services
JoytuBarua2
 

Recently uploaded (20)

addressing modes in computer architecture
addressing modes  in computer architectureaddressing modes  in computer architecture
addressing modes in computer architecture
 
CME397 Surface Engineering- Professional Elective
CME397 Surface Engineering- Professional ElectiveCME397 Surface Engineering- Professional Elective
CME397 Surface Engineering- Professional Elective
 
HYDROPOWER - Hydroelectric power generation
HYDROPOWER - Hydroelectric power generationHYDROPOWER - Hydroelectric power generation
HYDROPOWER - Hydroelectric power generation
 
Water Industry Process Automation and Control Monthly - May 2024.pdf
Water Industry Process Automation and Control Monthly - May 2024.pdfWater Industry Process Automation and Control Monthly - May 2024.pdf
Water Industry Process Automation and Control Monthly - May 2024.pdf
 
Cosmetic shop management system project report.pdf
Cosmetic shop management system project report.pdfCosmetic shop management system project report.pdf
Cosmetic shop management system project report.pdf
 
Courier management system project report.pdf
Courier management system project report.pdfCourier management system project report.pdf
Courier management system project report.pdf
 
Automobile Management System Project Report.pdf
Automobile Management System Project Report.pdfAutomobile Management System Project Report.pdf
Automobile Management System Project Report.pdf
 
Democratizing Fuzzing at Scale by Abhishek Arya
Democratizing Fuzzing at Scale by Abhishek AryaDemocratizing Fuzzing at Scale by Abhishek Arya
Democratizing Fuzzing at Scale by Abhishek Arya
 
J.Yang, ICLR 2024, MLILAB, KAIST AI.pdf
J.Yang,  ICLR 2024, MLILAB, KAIST AI.pdfJ.Yang,  ICLR 2024, MLILAB, KAIST AI.pdf
J.Yang, ICLR 2024, MLILAB, KAIST AI.pdf
 
Student information management system project report ii.pdf
Student information management system project report ii.pdfStudent information management system project report ii.pdf
Student information management system project report ii.pdf
 
ethical hacking in wireless-hacking1.ppt
ethical hacking in wireless-hacking1.pptethical hacking in wireless-hacking1.ppt
ethical hacking in wireless-hacking1.ppt
 
Hybrid optimization of pumped hydro system and solar- Engr. Abdul-Azeez.pdf
Hybrid optimization of pumped hydro system and solar- Engr. Abdul-Azeez.pdfHybrid optimization of pumped hydro system and solar- Engr. Abdul-Azeez.pdf
Hybrid optimization of pumped hydro system and solar- Engr. Abdul-Azeez.pdf
 
Architectural Portfolio Sean Lockwood
Architectural Portfolio Sean LockwoodArchitectural Portfolio Sean Lockwood
Architectural Portfolio Sean Lockwood
 
Vaccine management system project report documentation..pdf
Vaccine management system project report documentation..pdfVaccine management system project report documentation..pdf
Vaccine management system project report documentation..pdf
 
Halogenation process of chemical process industries
Halogenation process of chemical process industriesHalogenation process of chemical process industries
Halogenation process of chemical process industries
 
TECHNICAL TRAINING MANUAL GENERAL FAMILIARIZATION COURSE
TECHNICAL TRAINING MANUAL   GENERAL FAMILIARIZATION COURSETECHNICAL TRAINING MANUAL   GENERAL FAMILIARIZATION COURSE
TECHNICAL TRAINING MANUAL GENERAL FAMILIARIZATION COURSE
 
Top 10 Oil and Gas Projects in Saudi Arabia 2024.pdf
Top 10 Oil and Gas Projects in Saudi Arabia 2024.pdfTop 10 Oil and Gas Projects in Saudi Arabia 2024.pdf
Top 10 Oil and Gas Projects in Saudi Arabia 2024.pdf
 
Gen AI Study Jams _ For the GDSC Leads in India.pdf
Gen AI Study Jams _ For the GDSC Leads in India.pdfGen AI Study Jams _ For the GDSC Leads in India.pdf
Gen AI Study Jams _ For the GDSC Leads in India.pdf
 
WATER CRISIS and its solutions-pptx 1234
WATER CRISIS and its solutions-pptx 1234WATER CRISIS and its solutions-pptx 1234
WATER CRISIS and its solutions-pptx 1234
 
Planning Of Procurement o different goods and services
Planning Of Procurement o different goods and servicesPlanning Of Procurement o different goods and services
Planning Of Procurement o different goods and services
 

Compiler

  • 1. Compiler SUBMITTED BY: MD:SUMON FAKIR ID:173002024 Dept of CSE SUBMITTED TO: Md. Jahidul Islam Lecturer of CSE Green university of Bangladesh
  • 2. Table of Contents Introduction The structure of Compiler(All phases) All Phases of Compiler 1 Compiler & its Application Compiler vs Interpreter Symbol Table Management
  • 3. Table of Contents cont.. Derivations (with Examples) 2 Reference Conclusion
  • 4. Introduction 3 A compiler translates the code written in one language to some other language without changing the meaning of the program. It is also expected that a compiler should make the target code efficient and optimized in terms of time and space
  • 5. Compiler & its Application 4 A compiler is a program that reads a program written in one language and translates is into an equivalent program in another language. What is compiler ?
  • 6. Compiler & its Application cont.. 5 Application of compiler  Implementation of High-Level Programming Optimizations for Computer Architectures Design of New Computer Architectures Program Translations Software Productivity Tools
  • 7. Compiler vs Interpreter 6 1.Compiler scans the entire program and translate the whole it into machine code. 1.Interpreter translates just one statement of the program at time into machine code 2.Compiler takes a lot of time to anaylize the source code .however , the overall time taken to execute the process is much faster. 2.An interpreter takes vary less time to anaylize the source code .however, overall time to execute the process is much slower. 3.Compiler are used by program language like C and C++ for example 3.Interpreter are used by programming language like Ruby and python for example
  • 8. The Structure of Compiler (all phase ) 7 Lexical Analyzer Syntax Tree Semantic Analyzer Character stream Intermediate code generation Code Optimizer Code Generator Symbol Table manager Error Handler
  • 9. Lexical analysis coverts source program into a stream of valid word of the language, known as token. Lexical analyzer also known as(Lexer ,Scanner,Tokening ) 8 Lexical Analyzer Function of lexical Analyzer Convert the source code into stream of token. Removing white space , comments Recognizing keyword , identifier, Contents Show error when then lexeme doesn’t match of patten All phase of Compiler
  • 10. Syntax of a language refers to the structure of valid program or statement of the language. Specified using certain rules known as Productions Collection of such productions(rules) is known as grammar. Syntax Tree 9 Function of syntax tree Syntax analysis to verified that a string of token valid or not.  report syntactic error. recovery from such error so as to continuous to execution process All phase of Compiler (cont..)
  • 11. Semantic Analysis makes sure that declarations and statements of program are semantically correct. It is a collection of procedures which is called by syntax tree as and when required by grammar. Both syntax tree and symbol table are used to check the consistency of the given code. Semantic Analyzer 10 Function of syntax tree  Semantic error :Type mismatch, Undeclared variables, Reserved identifier.  Type Checking: Ensures that data types are used in a way consistent with their definition.  Label Checking –A program should contain labels references. All phase of Compiler (cont..)
  • 12. Semantic Analysis makes sure that declarations and statements of program are semantically correct. It is a collection of procedures which is called by syntax tree as and when required by grammar. Both syntax tree and symbol table are used to check the consistency of the given code. Intermediate code generation 11  Postfix Notation  Three-Address Code  Syntax Intermediate code representation All phase of Compiler (cont..)
  • 13. Optimization is a program transformation technique, which tries to improve the code by making it consume less resources example CPU, Memory and deliver high speed. In optimization, high-level general programming constructs are replaced by very efficient low-level programming codes Code Optimizer 12 Code generation can be considered as the final phase of compilation. Through post code generation, optimization process can be applied on the code Code Generator All phase of Compiler (cont..)
  • 14. 1 13 Symbol Table Manager Symbol table is an important data structure created and maintained by compilers in order to store information about the occurrence of various entities such as variable names, function names, objects, classes, interfaces, etc. Symbol table is used by both the analysis and the synthesis parts of a compiler.
  • 15. 1 14 Derivation derivation is used to find whether the string belongs to a given grammar. Type of Derivation 1. Leftmost derivation. 2. Rightmost derivation
  • 16. 1 15 Derivation cont.. Leftmost derivation Example A XYZ B  a Y b Z c SOLUTION A XYZ A aYZ A abZ A abc Rightmost derivation Example A XYZ B  a Y b Z c SOLUTION A XYZ A XYc A Xbc A abc
  • 17. 1 16 A compiler translates the code written in one language to some other language without changing the meaning of the program. It is also expected that a compiler should make the target code efficient and optimized in terms of time and space. Compiler design principles provide an in-depth view of translation and optimization process. Conclusion
  • 19. 1 18