SlideShare a Scribd company logo
  Course Goals  •  To provide students with an understanding of the  major phases of a compiler.  •  To introduce students to the theory behind the various  phases, including regular expressions, context-free grammars, and finite state automata.  •  To provide students with an understanding of the design and implementation of a compiler.  •  To have the students build a compiler, through type checking and intermediate code generation, for a small language.  •  To provide students with an opportunity to work in a group  on a large project.
  Course Outcomes •  Students will have experience using current compiler generation tools.  •  Students will be familiar with the different phases of compilation.  •  Students will have experience defining and specifying the semantic rules of a programming language
  Prerequisites •  In-depth knowledge of at least one structured programming language.  •  Strong background in algorithms, data structures, and abstract data types, including stacks, binary trees, graphs.  •  Understanding of grammar theories.  •  Understanding of data types and control structures, their design and implementation.  •  Understanding of the design and implementation of subprograms, parameter passing mechanisms, scope.
Major Topics Covered in the Course ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
  Textbook Compilers: Principles, Techniques, and Tools” by Aho, Lam, Sethi, and Ullman, 2 nd  edition.
GRADING Assignements & project:  40 Midterm Exam:  20 Final Exam:  40
Compilers and Interpreters ,[object Object],[object Object],Compiler Error messages Source Program Target Program Input Output
Compilers and Interpreters (cont’d) ,[object Object],[object Object],Interpreter Source Program Input Output Error messages
The Analysis-Synthesis Model of Compilation ,[object Object],[object Object],[object Object]
Preprocessors, Compilers, Assemblers, and Linkers Preprocessor Compiler Assembler Linker Skeletal Source Program Source Program Target Assembly Program Relocatable Object Code Absolute Machine Code Libraries and Relocatable Object Files Try for example: gcc -v myprog.c
The Phases of a Compiler Phase Output Sample Programmer (source code producer) Source string A=B+C; Scanner  (performs  lexical analysis ) Token string ‘ A’ ,  ‘=’ ,  ‘B’ ,  ‘+’ ,  ‘C’ ,  ‘;’ And  symbol table  with names Parser  (performs  syntax analysis  based on the grammar of the programming language) Parse tree or abstract syntax tree ;   |   =  / A  +   /   B  C Semantic analyzer  (type checking,  etc) Annotated parse tree or abstract syntax tree Intermediate code generator Three-address code, quads, or RTL int2fp B  t1 +  t1  C  t2 :=  t2  A Optimizer Three-address code, quads, or RTL int2fp B  t1 +  t1  #2.3  A Code generator Assembly code MOVF  #2.3,r1 ADDF2 r1,r2 MOVF  r2,A Peephole optimizer Assembly code ADDF2 #2.3,r2 MOVF  r2,A
The Grouping of Phases ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Compiler-Construction Tools ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
What qualities do you want in a  that compiler you buy  ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
High-level View of a Compiler  ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],Source code Machine code Compiler Errors
Traditional Two-pass Compiler ,[object Object],[object Object],[object Object],[object Object],Source code Front End Errors   Machine code Back End IR
The Front End ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],Source code Scanner IR Parser Errors   tokens
The Front End ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],Source code Scanner IR Parser Errors   tokens
The Front End ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],Source code Scanner IR Parser Errors   tokens
The Front End ,[object Object],[object Object],[object Object],The  AST  summarizes grammatical structure, without including detail about the derivation  + - < id, x > < number, 2 > < id, y >
The Back End Responsibilities Translate IR into target machine code Choose instructions to implement each IR operation Decide which value to keep in registers Ensure conformance with system interfaces Automation has been  much less  successful in the back end Errors   IR Instruction Scheduling Instruction Selection Machine code Register Allocation IR IR
The Back End ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],Errors   IR Instruction Scheduling Instruction Selection Machine code Register Allocation IR IR
The Back End ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],Errors   IR Instruction Scheduling Instruction Selection Machine code Register Allocation IR IR
The Back End ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],Errors   IR Instruction Scheduling Instruction Selection Machine code Register Allocation IR IR
Traditional Three-pass Compiler ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],Errors   Source Code Middle End Front End Machine code Back End IR IR
The Optimizer (or Middle End) Modern optimizers are structured as a series of passes Typical Transformations Discover & propagate some constant value Move a computation to a less frequently executed place Discover a redundant computation & remove it Remove useless or unreachable co de Errors   O p t 1 O p t 3 O p t 2 O p t n ... IR IR IR IR IR
The Big Picture ,[object Object],[object Object],[object Object],[object Object],[object Object],Scanner Scanner Generator specifications source code parts of speech tables or code
Lexical Analysis ,[object Object],[object Object],[object Object]
Example ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Specifying Lexical Patterns  (micro-syntax) ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],Specifying Lexical Patterns  (micro-syntax)
Regular Expressions ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],Precedence  is  closure , then  concatenation , then  alternation Ever type  “ rm *.o a.out” ?
Set Operations  (refresher) You need to know these definitions
Examples of Regular Expressions ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Regular Expressions  (the point) ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],Example  S 0  S 2  S 1  r ( 0 | 1 | 2 | …  9 ) accepting state ( 0 | 1 | 2 | …  9 ) Recognizer for  Register
[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],Example  (continued) S 0  S 2  S 1  r ( 0 | 1 | 2 | …  9 ) accepting state ( 0 | 1 | 2 | …  9 ) Recognizer for  Register
Example  (continued) char    next character; state    s 0 ; call action(state,char); while (char     eof ) state      (state,char); call action(state,char); char    next character; if   (state) =  final  then  report acceptance; else report failure; action(state,char) switch(  (state) ) case  start : word    char; break; case  normal : word    word + char; break; case  final : word    char; break; case  error : report error; break; end; ,[object Object],[object Object]
[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],What if we need a tighter specification?
Tighter register specification  (continued) ,[object Object],[object Object],[object Object],[object Object],S 0  S 5  S 1  r S 4  S 3  S 6  S 2  0 , 1 , 2 3 0 , 1 4 , 5 , 6 , 7 , 8 , 9 ( 0 | 1 | 2 | …  9 )
Tighter register specification  (continued) ,[object Object],[object Object],[object Object],[object Object],[object Object]

