Cpcs302 1

Cpcs302  1
  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]
Cpcs302  1
Cpcs302  1
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]
1 de 44

Recomendados

Compiler Construction por
Compiler ConstructionCompiler Construction
Compiler ConstructionAhmed Raza
1K visualizações39 slides
Compilers por
CompilersCompilers
CompilersSatyamevjayte Haxor
2.5K visualizações113 slides
Compiler1 por
Compiler1Compiler1
Compiler1Natish Kumar
7.5K visualizações14 slides
Compiler Design por
Compiler DesignCompiler Design
Compiler DesignDr. Jaydeep Patil
809 visualizações102 slides
Compiler Construction por
Compiler ConstructionCompiler Construction
Compiler ConstructionSarmad Ali
4.4K visualizações40 slides
Analysis of the source program por
Analysis of the source programAnalysis of the source program
Analysis of the source programHuawei Technologies
14.4K visualizações21 slides

Mais conteúdo relacionado

Mais procurados

Compiler Design por
Compiler DesignCompiler Design
Compiler DesignMir Majid
46.2K visualizações18 slides
Error detection recovery por
Error detection recoveryError detection recovery
Error detection recoveryTech_MX
32.1K visualizações61 slides
Compiler Construction introduction por
Compiler Construction introductionCompiler Construction introduction
Compiler Construction introductionRana Ehtisham Ul Haq
3.5K visualizações39 slides
Lexical analyzer por
Lexical analyzerLexical analyzer
Lexical analyzerAshwini Sonawane
48.3K visualizações79 slides
Spr ch-05-compilers por
Spr ch-05-compilersSpr ch-05-compilers
Spr ch-05-compilersVasim Pathan
6.7K visualizações41 slides
Principles of compiler design por
Principles of compiler designPrinciples of compiler design
Principles of compiler designDHARANI BABU
6.5K visualizações16 slides

Mais procurados(20)

Compiler Design por Mir Majid
Compiler DesignCompiler Design
Compiler Design
Mir Majid 46.2K visualizações
Error detection recovery por Tech_MX
Error detection recoveryError detection recovery
Error detection recovery
Tech_MX32.1K visualizações
Compiler Construction introduction por Rana Ehtisham Ul Haq
Compiler Construction introductionCompiler Construction introduction
Compiler Construction introduction
Rana Ehtisham Ul Haq3.5K visualizações
Lexical analyzer por Ashwini Sonawane
Lexical analyzerLexical analyzer
Lexical analyzer
Ashwini Sonawane48.3K visualizações
Spr ch-05-compilers por Vasim Pathan
Spr ch-05-compilersSpr ch-05-compilers
Spr ch-05-compilers
Vasim Pathan6.7K visualizações
Principles of compiler design por DHARANI BABU
Principles of compiler designPrinciples of compiler design
Principles of compiler design
DHARANI BABU6.5K visualizações
Compiler Design(Nanthu) por guest91cc85
Compiler Design(Nanthu)Compiler Design(Nanthu)
Compiler Design(Nanthu)
guest91cc8512.1K visualizações
phases of a compiler por Ms.SHANTHI.S CSE
 phases of a compiler phases of a compiler
phases of a compiler
Ms.SHANTHI.S CSE1.2K visualizações
Chapter 1 1 por bolovv
Chapter 1 1Chapter 1 1
Chapter 1 1
bolovv5.6K visualizações
Compiler Design Material por Dr. C.V. Suresh Babu
Compiler Design MaterialCompiler Design Material
Compiler Design Material
Dr. C.V. Suresh Babu14.9K visualizações
Compiler Design Lecture Notes por FellowBuddy.com
Compiler Design Lecture NotesCompiler Design Lecture Notes
Compiler Design Lecture Notes
FellowBuddy.com7.8K visualizações
Compiler unit 1 por BBDITM LUCKNOW
Compiler unit 1Compiler unit 1
Compiler unit 1
BBDITM LUCKNOW3.5K visualizações
Compiler Design Introduction por Richa Sharma
Compiler Design IntroductionCompiler Design Introduction
Compiler Design Introduction
Richa Sharma4.9K visualizações
Compiler Construction Course - Introduction por Muhammad Sanaullah
Compiler Construction Course - IntroductionCompiler Construction Course - Introduction
Compiler Construction Course - Introduction
Muhammad Sanaullah2.6K visualizações
Phases of compiler por Karan Deopura
Phases of compilerPhases of compiler
Phases of compiler
Karan Deopura7.6K visualizações
Ch1 por kinnarshah8888
Ch1Ch1
Ch1
kinnarshah88881.4K visualizações
Compiler Design(NANTHU NOTES) por guest251d9a
Compiler Design(NANTHU NOTES)Compiler Design(NANTHU NOTES)
Compiler Design(NANTHU NOTES)
guest251d9a45.8K visualizações
Cs6660 compiler design por hari2010
Cs6660 compiler designCs6660 compiler design
Cs6660 compiler design
hari20102.4K visualizações
Different phases of a compiler por Sumit Sinha
Different phases of a compilerDifferent phases of a compiler
Different phases of a compiler
Sumit Sinha18.2K visualizações
Compiler design por sanchi29
Compiler designCompiler design
Compiler design
sanchi29119 visualizações

