Spring Quarter 2005: March 28, 2005 - June 3, 2005
Catalog Description: Covers the fundamentals of compiler design, including lexical analysis, parsing, semantic analysis, compile-time memory organization, run-time memory organization, code generation, and compiler portability issues. Laboratory work involves exercises covering various aspects of compilers.
Prerequisite(s): CS 061: Machine Organization and Assembly Language Programming, CS 141: Intermediate Data Structures and Algorithms (may be taken concurrently), CS 150: The Theory of Automata and Formal Languages. You also need good programming skills to pass this course!
Time Requirements: Four units (12-16 hours/week): lecture (3 hours/week), laboratory (3 hours/week), individual study (6-10 hours/week; includes reading, writing, and hacking).
Instructor:
Peter H. Fröhlich
Office Hours:
Monday, Wednesday, Friday, 5:10 pm - 6:00 pm
(email for additional appointments)
Location:
Surge,
Room 341
Lectures:
Monday, Wednesday, Friday, 4:10 pm - 5:00 pm
Location:
Sproul,
Room 2355
Assistant:
Vi Pham
Office Hours:
Location:
Surge,
Room 282
Lab:
Wednesday, 11:10 am - 2:00 pm
Location:
Surge,
Room 283
Assistant:
Mikiko Matsunaga
Office Hours:
Location:
Surge,
Room 282
Lab:
Tuesday, 8:10 am - 11:00 am
Location:
Surge,
Room 283
Mailing List: cs152@lists.cs.ucr.edu (Archive)
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. Note that even the three programming books refer to techniques you'll learn in this course, they are not just restricted to 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, thanks to Professor Wirth's generosity, I can offer the complete text for download as a PDF file [6.2 MB]. Thanks are also due to Eric Frohnhoefer for scanning the book. Please do not print this at school! Organize yourselves and have someone print it for all interested students, for example at Kinko's.
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.
Note the word tentative above. Things seldom go according to plan, and I expect changes here and there as we go along. Please also read the notes below.
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.
Some topics we go over in lecture or lab are not covered in the text; I will try to provide additional references for those. Note that the readings don't always "match up" with the lectures very well, so the chapters given are approximations. Use your own judgement regarding what is important!
You are expected to do the assigned reading before a topic is covered in lecture or lab. 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...
The department's programming guidelines make for quite interesting reading, often highly relevant to this course.
I try to write slides for my lectures, but I am not always very lucky in getting them done (either on time or ever). In other words, it's a good idea to always take notes in class. :-) That said, I decided to put all my slides into one PDF file instead of posting every lecture by itself. The advantage is that you never have to guess whether I forgot to post a certain lecture, or whether I never wrote the slides for it. The drawback is that the file evolves during the quarter, so the version you download in one week will be quite different from the one available three weeks later. Keep that in mind please.
I'll try to email the list whenever I post a new version of the slides, but of course I might forget. If in doubt, just check back here.
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.
Here are a bunch of more or less useful resources for the course. Note that in the case of source code, we do not give any guarantee for its correctness. If you reuse our code for your assignment, you have the responsibility for testing it. If you find a bug, please notify us at once! And always feel free to email me any comments you might have. Thanks!
Assignments (8): 60%, Quizzes (2): 10%, Midterm (1): 15%, Comprehensive (1): 15%. See my policies for more information.