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

Introduction to Compiler Construction
Introduction to Compiler Construction Introduction to Compiler Construction
Introduction to Compiler Construction
Sarmad Ali
 
Semantic analysis
Semantic analysisSemantic analysis
Semantic analysis
Lahore Garrison University
 
Lexical analysis - Compiler Design
Lexical analysis - Compiler DesignLexical analysis - Compiler Design
Lexical analysis - Compiler Design
Muhammed Afsal Villan
 
Intermediate code generation (Compiler Design)
Intermediate code generation (Compiler Design)   Intermediate code generation (Compiler Design)
Intermediate code generation (Compiler Design)
Tasif Tanzim
 
Specification-of-tokens
Specification-of-tokensSpecification-of-tokens
Specification-of-tokens
Dattatray Gandhmal
 
Context free grammars
Context free grammarsContext free grammars
Context free grammars
Ronak Thakkar
 
Assemblers
AssemblersAssemblers
Assemblers
Dattatray Gandhmal
 
Lex
LexLex
Introduction to Compiler
Introduction to CompilerIntroduction to Compiler
Introduction to Compiler
Radhakrishnan Chinnusamy
 
Passes of compilers
Passes of compilersPasses of compilers
Passes of compilers
Vairavel C
 
Compiler construction tools
Compiler construction toolsCompiler construction tools
Compiler construction tools
Akhil Kaushik
 
Unit1 principle of programming language
Unit1 principle of programming languageUnit1 principle of programming language
Unit1 principle of programming language
Vasavi College of Engg
 
Principles of programming languages. Detail notes
Principles of programming languages. Detail notesPrinciples of programming languages. Detail notes
Principles of programming languages. Detail notes
VIKAS SINGH BHADOURIA
 
Compiler Design Unit 1
Compiler Design Unit 1Compiler Design Unit 1
Compiler Design Unit 1
Jena Catherine Bel D
 
Issues in the design of Code Generator
Issues in the design of Code GeneratorIssues in the design of Code Generator
Issues in the design of Code Generator
Darshan sai Reddy
 
Top down parsing
Top down parsingTop down parsing
Top down parsing
ASHOK KUMAR REDDY
 
Lecture 01 introduction to compiler
Lecture 01 introduction to compilerLecture 01 introduction to compiler
Lecture 01 introduction to compiler
Iffat Anjum
 
Principal source of optimization in compiler design
Principal source of optimization in compiler designPrincipal source of optimization in compiler design
Principal source of optimization in compiler design
Rajkumar R
 
Chapter 5 Syntax Directed Translation
Chapter 5   Syntax Directed TranslationChapter 5   Syntax Directed Translation
Chapter 5 Syntax Directed Translation
Radhakrishnan Chinnusamy
 
COMPILER DESIGN
COMPILER DESIGNCOMPILER DESIGN
COMPILER DESIGN
Vetukurivenkatashiva
 

What's hot (20)

Introduction to Compiler Construction
Introduction to Compiler Construction Introduction to Compiler Construction
Introduction to Compiler Construction
 
Semantic analysis
Semantic analysisSemantic analysis
Semantic analysis
 
Lexical analysis - Compiler Design
Lexical analysis - Compiler DesignLexical analysis - Compiler Design
Lexical analysis - Compiler Design
 
Intermediate code generation (Compiler Design)
Intermediate code generation (Compiler Design)   Intermediate code generation (Compiler Design)
Intermediate code generation (Compiler Design)
 
Specification-of-tokens
Specification-of-tokensSpecification-of-tokens
Specification-of-tokens
 
Context free grammars
Context free grammarsContext free grammars
Context free grammars
 
Assemblers
AssemblersAssemblers
Assemblers
 
Lex
LexLex
Lex
 
Introduction to Compiler
Introduction to CompilerIntroduction to Compiler
Introduction to Compiler
 
