SlideShare a Scribd company logo
1 of 10
Introduction to Compiler
              Construction
•   1
Objectives
• Be able to build a compiler for a (simplified)
  (programming) language
• Know how to use compiler construction tools,
  such as generators of scanners and parsers
• Be familiar with assembly code and virtual
  machines, such as the JVM, and bytecode
• Be able to define LL(1), LR(1), and LALR(1)
  grammars
• Be familiar with compiler analysis and
  optimization techniques
• … learn how to work on a larger software project!
                                                      2
Compilers and Interpreters
 • “Compilation”
    – Translation of a program written in a source
      language into a semantically equivalent
      program written in a target language
    – Oversimplified view:
                                                Input


 Source                                        Target
                      Compiler
Program                                       Program


                    Error messages             Output3
Compilers and Interpreters
              (cont’d)
 • “Interpretation”
    – Performing the operations implied by the
      source program
    – Oversimplified view:


 Source
Program
                      Interpreter           Output
  Input

                   Error messages                    4
The Analysis-Synthesis Model of
         Compilation

• There are two parts to compilation:
  – Analysis determines the operations implied by
    the source program which are recorded in a tree
    structure
  – Synthesis takes the tree structure and translates
    the operations therein into the target program



                                                    5
Other Tools that Use the
      Analysis-Synthesis Model
•   Editors (syntax highlighting)
•   Pretty printers (e.g. Doxygen)
•   Static checkers (e.g. Lint and Splint)
•   Interpreters
•   Text formatters (e.g. TeX and LaTeX)
•   Silicon compilers (e.g. VHDL)
•   Query interpreters/compilers (Databases)

                                               6
Preprocessors, Compilers,
          Assemblers, and Linkers
                        Skeletal Source Program

                             Preprocessor
                    Source Program
                                                    Try for example:
                               Compiler
                                                   gcc -v myprog.c
    Target Assembly Program
                        Assembler
   Relocatable Object Code
                          Linker                     Libraries and
                                                Relocatable Object Files
COP5621 Fall 2011                                                 7
                        Absolute Machine Code
The Grouping of Phases
• Compiler front and back ends:
   – Front end: analysis (machine independent)
   – Back end: synthesis (machine dependent)
• Compiler passes:
   – A collection of phases is done only once (single pass)
     or multiple times (multi pass)
      • Single pass: usually requires everything to be defined before
        being used in source program
      • Multi pass: compiler may have to keep entire program
        representation in memory



                                                                        8
Compiler-Construction Tools
• Software development tools are available to
  implement one or more compiler phases
  –   Scanner generators
  –   Parser generators
  –   Syntax-directed translation engines
  –   Automatic code generators
  –   Data-flow engines



                                                9
Outline
•   Introduction
•   A simple One-Pass Compiler for the JVM
•   Lexical Analysis and Lex/Flex
•   Syntax Analysis and Yacc/Bison
•   Syntax-Directed Translation
•   Static Semantics and Type Checking
•   Run-Time Environments
•   Intermediate Code Generation
•   Target Code Generation
•   Code Optimization
COP5621 Fall 2011                            10

More Related Content

What's hot

Unit 3
Unit 3Unit 3
Unit 3pm_ghate
 
Lexical Analysis
Lexical AnalysisLexical Analysis
Lexical AnalysisNayemid4676
 
Debuggers in system software
Debuggers in system softwareDebuggers in system software
Debuggers in system softwaregayathri ravi
 
Compiler Design
Compiler DesignCompiler Design
Compiler DesignMir Majid
 
Lecture 10 semantic analysis 01
Lecture 10 semantic analysis 01Lecture 10 semantic analysis 01
Lecture 10 semantic analysis 01Iffat Anjum
 
Predictive parser
Predictive parserPredictive parser
Predictive parserJothi Lakshmi
 
Lexical analyzer
Lexical analyzerLexical analyzer
Lexical analyzerPrincess Doll
 
Data link control & protocol concepts
Data link control & protocol conceptsData link control & protocol concepts
Data link control & protocol conceptsRaji Lakshmi
 
Syntax Analysis in Compiler Design
Syntax Analysis in Compiler Design Syntax Analysis in Compiler Design
Syntax Analysis in Compiler Design MAHASREEM
 
SRS(software requirement specification)
SRS(software requirement specification)SRS(software requirement specification)
SRS(software requirement specification)Akash Kumar Dhameja
 
2 phase locking protocol DBMS
2 phase locking protocol DBMS2 phase locking protocol DBMS
2 phase locking protocol DBMSDhananjaysinh Jhala
 