Destaque

Regular expression (compiler) por
Regular expression (compiler)Regular expression (compiler)
Regular expression (compiler)ReachLocal Services India
10.7K visualizações15 slides
Compiler vs Interpreter-Compiler design ppt. por
Compiler vs Interpreter-Compiler design ppt.Compiler vs Interpreter-Compiler design ppt.
Compiler vs Interpreter-Compiler design ppt.Md Hossen
17.4K visualizações16 slides
Ss ui lecture 2 por
Ss ui lecture 2Ss ui lecture 2
Ss ui lecture 2Avinash Kapse
367 visualizações25 slides
SS UI Lecture 1 por
SS UI Lecture 1SS UI Lecture 1
SS UI Lecture 1Avinash Kapse
231 visualizações18 slides
OpenOffice++: Improving the Quality of Open Source Software por
OpenOffice++: Improving the Quality of Open Source SoftwareOpenOffice++: Improving the Quality of Open Source Software
OpenOffice++: Improving the Quality of Open Source SoftwareAlexandro Colorado
480 visualizações24 slides
Diab Compiler Quality Overview por
Diab Compiler Quality OverviewDiab Compiler Quality Overview
Diab Compiler Quality Overviewkylefacchin
641 visualizações8 slides

Destaque(20)

Compiler vs Interpreter-Compiler design ppt. por Md Hossen
Compiler vs Interpreter-Compiler design ppt.Compiler vs Interpreter-Compiler design ppt.
Compiler vs Interpreter-Compiler design ppt.
Md Hossen17.4K visualizações
Ss ui lecture 2 por Avinash Kapse
Ss ui lecture 2Ss ui lecture 2
Ss ui lecture 2
Avinash Kapse367 visualizações
SS UI Lecture 1 por Avinash Kapse
SS UI Lecture 1SS UI Lecture 1
SS UI Lecture 1
Avinash Kapse231 visualizações
OpenOffice++: Improving the Quality of Open Source Software por Alexandro Colorado
OpenOffice++: Improving the Quality of Open Source SoftwareOpenOffice++: Improving the Quality of Open Source Software
OpenOffice++: Improving the Quality of Open Source Software
Alexandro Colorado480 visualizações
Diab Compiler Quality Overview por kylefacchin
Diab Compiler Quality OverviewDiab Compiler Quality Overview
Diab Compiler Quality Overview
kylefacchin641 visualizações
Principles of compiler design por Janani Parthiban
Principles of compiler designPrinciples of compiler design
Principles of compiler design
Janani Parthiban7.6K visualizações
Introduction to course por nikit meshram
Introduction to courseIntroduction to course
Introduction to course
nikit meshram250 visualizações
01. introduction por babaaasingh123
01. introduction01. introduction
01. introduction
babaaasingh123675 visualizações
Unit 1 cd por codereplugd
Unit 1 cdUnit 1 cd
Unit 1 cd
codereplugd3.6K visualizações
Compiler Engineering Lab#1 por MashaelQ
Compiler Engineering Lab#1Compiler Engineering Lab#1
Compiler Engineering Lab#1
MashaelQ1.6K visualizações
Computer graphics por Prianka Padmanaban
Computer graphics   Computer graphics
Computer graphics
Prianka Padmanaban4.4K visualizações
Compiler Design Tutorial por Sarit Chakraborty
Compiler Design Tutorial Compiler Design Tutorial
Compiler Design Tutorial
Sarit Chakraborty6.4K visualizações
compiler and their types por patchamounika7
compiler and their typescompiler and their types
compiler and their types
patchamounika730.1K visualizações
Lexical analysis por Richa Sharma
Lexical analysisLexical analysis
Lexical analysis
Richa Sharma4.8K visualizações
Top Down Parsing, Predictive Parsing por Tanzeela_Hussain
Top Down Parsing, Predictive ParsingTop Down Parsing, Predictive Parsing
Top Down Parsing, Predictive Parsing
Tanzeela_Hussain23K visualizações
Compiler vs interpreter por Paras Patel
Compiler vs interpreterCompiler vs interpreter
Compiler vs interpreter
Paras Patel11.3K visualizações
Introduction to Compiler Construction por Sarmad Ali
Introduction to Compiler Construction Introduction to Compiler Construction
Introduction to Compiler Construction
Sarmad Ali10.8K visualizações
Parsing por Roohaali
ParsingParsing
Parsing
Roohaali9.9K visualizações

