Compiler Design L T P C
3 0 0 3
Pre-requisites/Exposure Data Structures, knowledge of automata theory, basic knowledge
of computer architecture
Co-requisites --
Course Objectives
1. To introduce the major concept areas of language translation and compiler design.
2. To enrich the knowledge in various phases of compiler and its use, code optimization techniques,
machine code generation, and use of symbol table.
3. To extend the knowledge of parser by parsing LL parser and LR parser.
4. To provide practical programming skills necessary for constructing a compiler.
Course Outcomes
On completion of this course, the students will be able to
CO 1. Comprehend different phases of compiler.
CO 2. Use concepts of regular grammar to build lexical analyzer.
CO 3. Build parsers for a context free grammar.
CO 4. Synthesize syntax directed translations rules.
CO 5. Assess code and memory optimization techniques to improve the performance of a program.
Catalog Description
This course explores the principles, algorithms, and data structures involved in the design and
construction of compilers. Topics include finite-state machines, lexical analysis, context-free grammars,
LR and LALR parsers, other parsing techniques, symbol tables, error recovery, and an introduction to
intermediate code generation.
Course Content
UNIT I: Introduction 8 lecture hours
Introduction to Defining Language, Kleene Closures, Formal language theory , Arithmetic Expressions,
Defining Grammar, Chomsky Hierarchy. Compiler, Phases and Passes, Finite State Machines and
Regular Expressions and their Applications to Lexical Analysis, Implementation of Lexical Analyzers,
Lexical Analyzer Generator, LEX.
UNIT II: Basic Parsing Techniques 12 lecture hours
Formal Grammars and their Applications to Syntax Analysis, Context Free Grammars, Derivation and
Parse Tree, Capabilities of CFG. Push Down Automata (PDA), Description and Definition, Working of
PDA, Acceptance of a String by PDA. Parsers, Shift Reduce Parsing, Operator Precedence Parsing, Top
Down Parsing, Predictive Parsing, Automatic Construction of Efficient Parsers: LR Parsers, The
Canonical Collection of LR(0) items, Constructing SLR Parsing Tables, Constructing Canonical LR
Parsing Tables, Constructing LALR Parsing Tables, Using Ambiguous Grammars, An Automatic Parser
Generator, Implementation of LR Parsing Tables, Constructing LALR set of items, YACC as parser
generator.
UNIT III: Syntax-Directed Translation 8 lecture hours
Syntax Directed Translation Schemes, Implementation of Syntax Directed Translators, Intermediate
Code, Postfix Notation, Parse Tree & Syntax Tree, Three Address Code, Quadruples & Triples,
Translation of Assignment Statements, Boolean Expressions, Statements that alters the Flow of Control,
Postfix Translation, Translation with a Top Down Parser, More about Translation: Array Reference in
Arithmetic Expressions, Procedure Calls, Declaration, and Case Statements.
UNIT IV: Symbol Table 4 lecture hours
Data Structures for Symbol Tables, Representing Score Information, Run Time Administration:
Implementation of Simple Stack Allocation Scheme, Storage Allocation in Block Structures Language,
Error Detection and Recovery: Lexical Phase Error, Syntactic Phase Errors, Semantic Phase Errors.
UNIT V: Introduction to Code Optimization 4 lecture hours
Loop Optimization, the DAG Representation of Basic Blocks, Value Number and Algebraic Laws,
Global Data-Flow Analysis
Text Books
1. Alfred V. Aho, Ravi Sethi Jeffrey D. Ullman, “Compilers- Principles, Techniques, and Tools”, 2nd
Edition, Pearson Education Asia
2. Robin Hunter, “The Essence of Compiler”, 2nd Edition, Pearson Publication
Reference Books
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. Charles N. Fischer, Richard. J. LeBlanc, “Crafting a Compiler with C”, Pearson Education, 2008.
Modes of Evaluation: Quiz/Assignment/ Presentation/ Extempore/ Written Examination
Examination Scheme:
Components MSE Presentation/Assignment/ etc. ESE
Weightage (%) 20% 30% 50%
Relationship between the Course Outcomes (COs), Program Outcomes (POs) and Program Specific
Objectives (PSOs)
Course
PO10
PO11
PO12
PSO1
PSO2
PSO3
PO1
PO2
PO3
PO4
PO5
PO6
PO7
PO8
PO9
Outcomes
CO1 2 2 3 2
CO2 2 2 3 1 2
CO3 2 2 3 1 2
CO4 2 2 3 1 2
CO5 2 2 3 2
Average 2 2 3 1 2
1=weak 2= moderate 3=strong