SlideShare uma empresa Scribd logo
1 de 15
Baixar para ler offline
INTRODUCTION
TO COMPILER
DEVELOPMENT
Compiler Construction
PRESENTED BY
PRESENTED BY
PRESENTED BY
D E E P
C S - E 1 9 - 0 1 5
WHAT IS COMPILER
A compiler is a special program that processes statements written in a
particular programming language and turns them into machine language or
"code" that a computer's processor uses. Typically, a programmer writes
language statements in a language such as C++ or C one line at a time using
an editor. The file that is created contains what are called the source
statements. The programmer then runs the appropriate language compiler,
specifying the name of the file that contains the source statements.
Towards the end of the 1950s, machine-independent programming
languages were first proposed. Subsequently, several experimental
compilers were developed. The first compiler was written by Grace
Hopper, in 1952, for the A-0 programming language. The FORTRAN team
led by John Backus at IBM is generally credited as having introduced the
first complete compiler in 1957. COBOL was an early language to be
compiled on multiple architectures, in 1960
HISTORY OF COMPILER
WHY DO WE NEED A
COMPILER?
A Computer understands only binary language and executes instructions
coded in binary language. It cannot execute a single instruction given in any
other form. Therefore, we must provide instructions to the computer in binary
language. Means we must write computer programs entirely in binary
language (sequence of 0s and 1s). So, there was a need of a translator that
translates the computer instructions given in English language to binary
language.
Computers do not understand human languages. In fact, at the lowest
level, computers only understand sequences of numbers that represent
operational codes (op codes for short). On the other hand, it would be very
difficult for humans to write programs in terms of op codes. Therefore,
programming languages were invented to make it easier for humans to
write computer programs.
Programming languages are for humans to read and understand. The
program (source code) must be translated into machine language so that
the computer can execute the program (as the computer only
understands machine language). The way that this translation occurs
depends on whether the programming language is a compiled language
or an interpreted language.
HOW COMPILER WORKS
WORK OF PHASES
The compilation process is a sequence of
various phases. 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. Let us understand the phases
of a compiler.
HOW COMPILER WORK
THROUGH ITS PHASES
LEXICAL ANALYSIS


The first phase of scanner works as a text scanner. This phase scans the
source code as a stream of characters and converts it into meaningful
lexemes. Lexical analyzer represents these lexemes in the form of tokens
as:
<token-name, attribute-value>
#include <iostream>
int main() {
cout << "Hello World!";
return 0;
}
HELLO WORLD PROGRAM
SYNTAX ANALYSIS
The next phase is called the syntax analysis or
parsing. It takes the token produced by lexical
analysis as input and generates a parse tree (or
syntax tree). In this phase, token arrangements are
checked against the source code grammar, i.e. the
parser checks if the expression made by the
tokens is syntactically correct.
SEMANTIC
ANALYSIS Semantic analysis checks whether the parse tree
constructed follows the rules of language. For
example, assignment of values is between
compatible data types, and adding string to an
integer. Also, the semantic analyzer keeps track of
identifiers, their types and expressions; whether
identifiers are declared before use or not etc. The
semantic analyzer produces an annotated syntax
tree as an output.
After semantic analysis, the compiler generates an
intermediate code of the source code for the target machine.
It represents a program for some abstract machine. It is in
between the high-level language and the machine language.
This intermediate code should be generated in such a way
that it makes it easier to be translated into the target machine
code.
INTERMEDIATE CODE GENERATION
CODE OPTIMIZATION


THE NEXT PHASE DOES CODE OPTIMIZATION OF THE
INTERMEDIATE CODE. OPTIMIZATION CAN BE ASSUMED
AS SOMETHING THAT REMOVES UNNECESSARY CODE
LINES, AND ARRANGES THE SEQUENCE OF STATEMENTS
IN ORDER TO SPEED UP THE PROGRAM EXECUTION
WITHOUT WASTING RESOURCES (CPU, MEMORY).
CODE GENERATION