Linux commands
Linux commandsLinux commands
Linux commandsMannu Khani
 
Top down parsing
Top down parsingTop down parsing
Top down parsingPrankit Mishra
 
Language for specifying lexical Analyzer
Language for specifying lexical AnalyzerLanguage for specifying lexical Analyzer
Language for specifying lexical AnalyzerArchana Gopinath
 

What's hot (20)

Unit 3
Unit 3Unit 3
Unit 3
 
Lexical Analysis
Lexical AnalysisLexical Analysis
Lexical Analysis
 
Debuggers in system software
Debuggers in system softwareDebuggers in system software
Debuggers in system software
 
Context free grammar
Context free grammar Context free grammar
Context free grammar
 
Compiler Design
Compiler DesignCompiler Design
Compiler Design
 
Lecture 10 semantic analysis 01
Lecture 10 semantic analysis 01Lecture 10 semantic analysis 01
Lecture 10 semantic analysis 01
 
Phases of Compiler
Phases of CompilerPhases of Compiler
Phases of Compiler
 
Predictive parser
Predictive parserPredictive parser
Predictive parser
 
Lexical analyzer
Lexical analyzerLexical analyzer
Lexical analyzer
 
Data link control & protocol concepts
Data link control & protocol conceptsData link control & protocol concepts
Data link control & protocol concepts
 
Syntax Analysis in Compiler Design
Syntax Analysis in Compiler Design Syntax Analysis in Compiler Design
Syntax Analysis in Compiler Design
 
Software Engineering Practice
Software Engineering PracticeSoftware Engineering Practice
Software Engineering Practice
 
Specification-of-tokens
Specification-of-tokensSpecification-of-tokens
Specification-of-tokens
 
SRS(software requirement specification)
SRS(software requirement specification)SRS(software requirement specification)
SRS(software requirement specification)
 
2 phase locking protocol DBMS
2 phase locking protocol DBMS2 phase locking protocol DBMS
2 phase locking protocol DBMS
 
Linux commands
Linux commandsLinux commands
Linux commands
 
Compiler design
Compiler designCompiler design
Compiler design
 
Top down parsing
Top down parsingTop down parsing
Top down parsing
 
Language for specifying lexical Analyzer
Language for specifying lexical AnalyzerLanguage for specifying lexical Analyzer
Language for specifying lexical Analyzer
 
Compilers
CompilersCompilers
Compilers
 

Viewers also liked

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 compileradilmehmood93
 
Phases of the Compiler - Systems Programming
Phases of the Compiler - Systems ProgrammingPhases of the Compiler - Systems Programming
Phases of the Compiler - Systems ProgrammingMukesh Tekwani
 
Compiler Construction
Compiler ConstructionCompiler Construction
Compiler ConstructionSarmad Ali
 
Compiler Construction Course - Introduction
Compiler Construction Course - IntroductionCompiler Construction Course - Introduction
Compiler Construction Course - IntroductionMuhammad Sanaullah
 
Compiler Design - Introduction to Compiler
Compiler Design - Introduction to CompilerCompiler Design - Introduction to Compiler
Compiler Design - Introduction to CompilerIffat Anjum
 
compiler and their types
compiler and their typescompiler and their types
compiler and their typespatchamounika7
 
Lecture 11 semantic analysis 2
Lecture 11 semantic analysis 2Lecture 11 semantic analysis 2
Lecture 11 semantic analysis 2Iffat Anjum
 
Syntax directed translation
Syntax directed translationSyntax directed translation
Syntax directed translationAkshaya Arunan
 
Compiler Design Basics
Compiler Design BasicsCompiler Design Basics
Compiler Design BasicsAkhil Kaushik
 
Lexical analyzer
Lexical analyzerLexical analyzer
Lexical analyzerkiran acharya
 
Ktu - s1 me module 1 (Calculus Module 1)
Ktu  - s1 me module 1 (Calculus Module 1)Ktu  - s1 me module 1 (Calculus Module 1)
Ktu - s1 me module 1 (Calculus Module 1)Anoop T Vilakkuvettom
 
Compiler Construction
Compiler ConstructionCompiler Construction
Compiler ConstructionAhmed Raza
 
Lecture 1 introduction to language processors
Lecture 1  introduction to language processorsLecture 1  introduction to language processors
Lecture 1 introduction to language processorsRebaz Najeeb
 
Register Allocation
Register AllocationRegister Allocation
Register AllocationEelco Visser
 