Similar a Cpcs302 1

Compiler design por
Compiler designCompiler design
Compiler designsuganyasanjai
232 visualizações9 slides
Cd econtent link1 por
Cd econtent link1Cd econtent link1
Cd econtent link1suganyasanjai
36 visualizações9 slides
Ch1 (1).ppt por
Ch1 (1).pptCh1 (1).ppt
Ch1 (1).pptMDSayem35
3 visualizações11 slides
Chapter#01 cc por
Chapter#01 ccChapter#01 cc
Chapter#01 ccabdulbaki3
47 visualizações40 slides
Chapter One por
Chapter OneChapter One
Chapter Onebolovv
8.8K visualizações69 slides
COMPILER CONSTRUCTION KU 1.pptx por
COMPILER CONSTRUCTION KU 1.pptxCOMPILER CONSTRUCTION KU 1.pptx
COMPILER CONSTRUCTION KU 1.pptxRossy719186
4 visualizações46 slides

Similar a Cpcs302 1(20)

Compiler design por suganyasanjai
Compiler designCompiler design
Compiler design
suganyasanjai232 visualizações
Cd econtent link1 por suganyasanjai
Cd econtent link1Cd econtent link1
Cd econtent link1
suganyasanjai36 visualizações
Ch1 (1).ppt por MDSayem35
Ch1 (1).pptCh1 (1).ppt
Ch1 (1).ppt
MDSayem353 visualizações
Chapter#01 cc por abdulbaki3
Chapter#01 ccChapter#01 cc
Chapter#01 cc
abdulbaki347 visualizações
Chapter One por bolovv
Chapter OneChapter One
Chapter One
bolovv8.8K visualizações
COMPILER CONSTRUCTION KU 1.pptx por Rossy719186
COMPILER CONSTRUCTION KU 1.pptxCOMPILER CONSTRUCTION KU 1.pptx
COMPILER CONSTRUCTION KU 1.pptx
Rossy7191864 visualizações
unit1pdf__2021_12_14_12_37_34.pdf por DrIsikoIsaac
unit1pdf__2021_12_14_12_37_34.pdfunit1pdf__2021_12_14_12_37_34.pdf
unit1pdf__2021_12_14_12_37_34.pdf
DrIsikoIsaac49 visualizações
Chapter1pdf__2021_11_23_10_53_20.pdf por DrIsikoIsaac
Chapter1pdf__2021_11_23_10_53_20.pdfChapter1pdf__2021_11_23_10_53_20.pdf
Chapter1pdf__2021_11_23_10_53_20.pdf
DrIsikoIsaac54 visualizações
what is compiler and five phases of compiler por adilmehmood93
what is compiler and five phases of compilerwhat is compiler and five phases of compiler
what is compiler and five phases of compiler
adilmehmood939.2K visualizações
Presentation1 por Zarin Tasnim
Presentation1Presentation1
Presentation1
Zarin Tasnim30 visualizações
Presentation1 por Zarin Tasnim
Presentation1Presentation1
Presentation1
Zarin Tasnim12 visualizações
Introduction to compiler por Abha Damani
Introduction to compilerIntroduction to compiler
Introduction to compiler
Abha Damani8.8K visualizações
Techniques & applications of Compiler por Preethi AKNR
Techniques & applications of CompilerTechniques & applications of Compiler
Techniques & applications of Compiler
Preethi AKNR13.3K visualizações
The Phases of a Compiler por Radhika Talaviya
The Phases of a CompilerThe Phases of a Compiler
The Phases of a Compiler
Radhika Talaviya388 visualizações
Chapter 1.pptx por NesredinTeshome1
Chapter 1.pptxChapter 1.pptx
Chapter 1.pptx
NesredinTeshome110 visualizações
Concept of compiler in details por kazi_aihtesham
Concept of compiler in detailsConcept of compiler in details
Concept of compiler in details
kazi_aihtesham67 visualizações

