SlideShare a Scribd company logo
Compilers
CS 346
3 – 0 – 0 – 6
Monday – Tuesday – Wednesday
9.00 --- 9.55 10.00 --- 10.55 11.00 --- 11.55
Arijit Sur
Office: H-103
Department of Computer Science and Engineering
Email: arijit@iitg.ernet.in
Ph: 2361
Instructors: Dr. A. Sur and Dr. A. Sarkar
Syllabus
• Overview of different phases of a compiler: front-end; back-end;
• Lexical analysis: specification of tokens, recognition of tokens, input
buffering, automatic tools;
• Syntax analysis: context free grammars, top down and bottom up parsing
techniques, construction of efficient parsers, syntax-directed translation,
automatic tools;
• Semantic analysis: declaration processing, type checking, symbol tables,• Semantic analysis: declaration processing, type checking, symbol tables,
error recovery;
• Intermediate code generation: run-time environments, translation of
language constructs;
• Code generation: flow-graphs, register allocation, code-generation
algorithms;
• Introduction to code optimization techniques.
8-Jan-15 CS346 Lecture 1 2
Books
• Text Book
– Alfred V. Aho, Monica S. Lam, Ravi Sethi, Jeffrey D. Ullman,
Compilers: Principles, Techniques, and Tools, 2nd Edition,
Prentice Hall, 2009
• Reference Books
– V. Raghavan, Principles of Compiler Design, McGrawHill, 2010
– C.N. Fischer, R.J. Le Blanc, Crafting a Compiler with C, Pearson
Education, 2009
– K. D. Cooper, L. Torczon, Engineering a Compiler, Morgan
Kaufmann Publishers, 2004
– Allen Holub, Compiler Design in C, Prentice-Hall software series,
1990
8-Jan-15 CS346 Lecture 1 3
Grades
• 2 Quiz s
– 20% of grade
• Mid-Semester
– 30% of grade
• End-Semester
– 50% of grade
• Attendance below 75% --- F Grade
• Random Attendance
8-Jan-15 CS346 Lecture 1 4
8-Jan-15 CS346 Lecture 1 6
Basic Blocks of Computing System
8-Jan-15 CS346 Lecture 1 7
Program Execution: Layered Architecture
High Level Language
Program
Assembly Language
Program
Compiler
Assembler +
temp = v[k];
v[k] = v[k+1];
v[k+1] = temp;
lw $15, 0($2)
lw $16, 4($2)
sw $16, 0($2)
sw $15, 4($2)
Machine Language
Program
Control Signal
Specification
Assembler +
Linker + Loader
Machine Interpretation
sw $15, 4($2)
0000 1001 1100 0110 1010 1111 0101 1000
1010 1111 0101 1000 0000 1001 1100 0110
1100 0110 1010 1111 0101 1000 0000 1001
0101 1000 0000 1001 1100 0110 1010 1111
°
°
ALUOP[0:3] <= InstReg[9:11] & MASK
8-Jan-15 CS346 Lecture 1 8
Architecture of Computing System
Compiler
Operating
System
Application
Instruction Set
Architecture
Firmware
I/O systemInstr. Set Proc.
Digital Design
Circuit Design
Architecture
Datapath & Control
Layout
8-Jan-15 CS346 Lecture 1 9
Definitions
• What is a compiler?
– A program that accepts as input a program text in a certain language and
produces as output a program text in another language, while preserving the
meaning of that text (Grune et al, 2000).
– A program that reads a program written in one language (source language)
and translates it into an equivalent program in another language (target
language) (Aho et al)
– Report errors of source language which are detected during the
8-Jan-15 CS346 Lecture 1 10
– Report errors of source language which are detected during the
translation process
• What is an interpreter?
– A program that reads a source program and produces the results of executing
this source.
• We deal with compilers! Many of these issues arise with interpreters!
Compiler Vs. Interpreter
Compiler
Source Program
Interpreter
Source Program
Input
Output
Target Program
Target ProgramInput Output
Translator
Source Program
Intermediate
Program
Input
Virtual
Machine Output
A Hybrid Compiler
Examples
• C is typically compiled
• Lisp is typically interpreted
• Java is compiled to bytecodes, which are then interpreted
• source-to-source compiler, transcompiler, or transpiler :
– C++ to C
– High Performance Fortran (HPF) to Fortran (parallelising compiler)
8-Jan-15 12
– High Performance Fortran (HPF) to Fortran (parallelising compiler)
• Cross Compilers (wiki)
– A cross compiler is a compiler capable of
reading executable code for a platform other than the one on
which the compiler is running. For example, a compiler that runs
on a Windows 7 PC but generates code that runs
on Android Smartphone is a cross compiler.
CS346 Lecture 1
Qualities of a Good Compiler
What qualities would you want in a compiler?
– generates correct code (first and foremost!)
– generates fast code
– conforms to the specifications of the input language
– copes with essentially arbitrary input size, variables,
8-Jan-15 13
– copes with essentially arbitrary input size, variables,
etc.
– compilation time (linearly)proportional to size of source
– good diagnostics
– consistent optimisations
– works well with the debugger
CS346 Lecture 1
Principles of Compilation
The compiler must:
• preserve the meaning of the program being compiled.
• “improve” the source code in some way.
Other issues (depending on the setting):
8-Jan-15 14
Other issues (depending on the setting):
• Speed (of compiled code)
• Space (size of compiled code)
• Feedback (information provided to the user)
• Debugging (transformations obscure the relationship source code vs target)
• Compilation time efficiency (fast or slow compiler?)
CS346 Lecture 1
Applications
• Most common use: translate a high-level program to object code
– Program Translation: binary translation, hardware synthesis, …
• Optimizations for computer architectures:
– Improve program performance, take into account hardware parallelism, etc…
• Interpreters: e.g., BASIC, Lisp etc.
8-Jan-15 15
• Software productivity tools
– Debugging aids: e.g., purify
• Text formatters, just-in-time compilation for Java, power
management, global distributed computing, …
Key: Ability to extract properties of a source program (analysis) and
transform it to construct a target program (synthesis)
CS346 Lecture 1
Lecture1 introduction compilers