Viewers also liked (20)

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
 
Phases of the Compiler - Systems Programming
Phases of the Compiler - Systems ProgrammingPhases of the Compiler - Systems Programming
Phases of the Compiler - Systems Programming
 
Compiler Construction
Compiler ConstructionCompiler Construction
Compiler Construction
 
Compiler Construction Course - Introduction
Compiler Construction Course - IntroductionCompiler Construction Course - Introduction
Compiler Construction Course - Introduction
 
Compiler construction
Compiler constructionCompiler construction
Compiler construction
 
Compiler Design - Introduction to Compiler
Compiler Design - Introduction to CompilerCompiler Design - Introduction to Compiler
Compiler Design - Introduction to Compiler
 
Lexical analyzer
Lexical analyzerLexical analyzer
Lexical analyzer
 
Compiler
CompilerCompiler
Compiler
 
compiler and their types
compiler and their typescompiler and their types
compiler and their types
 
Lecture 11 semantic analysis 2
Lecture 11 semantic analysis 2Lecture 11 semantic analysis 2
Lecture 11 semantic analysis 2
 
Syntax directed translation
Syntax directed translationSyntax directed translation
Syntax directed translation
 
Compiler Design Basics
Compiler Design BasicsCompiler Design Basics
Compiler Design Basics
 
Ch5a
Ch5aCh5a
Ch5a
 
Lexical analyzer
Lexical analyzerLexical analyzer
Lexical analyzer
 
Input-Buffering
Input-BufferingInput-Buffering
Input-Buffering
 
Recognition-of-tokens
Recognition-of-tokensRecognition-of-tokens
Recognition-of-tokens
 
Ktu - s1 me module 1 (Calculus Module 1)
Ktu  - s1 me module 1 (Calculus Module 1)Ktu  - s1 me module 1 (Calculus Module 1)
Ktu - s1 me module 1 (Calculus Module 1)
 
Compiler Construction
Compiler ConstructionCompiler Construction
Compiler Construction
 
Lecture 1 introduction to language processors
Lecture 1  introduction to language processorsLecture 1  introduction to language processors
Lecture 1 introduction to language processors
 
Register Allocation
Register AllocationRegister Allocation
Register Allocation
 

Similar to Compiler Construction

4_5802928814682016556.pptx
4_5802928814682016556.pptx4_5802928814682016556.pptx
4_5802928814682016556.pptxAshenafiGirma5
 
Cd ch1 - introduction
Cd   ch1 - introductionCd   ch1 - introduction
Cd ch1 - introductionmengistu23
 
CD - CH1 - Introduction to compiler design.pptx
CD - CH1 - Introduction to compiler design.pptxCD - CH1 - Introduction to compiler design.pptx
CD - CH1 - Introduction to compiler design.pptxZiyadMohammed17
 
System software
System softwareSystem software
System softwareSenthil Kanth
 
Compiler Design Basics
Compiler Design BasicsCompiler Design Basics
Compiler Design BasicsAkhil Kaushik
 
Compiler Design Introduction
Compiler Design IntroductionCompiler Design Introduction
Compiler Design IntroductionKuppusamy P
 
Overall 23 11_2007_hdp
Overall 23 11_2007_hdpOverall 23 11_2007_hdp
Overall 23 11_2007_hdpMohd Arif
 
Introduction to Compilers
Introduction to CompilersIntroduction to Compilers
Introduction to CompilersAkhil Kaushik
 
1 introduction to compiler
1 introduction to compiler1 introduction to compiler
1 introduction to compilerBarwarBadradin
 
Ch1 (1).ppt
Ch1 (1).pptCh1 (1).ppt
Ch1 (1).pptMDSayem35
 
Compiler Design Introduction
Compiler Design Introduction Compiler Design Introduction
Compiler Design Introduction Thapar Institute
 
Compiler design
Compiler designCompiler design
Compiler designsuganyasanjai
 
Cd econtent link1
Cd econtent link1Cd econtent link1
Cd econtent link1suganyasanjai
 
Introduction to Compiler design
Introduction to Compiler design Introduction to Compiler design
Introduction to Compiler design Dr. C.V. Suresh Babu
 
Language processor
Language processorLanguage processor
Language processorAbha Damani
 
.NET Core, ASP.NET Core Course, Session 3
.NET Core, ASP.NET Core Course, Session 3.NET Core, ASP.NET Core Course, Session 3
.NET Core, ASP.NET Core Course, Session 3aminmesbahi
 