More Related Content

What's hot

Compiler Design
Compiler DesignCompiler Design
Compiler DesignMir Majid
 
Error detection recovery
Error detection recoveryError detection recovery
Error detection recoveryTech_MX
 
Compiler Construction introduction
Compiler Construction introductionCompiler Construction introduction
Compiler Construction introduction
Rana Ehtisham Ul Haq
 
Lexical analyzer
Lexical analyzerLexical analyzer
Lexical analyzer
Ashwini Sonawane
 
Spr ch-05-compilers
Spr ch-05-compilersSpr ch-05-compilers
Spr ch-05-compilersVasim Pathan
 
Principles of compiler design
Principles of compiler designPrinciples of compiler design
Principles of compiler design
DHARANI BABU
 
Compiler Design(Nanthu)
Compiler Design(Nanthu)Compiler Design(Nanthu)
Compiler Design(Nanthu)
guest91cc85
 
phases of a compiler
 phases of a compiler phases of a compiler
phases of a compiler
Ms.SHANTHI.S CSE
 
Chapter 1 1
Chapter 1 1Chapter 1 1
Chapter 1 1bolovv
 
Compiler Design Lecture Notes
Compiler Design Lecture NotesCompiler Design Lecture Notes
Compiler Design Lecture Notes
FellowBuddy.com
 
Compiler unit 1
Compiler unit 1Compiler unit 1
Compiler unit 1
BBDITM LUCKNOW
 
Compiler Design Introduction
Compiler Design IntroductionCompiler Design Introduction
Compiler Design Introduction
Richa Sharma
 
Compiler Construction Course - Introduction
Compiler Construction Course - IntroductionCompiler Construction Course - Introduction
Compiler Construction Course - Introduction
Muhammad Sanaullah
 
Phases of compiler
Phases of compilerPhases of compiler
Phases of compiler
Karan Deopura
 