More Related Content

What's hot

SystemVerilog OOP Ovm Features Summary
SystemVerilog OOP Ovm Features SummarySystemVerilog OOP Ovm Features Summary
SystemVerilog OOP Ovm Features Summary
Amal Khailtash
 
Yacc
YaccYacc
Introduction to System verilog
Introduction to System verilog Introduction to System verilog
Introduction to System verilog
Pushpa Yakkala
 
Line Of Code(LOC) In Software Engineering By NADEEM AHMED FROM DEPALPUR
Line Of Code(LOC) In Software Engineering By NADEEM AHMED FROM DEPALPURLine Of Code(LOC) In Software Engineering By NADEEM AHMED FROM DEPALPUR
Line Of Code(LOC) In Software Engineering By NADEEM AHMED FROM DEPALPUR
NA000000
 
Compiler construction tools
Compiler construction toolsCompiler construction tools
Compiler construction tools
Akhil Kaushik
 
Compiler Construction | Lecture 1 | What is a compiler?
Compiler Construction | Lecture 1 | What is a compiler?Compiler Construction | Lecture 1 | What is a compiler?
Compiler Construction | Lecture 1 | What is a compiler?
Eelco Visser
 
1.Role lexical Analyzer
1.Role lexical Analyzer1.Role lexical Analyzer
1.Role lexical Analyzer
Radhakrishnan Chinnusamy
 
Compiler Chapter 1
Compiler Chapter 1Compiler Chapter 1
Compiler Chapter 1
Huawei Technologies
 
Passes of compilers
Passes of compilersPasses of compilers
Passes of compilers
Vairavel C
 
Introduction to compiler
Introduction to compilerIntroduction to compiler
Introduction to compilerAbha Damani
 
Introduction to Compiler Construction
Introduction to Compiler Construction Introduction to Compiler Construction
Introduction to Compiler Construction
Sarmad Ali
 
System verilog control flow
System verilog control flowSystem verilog control flow
System verilog control flow
Pushpa Yakkala
 
Predictive parser
Predictive parserPredictive parser
Predictive parser
Jothi Lakshmi
 
UVM Methodology Tutorial
UVM Methodology TutorialUVM Methodology Tutorial
UVM Methodology Tutorial
Arrow Devices
 
Lecture 01 introduction to compiler
Lecture 01 introduction to compilerLecture 01 introduction to compiler
Lecture 01 introduction to compiler
Iffat Anjum
 
Language for specifying lexical Analyzer
Language for specifying lexical AnalyzerLanguage for specifying lexical Analyzer
Language for specifying lexical Analyzer
Archana Gopinath
 
AMBA Ahb 2.0
AMBA Ahb 2.0AMBA Ahb 2.0
AMBA Ahb 2.0
Akhil Srivastava
 
Lexical Analysis - Compiler design
Lexical Analysis - Compiler design Lexical Analysis - Compiler design
Lexical Analysis - Compiler design
Aman Sharma
 
UVM ARCHITECTURE FOR VERIFICATION
UVM ARCHITECTURE FOR VERIFICATIONUVM ARCHITECTURE FOR VERIFICATION
UVM ARCHITECTURE FOR VERIFICATION
IAEME Publication
 
Lecture2 general structure of a compiler
Lecture2 general structure of a compilerLecture2 general structure of a compiler
Lecture2 general structure of a compiler
Mahesh Kumar Chelimilla
 

What's hot (20)

SystemVerilog OOP Ovm Features Summary
SystemVerilog OOP Ovm Features SummarySystemVerilog OOP Ovm Features Summary
SystemVerilog OOP Ovm Features Summary
 
Yacc
YaccYacc
Yacc
 
Introduction to System verilog
Introduction to System verilog Introduction to System verilog
Introduction to System verilog
 
Line Of Code(LOC) In Software Engineering By NADEEM AHMED FROM DEPALPUR
Line Of Code(LOC) In Software Engineering By NADEEM AHMED FROM DEPALPURLine Of Code(LOC) In Software Engineering By NADEEM AHMED FROM DEPALPUR
Line Of Code(LOC) In Software Engineering By NADEEM AHMED FROM DEPALPUR
 
Compiler construction tools
Compiler construction toolsCompiler construction tools
Compiler construction tools
 
Compiler Construction | Lecture 1 | What is a compiler?
Compiler Construction | Lecture 1 | What is a compiler?Compiler Construction | Lecture 1 | What is a compiler?
Compiler Construction | Lecture 1 | What is a compiler?
 
1.Role lexical Analyzer
1.Role lexical Analyzer1.Role lexical Analyzer
1.Role lexical Analyzer
 
