Learn more Learn more

Upcoming Deadlines


Recent Discussions

Browse all discussions »

Announcements

Week 10 Lectures Posted

The final set of lectures is now available. They cover Java language features, interpreted through the concepts covered in the course.
Mon 19 May 2014 9:00 AM CEST

Final Posted

The final exam for the Compilers course is now available. Click on the
link in the "Upcoming Quizzes" box to the right of this announcement or
find it on the "Quizzes" page.

You may only take this exam once. You will have 4 hours from
when you click the "Start Quiz Now" button to submit your answers.
The final exam is due Sunday before midnight.
Any exam started by this time will receive full credit. Exams started
after this time will receive NO credit. Make sure to do the appropriate
math if you are in a different time zone.

The exam may cover material from the entire course, but more weight will
be given to material that came after the midterm.

Correct answers and explanations will be made available after the exam
period has finished. Until then, please avoid discussing the questions
(or answers!) on the forum. (Posts seeking clarification on the intent of
a question are of course permitted.)
Mon 19 May 2014 9:00 AM CEST

Final Survey

Please take a look and complete the survey for our course! It will be helpful to receive feedback as our online course is still in its early stage and we would love to hear any constructive comments to improve our course.
Mon 19 May 2014 9:00 AM CEST

Week 9 Lectures Posted

The lectures for Week 9, on register allocation and garbage collection, have been posted.
Mon 12 May 2014 10:00 AM CEST

Fourth (and last!) Programming Assignment Available

The fourth programming assignment is now available. This is the last and final stage to get a completely working compiler (you can also try the optimization). The time to complete this part of the project is roughly the same as the third assignment.
Mon 12 May 2014 9:00 AM CEST

Week 8 Lectures Posted

Lectures for week 8 on optimization have been posted.
Mon 5 May 2014 10:00 AM CEST

Week 7 Lectures Posted

The lectures for Week 7, covering code generation and operational semantics, have been posted.
Mon 28 Apr 2014 9:00 AM CEST

Third Assignment Available

The third programming assignment is now available for those that wish to get hands-on experience with writing a compiler. As we've said before, it will probably take longer to complete than you expect. From the feedback we received in the past offering, the time to complete the project is significantly longer than the first and second assignment so please start early!
Sat 26 Apr 2014 9:00 AM CEST

Week 6 Lectures Posted

The lectures for Week 6 have been posted; this week's topics are the Cool type system and runtime organization.
Mon 21 Apr 2014 10:00 AM CEST

DeduceIt Issues


Many students have pointed out that they have mysterious hangs when using DeduceIt, which obviously makes it a frustrating and rather uneducational experience to use.  Thanks to some suggestions from students in the class I've been able to reproduce the problems in my own sessions---and have realized that this is not something I want to try to fix in real time during a class offering.

So, my apologies for the DeduceIt debacle.  I regret wasting your time with software that isn't in a usable state.  I'm canceling the remaining DeduceIt assignments (4-6); they won't appear.  Since the first three assignments have already been out and some people have done them and others haven't, I'm extending those deadlines until the end of the class.  

I realize this is not a perfect solution.  Please keep in mind a few points that I think will address most concerns people may have:

First, you don't have to do any of the DeduceIt assignments.  They are all extra credit (and always have been). 

Second, you will get credit for any assignments you have already done.  And to be fair, everyone who hasn't done the assignments posted so far can still do them until the end of the class with no late penalty.

Third, if you really want to do the remaining DeduceIt assignments, you can still go to deduceit.stanford.edu and do them.  The system is still there and it is possible to work around the current issues if you really, really want to use it.  But it is not going to be part of the rest of the course.

Again, apologies for the problems and the mid-course correction.

Alex
Tue 15 Apr 2014 9:05 AM CEST

Week 5 Lectures Posted

The lectures for Week 5 on semantic analysis and type checking have been posted.
Mon 14 Apr 2014 10:00 AM CEST

Upcoming Midterm

It's the end of week 4 of the Compilers course and the upcoming week
will mark the course's midpoint, which means it is time for a midterm!
Here's how the midterm will work. It is a quiz, similar to the ones
you have already seen. It differs from normal quizzes in two important ways:

* You can only take the midterm once.

* The midterm is timed; you will have 2.5 hours to complete it. This
means that once you press the "start quiz" button, you must submit
your answers within 2.5 hours to receive credit for the midterm.