Compiler Design(NANTHU NOTES)
Compiler Design(NANTHU NOTES)Compiler Design(NANTHU NOTES)
Compiler Design(NANTHU NOTES)
guest251d9a
 
Cs6660 compiler design
Cs6660 compiler designCs6660 compiler design
Cs6660 compiler design
hari2010
 
Different phases of a compiler
Different phases of a compilerDifferent phases of a compiler
Different phases of a compiler
Sumit Sinha
 
Compiler design
Compiler designCompiler design
Compiler design
sanchi29
 

What's hot (20)

Compiler Design
Compiler DesignCompiler Design
Compiler Design
 
Error detection recovery
Error detection recoveryError detection recovery
Error detection recovery
 
Compiler Construction introduction
Compiler Construction introductionCompiler Construction introduction
Compiler Construction introduction
 
Lexical analyzer
Lexical analyzerLexical analyzer
Lexical analyzer
 
Spr ch-05-compilers
Spr ch-05-compilersSpr ch-05-compilers
Spr ch-05-compilers
 
Principles of compiler design
Principles of compiler designPrinciples of compiler design
Principles of compiler design
 
Compiler Design(Nanthu)
Compiler Design(Nanthu)Compiler Design(Nanthu)
Compiler Design(Nanthu)
 
phases of a compiler
 phases of a compiler phases of a compiler
phases of a compiler
 
Chapter 1 1
Chapter 1 1Chapter 1 1
Chapter 1 1
 
Compiler Design Material
Compiler Design MaterialCompiler Design Material
Compiler Design Material
 
Compiler Design Lecture Notes
Compiler Design Lecture NotesCompiler Design Lecture Notes
Compiler Design Lecture Notes
 
Compiler unit 1
Compiler unit 1Compiler unit 1
Compiler unit 1
 
Compiler Design Introduction
Compiler Design IntroductionCompiler Design Introduction
Compiler Design Introduction
 
Compiler Construction Course - Introduction
Compiler Construction Course - IntroductionCompiler Construction Course - Introduction
Compiler Construction Course - Introduction
 
Phases of compiler
Phases of compilerPhases of compiler
Phases of compiler
 
Ch1
Ch1Ch1
Ch1
 
Compiler Design(NANTHU NOTES)
Compiler Design(NANTHU NOTES)Compiler Design(NANTHU NOTES)
Compiler Design(NANTHU NOTES)
 
Cs6660 compiler design
Cs6660 compiler designCs6660 compiler design
Cs6660 compiler design
 
Different phases of a compiler
Different phases of a compilerDifferent phases of a compiler
Different phases of a compiler
 
Compiler design
Compiler designCompiler design
Compiler design
 

Viewers also liked

Compiler vs Interpreter-Compiler design ppt.
Compiler vs Interpreter-Compiler design ppt.Compiler vs Interpreter-Compiler design ppt.
Compiler vs Interpreter-Compiler design ppt.
Md Hossen
 
Ss ui lecture 2
Ss ui lecture 2Ss ui lecture 2
Ss ui lecture 2
Avinash Kapse
 
OpenOffice++: Improving the Quality of Open Source Software
OpenOffice++: Improving the Quality of Open Source SoftwareOpenOffice++: Improving the Quality of Open Source Software
OpenOffice++: Improving the Quality of Open Source SoftwareAlexandro Colorado
 
Diab Compiler Quality Overview
Diab Compiler Quality OverviewDiab Compiler Quality Overview
Diab Compiler Quality Overview
kylefacchin
 
Principles of compiler design
Principles of compiler designPrinciples of compiler design
Principles of compiler designJanani Parthiban
 
Introduction to course
Introduction to courseIntroduction to course
Introduction to course
nikit meshram
 
01. introduction
01. introduction01. introduction
01. introduction
babaaasingh123
 
Compiler Engineering Lab#1
Compiler Engineering Lab#1Compiler Engineering Lab#1
Compiler Engineering Lab#1
MashaelQ
 
Computer graphics
Computer graphics   Computer graphics
Computer graphics
Prianka Padmanaban
 