Compiler Chapter 1
Compiler Chapter 1Compiler Chapter 1
Compiler Chapter 1
 
Passes of compilers
Passes of compilersPasses of compilers
Passes of compilers
 
Introduction to compiler
Introduction to compilerIntroduction to compiler
Introduction to compiler
 
Introduction to Compiler Construction
Introduction to Compiler Construction Introduction to Compiler Construction
Introduction to Compiler Construction
 
System verilog control flow
System verilog control flowSystem verilog control flow
System verilog control flow
 
Predictive parser
Predictive parserPredictive parser
Predictive parser
 
UVM Methodology Tutorial
UVM Methodology TutorialUVM Methodology Tutorial
UVM Methodology Tutorial
 
Lecture 01 introduction to compiler
Lecture 01 introduction to compilerLecture 01 introduction to compiler
Lecture 01 introduction to compiler
 
Language for specifying lexical Analyzer
Language for specifying lexical AnalyzerLanguage for specifying lexical Analyzer
Language for specifying lexical Analyzer
 
AMBA Ahb 2.0
AMBA Ahb 2.0AMBA Ahb 2.0
AMBA Ahb 2.0
 
Lexical Analysis - Compiler design
Lexical Analysis - Compiler design Lexical Analysis - Compiler design
Lexical Analysis - Compiler design
 
UVM ARCHITECTURE FOR VERIFICATION
UVM ARCHITECTURE FOR VERIFICATIONUVM ARCHITECTURE FOR VERIFICATION
UVM ARCHITECTURE FOR VERIFICATION
 
Lecture2 general structure of a compiler
Lecture2 general structure of a compilerLecture2 general structure of a compiler
Lecture2 general structure of a compiler
 

Viewers also liked

Lecture6 syntax analysis_2
Lecture6 syntax analysis_2Lecture6 syntax analysis_2
Lecture6 syntax analysis_2
Mahesh Kumar Chelimilla
 
تعرف إلى-الهندسة المعلوماتية
تعرف إلى-الهندسة المعلوماتيةتعرف إلى-الهندسة المعلوماتية
تعرف إلى-الهندسة المعلوماتية
Business Clinic Damascus University
 
Lecture5 syntax analysis_1
Lecture5 syntax analysis_1Lecture5 syntax analysis_1
Lecture5 syntax analysis_1
Mahesh Kumar Chelimilla
 
ف 2 الدرس الأول والثانى والثالث
ف 2 الدرس الأول والثانى والثالثف 2 الدرس الأول والثانى والثالث
ف 2 الدرس الأول والثانى والثالث
فتيات بنها النموذجى
 
Symbolic Automata = Automata + SMT solvers at ExCape14
Symbolic Automata = Automata + SMT solvers at ExCape14Symbolic Automata = Automata + SMT solvers at ExCape14
Symbolic Automata = Automata + SMT solvers at ExCape14
Loris D'Antoni
 
Lecture3 lexical analysis
Lecture3 lexical analysisLecture3 lexical analysis
Lecture3 lexical analysis
Mahesh Kumar Chelimilla
 
DFA minimization algorithms in map reduce
DFA minimization algorithms in map reduceDFA minimization algorithms in map reduce
DFA minimization algorithms in map reduce
Iraj Hedayati
 
Lecture4 lexical analysis2
Lecture4 lexical analysis2Lecture4 lexical analysis2
Lecture4 lexical analysis2
Mahesh Kumar Chelimilla
 
Isdn
IsdnIsdn
Lexical analysis - Compiler Design
Lexical analysis - Compiler DesignLexical analysis - Compiler Design
Lexical analysis - Compiler Design
Muhammed Afsal Villan
 
optimization of DFA
optimization of DFAoptimization of DFA
optimization of DFA
Maulik Togadiya
 
Integrated service digital network
Integrated service digital networkIntegrated service digital network
Integrated service digital network
Rahul Karn
 
Basic ISDN
Basic ISDNBasic ISDN
Basic ISDN
Chris McAndrew
 
Lexical analyzer
Lexical analyzerLexical analyzer
Lexical analyzer
kiran acharya
 
Isdn
IsdnIsdn
Isdn networking
Isdn networkingIsdn networking
Isdn networking
Singh Pankaj
 
ISDN Integrated Services Digital Network
ISDN Integrated Services Digital NetworkISDN Integrated Services Digital Network
ISDN Integrated Services Digital Network
Madhumita Tamhane
 

Viewers also liked (20)

roshan.ppt
roshan.pptroshan.ppt
roshan.ppt
 
Lecture6 syntax analysis_2
Lecture6 syntax analysis_2Lecture6 syntax analysis_2
Lecture6 syntax analysis_2
 
تعرف إلى-الهندسة المعلوماتية
تعرف إلى-الهندسة المعلوماتيةتعرف إلى-الهندسة المعلوماتية
تعرف إلى-الهندسة المعلوماتية
 
Lecture5 syntax analysis_1
Lecture5 syntax analysis_1Lecture5 syntax analysis_1
Lecture5 syntax analysis_1
 
ف 2 الدرس الأول والثانى والثالث
ف 2 الدرس الأول والثانى والثالثف 2 الدرس الأول والثانى والثالث
ف 2 الدرس الأول والثانى والثالث
 
