600.328: Compilers and Interpreters

Spring Semester 2006: January 30, 2006 - May 5, 2006

Contents

Basics

Catalog Description: Introduction to compiler design, including lexical analysis, parsing, syntax-directed translation, symbol tables, run-time environments, and code generation and optimization. Students are required to write a compiler as a course project.

Prerequisite(s): 600.120: Intermediate Programming, 600.226: Data Structures; both 600.271: Automata and Computation Theory and 600.333: Computer System Fundamentals are helpful.

Academic Honesty: It is your responsibility to adhere to the Department Integrity Code and other applicable university regulations. Feel free to email us your questions or concerns.

Coordinates

Discussion List: cs328-discuss@bloat.org (open discussion, but subscribe here first)
Staff List: cs328-staff@bloat.org (to contact all of us, but only staff can subscribe)
Submit Assignment: cs328-submit@bloat.org (we grade your last submission before the deadline)

Lecture: Monday, Tuesday, Wednesday, 3:00 pm - 4:00 pm
Location: 101 Shaffer Hall

Instructor: Peter Fröhlich
Office Hours: Thursday & Friday, 11:00 am - 12:00 noon
Location: 326 New Engineering Building

Teaching Assistant: Raluca Musaloiu-E.
Office Hours: Monday, Tuesday, Wednesday, 1:00 pm - 2:00 pm; Thursday 12:00 noon - 1:00 pm
Location: 225 New Engineering Building

Final Exam: Saturday, May 13, 9:00 am - 12:00 noon

Schedule (Tentative!)

As there is no required text, all readings are "suggested" readings. The term "A c" refers to the text by Appel. The term "C c" refers to the text by Cooper. The term "W c" refers to the text by Wirth. For example, "A 3" refers to chapter 3 in Appel, while "W 3.1" refers to section 1 in chapter 3 in Wirth. Note that the readings don't always "match up" with the lectures very well, so the chapters given are approximations. You are expected to do the assigned reading before a topic is covered in lecture; reading assigned in the week of an exam is part of the exam! Please try to read ahead, you'll be surprised how much more sense the lectures make...

Week 1: Introduction and Overview (January 30 - February 5)

Lecture:

Reading:

Deadlines:

Week 2: Lexical Analysis (February 6 - February 12)

Lecture:

Reading:

Deadlines:

Week 3: Syntactic Analysis (February 13 - February 19)

Lecture:

Reading:

Deadlines:

Week 4: Semantic Analysis (February 20 - February 26)

Lecture:

Reading:

Deadlines:

Week 5: Semantic Analysis (February 27 - March 5)

Lecture:

Reading:

Deadlines:

Week 6: Semantic Analysis (March 6 - March 12)

Lecture:

Reading:

Deadlines:

Week 7: Semantic Analysis / Interpreters (March 13 - March 19)

Lecture:

Reading:

Deadlines:

Week 8: Spring Break (March 20 - March 26)

Week 9: MIPS / Code Generation (March 27 - April 2)

Lecture:

Reading:

Deadlines:

Week 10: Code Generation (April 3 - April 9)

Lecture:

Reading:

Deadlines:

Week 11: Code Generation (April 10 - April 16)

Lecture:

Deadlines:

Week 12: Procedures (April 17 - April 23)

Deadlines:

Week 13: Static Single-Assignment Form (April 24 - April 30)

Deadlines:

Week 14: Outlook on Optimization (May 1 - May 5)

Deadlines:

Resources

Books

Here is something weird: There is no required text for this course. Almost every compiler text out there contains the necessary theoretical background, so feel free to buy any book you like. That said, there are some recommended texts that make a lot of sense for this course. First, obviously, some compiler books; then, since there is a substantial amount of programming to be done, three books to help you organize your project and your code.

Compilers

Andrew Appel, Jens Palsberg: Modern Compiler Implementation in Java. Cambridge University Press, 2nd edition, 2003. The most up-to-date and comprehensive compiler text currently available. Provides much deeper coverage of most topics than the lectures do, and covers many more topics of interest than we have time for. All examples are in Java, but editions using C or ML exist as well. The 1st edition is also good enough for the course, and it's available much cheaper.

Keith Cooper, Linda Torczon: Engineering A Compiler. Morgan Kaufmann, 2004. A worthy contender for Appel's throne, this recent book also covers much more than you would need to know, but in a very different way. Personally I like it better than the Appel book, but that's mainly based on presentation, not necessarily on content. Examples are in all kinds of languages, but mostly pseudo-code.

Niklaus Wirth: Compiler Construction. Addison-Wesley, 1996. The most compact introduction to compiler construction I know, from an acknowledged master of the craft. Covers all the essentials for this course (in some way) and also develops a complete compiler. All examples are in Oberon, which might seem weird at first but turns out to be easy to read after a few hours.

Sadly, this book is currently out of print. However, Professor Wirth has made a slightly updated edition available for free as a PDF file [597 KB]. Please do not print this at school! Organize yourselves and have someone print it for all interested students, for example at Kinko's.

Programming

Andrew Hunt, David Thomas: The Pragmatic Programmer. Addison-Wesley, 1999. A wealth of practical advice on various topics relevant to software construction, including design, implementation, testing, debugging, etc. Organized in 46 relatively small "lessons," extensively cross-referenced, including 70 "rules" and several check lists on a reference card. You can download additional material for this book here. An errata is available.

Erich Gamma, Richard Helm, Ralph Johnson, John Vlissides: Design Patterns. Addison-Wesley, 1995. The standard reference for object-oriented design patterns: well-documented solutions to recurring design and implementation problems. The case study in chapter 2 is also a great introduction to object-oriented design and programming. We'll use a number of patterns in the course, for example Singleton, Composite, Visitor, and Observer.

Brian Kernighan, Rob Pike: The Practice of Programming. Addison-Wesley, 1999. Succinct discussion of a variety of programming topics. Deals with style, documentation, design, testing, debugging, portability, etc. Uses several programming languages (C, C++, Java, Perl) and discusses the tradeoffs involved. An errata is available.

Slides

Here are my old-ish lecture slides, mostly from 2004 and earlier. I'll be updating the slides a little as we go along, and I'll let you know when a newer version is available. With that in mind, I would not print this version; especially the later parts are 100% useless since the course has changed a lot (e.g. we're now using MIPS and not some strange stack machine).

Sample Solutions

Here are old-ish sample solutions that previous TAs and I wrote for the course. You use these at your own risk, you can't blame our code for your assignment doing the wrong thing...

Links

Here are a bunch of links you might be interested in as you try to get a grip on compilers and interpreters. Some of these are links to online books, so they are not exactly quick reads...

Miscellaneous

Tools

Assessment (Extremely Tentative)

Assignments (about 10 or so): 60%, Midterms (2): 20%, Final (1): 20%.

Updated: $Id: index.html 84 2006-05-10 19:29:05Z phf $ Validate: XHTML CSS
Copyright © 2001-2006 Peter H. Fröhlich. All rights reserved.