We've timed the quiz and we believe that 2.5 hours should be a very
conservative amount of time. We're making the time limit that long to
help deal with any issues people may have with connectivity, but it is
definitely a good idea to be in a place where you will have a decent
internet connection while you take the midterm, and you should allow
yourself the full 2.5 hours if you can. We think the midterm is
similar in length to the quizzes you have already done; the level of
questions is similar and there are about the same number of questions
as in a weekly quiz.

The midterm will cover the material through the first four weeks of
the class; this week's lectures (week 5) are NOT on the midterm.
Also, because of the midterm, there is no regular quiz nor any
DeduceIt problems this week, but keep in mind that some quizzes and
DeduceIt problems from previous weeks are still open if you haven't
done them yet.
Fri 11 Apr 2014 9:00 AM CEST

Second Programmng Assignment Available

The second programming assignment is now available for those that wish to get hands-on experience with writing a compiler. Again, it will probably take longer to complete than you expect, so try to get started on it early. From the feedback we received in past offerings, the amount of work required is roughly the same as the first programming assignment.
Wed 9 Apr 2014 9:00 AM CEST

Week 4 Lectures Posted

The lectures for Week 4, covering bottom-up parsing, have been posted.
Mon 7 Apr 2014 9:00 AM CEST

Sample Bison Parser

An example of a simple (but working) bison parser can be found here for your reference:

Compilation instructions are in the comments at the top of sample.y. Unfortunately, we don't have a JCup version (sorry!).
Mon 31 Mar 2014 9:00 AM CEST

Week 3 Lectures Posted

The lectures for Week 3, covering basic parsing concepts and top down parsing, are now available.
Mon 31 Mar 2014 9:00 AM CEST

Example flex and jlex files

For those of you doing the lexical analysis programming assignment, here are a sample flex (for C/C++ programmers) and jlex (for Java programmers) files. These should compile using the commands in the comments at the top of the file; there is also a sample input you can try. Both specifications tokenize the same thing, a small lambda calculus-like language where the tokens are things like '\', '.', variable names, integers, +, and parentheses.


The particular language is not so important here as the structure of the lexical analyzer. Both flex and jlex files consist of three parts: a declarations section where you can put C/Java declarations you want to have available, a rules section where you can put regular expressions that will match parts of the input and then an action (in the form of C or Java code) that will fire when that pattern matches, and finally a code section where you can put other functionality (e.g., a main function).



Your lexical analyzer will of course be very different from this one - this example is not a partial solution to the assignment! But the example should help you understand how these tools work. You can also find much more information in the flex and jlex reference manuals.

Mon 24 Mar 2014 8:00 AM CET

Week 2 Lectures Posted

The video lectures for week 2, covering regular expressions, lexical analysis,
and finite automata have been posted.
Mon 24 Mar 2014 8:00 AM CET

First Programming Assignment is Available

The first programming assignment is now available for those interested in building a Cool compiler. A word to the wise: It is very likely that this assignment will take longer than you expect (even taking this rule into account!), so start early!
Mon 24 Mar 2014 8:00 AM CET

Welcome!

Welcome to a public version of Stanford's undergraduate course on compilers. The first week of lectures are available, and that is all that is assigned for the first week.

The course will last eleven weeks. Starting with the second week, we'll begin having short in-lecture quizzes to help you master the material, as well as a weekly multiple-choice quiz. There will also be weekly homeworks using DeduceIt, a system for delivering free-form exercises in the form of derivations or proofs. Though completely optional, these experimental DeduceIt exercises aim to strengthen your understanding of the materials. We hope these assignments will help you learn the material at a level in a way that was previously impossible without one-on-one instruction. Halfway through the course there will be a midterm and at the end we'll have a final, both of which will be structured as longer, timed on-line quizzes.

No compiler course would be complete without the opportunity to have the experience of implementing a full compiler for at least a simplified programming language. We realize that many students will have claims on their time besides writing a substantial software system for an on-line class, but we will have a series of optional assignments that, if completed, will lead you to build a full compiler for COOL, the Classroom Object Oriented Language.

At the end of the class we'll issue certificates of accomplishment for those who finished the coursework, with an extra acknowledgment for those who have done the compiler project.

We hope you enjoy the course!
Mon 17 Mar 2014 8:00 AM CET

Cool Examples

The Cool example programs mentioned in the Cool Examples lectures are now available:

Descriptions of most of the programs are included in the README as well as in the comments at the top of each file.
Mon 17 Mar 2014 8:00 AM CET

Virtual Machine for Programming Assignments Available

Please read the instructions on the "Virtual Machine Info" link to get started.
Any questions or suggestions you have that aren't answered by one of the other
resources provided should be posted here.
Mon 17 Mar 2014 8:00 AM CET