CSCI 434T: Compiler Design

This tutorial covers the principles and practices for the design and implementation of compilers and interpreters. Topics include all stages of the compilation and execution process: lexical analysis; parsing; symbol tables; type systems; scope; semantic analysis; intermediate representations; run-time environments and interpreters; code generation; program analysis and optimization; and garbage collection. The course covers both the theoretical and practical implications of these topics. As a project course, students will construct a full compiler for a simple object-oriented language.

Syllabus

Instructor           Prof. Stephen Freund
Email freund@cs.williams.edu
Phone x4260
Office TPL 302

Week 1: Overview and Lexical Analysis

Reading
  • Dragon 1
  • Dragon 3.3, 3.5-3.7
  • Regular Expression Matching Can Be Simple And Fast (but is slow in Java, Perl, PHP, Python, Ruby, ...), Russ Cox, January, 2007.
  • An amusing regular expression
  • (If you do not know Scala) Scala Tutorial
  • (If you do not know Scala) Scala By Example
  • Assignment HW 1
    Scala Starter Code :: Java Starter Code

    Week 2: Lexical Analysis, Grammars, Top-Down Parsing

    Reading
  • Dragon 3.8, 3.9.6
  • Dragon 4.1-4.4
  • JFlex user manual and examples.
  • Assignment HW 2
    PA 1
    PA 1 Starter Code
    Lab tutorial

    Week 3: Bottom-Up Parsing, Error Recovery

    Reading
  • Dragon 4.5-4.6, 4.7-4.7.3, 4.8.1-4.8.3
  • (early sections)A practical method for LR and LL syntactic error diagnosis and recovery, Burke and Fisher, 1987.
  • Assignment HW 3 [Table for 8 fixed 9/28]

    Sample Test Script
    PA1 Test Suite

    Week 4: ASTs and Symbol Tables

    Reading
  • JavaCup.
  • Engineering a Compiler, Cooper and Torczon, 4.1-4.3, 5.1-5.4, 5.7.
  • Modern Compiler Implementation in Java, Appel, Ch. 4.
  • Assignment
  • HW 4
  • Expression Parser Starter Code for problem 1
  • Simple TAC Definition for problem 2
  • RE Compiler Starter Code for problem 3

  • PA 2
  • PA 2 Starter Code
  • Week 5: Scopes, Types, Type Checking

    Reading
  • Type Systems, Luca Cardelli, 1997. Sections 1-3 (up to Table 9), and 9
  • Dragon 6.3-6.3.2,6.5 (skim)
  • Type System Spec for IC (Section 16)
  • Foundations of Object-Oriented Languages, Kim Bruce, 2002. Chapters 2-3 (reference)
  • Assignment HW 5
    IndentingPrintStream.java
    Symbol Table Design

    Week 6: Object Types, Subtyping, and TAC

    Reading
  • Type Systems, Luca Cardelli, 1997. Section 6, 28--30
  • Type-Based Race Detection for Java, Cormac Flanagan and Stephen N. Freund, 2000
  • Language-Based Information-Flow Security, Andrei Sabelfeld and Andrew C. Myers, 2003
  • Assignment HW 6

    Week 7: TAC, Object Representation, Type-Based Optimizations

    Reading
  • Dragon 6.2 -- 6.2.1 (Skim)
  • Appel, Chapter 14 (available in my box)
  • Optimization of Object-Oriented Programs Using Static Class Hierarchy Analysis, Jeffrey Dean, David Grove, and Craig Chambers, 1995.
  • Optimizing Dynamically-Typed Object-Oriented Languages With Polymorphic Inline Caches, Urs Hölzle, Craig Chambers, David Ungar, 1991.
  • Assignment
  • HW 7
  • Eclipse Debugging Notes
  • Week 8: TAC, Code Generation, Intro to Optimization

    Reading
  • Dragon 7 -- 7.2
  • Dragon 8 -- 8.5
  • Appel 14 (from last week)
  • Code Generation Materials
  • Cooper and Torczon 8.1 -- 8.4 (in my box -- skip 8.4.2 and 8.4.3)
  • Assignment
  • HW 8
  • PA 3
  • Simple TAC Definition
  • Code Generation Material
  • CodeGenerator64.scala skeleton
  • Week 9: Introduction to Dataflow Analysis

    Reading Dragon 9 - 9.2
    Assignment
  • HW 9
  • Week 10: Dataflow Analysis Foundations

    Reading
  • Dragon 9.3 - 9.5.2
  • Dragon 9.5.3 - 9.5.5 (optional)
  • Assignment
  • HW 10
  • Final Project
  • libic source
  • Week 11: More Optimization, Code Generation

    Reading Dragon 8.9 -- 8.9.2
    Assignment
  • HW 11 (for after Thanksgiving)
  • PA 4
  • PA 4 Starter Files
  • Week 12: Register Alloc, GC, JITs

    Reading
  • Register Allocation
    • Dragon 8.8
  • JITs and Dynamic Optimization
  • GC
  • Assignment HW 12

    IC Programming Project

    Scala Documentation

    Additional Tools

    Random Items

    Other