Passes of compilers
Passes of compilersPasses of compilers
Passes of compilers
 
Compiler construction tools
Compiler construction toolsCompiler construction tools
Compiler construction tools
 
Unit1 principle of programming language
Unit1 principle of programming languageUnit1 principle of programming language
Unit1 principle of programming language
 
Principles of programming languages. Detail notes
Principles of programming languages. Detail notesPrinciples of programming languages. Detail notes
Principles of programming languages. Detail notes
 
Compiler Design Unit 1
Compiler Design Unit 1Compiler Design Unit 1
Compiler Design Unit 1
 
Issues in the design of Code Generator
Issues in the design of Code GeneratorIssues in the design of Code Generator
Issues in the design of Code Generator
 
Top down parsing
Top down parsingTop down parsing
Top down parsing
 
Lecture 01 introduction to compiler
Lecture 01 introduction to compilerLecture 01 introduction to compiler
Lecture 01 introduction to compiler
 
Principal source of optimization in compiler design
Principal source of optimization in compiler designPrincipal source of optimization in compiler design
Principal source of optimization in compiler design
 
Chapter 5 Syntax Directed Translation
Chapter 5   Syntax Directed TranslationChapter 5   Syntax Directed Translation
Chapter 5 Syntax Directed Translation
 
COMPILER DESIGN
COMPILER DESIGNCOMPILER DESIGN
COMPILER DESIGN
 

Viewers also liked

Compiler Chapter 1
Compiler Chapter 1Compiler Chapter 1
Compiler Chapter 1
Huawei Technologies
 
what is compiler and five phases of compiler
what is compiler and five phases of compilerwhat is compiler and five phases of compiler
what is compiler and five phases of compiler
adilmehmood93
 
Phases of the Compiler - Systems Programming
Phases of the Compiler - Systems ProgrammingPhases of the Compiler - Systems Programming
Phases of the Compiler - Systems Programming
Mukesh Tekwani
 
Compiler Construction
Compiler ConstructionCompiler Construction
Compiler Construction
Sarmad Ali
 
Compiler Construction Course - Introduction
Compiler Construction Course - IntroductionCompiler Construction Course - Introduction
Compiler Construction Course - Introduction
Muhammad Sanaullah
 
Compiler construction
Compiler constructionCompiler construction
Compiler construction
Muhammed Afsal Villan
 
Compiler Design - Introduction to Compiler
Compiler Design - Introduction to CompilerCompiler Design - Introduction to Compiler
Compiler Design - Introduction to Compiler
Iffat Anjum
 
Lexical analyzer
Lexical analyzerLexical analyzer
Lexical analyzer
Ashwini Sonawane
 
Compiler
CompilerCompiler
compiler and their types
compiler and their typescompiler and their types
compiler and their types
patchamounika7
 
Lecture 11 semantic analysis 2
Lecture 11 semantic analysis 2Lecture 11 semantic analysis 2
Lecture 11 semantic analysis 2
Iffat Anjum
 
Syntax directed translation
Syntax directed translationSyntax directed translation
Syntax directed translation
Akshaya Arunan
 
Compiler Design Basics
Compiler Design BasicsCompiler Design Basics
Compiler Design Basics
Akhil Kaushik
 
Ch5a
Ch5aCh5a
Lexical analyzer
Lexical analyzerLexical analyzer
Lexical analyzer
kiran acharya
 
Input-Buffering
Input-BufferingInput-Buffering
Input-Buffering
Dattatray Gandhmal
 
Recognition-of-tokens
Recognition-of-tokensRecognition-of-tokens
Recognition-of-tokens
Dattatray Gandhmal
 
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
 
Lecture 1 introduction to language processors
Lecture 1  introduction to language processorsLecture 1  introduction to language processors
Lecture 1 introduction to language processors
Rebaz Najeeb
 
Register Allocation
Register AllocationRegister Allocation
Register Allocation
Eelco Visser
 