IN THIS PHASE, THE CODE GENERATOR TAKES THE
OPTIMIZED REPRESENTATION OF THE INTERMEDIATE
CODE AND MAPS IT TO THE TARGET MACHINE
LANGUAGE. THE CODE GENERATOR TRANSLATES THE
INTERMEDIATE CODE INTO A SEQUENCE OF (GENERALLY)
RE-LOCATABLE MACHINE CODE. SEQUENCE OF
INSTRUCTIONS OF MACHINE CODE PERFORMS THE TASK
AS THE INTERMEDIATE CODE WOULD DO.
SYMBOL TABLE


IT IS A DATA-STRUCTURE MAINTAINED THROUGHOUT ALL
THE PHASES OF A COMPILER. ALL THE IDENTIFIER'S
NAMES ALONG WITH THEIR TYPES ARE STORED HERE.
THE SYMBOL TABLE MAKES IT EASIER FOR THE
COMPILER TO QUICKLY SEARCH THE IDENTIFIER RECORD
AND RETRIEVE IT. THE SYMBOL TABLE IS ALSO USED
FOR SCOPE MANAGEMENT.
Thank you
Q&A YOU MAY ASK

Mais conteúdo relacionado

Mais procurados

BASIC Programming Language
BASIC Programming LanguageBASIC Programming Language
BASIC Programming LanguageJeff Valerio
 
Features of machine language, assembly language, high level language & their ...
Features of machine language, assembly language, high level language & their ...Features of machine language, assembly language, high level language & their ...
Features of machine language, assembly language, high level language & their ...SHUBHAM PATIDAR FISHERIES ADDAA
 
FIT-Unit3 chapter2- Computer Languages
FIT-Unit3 chapter2- Computer LanguagesFIT-Unit3 chapter2- Computer Languages
FIT-Unit3 chapter2- Computer Languagesraksharao
 
History of Programming Language
History of Programming LanguageHistory of Programming Language
History of Programming Languagetahria123
 
Programming languages
Programming languagesProgramming languages
Programming languagesvito_carleone
 
La 5 Pl Translator
La 5   Pl TranslatorLa 5   Pl Translator
La 5 Pl TranslatorCma Mohd
 
Language Translator ( Compiler)
Language Translator ( Compiler)Language Translator ( Compiler)
Language Translator ( Compiler)Nazmul Hyder
 
High Level Language (HLL)
High Level Language (HLL)High Level Language (HLL)
High Level Language (HLL)Maliha Jahan
 
Programming languages,compiler,interpreter,softwares
Programming languages,compiler,interpreter,softwaresProgramming languages,compiler,interpreter,softwares
Programming languages,compiler,interpreter,softwaresNisarg Amin
 
software development and programming languages
software development and programming languages software development and programming languages
software development and programming languages PraShant Kumar
 
Computer Language Translator
Computer Language TranslatorComputer Language Translator
Computer Language TranslatorRanjeet Kumar
 
Programming languages
Programming languagesProgramming languages
Programming languagesAkash Varaiya
 

Mais procurados (20)

BASIC Programming Language
BASIC Programming LanguageBASIC Programming Language
BASIC Programming Language
 
Chapter 5
Chapter 5Chapter 5
Chapter 5
 
Features of machine language, assembly language, high level language & their ...
Features of machine language, assembly language, high level language & their ...Features of machine language, assembly language, high level language & their ...
Features of machine language, assembly language, high level language & their ...
 
Computer programming languages
Computer programming languagesComputer programming languages
Computer programming languages
 
Computer languages 11
Computer languages 11Computer languages 11
Computer languages 11
 
FIT-Unit3 chapter2- Computer Languages
FIT-Unit3 chapter2- Computer LanguagesFIT-Unit3 chapter2- Computer Languages
FIT-Unit3 chapter2- Computer Languages
 
History of Programming Language
History of Programming LanguageHistory of Programming Language
History of Programming Language
 
compiler vs interpreter
compiler vs interpretercompiler vs interpreter
compiler vs interpreter
 