Último

ICS3211_lecture 09_2023.pdf por
ICS3211_lecture 09_2023.pdfICS3211_lecture 09_2023.pdf
ICS3211_lecture 09_2023.pdfVanessa Camilleri
134 visualizações10 slides
The Accursed House by Émile Gaboriau por
The Accursed House  by Émile GaboriauThe Accursed House  by Émile Gaboriau
The Accursed House by Émile GaboriauDivyaSheta
246 visualizações15 slides
Monthly Information Session for MV Asterix (November) por
Monthly Information Session for MV Asterix (November)Monthly Information Session for MV Asterix (November)
Monthly Information Session for MV Asterix (November)Esquimalt MFRC
98 visualizações26 slides
STRATEGIC MANAGEMENT MODULE 1_UNIT1 _UNIT2.pdf por
STRATEGIC MANAGEMENT MODULE 1_UNIT1 _UNIT2.pdfSTRATEGIC MANAGEMENT MODULE 1_UNIT1 _UNIT2.pdf
STRATEGIC MANAGEMENT MODULE 1_UNIT1 _UNIT2.pdfDr Vijay Vishwakarma
90 visualizações68 slides
MercerJesse2.1Doc.pdf por
MercerJesse2.1Doc.pdfMercerJesse2.1Doc.pdf
MercerJesse2.1Doc.pdfjessemercerail
301 visualizações5 slides
Creative Restart 2023: Leonard Savage - The Permanent Brief: Unearthing unobv... por
Creative Restart 2023: Leonard Savage - The Permanent Brief: Unearthing unobv...Creative Restart 2023: Leonard Savage - The Permanent Brief: Unearthing unobv...
Creative Restart 2023: Leonard Savage - The Permanent Brief: Unearthing unobv...Taste
53 visualizações21 slides

Último(20)