Viewers also liked (20)

Compiler Chapter 1
Compiler Chapter 1Compiler Chapter 1
Compiler Chapter 1
 
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)
 
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.pptx
AshenafiGirma5
 
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
ZiyadMohammed17
 
Cd ch1 - introduction
Cd   ch1 - introductionCd   ch1 - introduction
Cd ch1 - introduction
mengistu23
 
Chap01-Intro.ppt
Chap01-Intro.pptChap01-Intro.ppt
Chap01-Intro.ppt
AhmadAbubaker16
 
System software
System softwareSystem software
System software
Senthil Kanth
 
COMPILER DESIGN PPTS.pptx
COMPILER DESIGN PPTS.pptxCOMPILER DESIGN PPTS.pptx
COMPILER DESIGN PPTS.pptx
MUSHAMHARIKIRAN6737
 
Compiler Design Basics
Compiler Design BasicsCompiler Design Basics
Compiler Design Basics
Akhil Kaushik
 
Compiler Design Introduction
Compiler Design IntroductionCompiler Design Introduction
Compiler Design Introduction
Kuppusamy P
 
Cd unit i
Cd unit iCd unit i
Cd unit i
Abhimanyu Mishra
 
Overall 23 11_2007_hdp
Overall 23 11_2007_hdpOverall 23 11_2007_hdp
Overall 23 11_2007_hdp
Mohd Arif
 
Introduction to Compilers
Introduction to CompilersIntroduction to Compilers
Introduction to Compilers
Akhil Kaushik
 
1 introduction to compiler
1 introduction to compiler1 introduction to compiler
1 introduction to compiler
BarwarBadradin
 
Ch1 (1).ppt
Ch1 (1).pptCh1 (1).ppt
Ch1 (1).ppt
MDSayem35
 
Compiler Design Introduction
Compiler Design Introduction Compiler Design Introduction
Compiler Design Introduction
Thapar Institute
 
Compiler design
Compiler designCompiler design
Compiler design
suganyasanjai
 
Cd econtent link1
Cd econtent link1Cd econtent link1
Cd econtent link1
suganyasanjai
 
Compiler1
Compiler1Compiler1
Compiler1
Natish Kumar
 
Language processor
Language processorLanguage processor
Language processor
Abha 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 3
aminmesbahi
 
Introduction to compiler
Introduction to compilerIntroduction to compiler
Introduction to compiler
Abha Damani
 

Similar to Compiler Construction (20)

4_5802928814682016556.pptx
4_5802928814682016556.pptx4_5802928814682016556.pptx
4_5802928814682016556.pptx
 
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
 
Cd ch1 - introduction
Cd   ch1 - introductionCd   ch1 - introduction
Cd ch1 - introduction
 
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
 
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
 
Introduction to compiler
Introduction to compilerIntroduction to compiler
Introduction to compiler
 

More from Army Public School and College -Faisal

SENSOR WHITEBOARDS
SENSOR WHITEBOARDSSENSOR WHITEBOARDS
INPUT AND OUTPUT DEVICES
INPUT AND OUTPUT DEVICESINPUT AND OUTPUT DEVICES
INPUT AND OUTPUT DEVICES
Army Public School and College -Faisal
 
INPUT AND OUTPUT DEVICES
INPUT AND OUTPUT DEVICESINPUT AND OUTPUT DEVICES
INPUT AND OUTPUT DEVICES
Army Public School and College -Faisal
 
2d and 3d cutters
2d and 3d cutters 2d and 3d cutters
SCANNERS /BARCODE
SCANNERS /BARCODE SCANNERS /BARCODE
3D PRINTERS
3D PRINTERS3D PRINTERS
Operaing system
Operaing systemOperaing system
Module 2 handouts part 2
Module 2 handouts part 2Module 2 handouts part 2
Module 2 handouts part 2
Army Public School and College -Faisal
 