Symbolic Automata = Automata + SMT solvers at ExCape14
Symbolic Automata = Automata + SMT solvers at ExCape14Symbolic Automata = Automata + SMT solvers at ExCape14
Symbolic Automata = Automata + SMT solvers at ExCape14
 
Lecture3 lexical analysis
Lecture3 lexical analysisLecture3 lexical analysis
Lecture3 lexical analysis
 
DFA minimization algorithms in map reduce
DFA minimization algorithms in map reduceDFA minimization algorithms in map reduce
DFA minimization algorithms in map reduce
 
DFA Minimization
DFA MinimizationDFA Minimization
DFA Minimization
 
Lecture4 lexical analysis2
Lecture4 lexical analysis2Lecture4 lexical analysis2
Lecture4 lexical analysis2
 
Isdn
IsdnIsdn
Isdn
 
Lexical analysis - Compiler Design
Lexical analysis - Compiler DesignLexical analysis - Compiler Design
Lexical analysis - Compiler Design
 
Forouzan isdn
Forouzan isdnForouzan isdn
Forouzan isdn
 
optimization of DFA
optimization of DFAoptimization of DFA
optimization of DFA
 
Integrated service digital network
Integrated service digital networkIntegrated service digital network
Integrated service digital network
 
Basic ISDN
Basic ISDNBasic ISDN
Basic ISDN
 
Lexical analyzer
Lexical analyzerLexical analyzer
Lexical analyzer
 
Isdn
IsdnIsdn
Isdn
 
Isdn networking
Isdn networkingIsdn networking
Isdn networking
 
ISDN Integrated Services Digital Network
ISDN Integrated Services Digital NetworkISDN Integrated Services Digital Network
ISDN Integrated Services Digital Network
 

Similar to Lecture1 introduction compilers

Compilers.pptx
Compilers.pptxCompilers.pptx
Compilers.pptx
MohammedMohammed578197
 
Introduction to Compiler
Introduction to CompilerIntroduction to Compiler
Introduction to Compiler
Radhakrishnan Chinnusamy
 
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
 
Introduction_to_Programming.pptx
Introduction_to_Programming.pptxIntroduction_to_Programming.pptx
Introduction_to_Programming.pptx
PmarkNorcio
 
Lecture1 compilers
Lecture1 compilersLecture1 compilers
Lecture1 compilers
Aftab Ahmad
 
Unit1 principle of programming language
Unit1 principle of programming languageUnit1 principle of programming language
Unit1 principle of programming languageVasavi College of Engg
 
introduction to computer vision and image processing
introduction to computer vision and image processingintroduction to computer vision and image processing
introduction to computer vision and image processing
pakboy12
 
Introduction to Compiler design
Introduction to Compiler design Introduction to Compiler design
Introduction to Compiler design
Dr. C.V. Suresh Babu
 
Cpcs302 1
Cpcs302  1Cpcs302  1
Cpcs302 1
guest5de1a5
 
Compiler design
Compiler designCompiler design
Compiler design
suganyasanjai
 
Cd econtent link1
Cd econtent link1Cd econtent link1
Cd econtent link1
suganyasanjai
 
Chapter 4 computer language
Chapter 4 computer languageChapter 4 computer language
Chapter 4 computer language
Azimjon Khamdamov
 
Compiler Design Introduction
Compiler Design Introduction Compiler Design Introduction
Compiler Design Introduction
Thapar Institute
 
Compiler an overview
Compiler  an overviewCompiler  an overview
Compiler an overview
amudha arul
 
X-CS-8.0 Programming in C Language 2022-2023.pdf
X-CS-8.0 Programming in C Language 2022-2023.pdfX-CS-8.0 Programming in C Language 2022-2023.pdf
X-CS-8.0 Programming in C Language 2022-2023.pdf
Alefya1
 
Embedded c c++ programming fundamentals master
Embedded c c++ programming fundamentals masterEmbedded c c++ programming fundamentals master
Embedded c c++ programming fundamentals master
Hossam Hassan
 
Bsc cs 1 fit u-2 application and system software
Bsc cs 1 fit u-2 application and system softwareBsc cs 1 fit u-2 application and system software
Bsc cs 1 fit u-2 application and system software
Rai University
 
Bba i-introduction to computer-u-2- application and system software
Bba  i-introduction to computer-u-2- application and system softwareBba  i-introduction to computer-u-2- application and system software
Bba i-introduction to computer-u-2- application and system software
Rai University
 
CD U1-5.pptx
CD U1-5.pptxCD U1-5.pptx
CD U1-5.pptx
Himajanaidu2
 
Computer Programming In C.pptx
Computer Programming In C.pptxComputer Programming In C.pptx
Computer Programming In C.pptx
chouguleamruta24
 

Similar to Lecture1 introduction compilers (20)

Compilers.pptx
Compilers.pptxCompilers.pptx
Compilers.pptx
 
Introduction to Compiler
Introduction to CompilerIntroduction to Compiler
Introduction to Compiler
 
Lecture 1 introduction to language processors
Lecture 1  introduction to language processorsLecture 1  introduction to language processors
Lecture 1 introduction to language processors
 
Introduction_to_Programming.pptx
Introduction_to_Programming.pptxIntroduction_to_Programming.pptx
Introduction_to_Programming.pptx
 
Lecture1 compilers
Lecture1 compilersLecture1 compilers
Lecture1 compilers
 
Unit1 principle of programming language
Unit1 principle of programming languageUnit1 principle of programming language
Unit1 principle of programming language
 