Similar to Compiler Construction (20)

4_5802928814682016556.pptx
4_5802928814682016556.pptx4_5802928814682016556.pptx
4_5802928814682016556.pptx
 
Cd ch1 - introduction
Cd   ch1 - introductionCd   ch1 - introduction
Cd ch1 - introduction
 
CD - CH1 - Introduction to compiler design.pptx
CD - CH1 - Introduction to compiler design.pptxCD - CH1 - Introduction to compiler design.pptx
CD - CH1 - Introduction to compiler design.pptx
 
Chap01-Intro.ppt
Chap01-Intro.pptChap01-Intro.ppt
Chap01-Intro.ppt
 
System software
System softwareSystem software
System software
 
COMPILER DESIGN PPTS.pptx
COMPILER DESIGN PPTS.pptxCOMPILER DESIGN PPTS.pptx
COMPILER DESIGN PPTS.pptx
 
Compiler Design Basics
Compiler Design BasicsCompiler Design Basics
Compiler Design Basics
 
Compiler Design Introduction
Compiler Design IntroductionCompiler Design Introduction
Compiler Design Introduction
 
Cd unit i
Cd unit iCd unit i
Cd unit i
 
Overall 23 11_2007_hdp
Overall 23 11_2007_hdpOverall 23 11_2007_hdp
Overall 23 11_2007_hdp
 
Introduction to Compilers
Introduction to CompilersIntroduction to Compilers
Introduction to Compilers
 
1 introduction to compiler
1 introduction to compiler1 introduction to compiler
1 introduction to compiler
 
Ch1 (1).ppt
Ch1 (1).pptCh1 (1).ppt
Ch1 (1).ppt
 
Compiler Design Introduction
Compiler Design Introduction Compiler Design Introduction
Compiler Design Introduction
 
Compiler design
Compiler designCompiler design
Compiler design
 
Cd econtent link1
Cd econtent link1Cd econtent link1
Cd econtent link1
 
Compiler1
Compiler1Compiler1
Compiler1
 
Introduction to Compiler design
Introduction to Compiler design Introduction to Compiler design
Introduction to Compiler design
 
Language processor
Language processorLanguage processor
Language processor
 
.NET Core, ASP.NET Core Course, Session 3
.NET Core, ASP.NET Core Course, Session 3.NET Core, ASP.NET Core Course, Session 3
.NET Core, ASP.NET Core Course, Session 3
 

More from Army Public School and College -Faisal

More from Army Public School and College -Faisal (20)

SENSOR WHITEBOARDS
SENSOR WHITEBOARDSSENSOR WHITEBOARDS
SENSOR WHITEBOARDS
 
INPUT AND OUTPUT DEVICES
INPUT AND OUTPUT DEVICESINPUT AND OUTPUT DEVICES
INPUT AND OUTPUT DEVICES
 
INPUT AND OUTPUT DEVICES
INPUT AND OUTPUT DEVICESINPUT AND OUTPUT DEVICES
INPUT AND OUTPUT DEVICES
 
2d and 3d cutters
2d and 3d cutters 2d and 3d cutters
2d and 3d cutters
 
SCANNERS /BARCODE
SCANNERS /BARCODE SCANNERS /BARCODE
SCANNERS /BARCODE
 
3D PRINTERS
3D PRINTERS3D PRINTERS
3D PRINTERS
 
Operaing system
Operaing systemOperaing system
Operaing system
 
Module 2 handouts part 2
Module 2 handouts part 2Module 2 handouts part 2
Module 2 handouts part 2
 
Module 2 handouts part 1
Module 2 handouts part 1Module 2 handouts part 1
Module 2 handouts part 1
 
Module 1 ELECTRONICS
Module 1  ELECTRONICSModule 1  ELECTRONICS
Module 1 ELECTRONICS
 
Module 1
Module 1 Module 1
Module 1
 
Cookies may be set by the website you are visiting
Cookies may be set by the website you are visitingCookies may be set by the website you are visiting
Cookies may be set by the website you are visiting
 
Css
CssCss
Css
 
python 1
python 1python 1
python 1
 
Boolean and comparison_instructions
Boolean and comparison_instructionsBoolean and comparison_instructions
Boolean and comparison_instructions
 
hadoop_module
hadoop_modulehadoop_module
hadoop_module
 
Polymorphism (2)
Polymorphism (2)Polymorphism (2)
Polymorphism (2)
 
Object Oriented Programming
Object Oriented ProgrammingObject Oriented Programming
Object Oriented Programming
 