Module 2 handouts part 1
Module 2 handouts part 1Module 2 handouts part 1
Module 2 handouts part 1
Army Public School and College -Faisal
 
Module 1 ELECTRONICS
Module 1  ELECTRONICSModule 1  ELECTRONICS
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
Army Public School and College -Faisal
 
Css
CssCss
python 1
python 1python 1
Boolean and comparison_instructions
Boolean and comparison_instructionsBoolean and comparison_instructions
Boolean and comparison_instructions
Army Public School and College -Faisal
 
hadoop_module
hadoop_modulehadoop_module
Polymorphism (2)
Polymorphism (2)Polymorphism (2)
Object Oriented Programming
Object Oriented ProgrammingObject Oriented Programming
Object Oriented Programming
Army Public School and College -Faisal
 
Presentation 2
Presentation 2Presentation 2
Lecture 1 progrmming with C
Lecture 1 progrmming with C Lecture 1 progrmming with C
Lecture 1 progrmming with C
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

RPMS TEMPLATE FOR SCHOOL YEAR 2023-2024 FOR TEACHER 1 TO TEACHER 3
RPMS TEMPLATE FOR SCHOOL YEAR 2023-2024 FOR TEACHER 1 TO TEACHER 3RPMS TEMPLATE FOR SCHOOL YEAR 2023-2024 FOR TEACHER 1 TO TEACHER 3
RPMS TEMPLATE FOR SCHOOL YEAR 2023-2024 FOR TEACHER 1 TO TEACHER 3
IreneSebastianRueco1
 
Your Skill Boost Masterclass: Strategies for Effective Upskilling
Your Skill Boost Masterclass: Strategies for Effective UpskillingYour Skill Boost Masterclass: Strategies for Effective Upskilling
Your Skill Boost Masterclass: Strategies for Effective Upskilling
Excellence Foundation for South Sudan
 
Digital Artifact 1 - 10VCD Environments Unit
Digital Artifact 1 - 10VCD Environments UnitDigital Artifact 1 - 10VCD Environments Unit
Digital Artifact 1 - 10VCD Environments Unit
chanes7
 
Hindi varnamala | hindi alphabet PPT.pdf
Hindi varnamala | hindi alphabet PPT.pdfHindi varnamala | hindi alphabet PPT.pdf
Hindi varnamala | hindi alphabet PPT.pdf
Dr. Mulla Adam Ali
 
Exploiting Artificial Intelligence for Empowering Researchers and Faculty, In...
Exploiting Artificial Intelligence for Empowering Researchers and Faculty, In...Exploiting Artificial Intelligence for Empowering Researchers and Faculty, In...
Exploiting Artificial Intelligence for Empowering Researchers and Faculty, In...
Dr. Vinod Kumar Kanvaria
 
Main Java[All of the Base Concepts}.docx
Main Java[All of the Base Concepts}.docxMain Java[All of the Base Concepts}.docx
Main Java[All of the Base Concepts}.docx
adhitya5119
 
S1-Introduction-Biopesticides in ICM.pptx
S1-Introduction-Biopesticides in ICM.pptxS1-Introduction-Biopesticides in ICM.pptx
S1-Introduction-Biopesticides in ICM.pptx
tarandeep35
 
Pride Month Slides 2024 David Douglas School District
Pride Month Slides 2024 David Douglas School DistrictPride Month Slides 2024 David Douglas School District
Pride Month Slides 2024 David Douglas School District
David Douglas School District
 
clinical examination of hip joint (1).pdf
clinical examination of hip joint (1).pdfclinical examination of hip joint (1).pdf
clinical examination of hip joint (1).pdf
Priyankaranawat4
 
The basics of sentences session 6pptx.pptx
The basics of sentences session 6pptx.pptxThe basics of sentences session 6pptx.pptx
The basics of sentences session 6pptx.pptx
heathfieldcps1
 
