CS 434T: Compilers

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.
Full Syllabus

Class Details

      Instructor:   Stephen Freund
Office: TPL 302
Office Hours:     Monday 12:45-1:30, 2:30-4:00, Thursday 2:30-4:00
email: freund@cs.williams.edu
phone: 413-597-4260



Calendar


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
  • Scala Materials from CS 334: ExamplesHW Problems (P1-P3)HW Starter Files

  • 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
    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

    Some tests for PA 1:
    Sample Test Script
    PA1 Test Suite



    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 (feel free to use in your pretty printer)
    Symbol Table Design
    Symbol Table Example


    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
  • 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

  • Week 8: TAC, Code Generation, Intro to Optimization


    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
  • PA 4
  • PA 4 Starter Files
  • Optimization Test Files

  • Week 12: Register Alloc, GC, JITs
    Reading
  • Register Allocation
    • Dragon 8.8
  • JITs and Dynamic Optimization
  • GC

  • Assignment HW 12



    Resources

    IC Programming Project
    Scala Documentation
    Additional Tools
    Williams CS GitLab
    Random Items
    Other