introduction to computer vision and image processing
introduction to computer vision and image processingintroduction to computer vision and image processing
introduction to computer vision and image processing
 
Introduction to Compiler design
Introduction to Compiler design Introduction to Compiler design
Introduction to Compiler design
 
Cpcs302 1
Cpcs302  1Cpcs302  1
Cpcs302 1
 
Compiler design
Compiler designCompiler design
Compiler design
 
Cd econtent link1
Cd econtent link1Cd econtent link1
Cd econtent link1
 
Chapter 4 computer language
Chapter 4 computer languageChapter 4 computer language
Chapter 4 computer language
 
Compiler Design Introduction
Compiler Design Introduction Compiler Design Introduction
Compiler Design Introduction
 
Compiler an overview
Compiler  an overviewCompiler  an overview
Compiler an overview
 
X-CS-8.0 Programming in C Language 2022-2023.pdf
X-CS-8.0 Programming in C Language 2022-2023.pdfX-CS-8.0 Programming in C Language 2022-2023.pdf
X-CS-8.0 Programming in C Language 2022-2023.pdf
 
Embedded c c++ programming fundamentals master
Embedded c c++ programming fundamentals masterEmbedded c c++ programming fundamentals master
Embedded c c++ programming fundamentals master
 
Bsc cs 1 fit u-2 application and system software
Bsc cs 1 fit u-2 application and system softwareBsc cs 1 fit u-2 application and system software
Bsc cs 1 fit u-2 application and system software
 
Bba i-introduction to computer-u-2- application and system software
Bba  i-introduction to computer-u-2- application and system softwareBba  i-introduction to computer-u-2- application and system software
Bba i-introduction to computer-u-2- application and system software
 
CD U1-5.pptx
CD U1-5.pptxCD U1-5.pptx
CD U1-5.pptx
 
Computer Programming In C.pptx
Computer Programming In C.pptxComputer Programming In C.pptx
Computer Programming In C.pptx
 

More from Mahesh Kumar Chelimilla

Lecture11 syntax analysis_7
Lecture11 syntax analysis_7Lecture11 syntax analysis_7
Lecture11 syntax analysis_7
Mahesh Kumar Chelimilla
 
Lecture10 syntax analysis_6
Lecture10 syntax analysis_6Lecture10 syntax analysis_6
Lecture10 syntax analysis_6
Mahesh Kumar Chelimilla
 
Lecture9 syntax analysis_5
Lecture9 syntax analysis_5Lecture9 syntax analysis_5
Lecture9 syntax analysis_5
Mahesh Kumar Chelimilla
 
Lecture8 syntax analysis_4
Lecture8 syntax analysis_4Lecture8 syntax analysis_4
Lecture8 syntax analysis_4
Mahesh Kumar Chelimilla
 
Lecture7 syntax analysis_3
Lecture7 syntax analysis_3Lecture7 syntax analysis_3
Lecture7 syntax analysis_3
Mahesh Kumar Chelimilla
 
Transportlayer tanenbaum
Transportlayer tanenbaumTransportlayer tanenbaum
Transportlayer tanenbaum
Mahesh Kumar Chelimilla
 
Network layer tanenbaum
Network layer tanenbaumNetwork layer tanenbaum
Network layer tanenbaum
Mahesh Kumar Chelimilla
 
Forouzan frame relay
Forouzan frame relayForouzan frame relay
Forouzan frame relay
Mahesh Kumar Chelimilla
 
Forouzan data link_2
Forouzan data link_2Forouzan data link_2
Forouzan data link_2
Mahesh Kumar Chelimilla
 
Forouzan data link_1
Forouzan data link_1Forouzan data link_1
Forouzan data link_1
Mahesh Kumar Chelimilla
 
Datalinklayer tanenbaum
Datalinklayer tanenbaumDatalinklayer tanenbaum
Datalinklayer tanenbaum
Mahesh Kumar Chelimilla
 

More from Mahesh Kumar Chelimilla (14)

Lecture11 syntax analysis_7
Lecture11 syntax analysis_7Lecture11 syntax analysis_7
Lecture11 syntax analysis_7
 
Lecture10 syntax analysis_6
Lecture10 syntax analysis_6Lecture10 syntax analysis_6
Lecture10 syntax analysis_6
 
Lecture9 syntax analysis_5
Lecture9 syntax analysis_5Lecture9 syntax analysis_5
Lecture9 syntax analysis_5
 
Lecture8 syntax analysis_4
Lecture8 syntax analysis_4Lecture8 syntax analysis_4
Lecture8 syntax analysis_4
 
Lecture7 syntax analysis_3
Lecture7 syntax analysis_3Lecture7 syntax analysis_3
Lecture7 syntax analysis_3
 
Transportlayer tanenbaum
Transportlayer tanenbaumTransportlayer tanenbaum
Transportlayer tanenbaum
 
Network layer tanenbaum
Network layer tanenbaumNetwork layer tanenbaum
Network layer tanenbaum
 
Forouzan x25
Forouzan x25Forouzan x25
Forouzan x25
 
Forouzan ppp
Forouzan pppForouzan ppp
Forouzan ppp
 
Forouzan frame relay
Forouzan frame relayForouzan frame relay
Forouzan frame relay
 
Forouzan data link_2
Forouzan data link_2Forouzan data link_2
Forouzan data link_2
 
