CS126: Compilers and Program Analysis

(Fall 2017)

Course Description

This course will teach the basic concepts of compilers and program analysis. Our goal is to provide enough knowledge so that students will be able to write a simple compiler or perform basic program analysis for various languages or front ends that they may develop or want to try. We will cover the basics of compilation, including lexical and syntactic analysis, semantic analysis, optimization, and code generation. Our emphasis here will be on semantic analysis and optimization since they are the most complex and have a broader range of applications. We will also cover a variety of program analyses. Some of these are used during compilation, particularly for optimization. Others are useful for program understanding, security analysis, formal methods, and finding or fixing bugs.

Course Info

Friday 3-5:20pm, CIT 477
We will also meet either Monday 9/23 or Monday 9/30 from 3-5:20
Prof. Steve Reiss (spr@cs), Office hour: MTh 12:00-2:00pm


The syllabus is available here.


Engineering a Compiler, Second Edition, by Cooper and Torczon. An electronic version of the text can be found in /u/spr/courses/cs126.


The bulk of your grade (70%) will be based on your project, both in the final handin and the various reports that you will give during the semester. The take-home final will account for 15%. Class participation and homeworks will account for the remainder.

Lecture Notes

Lecture notes can be found here


The course will be project-based with students working either individually or in small teams to implement a tool that is of interest to them. This could be a full compiler for a simple language, a program analysis for an existing language, a translator that maps one language into another, or something similar. Unless you have a potential project or application in mind, we suggest you undertake the default project, building a compiler for a simple object-oriented language, DECAF. We provide a timeline for completing portions of the default project that matches the lecture topics.

If you are interested in undertaking your own project, you should hand in an initial proposal to Dr. Reiss by 9/11, with a final project proposal including a time line with incremental milestones by 9/23.

Decaf References