Assignment on basic programming language
Assignment on  basic programming languageAssignment on  basic programming language
Assignment on basic programming language
 
LANGUAGE TRANSLATOR
LANGUAGE TRANSLATORLANGUAGE TRANSLATOR
LANGUAGE TRANSLATOR
 
Programming languages
Programming languagesProgramming languages
Programming languages
 
La 5 Pl Translator
La 5   Pl TranslatorLa 5   Pl Translator
La 5 Pl Translator
 
What is Compiler?
What is Compiler?What is Compiler?
What is Compiler?
 
Rajesh ppt
Rajesh pptRajesh ppt
Rajesh ppt
 
Language Translator ( Compiler)
Language Translator ( Compiler)Language Translator ( Compiler)
Language Translator ( Compiler)
 
High Level Language (HLL)
High Level Language (HLL)High Level Language (HLL)
High Level Language (HLL)
 
Programming languages,compiler,interpreter,softwares
Programming languages,compiler,interpreter,softwaresProgramming languages,compiler,interpreter,softwares
Programming languages,compiler,interpreter,softwares
 
software development and programming languages
software development and programming languages software development and programming languages
software development and programming languages
 
Computer Language Translator
Computer Language TranslatorComputer Language Translator
Computer Language Translator
 
Programming languages
Programming languagesProgramming languages
Programming languages
 

Semelhante a Introduction to compiler development

2 Programming Language.pdf
2 Programming Language.pdf2 Programming Language.pdf
2 Programming Language.pdfKINGZzofYouTube
 
Compiler_Lecture1.pdf
Compiler_Lecture1.pdfCompiler_Lecture1.pdf
Compiler_Lecture1.pdfAkarTaher
 
Chapter 2 Program language translation.pptx
Chapter 2 Program language translation.pptxChapter 2 Program language translation.pptx
Chapter 2 Program language translation.pptxdawod yimer
 
computerprogramminglanguages-201216152310.pptx
computerprogramminglanguages-201216152310.pptxcomputerprogramminglanguages-201216152310.pptx
computerprogramminglanguages-201216152310.pptxSubramanian Mani
 
Language translators
Language translatorsLanguage translators
Language translatorsAditya Sharat
 
Insight into progam execution ppt
Insight into progam execution pptInsight into progam execution ppt
Insight into progam execution pptKeerty Smile
 
Compiler design slide share
Compiler design slide shareCompiler design slide share
Compiler design slide shareSudhaa Ravi
 
Compiler Construction Lecture One .pptx
Compiler Construction Lecture One  .pptxCompiler Construction Lecture One  .pptx
Compiler Construction Lecture One .pptxانشال عارف
 
Software programming and development
Software programming and developmentSoftware programming and development
Software programming and developmentAli Raza
 
basics of compiler design
basics of compiler designbasics of compiler design
basics of compiler designPreeti Katiyar
 
Introduction to Programming Concepts By Aamir Saleem Ansari
Introduction to Programming Concepts By Aamir Saleem AnsariIntroduction to Programming Concepts By Aamir Saleem Ansari
Introduction to Programming Concepts By Aamir Saleem AnsariTech
 
Introduction to computer programming
Introduction to computer programmingIntroduction to computer programming
Introduction to computer programmingNoel Malle
 
COMPILER DESIGN OPTIONS
COMPILER DESIGN OPTIONSCOMPILER DESIGN OPTIONS
COMPILER DESIGN OPTIONSsonalikharade3
 
Basic programming concepts
Basic programming conceptsBasic programming concepts
Basic programming conceptssalmankhan570
 

Semelhante a Introduction to compiler development (20)

2 Programming Language.pdf
2 Programming Language.pdf2 Programming Language.pdf
2 Programming Language.pdf
 
Compiler_Lecture1.pdf
Compiler_Lecture1.pdfCompiler_Lecture1.pdf
Compiler_Lecture1.pdf
 
Chapter 2 Program language translation.pptx
Chapter 2 Program language translation.pptxChapter 2 Program language translation.pptx
Chapter 2 Program language translation.pptx
 