Forouzan data link_1
Forouzan data link_1Forouzan data link_1
Forouzan data link_1
 
Forouzan atm
Forouzan atmForouzan atm
Forouzan atm
 
Datalinklayer tanenbaum
Datalinklayer tanenbaumDatalinklayer tanenbaum
Datalinklayer tanenbaum
 

Recently uploaded

The role of big data in decision making.
The role of big data in decision making.The role of big data in decision making.
The role of big data in decision making.
ankuprajapati0525
 
The Benefits and Techniques of Trenchless Pipe Repair.pdf
The Benefits and Techniques of Trenchless Pipe Repair.pdfThe Benefits and Techniques of Trenchless Pipe Repair.pdf
The Benefits and Techniques of Trenchless Pipe Repair.pdf
Pipe Restoration Solutions
 
power quality voltage fluctuation UNIT - I.pptx
power quality voltage fluctuation UNIT - I.pptxpower quality voltage fluctuation UNIT - I.pptx
power quality voltage fluctuation UNIT - I.pptx
ViniHema
 
CME397 Surface Engineering- Professional Elective
CME397 Surface Engineering- Professional ElectiveCME397 Surface Engineering- Professional Elective
CME397 Surface Engineering- Professional Elective
karthi keyan
 
road safety engineering r s e unit 3.pdf
road safety engineering  r s e unit 3.pdfroad safety engineering  r s e unit 3.pdf
road safety engineering r s e unit 3.pdf
VENKATESHvenky89705
 
Top 10 Oil and Gas Projects in Saudi Arabia 2024.pdf
Top 10 Oil and Gas Projects in Saudi Arabia 2024.pdfTop 10 Oil and Gas Projects in Saudi Arabia 2024.pdf
Top 10 Oil and Gas Projects in Saudi Arabia 2024.pdf
Teleport Manpower Consultant
 
Halogenation process of chemical process industries
Halogenation process of chemical process industriesHalogenation process of chemical process industries
Halogenation process of chemical process industries
MuhammadTufail242431
 
Event Management System Vb Net Project Report.pdf
Event Management System Vb Net  Project Report.pdfEvent Management System Vb Net  Project Report.pdf
Event Management System Vb Net Project Report.pdf
Kamal Acharya
 
addressing modes in computer architecture
addressing modes  in computer architectureaddressing modes  in computer architecture
addressing modes in computer architecture
ShahidSultan24
 
一比一原版(SFU毕业证)西蒙菲莎大学毕业证成绩单如何办理
一比一原版(SFU毕业证)西蒙菲莎大学毕业证成绩单如何办理一比一原版(SFU毕业证)西蒙菲莎大学毕业证成绩单如何办理
一比一原版(SFU毕业证)西蒙菲莎大学毕业证成绩单如何办理
bakpo1
 
weather web application report.pdf
weather web application report.pdfweather web application report.pdf
weather web application report.pdf
Pratik Pawar
 
AKS UNIVERSITY Satna Final Year Project By OM Hardaha.pdf
AKS UNIVERSITY Satna Final Year Project By OM Hardaha.pdfAKS UNIVERSITY Satna Final Year Project By OM Hardaha.pdf
AKS UNIVERSITY Satna Final Year Project By OM Hardaha.pdf
SamSarthak3
 
ethical hacking in wireless-hacking1.ppt
ethical hacking in wireless-hacking1.pptethical hacking in wireless-hacking1.ppt
ethical hacking in wireless-hacking1.ppt
Jayaprasanna4
 
Pile Foundation by Venkatesh Taduvai (Sub Geotechnical Engineering II)-conver...
Pile Foundation by Venkatesh Taduvai (Sub Geotechnical Engineering II)-conver...Pile Foundation by Venkatesh Taduvai (Sub Geotechnical Engineering II)-conver...
Pile Foundation by Venkatesh Taduvai (Sub Geotechnical Engineering II)-conver...
AJAYKUMARPUND1
 
ASME IX(9) 2007 Full Version .pdf
ASME IX(9)  2007 Full Version       .pdfASME IX(9)  2007 Full Version       .pdf
ASME IX(9) 2007 Full Version .pdf
AhmedHussein950959
 
Water Industry Process Automation and Control Monthly - May 2024.pdf
Water Industry Process Automation and Control Monthly - May 2024.pdfWater Industry Process Automation and Control Monthly - May 2024.pdf
Water Industry Process Automation and Control Monthly - May 2024.pdf
Water Industry Process Automation & Control
 
在线办理(ANU毕业证书)澳洲国立大学毕业证录取通知书一模一样
在线办理(ANU毕业证书)澳洲国立大学毕业证录取通知书一模一样在线办理(ANU毕业证书)澳洲国立大学毕业证录取通知书一模一样
在线办理(ANU毕业证书)澳洲国立大学毕业证录取通知书一模一样
obonagu
 
MCQ Soil mechanics questions (Soil shear strength).pdf
MCQ Soil mechanics questions (Soil shear strength).pdfMCQ Soil mechanics questions (Soil shear strength).pdf
MCQ Soil mechanics questions (Soil shear strength).pdf
Osamah Alsalih
 
Student information management system project report ii.pdf
Student information management system project report ii.pdfStudent information management system project report ii.pdf
Student information management system project report ii.pdf
Kamal Acharya
 
