22CSC52 COMPILER DESIGN
L T P C
3 0 0 3
COURSE OBJECTIVES:
To learn the various phases of compiler.
To learn the various parsing techniques.
To understand intermediate code generation and run-time environment.
To learn to implement the front-end of the compiler.
To learn to implement code generator.
To learn to implement code optimization.
COURSE OUTCOMES:
On Completion of the course, the students should be able to:
CO1:Understand the techniques in different phases of a compiler.
CO2:Design a lexical analyzer for a sample language and learn to use the LEX tool.
CO3:Apply different parsing algorithms to develop a parser and learn to use YACC tool
CO4:Understand semantics rules (SDT), intermediate code generation and run-time environment.
CO5:Implement code generation and apply code optimization techniques.
COURSE CONTENT:
UNIT 1: INTRODUCTION TO COMPILERS & LEXICAL ANALYSIS 8 hrs
Introduction- Translators- Compilation and Interpretation- Language processors -The Phases of
Compiler – Lexical Analysis – Role of Lexical Analyzer – Input Buffering – Specification of Tokens
– Recognition of Tokens – Finite Automata – Regular Expressions to Automata NFA, DFA –
Minimizing DFA - Language for Specifying Lexical Analyzers – Lex tool.
UNIT 2: SYNTAX ANALYSIS 11 hrs
Role of Parser – Grammars – Context-free grammars – Writing a grammar -Top Down Parsing: -
General Strategies - Recursive Descent Parser, Predictive Parser-LL Grammar- Bottom-Up Parsing:
Shift Reduce Parser-LR Parser- LR(0) Item - Construction of SLR Parsing Table - Introduction to
LALR Parser - Error Handling and Recovery in Syntax Analyzer-YACC tool - Design of a syntax
Analyzer for a Sample Language
UNIT 3: SYNTAX DIRECTED TRANSLATION & INTERMEDIATE CODE GENERATION 9 hrs
Syntax Directed Definitions, Evaluation Orders for Syntax Directed Definitions, Syntax Directed
Translation Schemes - Type Systems-Specification of a simple type Checker- Equivalence of Type
Expressions-Type Conversions. Intermediate Languages: Syntax Tree, Three Address Code, Types
and Declarations, Translation of Expressions, Type Checking, Back patching.
UNIT 4: RUN-TIME ENVIRONMENT AND CODE GENERATION 9 hrs
Runtime Environments – source language issues – Storage organization – Storage Allocation
Strategies: Static, Stack and Heap allocation - Parameter Passing-Symbol Tables - Dynamic Storage
Allocation - Issues in the Design of a code generator – Basic Blocks and Flow graphs - Design of a
simple Code Generator - Optimal Code Generation for Expressions– Dynamic Programming Code
Generation.
UNIT 5: CODE OPTIMIZATION 8 hrs
Principal Sources of Optimization – Peep-hole optimization - DAG- Optimization of Basic Blocks -
Global Data Flow Analysis - Efficient Data Flow Algorithm – Recent trends in Compiler Design.
Total Hours 45
TEXT BOOKS:
1. Alfred V. Aho, Monica S. Lam, Ravi Sethi, Jeffrey D. Ullman, “Compilers: Principles, Techniques
and Tools”, Second Edition, Pearson Education, 2009.
REFERENCES:
1. Randy Allen, Ken Kennedy, Optimizing Compilers for Modern Architectures: A Dependence
based Approach, Morgan Kaufmann Publishers, 2002.
2. Steven S. Muchnick, Advanced Compiler Design and Implementation, Morgan Kaufmann
Publishers - Elsevier Science, India, Indian Reprint 2003.
3. Keith D Cooper and Linda Torczon, Engineering a Compiler, Morgan Kaufmann Publishers
Elsevier Science, 2004.
4. V. Raghavan, Principles of Compiler Design, Tata McGraw Hill Education Publishers, 2010.
5. Allen I. Holub, Compiler Design in C, Prentice-Hall Software Series, 1993.
1. https://elearn.nptel.ac.in/shop/nptel/compiler-design/?v=c86ee0d9d7ed
2. https://online.stanford.edu/courses/soe-ycscs1-compilers
3. https://www.udemy.com/course/creating-a-c-compiler-from-scratch
MAPPING OF PROGRAMME OUTCOMES WITH COURSE OUTCOMES
Programme Outcomes / Programme Specific Outcomes
Mapping PO1 PO2 PO3 PO4 PO5 PO6 PO7 PO8 PO9 PO10 PO11 PO12 PSO1 PSO2 PSO3
K3 K4 K5 K5 K5 K5 K2 A5 A5 K5 K3 A3 K5 K5 K5
CO1 K6 2 - 2 - 3 - - - - - - - 2 3 2
Course Outcomes
CO2 K3 - 3 2 - 2 - - - - - - - - 2 -
CO3 K6 - - 3 - 3 - - -- - - - - 2 - -
CO4 K4 - - 2 3 2 - - - - - - - - 3 -
CO5 K3 - 2 3 2 - - - - - - - - 2 - -
Average
2 2.5 2.4 2.5 2.5 - - - - - - - 2.5 2.5 -
Correlation Level