Chapter1.pdf
Chapter1.pdfChapter1.pdf
Chapter1.pdf
 
computerprogramminglanguages-201216152310.pptx
computerprogramminglanguages-201216152310.pptxcomputerprogramminglanguages-201216152310.pptx
computerprogramminglanguages-201216152310.pptx
 
Language translators
Language translatorsLanguage translators
Language translators
 
Insight into progam execution ppt
Insight into progam execution pptInsight into progam execution ppt
Insight into progam execution ppt
 
Compiler design slide share
Compiler design slide shareCompiler design slide share
Compiler design slide share
 
Assembler
AssemblerAssembler
Assembler
 
Unit 1
Unit 1Unit 1
Unit 1
 
Compiler Construction Lecture One .pptx
Compiler Construction Lecture One  .pptxCompiler Construction Lecture One  .pptx
Compiler Construction Lecture One .pptx
 
Software programming and development
Software programming and developmentSoftware programming and development
Software programming and development
 
basics of compiler design
basics of compiler designbasics of compiler design
basics of compiler design
 
Introduction to Programming Concepts By Aamir Saleem Ansari
Introduction to Programming Concepts By Aamir Saleem AnsariIntroduction to Programming Concepts By Aamir Saleem Ansari
Introduction to Programming Concepts By Aamir Saleem Ansari
 
Introduction to computer programming
Introduction to computer programmingIntroduction to computer programming
Introduction to computer programming
 
COMPILER DESIGN OPTIONS
COMPILER DESIGN OPTIONSCOMPILER DESIGN OPTIONS
COMPILER DESIGN OPTIONS
 
COMPILER DESIGN.docx
COMPILER DESIGN.docxCOMPILER DESIGN.docx
COMPILER DESIGN.docx
 
df
dfdf
df
 
Chapter#01 cc
Chapter#01 ccChapter#01 cc
Chapter#01 cc
 
Basic programming concepts
Basic programming conceptsBasic programming concepts
Basic programming concepts
 

Último

AWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAndrey Devyatkin
 
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ..."I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...Zilliz
 
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...apidays
 
MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MIND CTI
 
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...Orbitshub
 
Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...apidays
 
FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024The Digital Insurer
 
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...DianaGray10
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FMESafe Software
 
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc
 
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...apidays
 
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...Angeliki Cooney
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024The Digital Insurer
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century educationjfdjdjcjdnsjd
 
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...Zilliz
 
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...Jeffrey Haguewood
 
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodPolkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodJuan lago vázquez
 
Artificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyArtificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyKhushali Kathiriya
 
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdfRising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdfOrbitshub
 

Último (20)

AWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of Terraform
 
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ..."I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
 
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
 
MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024
 
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
 
Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...
 
FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024
 
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
 
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
 
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
 
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century education
 
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
 
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
 
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodPolkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
 
Artificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyArtificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : Uncertainty
 
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdfRising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
 
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
 

