
Compilers
Alex Aiken
Course Description
In this course, you will learn principles and practices for design and implementation of compilers and interpreters. Topics covered include: lexical analysis; parsing theory; symbol tables; type systems; scope; semantic analysis; intermediate representations; runtime environments; code generation; and basic program analysis and optimization. Students will construct a compiler for a simple object-oriented language during the course's programming projects.
To understand the concepts in this course, you should be familiar with regular expressions, context-free grammars, graphs, sets, and formal languages. Well-developed programming skills and debugging ability will also be important for the programming assignments. An understanding of simple code generation and function calling conventions, as well as some exposure to different language paradigms would also be helpful. If you are unsure about some of these topics, be prepared to brush up on your own to fill in the gaps as you encounter them.
While a textbook is not required to complete the course, Compilers: Principles, Techniques, and Tools (2nd Edition) by Aho, Sethi, Lam, and Ullman (a.k.a. the "purple dragon" book) can be a useful reference. This is a new edition of the classic compiler text and is a very thorough and solid treatment of the material. Some students may find it helpful as a reference or supplemental source.
This course is a work in progress. Not all of the videos, assignments, and materials for this course have been uploaded (or even filmed/written, for that matter). Please be patient as we work to finish the course.
I. INTRODUCTION
 Introduction (8 min)
II. THE COOL PROGRAMMING LANGUAGE
III. LEXICAL ANALYSIS
IV. FINITE AUTOMATA
 NFA to DFA (15 min)
V. PARSING
 Derivations (7 min)
 Ambiguity (17 min)
VI. TOP-DOWN PARSING
VII. BOTTOM-UP PARSING I
 First Sets (14 min)
 Follow Sets (17 min)
VIII. BOTTOM-UP PARSING II
 Handles (6 min)
 Valid Items (3 min)
 SLR Parsing (14 min)
IX. SEMANTIC ANALYSIS AND TYPE CHECKING
 Scope (8 min)
 Types (11 min)
 Subtyping (11 min)
X. COOL TYPE CHECKING
 Self Type (7 min)
XI. RUNTIME ORGANIZATION
 Activations (13 min)
 Alignment (6 min)
XII. CODE GENERATION
 Temporaries (16 min)
XIII. OPERATIONAL SEMANTICS
XIV. LOCAL OPTIMIZATION
XV. GLOBAL OPTIMIZATION
 Orderings (6 min)
XVI. REGISTER ALLOCATION
 Spilling (14 min)
XVII. GARBAGE COLLECTION
XVIII. JAVA
 Java (7 min)
 Java Arrays (8 min)