Presentation 2
Presentation 2Presentation 2
Presentation 2
 
Lecture 1 progrmming with C
Lecture 1 progrmming with C Lecture 1 progrmming with C
Lecture 1 progrmming with C
 

Recently uploaded

Hybridoma Technology ( Production , Purification , and Application )
Hybridoma Technology  ( Production , Purification , and Application  ) Hybridoma Technology  ( Production , Purification , and Application  )
Hybridoma Technology ( Production , Purification , and Application ) Sakshi Ghasle
 
Separation of Lanthanides/ Lanthanides and Actinides
Separation of Lanthanides/ Lanthanides and ActinidesSeparation of Lanthanides/ Lanthanides and Actinides
Separation of Lanthanides/ Lanthanides and ActinidesFatimaKhan178732
 
Alper Gobel In Media Res Media Component
Alper Gobel In Media Res Media ComponentAlper Gobel In Media Res Media Component
Alper Gobel In Media Res Media ComponentInMediaRes1
 
Employee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptxEmployee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptxNirmalaLoungPoorunde1
 
Sanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdfSanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdfsanyamsingh5019
 
_Math 4-Q4 Week 5.pptx Steps in Collecting Data
_Math 4-Q4 Week 5.pptx Steps in Collecting Data_Math 4-Q4 Week 5.pptx Steps in Collecting Data
_Math 4-Q4 Week 5.pptx Steps in Collecting DataJhengPantaleon
 
Introduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptxIntroduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptxpboyjonauth
 
Micromeritics - Fundamental and Derived Properties of Powders
Micromeritics - Fundamental and Derived Properties of PowdersMicromeritics - Fundamental and Derived Properties of Powders
Micromeritics - Fundamental and Derived Properties of PowdersChitralekhaTherkar
 
Crayon Activity Handout For the Crayon A
Crayon Activity Handout For the Crayon ACrayon Activity Handout For the Crayon A
Crayon Activity Handout For the Crayon AUnboundStockton
 
Q4-W6-Restating Informational Text Grade 3
Q4-W6-Restating Informational Text Grade 3Q4-W6-Restating Informational Text Grade 3
Q4-W6-Restating Informational Text Grade 3JemimahLaneBuaron
 
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxSOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxiammrhaywood
 
Solving Puzzles Benefits Everyone (English).pptx
Solving Puzzles Benefits Everyone (English).pptxSolving Puzzles Benefits Everyone (English).pptx
Solving Puzzles Benefits Everyone (English).pptxOH TEIK BIN
 
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdfssuser54595a
 
CARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptxCARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptxGaneshChakor2
 
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17Incoming and Outgoing Shipments in 1 STEP Using Odoo 17
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17Celine George
 
Science 7 - LAND and SEA BREEZE and its Characteristics
Science 7 - LAND and SEA BREEZE and its CharacteristicsScience 7 - LAND and SEA BREEZE and its Characteristics
Science 7 - LAND and SEA BREEZE and its CharacteristicsKarinaGenton
 
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdfBASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdfSoniaTolstoy
 

Recently uploaded (20)

Hybridoma Technology ( Production , Purification , and Application )
Hybridoma Technology  ( Production , Purification , and Application  ) Hybridoma Technology  ( Production , Purification , and Application  )
Hybridoma Technology ( Production , Purification , and Application )
 
TataKelola dan KamSiber Kecerdasan Buatan v022.pdf
TataKelola dan KamSiber Kecerdasan Buatan v022.pdfTataKelola dan KamSiber Kecerdasan Buatan v022.pdf
TataKelola dan KamSiber Kecerdasan Buatan v022.pdf
 
Separation of Lanthanides/ Lanthanides and Actinides
Separation of Lanthanides/ Lanthanides and ActinidesSeparation of Lanthanides/ Lanthanides and Actinides
Separation of Lanthanides/ Lanthanides and Actinides
 
Alper Gobel In Media Res Media Component
Alper Gobel In Media Res Media ComponentAlper Gobel In Media Res Media Component
Alper Gobel In Media Res Media Component
 
Employee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptxEmployee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptx
 
Sanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdfSanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdf
 
Staff of Color (SOC) Retention Efforts DDSD
Staff of Color (SOC) Retention Efforts DDSDStaff of Color (SOC) Retention Efforts DDSD
Staff of Color (SOC) Retention Efforts DDSD
 
