COMP3002: Compiler Construction
This is the course webpage for the Fall 2011 offering of COMP3002. It is no longer current.
Always looking to improve, our TA, Sander, asked me
to post a link to the newly-created
TA feedback form so that you can offer any constructive criticism you might have.
Assignment 4 is now available (see below).
Here are the
Assignment 1, 2, and 3 marks.
To compute your
secret ID, enter your student number in the form below:
(Note: Sander has some updated marks for Assignments 1 and 2. The updates are not in this spreadsheet yet.) (Note 2: Assignment 3 was marked out of 45. The last question was treated as a bonus question.)
Office hours
The TAs/office hours for this course are:
Pat Morin | Tue 9:00-10:00 | 5177 HP |
Pat Morin | Tue 13:30-14:30 | 5177 HP |
Sander Verdonschott | Fri 13:00-14:00 | 1175 HP |
The TAs' office hours will be posted here as soon as we get some TAs.
If you need to see me outside of my office hours you can always try dropping by my office. Send me an email in advance if you really need me to be there.
The
CCSS COMP3002 Forum is now up. Please post any questions you have about the assignment or course material there.
Course outline
This course is about how to build a compiler. The main areas covered
are:
- Lexical analysis (tokenizing)
- Syntactical analysis (parsing)
- Code generation
- Code optimization
Assignments and software
The CCSS COMP 3002 Forum will be a good place to ask and answer questions about assignments. I'll be monitoring the forum. Students are encouraged to help each other by sharing test code (but not assignment code) on the forum.
Assignments will be posted here when they are ready. For now, these are the due dates for the assignments:
Assignments in this course will be programming assignments in Java.
For the first assignment you will be asked to make modifications to a
simple interpreter that I have hand-coded in Java. For subsequent
assignments, you will be working with JavaCC, an automated parser
generator system.
The following are sites at which you can download software and
documentation you will need for this course. All of this software is
sufficiently well-documented, so I don't offer any installation
support.
- In the third and fourth assignments, you will be working
with the Jasmin
JVM assembly language.
- If you don't have it already, you will need the Java SDK.
- For the second and third assignments you will be using SiCC.
Course notes
Most of the material I will teach is taken from the famous Red Dragon Book:
- Alfred V. Aho, Ravi Sethi and Jeffrey D. Ullman. Compilers:
Principles, Techniques and Tools. Addison-Wesley, reprinted in 1998.
This book has been updated
with a second edition and is now available as
- Alfred V. Aho, Monica S. Lam, Ravi Sethi and Jeffrey D. Ullman. Compilers:
Principles, Techniques and Tools. Addison-Wesley, Second Edition, 2007.
These are both very good books for compiler front-end theory.
Unfortunately, even the second edition is lacking when it comes to modern
compiler work. I don't recommend buying either book unless you can pick
up a used copy cheap.
The in-class slides are here. These are constantly being updated. In
particular, before each class I will revise the slides for that class.
- Introduction to compilers
(odp, pdf)
- Recursive descent parsing
(odp, pdf)
- Demo compiler overview
- Lexical analysis (tokenizing)
(odp,
pdf,
NumReader.java,
NumReader2.java,
PRM.jjt,
prm.t
)
- Parsing (including LL(1) grammars)
(odp, pdf)
- ssCC
(pdf)
- Shift-reduce (LR) parsing
(odp,
pdf)
- Intermediate code generation and type checking
(odp, pdf)
- Scope and Code Generation
(odp, pdf)
- The Java Virtual Machine
(odp, pdf,
jasmin)
- Basic Blocks, flow graphs and simple code optimization
(odp, pdf)
- Basic blocks as DAGs, peephole optimization, and graph coloring
(odp, pdf)
- Ershov numbers and data-flow analysis
(odp, pdf)
- The GNU Compiler Collection
(odp,pdf,
test.c,
gimple,
rtl)
The Cathedral and the Bazaar
- Compilers and security
(odp, pdf, additional info)
- History and context
(odp,pdf)
- Want to build a compiler?
(odp, pdf)
- Review
(odp, pdf)
- Old final exam
(pdf)
Grading scheme
Grades will be assigned using the following grading scheme.
Assignment 1 | 20% |
Assignment 2 | 20% |
Assignment 3 | 20% |
Assignment 4 | 20% |
End-of-term exam | 20% |
Total | 100% |
I may, at my discretion, increase the grades of certain students to
raise the class average or change the distribution. This will never
cause a student's grade to go down, nor will it change the relative
rankings of students so, e.g., it is not possible for a student who
earned an 80% to receive a lower grade than a student who earned a
75%.
Policy regarding unoriginal work
Students are encouraged to collaborate on assignments, but at the
level of discussion only. That is, they may work together to solve
problems and discuss their solutions, but when writing code should do
so on their own. No student should show another student his or her
source code.
Any student who is caught submitting work that they did not do
themselves will have all relevant material sent to the Dean, who will
determine the students fate. Possibilities punishments include receiving
reduced marks, no marks, expulsion from the course, suspension and/or
expulsion from Carleton University, and so on, at the discretion of the
Dean.
Students with Special Needs
Students with special needs should obtain documentation from the
Paul-Menton Center and notify me as soon as possible.