MARY JANE WILSON, A “BOA MÃE” .
MARY JANE WILSON, A “BOA MÃE”           .MARY JANE WILSON, A “BOA MÃE”           .
MARY JANE WILSON, A “BOA MÃE” .
Colégio Santa Teresinha
 
How to Fix the Import Error in the Odoo 17
How to Fix the Import Error in the Odoo 17How to Fix the Import Error in the Odoo 17
How to Fix the Import Error in the Odoo 17
Celine George
 
Smart-Money for SMC traders good time and ICT
Smart-Money for SMC traders good time and ICTSmart-Money for SMC traders good time and ICT
Smart-Money for SMC traders good time and ICT
simonomuemu
 
Film vocab for eal 3 students: Australia the movie
Film vocab for eal 3 students: Australia the movieFilm vocab for eal 3 students: Australia the movie
Film vocab for eal 3 students: Australia the movie
Nicholas Montgomery
 
How to Build a Module in Odoo 17 Using the Scaffold Method
How to Build a Module in Odoo 17 Using the Scaffold MethodHow to Build a Module in Odoo 17 Using the Scaffold Method
How to Build a Module in Odoo 17 Using the Scaffold Method
Celine George
 
Pengantar Penggunaan Flutter - Dart programming language1.pptx
Pengantar Penggunaan Flutter - Dart programming language1.pptxPengantar Penggunaan Flutter - Dart programming language1.pptx
Pengantar Penggunaan Flutter - Dart programming language1.pptx
Fajar Baskoro
 
How to Add Chatter in the odoo 17 ERP Module
How to Add Chatter in the odoo 17 ERP ModuleHow to Add Chatter in the odoo 17 ERP Module
How to Add Chatter in the odoo 17 ERP Module
Celine George
 
How to Make a Field Mandatory in Odoo 17
How to Make a Field Mandatory in Odoo 17How to Make a Field Mandatory in Odoo 17
How to Make a Field Mandatory in Odoo 17
Celine George
 
Community pharmacy- Social and preventive pharmacy UNIT 5
Community pharmacy- Social and preventive pharmacy UNIT 5Community pharmacy- Social and preventive pharmacy UNIT 5
Community pharmacy- Social and preventive pharmacy UNIT 5
sayalidalavi006
 
Pollock and Snow "DEIA in the Scholarly Landscape, Session One: Setting Expec...
Pollock and Snow "DEIA in the Scholarly Landscape, Session One: Setting Expec...Pollock and Snow "DEIA in the Scholarly Landscape, Session One: Setting Expec...
Pollock and Snow "DEIA in the Scholarly Landscape, Session One: Setting Expec...
National Information Standards Organization (NISO)
 

Recently uploaded (20)

RPMS TEMPLATE FOR SCHOOL YEAR 2023-2024 FOR TEACHER 1 TO TEACHER 3
RPMS TEMPLATE FOR SCHOOL YEAR 2023-2024 FOR TEACHER 1 TO TEACHER 3RPMS TEMPLATE FOR SCHOOL YEAR 2023-2024 FOR TEACHER 1 TO TEACHER 3
RPMS TEMPLATE FOR SCHOOL YEAR 2023-2024 FOR TEACHER 1 TO TEACHER 3
 
Your Skill Boost Masterclass: Strategies for Effective Upskilling
Your Skill Boost Masterclass: Strategies for Effective UpskillingYour Skill Boost Masterclass: Strategies for Effective Upskilling
Your Skill Boost Masterclass: Strategies for Effective Upskilling
 
Digital Artifact 1 - 10VCD Environments Unit
Digital Artifact 1 - 10VCD Environments UnitDigital Artifact 1 - 10VCD Environments Unit
Digital Artifact 1 - 10VCD Environments Unit
 
Hindi varnamala | hindi alphabet PPT.pdf
Hindi varnamala | hindi alphabet PPT.pdfHindi varnamala | hindi alphabet PPT.pdf
Hindi varnamala | hindi alphabet PPT.pdf
 