Standard Reomte Control Interface - Neometrix
Standard Reomte Control Interface - NeometrixStandard Reomte Control Interface - Neometrix
Standard Reomte Control Interface - Neometrix
Neometrix_Engineering_Pvt_Ltd
 

Recently uploaded (20)

The role of big data in decision making.
The role of big data in decision making.The role of big data in decision making.
The role of big data in decision making.
 
The Benefits and Techniques of Trenchless Pipe Repair.pdf
The Benefits and Techniques of Trenchless Pipe Repair.pdfThe Benefits and Techniques of Trenchless Pipe Repair.pdf
The Benefits and Techniques of Trenchless Pipe Repair.pdf
 
power quality voltage fluctuation UNIT - I.pptx
power quality voltage fluctuation UNIT - I.pptxpower quality voltage fluctuation UNIT - I.pptx
power quality voltage fluctuation UNIT - I.pptx
 
CME397 Surface Engineering- Professional Elective
CME397 Surface Engineering- Professional ElectiveCME397 Surface Engineering- Professional Elective
CME397 Surface Engineering- Professional Elective
 
road safety engineering r s e unit 3.pdf
road safety engineering  r s e unit 3.pdfroad safety engineering  r s e unit 3.pdf
road safety engineering r s e unit 3.pdf
 
Top 10 Oil and Gas Projects in Saudi Arabia 2024.pdf
Top 10 Oil and Gas Projects in Saudi Arabia 2024.pdfTop 10 Oil and Gas Projects in Saudi Arabia 2024.pdf
Top 10 Oil and Gas Projects in Saudi Arabia 2024.pdf
 
Halogenation process of chemical process industries
Halogenation process of chemical process industriesHalogenation process of chemical process industries
Halogenation process of chemical process industries
 
Event Management System Vb Net Project Report.pdf
Event Management System Vb Net  Project Report.pdfEvent Management System Vb Net  Project Report.pdf
Event Management System Vb Net Project Report.pdf
 
addressing modes in computer architecture
addressing modes  in computer architectureaddressing modes  in computer architecture
addressing modes in computer architecture
 
一比一原版(SFU毕业证)西蒙菲莎大学毕业证成绩单如何办理
一比一原版(SFU毕业证)西蒙菲莎大学毕业证成绩单如何办理一比一原版(SFU毕业证)西蒙菲莎大学毕业证成绩单如何办理
一比一原版(SFU毕业证)西蒙菲莎大学毕业证成绩单如何办理
 
weather web application report.pdf
weather web application report.pdfweather web application report.pdf
weather web application report.pdf
 
AKS UNIVERSITY Satna Final Year Project By OM Hardaha.pdf
AKS UNIVERSITY Satna Final Year Project By OM Hardaha.pdfAKS UNIVERSITY Satna Final Year Project By OM Hardaha.pdf
AKS UNIVERSITY Satna Final Year Project By OM Hardaha.pdf
 
ethical hacking in wireless-hacking1.ppt
ethical hacking in wireless-hacking1.pptethical hacking in wireless-hacking1.ppt
ethical hacking in wireless-hacking1.ppt
 
Pile Foundation by Venkatesh Taduvai (Sub Geotechnical Engineering II)-conver...
Pile Foundation by Venkatesh Taduvai (Sub Geotechnical Engineering II)-conver...Pile Foundation by Venkatesh Taduvai (Sub Geotechnical Engineering II)-conver...
Pile Foundation by Venkatesh Taduvai (Sub Geotechnical Engineering II)-conver...
 
ASME IX(9) 2007 Full Version .pdf
ASME IX(9)  2007 Full Version       .pdfASME IX(9)  2007 Full Version       .pdf
ASME IX(9) 2007 Full Version .pdf
 
Water Industry Process Automation and Control Monthly - May 2024.pdf
Water Industry Process Automation and Control Monthly - May 2024.pdfWater Industry Process Automation and Control Monthly - May 2024.pdf
Water Industry Process Automation and Control Monthly - May 2024.pdf
 
在线办理(ANU毕业证书)澳洲国立大学毕业证录取通知书一模一样
在线办理(ANU毕业证书)澳洲国立大学毕业证录取通知书一模一样在线办理(ANU毕业证书)澳洲国立大学毕业证录取通知书一模一样
在线办理(ANU毕业证书)澳洲国立大学毕业证录取通知书一模一样
 
MCQ Soil mechanics questions (Soil shear strength).pdf
MCQ Soil mechanics questions (Soil shear strength).pdfMCQ Soil mechanics questions (Soil shear strength).pdf
MCQ Soil mechanics questions (Soil shear strength).pdf
 
Student information management system project report ii.pdf
Student information management system project report ii.pdfStudent information management system project report ii.pdf
Student information management system project report ii.pdf
 
Standard Reomte Control Interface - Neometrix
Standard Reomte Control Interface - NeometrixStandard Reomte Control Interface - Neometrix
Standard Reomte Control Interface - Neometrix
 

