CSE 304 Compiler Design

Fall 2010

Course Description Grading Schedule Lecture Notes Prerequisites
Manuals Instructor and TA Texts Special needs Survival Tips


Course Objectives

Compilers and interpreters are among the most widely used tools in software development. It is important for a computer scientist to understand the process by which programs written in high-level languages are translated and executed. Among other things, this will help you write better programs, and enable you to make more effective use of available compiler technology. The main objective of this course is to gain an in-depth understanding of the compilation process.

An important side benefit of this course would be that you will gain significant experience in OO-programming with C++.

Course Description

In the class, we will discuss the theory and principles of developing compilers and interpreters. In the projects, you will then apply this theory (directly and indirectly) to develop a complete compiler for a high-level language. The problem of language translation is traditionally decomposed into many phases. Most common are:

All phases use a symbol table to keep track of the properties (types, number of parameters etc.) of each symbol (variables, procedures etc.). In the end, code is generated, which will be executed either directly by a machine (the so-called compiled-code approach) or by a software program that implements an "abstract machine" (the interpreter approach). Some languages (e.g., C) prefer the compiled-code approach due to its increased efficiency. Others (e.g., Java) prefer the interpreted approach due to its portability and flexibility.

The compiler will be written in C++. We don't expect that students already know C++ --- in fact, most students view this course as an opportunity to learn C++ at some level of depth. The structure and nature of a compiler makes it a natural candidate for learning OO-programming and appreciating its benefits.

The programming projects will be based on an event-processing language we call E--. In the first assignment, you will learn to use the Flex lexical analyzer generator to implement a lexical analyzer for E--. In the second and third assignments, you will learn to use the Bison parser generator to parse E-- programs and construct an abstract syntax tree (AST). The fourth and fifth assignments will involve type checking and code generation for E--. The first two programming assignments will be individual projects, while the fourth and fifth assignments will be group projects. For the first four assignments, we will provide most test cases.

We will use GNU g++ compiler on Linux. If you are unfamiliar with working in an UNIX environment, including the use of Makefiles and so on, then you should plan on spending some time in the course to catch up. The files will also work on cygwin. For both Linux and cygwin, there may be compatibility issues with some versions --- we expect to be able to support the latest stable versions, but the code we provide may not work with older versions or bleeding-edge versions.

We expect your submissions to work without any effort on our part. If there are syntax errors or other problems that cause your program to work incorrectly for certain test cases, then you will get a zero grade for those tests.


Lecture time/location: TuTh 9:50am to 11:10am, CS 2129

Programming Assignments: (Tentative)

Mid-term 1: 9/28/10

Mid-term: 11/4/10

Last lecture: Dec 9, Thursday

Final Exam:11:15-1:45AM, December 16, 2010 (Thursday)

Lecture Notes:


R. Sekar
Office: 2313E Computer Science
Office Hours: TuTh 11:15am to 12:15pm


We will use the latest edition of the "Dragon book". Compilers: Principles, Techniques, and Tools, Second Edition by Aho, Lam, Sethi, and Ullman.Addison-Wesley


The weightage for programming assignments, midterm and final exams will be as follows.

You are advised to start working on the projects at the earliest possible time even if the deadlines are far away. The date the projects are due will be clearly specified. Projects are due by 11:59pm on the specified date. Late projects will be penalized at the rate of 5% for the first day, 15% the second day and 25% per day after that. So, there is no point submitting a project more than 4 days late! No further extensions will be allowed.

Any form of copying in the course, and all forms of academic dishonesty, are considered serious offenses, and will be prosecuted to the maximum extent permitted by university policies.The minimum penalty for any form of copying, whether from your friends, the Internet or outside sources, or from previous offerings of the course, will be an F-grade. There will be no exceptions.


Official prerequisite is CSE 219 or CSE 260, CSE 220, and CSE 303. I am usually willing to allow students that do not have one of these prerequisites, as long as I can be satisfied about their programming background, and they commit to picking up the required material on their own.

Manuals for Compiler Tools

The following manuals are available online. These manuals are linked from GNU documentation site.

Special Needs

If you have a physical, psychological, medical or learning disability that may impact on your ability to carry out assigned course work, I would urge that you contact the staff in the Disabled Student Services office (DSS), in the ECC building (where the Computer Store used to be), 632-6748v/TDD. DSS will review your concerns and determine, with you, what accommodations are necessary and appropriate. All information and documentation of disability is confidential.

Survival Tips