Compiler construction
Compiler constructionCompiler construction
Compiler construction
Muhammed Afsal Villan
 
Compiler Design Tutorial
Compiler Design Tutorial Compiler Design Tutorial
Compiler Design Tutorial
Sarit Chakraborty
 
compiler and their types
compiler and their typescompiler and their types
compiler and their types
patchamounika7
 
Lexical analysis
Lexical analysisLexical analysis
Lexical analysis
Richa Sharma
 
Top Down Parsing, Predictive Parsing
Top Down Parsing, Predictive ParsingTop Down Parsing, Predictive Parsing
Top Down Parsing, Predictive Parsing
Tanzeela_Hussain
 
Compiler vs interpreter
Compiler vs interpreterCompiler vs interpreter
Compiler vs interpreter
Paras Patel
 
Introduction to Compiler Construction
Introduction to Compiler Construction Introduction to Compiler Construction
Introduction to Compiler Construction
Sarmad Ali
 

Viewers also liked (20)

Regular expression (compiler)
Regular expression (compiler)Regular expression (compiler)
Regular expression (compiler)
 
Compiler vs Interpreter-Compiler design ppt.
Compiler vs Interpreter-Compiler design ppt.Compiler vs Interpreter-Compiler design ppt.
Compiler vs Interpreter-Compiler design ppt.
 
Ss ui lecture 2
Ss ui lecture 2Ss ui lecture 2
Ss ui lecture 2
 
SS UI Lecture 1
SS UI Lecture 1SS UI Lecture 1
SS UI Lecture 1
 
OpenOffice++: Improving the Quality of Open Source Software
OpenOffice++: Improving the Quality of Open Source SoftwareOpenOffice++: Improving the Quality of Open Source Software
OpenOffice++: Improving the Quality of Open Source Software
 
Diab Compiler Quality Overview
Diab Compiler Quality OverviewDiab Compiler Quality Overview
Diab Compiler Quality Overview
 
Principles of compiler design
Principles of compiler designPrinciples of compiler design
Principles of compiler design
 
Introduction to course
Introduction to courseIntroduction to course
Introduction to course
 
01. introduction
01. introduction01. introduction
01. introduction
 
Unit 1 cd
Unit 1 cdUnit 1 cd
Unit 1 cd
 
Compiler Engineering Lab#1
Compiler Engineering Lab#1Compiler Engineering Lab#1
Compiler Engineering Lab#1
 
Computer graphics
Computer graphics   Computer graphics
Computer graphics
 
Compiler construction
Compiler constructionCompiler construction
Compiler construction
 
Compiler Design Tutorial
Compiler Design Tutorial Compiler Design Tutorial
Compiler Design Tutorial
 
compiler and their types
compiler and their typescompiler and their types
compiler and their types
 
Lexical analysis
Lexical analysisLexical analysis
Lexical analysis
 
Top Down Parsing, Predictive Parsing
Top Down Parsing, Predictive ParsingTop Down Parsing, Predictive Parsing
Top Down Parsing, Predictive Parsing
 
Compiler vs interpreter
Compiler vs interpreterCompiler vs interpreter
Compiler vs interpreter
 
Introduction to Compiler Construction
Introduction to Compiler Construction Introduction to Compiler Construction
Introduction to Compiler Construction
 
Parsing
ParsingParsing
Parsing
 

Similar to Cpcs302 1

01. Introduction.ppt
01. Introduction.ppt01. Introduction.ppt
01. Introduction.ppt
ReshmaR57
 
Compiler design
Compiler designCompiler design
Compiler design
suganyasanjai
 
Cd econtent link1
Cd econtent link1Cd econtent link1
Cd econtent link1
suganyasanjai
 
Ch1 (1).ppt
Ch1 (1).pptCh1 (1).ppt
Ch1 (1).ppt
MDSayem35
 
Chapter#01 cc
Chapter#01 ccChapter#01 cc
Chapter#01 cc
abdulbaki3
 
Chapter One
Chapter OneChapter One
Chapter Onebolovv
 