Exploiting Artificial Intelligence for Empowering Researchers and Faculty, In...
Exploiting Artificial Intelligence for Empowering Researchers and Faculty, In...Exploiting Artificial Intelligence for Empowering Researchers and Faculty, In...
Exploiting Artificial Intelligence for Empowering Researchers and Faculty, In...
 
Main Java[All of the Base Concepts}.docx
Main Java[All of the Base Concepts}.docxMain Java[All of the Base Concepts}.docx
Main Java[All of the Base Concepts}.docx
 
S1-Introduction-Biopesticides in ICM.pptx
S1-Introduction-Biopesticides in ICM.pptxS1-Introduction-Biopesticides in ICM.pptx
S1-Introduction-Biopesticides in ICM.pptx
 
Pride Month Slides 2024 David Douglas School District
Pride Month Slides 2024 David Douglas School DistrictPride Month Slides 2024 David Douglas School District
Pride Month Slides 2024 David Douglas School District
 
clinical examination of hip joint (1).pdf
clinical examination of hip joint (1).pdfclinical examination of hip joint (1).pdf
clinical examination of hip joint (1).pdf
 
The basics of sentences session 6pptx.pptx
The basics of sentences session 6pptx.pptxThe basics of sentences session 6pptx.pptx
The basics of sentences session 6pptx.pptx
 
MARY JANE WILSON, A “BOA MÃE” .
MARY JANE WILSON, A “BOA MÃE”           .MARY JANE WILSON, A “BOA MÃE”           .
MARY JANE WILSON, A “BOA MÃE” .
 
How to Fix the Import Error in the Odoo 17
How to Fix the Import Error in the Odoo 17How to Fix the Import Error in the Odoo 17
How to Fix the Import Error in the Odoo 17
 
Smart-Money for SMC traders good time and ICT
Smart-Money for SMC traders good time and ICTSmart-Money for SMC traders good time and ICT
Smart-Money for SMC traders good time and ICT
 
Film vocab for eal 3 students: Australia the movie
Film vocab for eal 3 students: Australia the movieFilm vocab for eal 3 students: Australia the movie
Film vocab for eal 3 students: Australia the movie
 
How to Build a Module in Odoo 17 Using the Scaffold Method
How to Build a Module in Odoo 17 Using the Scaffold MethodHow to Build a Module in Odoo 17 Using the Scaffold Method
How to Build a Module in Odoo 17 Using the Scaffold Method
 
Pengantar Penggunaan Flutter - Dart programming language1.pptx
Pengantar Penggunaan Flutter - Dart programming language1.pptxPengantar Penggunaan Flutter - Dart programming language1.pptx
Pengantar Penggunaan Flutter - Dart programming language1.pptx
 
How to Add Chatter in the odoo 17 ERP Module
How to Add Chatter in the odoo 17 ERP ModuleHow to Add Chatter in the odoo 17 ERP Module
How to Add Chatter in the odoo 17 ERP Module
 
How to Make a Field Mandatory in Odoo 17
How to Make a Field Mandatory in Odoo 17How to Make a Field Mandatory in Odoo 17
How to Make a Field Mandatory in Odoo 17
 
Community pharmacy- Social and preventive pharmacy UNIT 5
Community pharmacy- Social and preventive pharmacy UNIT 5Community pharmacy- Social and preventive pharmacy UNIT 5
Community pharmacy- Social and preventive pharmacy UNIT 5
 
Pollock and Snow "DEIA in the Scholarly Landscape, Session One: Setting Expec...
Pollock and Snow "DEIA in the Scholarly Landscape, Session One: Setting Expec...Pollock and Snow "DEIA in the Scholarly Landscape, Session One: Setting Expec...
Pollock and Snow "DEIA in the Scholarly Landscape, Session One: Setting Expec...
 

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