Lecture1 introduction compilers

  • 1. Compilers CS 346 3 – 0 – 0 – 6 Monday – Tuesday – Wednesday 9.00 --- 9.55 10.00 --- 10.55 11.00 --- 11.55 Arijit Sur Office: H-103 Department of Computer Science and Engineering Email: arijit@iitg.ernet.in Ph: 2361 Instructors: Dr. A. Sur and Dr. A. Sarkar
  • 2. Syllabus • Overview of different phases of a compiler: front-end; back-end; • Lexical analysis: specification of tokens, recognition of tokens, input buffering, automatic tools; • Syntax analysis: context free grammars, top down and bottom up parsing techniques, construction of efficient parsers, syntax-directed translation, automatic tools; • Semantic analysis: declaration processing, type checking, symbol tables,• Semantic analysis: declaration processing, type checking, symbol tables, error recovery; • Intermediate code generation: run-time environments, translation of language constructs; • Code generation: flow-graphs, register allocation, code-generation algorithms; • Introduction to code optimization techniques. 8-Jan-15 CS346 Lecture 1 2
  • 3. Books • Text Book – Alfred V. Aho, Monica S. Lam, Ravi Sethi, Jeffrey D. Ullman, Compilers: Principles, Techniques, and Tools, 2nd Edition, Prentice Hall, 2009 • Reference Books – V. Raghavan, Principles of Compiler Design, McGrawHill, 2010 – C.N. Fischer, R.J. Le Blanc, Crafting a Compiler with C, Pearson Education, 2009 – K. D. Cooper, L. Torczon, Engineering a Compiler, Morgan Kaufmann Publishers, 2004 – Allen Holub, Compiler Design in C, Prentice-Hall software series, 1990 8-Jan-15 CS346 Lecture 1 3
  • 4. Grades • 2 Quiz s – 20% of grade • Mid-Semester – 30% of grade • End-Semester – 50% of grade • Attendance below 75% --- F Grade • Random Attendance 8-Jan-15 CS346 Lecture 1 4
  • 5.
  • 7. Basic Blocks of Computing System 8-Jan-15 CS346 Lecture 1 7
  • 8. Program Execution: Layered Architecture High Level Language Program Assembly Language Program Compiler Assembler + temp = v[k]; v[k] = v[k+1]; v[k+1] = temp; lw $15, 0($2) lw $16, 4($2) sw $16, 0($2) sw $15, 4($2) Machine Language Program Control Signal Specification Assembler + Linker + Loader Machine Interpretation sw $15, 4($2) 0000 1001 1100 0110 1010 1111 0101 1000 1010 1111 0101 1000 0000 1001 1100 0110 1100 0110 1010 1111 0101 1000 0000 1001 0101 1000 0000 1001 1100 0110 1010 1111 ° ° ALUOP[0:3] <= InstReg[9:11] & MASK 8-Jan-15 CS346 Lecture 1 8
  • 9. Architecture of Computing System Compiler Operating System Application Instruction Set Architecture Firmware I/O systemInstr. Set Proc. Digital Design Circuit Design Architecture Datapath & Control Layout 8-Jan-15 CS346 Lecture 1 9
  • 10. Definitions • What is a compiler? – A program that accepts as input a program text in a certain language and produces as output a program text in another language, while preserving the meaning of that text (Grune et al, 2000). – A program that reads a program written in one language (source language) and translates it into an equivalent program in another language (target language) (Aho et al) – Report errors of source language which are detected during the 8-Jan-15 CS346 Lecture 1 10 – Report errors of source language which are detected during the translation process • What is an interpreter? – A program that reads a source program and produces the results of executing this source. • We deal with compilers! Many of these issues arise with interpreters!
  • 11. Compiler Vs. Interpreter Compiler Source Program Interpreter Source Program Input Output Target Program Target ProgramInput Output Translator Source Program Intermediate Program Input Virtual Machine Output A Hybrid Compiler
  • 12. Examples • C is typically compiled • Lisp is typically interpreted • Java is compiled to bytecodes, which are then interpreted • source-to-source compiler, transcompiler, or transpiler : – C++ to C – High Performance Fortran (HPF) to Fortran (parallelising compiler) 8-Jan-15 12 – High Performance Fortran (HPF) to Fortran (parallelising compiler) • Cross Compilers (wiki) – A cross compiler is a compiler capable of reading executable code for a platform other than the one on which the compiler is running. For example, a compiler that runs on a Windows 7 PC but generates code that runs on Android Smartphone is a cross compiler. CS346 Lecture 1
  • 13. Qualities of a Good Compiler What qualities would you want in a compiler? – generates correct code (first and foremost!) – generates fast code – conforms to the specifications of the input language – copes with essentially arbitrary input size, variables, 8-Jan-15 13 – copes with essentially arbitrary input size, variables, etc. – compilation time (linearly)proportional to size of source – good diagnostics – consistent optimisations – works well with the debugger CS346 Lecture 1
  • 14. Principles of Compilation The compiler must: • preserve the meaning of the program being compiled. • “improve” the source code in some way. Other issues (depending on the setting): 8-Jan-15 14 Other issues (depending on the setting): • Speed (of compiled code) • Space (size of compiled code) • Feedback (information provided to the user) • Debugging (transformations obscure the relationship source code vs target) • Compilation time efficiency (fast or slow compiler?) CS346 Lecture 1
  • 15. Applications • Most common use: translate a high-level program to object code – Program Translation: binary translation, hardware synthesis, … • Optimizations for computer architectures: – Improve program performance, take into account hardware parallelism, etc… • Interpreters: e.g., BASIC, Lisp etc. 8-Jan-15 15 • Software productivity tools – Debugging aids: e.g., purify • Text formatters, just-in-time compilation for Java, power management, global distributed computing, … Key: Ability to extract properties of a source program (analysis) and transform it to construct a target program (synthesis) CS346 Lecture 1