COMPILER CONSTRUCTION KU 1.pptx
COMPILER CONSTRUCTION KU 1.pptxCOMPILER CONSTRUCTION KU 1.pptx
COMPILER CONSTRUCTION KU 1.pptx
Rossy719186
 
1._Introduction_.pptx
1._Introduction_.pptx1._Introduction_.pptx
1._Introduction_.pptx
Anbarasan Radhakrishnan R
 
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
 
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
 
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
 
Presentation1
Presentation1Presentation1
Presentation1
Zarin Tasnim
 
Presentation1
Presentation1Presentation1
Presentation1
Zarin Tasnim
 
Compiler_Lecture1.pdf
Compiler_Lecture1.pdfCompiler_Lecture1.pdf
Compiler_Lecture1.pdf
AkarTaher
 
Introduction to compiler
Introduction to compilerIntroduction to compiler
Introduction to compilerAbha Damani
 
Compier Design_Unit I.ppt
Compier Design_Unit I.pptCompier Design_Unit I.ppt
Compier Design_Unit I.ppt
sivaganesh293
 
Compier Design_Unit I.ppt
Compier Design_Unit I.pptCompier Design_Unit I.ppt
Compier Design_Unit I.ppt
sivaganesh293
 
Techniques & applications of Compiler
Techniques & applications of CompilerTechniques & applications of Compiler
Techniques & applications of Compiler
Preethi AKNR
 
The Phases of a Compiler
The Phases of a CompilerThe Phases of a Compiler
The Phases of a Compiler
Radhika Talaviya
 

Similar to Cpcs302 1 (20)

01. Introduction.ppt
01. Introduction.ppt01. Introduction.ppt
01. Introduction.ppt
 
Compiler design
Compiler designCompiler design
Compiler design
 
Cd econtent link1
Cd econtent link1Cd econtent link1
Cd econtent link1
 
Ch1 (1).ppt
Ch1 (1).pptCh1 (1).ppt
Ch1 (1).ppt
 
Chapter#01 cc
Chapter#01 ccChapter#01 cc
Chapter#01 cc
 
Chapter One
Chapter OneChapter One
Chapter One
 
COMPILER CONSTRUCTION KU 1.pptx
COMPILER CONSTRUCTION KU 1.pptxCOMPILER CONSTRUCTION KU 1.pptx
COMPILER CONSTRUCTION KU 1.pptx
 
1._Introduction_.pptx
1._Introduction_.pptx1._Introduction_.pptx
1._Introduction_.pptx
 
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
 
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
 
LANGUAGE TRANSLATOR
LANGUAGE TRANSLATORLANGUAGE TRANSLATOR
LANGUAGE TRANSLATOR
 
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
 
Presentation1
Presentation1Presentation1
Presentation1
 
Presentation1
Presentation1Presentation1
Presentation1
 
Compiler_Lecture1.pdf
Compiler_Lecture1.pdfCompiler_Lecture1.pdf
Compiler_Lecture1.pdf
 
Introduction to compiler
Introduction to compilerIntroduction to compiler
Introduction to compiler
 
Compier Design_Unit I.ppt
Compier Design_Unit I.pptCompier Design_Unit I.ppt
Compier Design_Unit I.ppt
 
Compier Design_Unit I.ppt
Compier Design_Unit I.pptCompier Design_Unit I.ppt
Compier Design_Unit I.ppt
 
Techniques & applications of Compiler
Techniques & applications of CompilerTechniques & applications of Compiler
Techniques & applications of Compiler
 
The Phases of a Compiler
The Phases of a CompilerThe Phases of a Compiler
The Phases of a Compiler
 

Recently uploaded

The geography of Taylor Swift - some ideas
The geography of Taylor Swift - some ideasThe geography of Taylor Swift - some ideas
The geography of Taylor Swift - some ideas
GeoBlogs
 
Introduction to AI for Nonprofits with Tapp Network
Introduction to AI for Nonprofits with Tapp NetworkIntroduction to AI for Nonprofits with Tapp Network
Introduction to AI for Nonprofits with Tapp Network
TechSoup
 
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
siemaillard
 
