
Explore the six phases of compiler design—from lexical and syntax analysis to semantic analysis, intermediate code generation, optimization, and code generation—plus practical skills with tools like Lex.
Explore modeling a compiler design and the science of code optimization, including finite state machines, regular expressions, context-free grammars, and parse trees, preserving meaning while improving performance.
Explore predictive parser fundamentals, a top-down, non-backtracking alternative to recursive descent, featuring stack-based parsing, parsing tables, and step-by-step moves with an example.
Explore how to compute first and follow values for a predictive parser and use them to build the predictive parsing table.
Explore syntax directed translation schemes with embedded semantic actions, including postfix and parser-stack implementations; learn s-attributed and l-attributed forms for LR and predictive parsing, illustrated by a desk calculator.
Explore loops in flow graphs, dominators and dominator trees, natural and inner loops, back edges, and reducible graphs, then learn constant propagation and partial redundancy elimination in code optimization.
Apply iterative data-flow analysis on a flow graph of basic blocks to compute in and out sets for reaching definitions using gen, kill, and union as the confluence operator.
Course Objectives:
Introduce the major concepts of language translation and compiler design and impart the knowledge of practical skills necessary for constructing a compiler.
Topics include phases of compiler, parsing, syntax directed translation, type checking use of symbol tables, code optimization techniques, intermediate code generation, code generation and data flow analysis.
Course Outcomes:
Demonstrate the ability to design a compiler given a set of language features.
Demonstrate the the knowledge of patterns, tokens & regular expressions for lexical analysis.
Acquire skills in using lex tool & yacc tool for developing a scanner and parser.
Design and implement LL and LR parsers
Design algorithms to do code optimization in order to improve the performance of a program in terms of space and time complexity.
Design algorithms to generate machine code.
SYLLABUS:
Module- I:
Introduction: The structure of a compiler, the science of building a compiler, programming language basics.
Lexical Analysis: The Role of the Lexical Analyzer, Input Buffering, Recognition of Tokens, The Lexical-Analyzer Generator Lex, Finite Automata, From Regular Expressions to Automata, Design of a Lexical-Analyzer Generator, Optimization of DFA-Based Pattern Matchers.
Module- II:
Syntax Analysis: Introduction, Context-Free Grammars, Writing a Grammar.
Top-Down Parsing, Bottom-Up Parsing.
Introduction to LR Parsing: Simple LR, More Powerful LR Parsers, Using Ambiguous Grammars and Parser Generators.
Module- III:
Syntax-Directed Translation: Syntax-Directed Definitions, Evaluation Orders for SDD's, Applications of Syntax-Directed Translation, Syntax-Directed Translation Schemes, Implementing L-Attributed SDD's.
Intermediate-Code Generation: Variants of Syntax Trees, Three-Address Code, Types and Declarations, Type Checking, Control Flow, Switch-Statements, Intermediate Code for Procedures.
Module- IV:
Run-Time Environments: Stack Allocation of Space, Access to Non-local Data on the Stack, Heap Management, Introduction to Garbage Collection, Introduction to Trace-Based Collection.
Code Generation: Issues in the Design of a Code Generator, The Target Language, Addresses in the Target Code, Basic Blocks and Flow Graphs, Optimization of Basic Blocks, A Simple Code Generator, Peephole Optimization, Register Allocation and Assignment, Dynamic Programming Code-Generation.
Module- V:
Machine-Independent Optimization: The Principal Sources of Optimization, Introduction to Data-Flow Analysis, Foundations of Data-Flow Analysis, Constant Propagation, Partial-Redundancy Elimination, Loops in Flow Graphs.
Reference:
Compilers: Principles, Techniques and Tools, Second Edition, Alfred V. Aho, Monica S. Lam, Ravi Sethi, Jeffry D. Ullman.