ICS3211_lecture 09_2023.pdf por Vanessa Camilleri
ICS3211_lecture 09_2023.pdfICS3211_lecture 09_2023.pdf
ICS3211_lecture 09_2023.pdf
Vanessa Camilleri134 visualizações
The Accursed House by Émile Gaboriau por DivyaSheta
The Accursed House  by Émile GaboriauThe Accursed House  by Émile Gaboriau
The Accursed House by Émile Gaboriau
DivyaSheta246 visualizações
Monthly Information Session for MV Asterix (November) por Esquimalt MFRC
Monthly Information Session for MV Asterix (November)Monthly Information Session for MV Asterix (November)
Monthly Information Session for MV Asterix (November)
Esquimalt MFRC98 visualizações
STRATEGIC MANAGEMENT MODULE 1_UNIT1 _UNIT2.pdf por Dr Vijay Vishwakarma
STRATEGIC MANAGEMENT MODULE 1_UNIT1 _UNIT2.pdfSTRATEGIC MANAGEMENT MODULE 1_UNIT1 _UNIT2.pdf
STRATEGIC MANAGEMENT MODULE 1_UNIT1 _UNIT2.pdf
Dr Vijay Vishwakarma90 visualizações
MercerJesse2.1Doc.pdf por jessemercerail
MercerJesse2.1Doc.pdfMercerJesse2.1Doc.pdf
MercerJesse2.1Doc.pdf
jessemercerail301 visualizações
Creative Restart 2023: Leonard Savage - The Permanent Brief: Unearthing unobv... por Taste
Creative Restart 2023: Leonard Savage - The Permanent Brief: Unearthing unobv...Creative Restart 2023: Leonard Savage - The Permanent Brief: Unearthing unobv...
Creative Restart 2023: Leonard Savage - The Permanent Brief: Unearthing unobv...
Taste53 visualizações
NodeJS and ExpressJS.pdf por ArthyR3
NodeJS and ExpressJS.pdfNodeJS and ExpressJS.pdf
NodeJS and ExpressJS.pdf
ArthyR347 visualizações
BÀI TẬP BỔ TRỢ TIẾNG ANH 11 THEO ĐƠN VỊ BÀI HỌC - CẢ NĂM - CÓ FILE NGHE (FRIE... por Nguyen Thanh Tu Collection
BÀI TẬP BỔ TRỢ TIẾNG ANH 11 THEO ĐƠN VỊ BÀI HỌC - CẢ NĂM - CÓ FILE NGHE (FRIE...BÀI TẬP BỔ TRỢ TIẾNG ANH 11 THEO ĐƠN VỊ BÀI HỌC - CẢ NĂM - CÓ FILE NGHE (FRIE...
BÀI TẬP BỔ TRỢ TIẾNG ANH 11 THEO ĐƠN VỊ BÀI HỌC - CẢ NĂM - CÓ FILE NGHE (FRIE...
Nguyen Thanh Tu Collection71 visualizações
SURGICAL MANAGEMENT OF CERVICAL CANCER DR. NN CHAVAN 28102023.pptx por Niranjan Chavan
SURGICAL MANAGEMENT OF CERVICAL CANCER DR. NN CHAVAN 28102023.pptxSURGICAL MANAGEMENT OF CERVICAL CANCER DR. NN CHAVAN 28102023.pptx
SURGICAL MANAGEMENT OF CERVICAL CANCER DR. NN CHAVAN 28102023.pptx
Niranjan Chavan43 visualizações
Class 9 lesson plans por TARIQ KHAN
Class 9 lesson plansClass 9 lesson plans
Class 9 lesson plans
TARIQ KHAN68 visualizações
Gross Anatomy of the Liver por obaje godwin sunday
Gross Anatomy of the LiverGross Anatomy of the Liver
Gross Anatomy of the Liver
obaje godwin sunday74 visualizações
Pharmaceutical Inorganic Chemistry Unit IVMiscellaneous compounds Expectorant... por Ms. Pooja Bhandare
Pharmaceutical Inorganic Chemistry Unit IVMiscellaneous compounds Expectorant...Pharmaceutical Inorganic Chemistry Unit IVMiscellaneous compounds Expectorant...
Pharmaceutical Inorganic Chemistry Unit IVMiscellaneous compounds Expectorant...
Ms. Pooja Bhandare194 visualizações
Java Simplified: Understanding Programming Basics por Akshaj Vadakkath Joshy
Java Simplified: Understanding Programming BasicsJava Simplified: Understanding Programming Basics
Java Simplified: Understanding Programming Basics
Akshaj Vadakkath Joshy625 visualizações
Create a Structure in VBNet.pptx por Breach_P
Create a Structure in VBNet.pptxCreate a Structure in VBNet.pptx
Create a Structure in VBNet.pptx
Breach_P82 visualizações
Berry country.pdf por MariaKenney3
Berry country.pdfBerry country.pdf
Berry country.pdf
MariaKenney361 visualizações
Nelson_RecordStore.pdf por BrynNelson5
Nelson_RecordStore.pdfNelson_RecordStore.pdf
Nelson_RecordStore.pdf
BrynNelson546 visualizações
Guess Papers ADC 1, Karachi University por Khalid Aziz
Guess Papers ADC 1, Karachi UniversityGuess Papers ADC 1, Karachi University
Guess Papers ADC 1, Karachi University
Khalid Aziz83 visualizações
Guidelines & Identification of Early Sepsis DR. NN CHAVAN 02122023.pptx por Niranjan Chavan
Guidelines & Identification of Early Sepsis DR. NN CHAVAN 02122023.pptxGuidelines & Identification of Early Sepsis DR. NN CHAVAN 02122023.pptx
Guidelines & Identification of Early Sepsis DR. NN CHAVAN 02122023.pptx
Niranjan Chavan38 visualizações

Cpcs302 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.
  • 33.
  • 34.
  • 35.
  • 36. Set Operations (refresher) You need to know these definitions
  • 37.
  • 38.
  • 39.
  • 40.
  • 41.
  • 42.
  • 43.
  • 44.