Model Attribute Check Company Auto Property
Model Attribute  Check Company Auto PropertyModel Attribute  Check Company Auto Property
Model Attribute Check Company Auto Property
Celine George
 
Home assignment II on Spectroscopy 2024 Answers.pdf
Home assignment II on Spectroscopy 2024 Answers.pdfHome assignment II on Spectroscopy 2024 Answers.pdf
Home assignment II on Spectroscopy 2024 Answers.pdf
Tamralipta Mahavidyalaya
 
Biological Screening of Herbal Drugs in detailed.
Biological Screening of Herbal Drugs in detailed.Biological Screening of Herbal Drugs in detailed.
Biological Screening of Herbal Drugs in detailed.
Ashokrao Mane college of Pharmacy Peth-Vadgaon
 
The French Revolution Class 9 Study Material pdf free download
The French Revolution Class 9 Study Material pdf free downloadThe French Revolution Class 9 Study Material pdf free download
The French Revolution Class 9 Study Material pdf free download
Vivekanand Anglo Vedic Academy
 
Embracing GenAI - A Strategic Imperative
Embracing GenAI - A Strategic ImperativeEmbracing GenAI - A Strategic Imperative
Embracing GenAI - A Strategic Imperative
Peter Windle
 
678020731-Sumas-y-Restas-Para-Colorear.pdf
678020731-Sumas-y-Restas-Para-Colorear.pdf678020731-Sumas-y-Restas-Para-Colorear.pdf
678020731-Sumas-y-Restas-Para-Colorear.pdf
CarlosHernanMontoyab2
 
Digital Tools and AI for Teaching Learning and Research
Digital Tools and AI for Teaching Learning and ResearchDigital Tools and AI for Teaching Learning and Research
Digital Tools and AI for Teaching Learning and Research
Vikramjit Singh
 
How to Make a Field invisible in Odoo 17
How to Make a Field invisible in Odoo 17How to Make a Field invisible in Odoo 17
How to Make a Field invisible in Odoo 17
Celine George
 
Language Across the Curriculm LAC B.Ed.
Language Across the  Curriculm LAC B.Ed.Language Across the  Curriculm LAC B.Ed.
Language Across the Curriculm LAC B.Ed.
Atul Kumar Singh
 
Polish students' mobility in the Czech Republic
Polish students' mobility in the Czech RepublicPolish students' mobility in the Czech Republic
Polish students' mobility in the Czech Republic
Anna Sz.
 
A Strategic Approach: GenAI in Education
A Strategic Approach: GenAI in EducationA Strategic Approach: GenAI in Education
A Strategic Approach: GenAI in Education
Peter Windle
 
special B.ed 2nd year old paper_20240531.pdf
special B.ed 2nd year old paper_20240531.pdfspecial B.ed 2nd year old paper_20240531.pdf
special B.ed 2nd year old paper_20240531.pdf
Special education needs
 
Lapbook sobre os Regimes Totalitários.pdf
Lapbook sobre os Regimes Totalitários.pdfLapbook sobre os Regimes Totalitários.pdf
Lapbook sobre os Regimes Totalitários.pdf
Jean Carlos Nunes Paixão
 
Overview on Edible Vaccine: Pros & Cons with Mechanism
Overview on Edible Vaccine: Pros & Cons with MechanismOverview on Edible Vaccine: Pros & Cons with Mechanism
Overview on Edible Vaccine: Pros & Cons with Mechanism
DeeptiGupta154
 
Operation Blue Star - Saka Neela Tara
Operation Blue Star   -  Saka Neela TaraOperation Blue Star   -  Saka Neela Tara
Operation Blue Star - Saka Neela Tara
Balvir Singh
 
Phrasal Verbs.XXXXXXXXXXXXXXXXXXXXXXXXXX
Phrasal Verbs.XXXXXXXXXXXXXXXXXXXXXXXXXXPhrasal Verbs.XXXXXXXXXXXXXXXXXXXXXXXXXX
Phrasal Verbs.XXXXXXXXXXXXXXXXXXXXXXXXXX
MIRIAMSALINAS13
 