_Math 4-Q4 Week 5.pptx Steps in Collecting Data
_Math 4-Q4 Week 5.pptx Steps in Collecting Data_Math 4-Q4 Week 5.pptx Steps in Collecting Data
_Math 4-Q4 Week 5.pptx Steps in Collecting Data
 
Introduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptxIntroduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptx
 
Micromeritics - Fundamental and Derived Properties of Powders
Micromeritics - Fundamental and Derived Properties of PowdersMicromeritics - Fundamental and Derived Properties of Powders
Micromeritics - Fundamental and Derived Properties of Powders
 
Model Call Girl in Bikash Puri Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Bikash Puri  Delhi reach out to us at 🔝9953056974🔝Model Call Girl in Bikash Puri  Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Bikash Puri Delhi reach out to us at 🔝9953056974🔝
 
Crayon Activity Handout For the Crayon A
Crayon Activity Handout For the Crayon ACrayon Activity Handout For the Crayon A
Crayon Activity Handout For the Crayon A
 
Q4-W6-Restating Informational Text Grade 3
Q4-W6-Restating Informational Text Grade 3Q4-W6-Restating Informational Text Grade 3
Q4-W6-Restating Informational Text Grade 3
 
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxSOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
 
Solving Puzzles Benefits Everyone (English).pptx
Solving Puzzles Benefits Everyone (English).pptxSolving Puzzles Benefits Everyone (English).pptx
Solving Puzzles Benefits Everyone (English).pptx
 
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
 
CARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptxCARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptx
 
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17Incoming and Outgoing Shipments in 1 STEP Using Odoo 17
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17
 
Science 7 - LAND and SEA BREEZE and its Characteristics
Science 7 - LAND and SEA BREEZE and its CharacteristicsScience 7 - LAND and SEA BREEZE and its Characteristics
Science 7 - LAND and SEA BREEZE and its Characteristics
 
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdfBASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdf
 

Compiler Construction

  • 1. Introduction to Compiler Construction • 1
  • 2. Objectives • Be able to build a compiler for a (simplified) (programming) language • Know how to use compiler construction tools, such as generators of scanners and parsers • Be familiar with assembly code and virtual machines, such as the JVM, and bytecode • Be able to define LL(1), LR(1), and LALR(1) grammars • Be familiar with compiler analysis and optimization techniques • … learn how to work on a larger software project! 2
  • 3. Compilers and Interpreters • “Compilation” – Translation of a program written in a source language into a semantically equivalent program written in a target language – Oversimplified view: Input Source Target Compiler Program Program Error messages Output3
  • 4. Compilers and Interpreters (cont’d) • “Interpretation” – Performing the operations implied by the source program – Oversimplified view: Source Program Interpreter Output Input Error messages 4
  • 5. The Analysis-Synthesis Model of Compilation • There are two parts to compilation: – Analysis determines the operations implied by the source program which are recorded in a tree structure – Synthesis takes the tree structure and translates the operations therein into the target program 5
  • 6. Other Tools that Use the Analysis-Synthesis Model • Editors (syntax highlighting) • Pretty printers (e.g. Doxygen) • Static checkers (e.g. Lint and Splint) • Interpreters • Text formatters (e.g. TeX and LaTeX) • Silicon compilers (e.g. VHDL) • Query interpreters/compilers (Databases) 6
  • 7. Preprocessors, Compilers, Assemblers, and Linkers Skeletal Source Program Preprocessor Source Program Try for example: Compiler gcc -v myprog.c Target Assembly Program Assembler Relocatable Object Code Linker Libraries and Relocatable Object Files COP5621 Fall 2011 7 Absolute Machine Code
  • 8. The Grouping of Phases • Compiler front and back ends: – Front end: analysis (machine independent) – Back end: synthesis (machine dependent) • Compiler passes: – A collection of phases is done only once (single pass) or multiple times (multi pass) • Single pass: usually requires everything to be defined before being used in source program • Multi pass: compiler may have to keep entire program representation in memory 8
  • 9. Compiler-Construction Tools • Software development tools are available to implement one or more compiler phases – Scanner generators – Parser generators – Syntax-directed translation engines – Automatic code generators – Data-flow engines 9
  • 10. Outline • Introduction • A simple One-Pass Compiler for the JVM • Lexical Analysis and Lex/Flex • Syntax Analysis and Yacc/Bison • Syntax-Directed Translation • Static Semantics and Type Checking • Run-Time Environments • Intermediate Code Generation • Target Code Generation • Code Optimization COP5621 Fall 2011 10