Introduction to compiler development

  • 1. INTRODUCTION TO COMPILER DEVELOPMENT Compiler Construction PRESENTED BY PRESENTED BY PRESENTED BY D E E P C S - E 1 9 - 0 1 5
  • 2. WHAT IS COMPILER A compiler is a special program that processes statements written in a particular programming language and turns them into machine language or "code" that a computer's processor uses. Typically, a programmer writes language statements in a language such as C++ or C one line at a time using an editor. The file that is created contains what are called the source statements. The programmer then runs the appropriate language compiler, specifying the name of the file that contains the source statements.
  • 3. Towards the end of the 1950s, machine-independent programming languages were first proposed. Subsequently, several experimental compilers were developed. The first compiler was written by Grace Hopper, in 1952, for the A-0 programming language. The FORTRAN team led by John Backus at IBM is generally credited as having introduced the first complete compiler in 1957. COBOL was an early language to be compiled on multiple architectures, in 1960 HISTORY OF COMPILER
  • 4. WHY DO WE NEED A COMPILER? A Computer understands only binary language and executes instructions coded in binary language. It cannot execute a single instruction given in any other form. Therefore, we must provide instructions to the computer in binary language. Means we must write computer programs entirely in binary language (sequence of 0s and 1s). So, there was a need of a translator that translates the computer instructions given in English language to binary language.
  • 5. Computers do not understand human languages. In fact, at the lowest level, computers only understand sequences of numbers that represent operational codes (op codes for short). On the other hand, it would be very difficult for humans to write programs in terms of op codes. Therefore, programming languages were invented to make it easier for humans to write computer programs. Programming languages are for humans to read and understand. The program (source code) must be translated into machine language so that the computer can execute the program (as the computer only understands machine language). The way that this translation occurs depends on whether the programming language is a compiled language or an interpreted language. HOW COMPILER WORKS
  • 6. WORK OF PHASES The compilation process is a sequence of various phases. 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. Let us understand the phases of a compiler. HOW COMPILER WORK THROUGH ITS PHASES
  • 7. LEXICAL ANALYSIS The first phase of scanner works as a text scanner. This phase scans the source code as a stream of characters and converts it into meaningful lexemes. Lexical analyzer represents these lexemes in the form of tokens as: <token-name, attribute-value>
  • 8. #include <iostream> int main() { cout << "Hello World!"; return 0; } HELLO WORLD PROGRAM
  • 9. SYNTAX ANALYSIS The next phase is called the syntax analysis or parsing. It takes the token produced by lexical analysis as input and generates a parse tree (or syntax tree). In this phase, token arrangements are checked against the source code grammar, i.e. the parser checks if the expression made by the tokens is syntactically correct.
  • 10. SEMANTIC ANALYSIS Semantic analysis checks whether the parse tree constructed follows the rules of language. For example, assignment of values is between compatible data types, and adding string to an integer. Also, the semantic analyzer keeps track of identifiers, their types and expressions; whether identifiers are declared before use or not etc. The semantic analyzer produces an annotated syntax tree as an output.
  • 11. After semantic analysis, the compiler generates an intermediate code of the source code for the target machine. It represents a program for some abstract machine. It is in between the high-level language and the machine language. This intermediate code should be generated in such a way that it makes it easier to be translated into the target machine code. INTERMEDIATE CODE GENERATION
  • 12. CODE OPTIMIZATION THE NEXT PHASE DOES CODE OPTIMIZATION OF THE INTERMEDIATE CODE. OPTIMIZATION CAN BE ASSUMED AS SOMETHING THAT REMOVES UNNECESSARY CODE LINES, AND ARRANGES THE SEQUENCE OF STATEMENTS IN ORDER TO SPEED UP THE PROGRAM EXECUTION WITHOUT WASTING RESOURCES (CPU, MEMORY).
  • 13. CODE GENERATION IN THIS PHASE, THE CODE GENERATOR TAKES THE OPTIMIZED REPRESENTATION OF THE INTERMEDIATE CODE AND MAPS IT TO THE TARGET MACHINE LANGUAGE. THE CODE GENERATOR TRANSLATES THE INTERMEDIATE CODE INTO A SEQUENCE OF (GENERALLY) RE-LOCATABLE MACHINE CODE. SEQUENCE OF INSTRUCTIONS OF MACHINE CODE PERFORMS THE TASK AS THE INTERMEDIATE CODE WOULD DO.
  • 14. SYMBOL TABLE IT IS A DATA-STRUCTURE MAINTAINED THROUGHOUT ALL THE PHASES OF A COMPILER. ALL THE IDENTIFIER'S NAMES ALONG WITH THEIR TYPES ARE STORED HERE. THE SYMBOL TABLE MAKES IT EASIER FOR THE COMPILER TO QUICKLY SEARCH THE IDENTIFIER RECORD AND RETRIEVE IT. THE SYMBOL TABLE IS ALSO USED FOR SCOPE MANAGEMENT.
  • 15. Thank you Q&A YOU MAY ASK