"Protectable subject matters, Protection in biotechnology, Protection of othe...
"Protectable subject matters, Protection in biotechnology, Protection of othe..."Protectable subject matters, Protection in biotechnology, Protection of othe...
"Protectable subject matters, Protection in biotechnology, Protection of othe...
SACHIN R KONDAGURI
 

Recently uploaded (20)

The geography of Taylor Swift - some ideas
The geography of Taylor Swift - some ideasThe geography of Taylor Swift - some ideas
The geography of Taylor Swift - some ideas
 
Introduction to AI for Nonprofits with Tapp Network
Introduction to AI for Nonprofits with Tapp NetworkIntroduction to AI for Nonprofits with Tapp Network
Introduction to AI for Nonprofits with Tapp Network
 
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
 
Model Attribute Check Company Auto Property
Model Attribute  Check Company Auto PropertyModel Attribute  Check Company Auto Property
Model Attribute Check Company Auto Property
 
Home assignment II on Spectroscopy 2024 Answers.pdf
Home assignment II on Spectroscopy 2024 Answers.pdfHome assignment II on Spectroscopy 2024 Answers.pdf
Home assignment II on Spectroscopy 2024 Answers.pdf
 
Biological Screening of Herbal Drugs in detailed.
Biological Screening of Herbal Drugs in detailed.Biological Screening of Herbal Drugs in detailed.
Biological Screening of Herbal Drugs in detailed.
 
The French Revolution Class 9 Study Material pdf free download
The French Revolution Class 9 Study Material pdf free downloadThe French Revolution Class 9 Study Material pdf free download
The French Revolution Class 9 Study Material pdf free download
 
Embracing GenAI - A Strategic Imperative
Embracing GenAI - A Strategic ImperativeEmbracing GenAI - A Strategic Imperative
Embracing GenAI - A Strategic Imperative
 
678020731-Sumas-y-Restas-Para-Colorear.pdf
678020731-Sumas-y-Restas-Para-Colorear.pdf678020731-Sumas-y-Restas-Para-Colorear.pdf
678020731-Sumas-y-Restas-Para-Colorear.pdf
 
Digital Tools and AI for Teaching Learning and Research
Digital Tools and AI for Teaching Learning and ResearchDigital Tools and AI for Teaching Learning and Research
Digital Tools and AI for Teaching Learning and Research
 
How to Make a Field invisible in Odoo 17
How to Make a Field invisible in Odoo 17How to Make a Field invisible in Odoo 17
How to Make a Field invisible in Odoo 17
 
Language Across the Curriculm LAC B.Ed.
Language Across the  Curriculm LAC B.Ed.Language Across the  Curriculm LAC B.Ed.
Language Across the Curriculm LAC B.Ed.
 
Polish students' mobility in the Czech Republic
Polish students' mobility in the Czech RepublicPolish students' mobility in the Czech Republic
Polish students' mobility in the Czech Republic
 
A Strategic Approach: GenAI in Education
A Strategic Approach: GenAI in EducationA Strategic Approach: GenAI in Education
A Strategic Approach: GenAI in Education
 
special B.ed 2nd year old paper_20240531.pdf
special B.ed 2nd year old paper_20240531.pdfspecial B.ed 2nd year old paper_20240531.pdf
special B.ed 2nd year old paper_20240531.pdf
 
Lapbook sobre os Regimes Totalitários.pdf
Lapbook sobre os Regimes Totalitários.pdfLapbook sobre os Regimes Totalitários.pdf
Lapbook sobre os Regimes Totalitários.pdf
 
Overview on Edible Vaccine: Pros & Cons with Mechanism
Overview on Edible Vaccine: Pros & Cons with MechanismOverview on Edible Vaccine: Pros & Cons with Mechanism
Overview on Edible Vaccine: Pros & Cons with Mechanism
 
Operation Blue Star - Saka Neela Tara
Operation Blue Star   -  Saka Neela TaraOperation Blue Star   -  Saka Neela Tara
Operation Blue Star - Saka Neela Tara
 
Phrasal Verbs.XXXXXXXXXXXXXXXXXXXXXXXXXX
Phrasal Verbs.XXXXXXXXXXXXXXXXXXXXXXXXXXPhrasal Verbs.XXXXXXXXXXXXXXXXXXXXXXXXXX
Phrasal Verbs.XXXXXXXXXXXXXXXXXXXXXXXXXX
 
"Protectable subject matters, Protection in biotechnology, Protection of othe...
"Protectable subject matters, Protection in biotechnology, Protection of othe..."Protectable subject matters, Protection in biotechnology, Protection of othe...
"Protectable subject matters, Protection in biotechnology, Protection of othe...
 

Cpcs302 1

  • 1.
  • 2. Course Goals • To provide students with an understanding of the major phases of a compiler. • To introduce students to the theory behind the various phases, including regular expressions, context-free grammars, and finite state automata. • To provide students with an understanding of the design and implementation of a compiler. • To have the students build a compiler, through type checking and intermediate code generation, for a small language. • To provide students with an opportunity to work in a group on a large project.
  • 3. Course Outcomes • Students will have experience using current compiler generation tools. • Students will be familiar with the different phases of compilation. • Students will have experience defining and specifying the semantic rules of a programming language
  • 4. Prerequisites • In-depth knowledge of at least one structured programming language. • Strong background in algorithms, data structures, and abstract data types, including stacks, binary trees, graphs. • Understanding of grammar theories. • Understanding of data types and control structures, their design and implementation. • Understanding of the design and implementation of subprograms, parameter passing mechanisms, scope.
  • 5.
  • 6. Textbook Compilers: Principles, Techniques, and Tools” by Aho, Lam, Sethi, and Ullman, 2 nd edition.
  • 7. GRADING Assignements & project: 40 Midterm Exam: 20 Final Exam: 40
  • 8.
  • 9.
  • 10.
  • 11. Preprocessors, Compilers, Assemblers, and Linkers Preprocessor Compiler Assembler Linker Skeletal Source Program Source Program Target Assembly Program Relocatable Object Code Absolute Machine Code Libraries and Relocatable Object Files Try for example: gcc -v myprog.c
  • 12. The Phases of a Compiler Phase Output Sample Programmer (source code producer) Source string A=B+C; Scanner (performs lexical analysis ) Token string ‘ A’ , ‘=’ , ‘B’ , ‘+’ , ‘C’ , ‘;’ And symbol table with names Parser (performs syntax analysis based on the grammar of the programming language) Parse tree or abstract syntax tree ; | = / A + / B C Semantic analyzer (type checking, etc) Annotated parse tree or abstract syntax tree Intermediate code generator Three-address code, quads, or RTL int2fp B t1 + t1 C t2 := t2 A Optimizer Three-address code, quads, or RTL int2fp B t1 + t1 #2.3 A Code generator Assembly code MOVF #2.3,r1 ADDF2 r1,r2 MOVF r2,A Peephole optimizer Assembly code ADDF2 #2.3,r2 MOVF r2,A
  • 13.
  • 14.
  • 15.
  • 16.
  • 17.
  • 18.
  • 19.
  • 20.
  • 21.
  • 22. The Back End Responsibilities Translate IR into target machine code Choose instructions to implement each IR operation Decide which value to keep in registers Ensure conformance with system interfaces Automation has been much less successful in the back end Errors IR Instruction Scheduling Instruction Selection Machine code Register Allocation IR IR
  • 23.
  • 24.
  • 25.
  • 26.
  • 27. The Optimizer (or Middle End) Modern optimizers are structured as a series of passes Typical Transformations Discover & propagate some constant value Move a computation to a less frequently executed place Discover a redundant computation & remove it Remove useless or unreachable co de Errors O p t 1 O p t 3 O p t 2 O p t n ... IR IR IR IR IR
  • 28.
  • 29.
  • 30.
  • 31.
  • 32.
  • 33.
  • 34.
  • 35.
  • 36. Set Operations (refresher) You need to know these definitions
  • 37.
  • 38.
  • 39.
  • 40.
  • 41.
  • 42.
  • 43.
  • 44.