COMP 520 Compiler Design
Fall 2004
  (PLEASE NOTE, THIS PAGE HAS BEEN UPDATED TO REFLECT the FALL 2004 VERSION OF THE COURSE. Please refer to the web page weekly to review the course material and to check for updates.)

Academic Integrity at McGill University

McGill University values academic integrity. Therefore all students must understand the meaning and consequences of cheating, plagiarism and other academic offences under the Code of Student Conduct and Disciplinary Procedures (see for more information). A helpful article on how to avoid plagiarism can be found at:

In terms of this course, part of your responsibility is to ensure that you put the name of the author on all code that is submitted. By putting your name on the code you are indicating that it is completely your own work. If you use some third-party code you must have permission to use it and you must clearly indicate the source of the code.


  • Nov 10, Chris had added more scripts to the joos benchmarks to make it easy to run the peephole patterns on the A-, A+ and your Joos compilers. Please see for instructions on how to use it.

    You will find the new tar-ball, with the new peephole scripts at: These have all been upacked in the directory:

  • Nov 5, Chris has made a few improvements to benchmarks available as in point below. You probably want to refresh and take a new copy of the .tar.gz file.
  • Nov 3, Joos and Wig benchmarks are available at: . You may take the entire suite by grabbing the file fall2004.tar.gz , or you may browse the directories. Chris Pickett has also prepared some scripts which you may find useful -- check out the subdirectory fall2004/joos . Any questions you have about the benchmarks or how to run them should be directed to Chris.
  • Use bsdwig4, bsdwig18, bsdperfectwig on lab4 BSD machines (and then compile the resulting file on Or, use wig4, wig18, perfectwig on a SUN server (willy,mimi) and then compile resulting file on wig10 should work anywhere that Java runs ..., but generated code must be compiled on
  • Oct 5, updated information about WIG compilers sent in e-mail. A copy of the message is found here .
  • Oct 2, IMPORTANT INFO about WIG compilers . Please read these important updates
  • Oct 2, svn documents updated. (html) --- (pdf)
  • Sept 30 , TENTATIVE Final Exam Timetable has COMP 520 final exam scheduled for Tuesday Dec 07, 14:00. The date and time may still change, keep a watch on
  • Sept 25, SOCS has an svn server now, and you might prefer to use svn instead of cvs (I prefer svn myself). Kacper has kindly written a small document with all of the basics for using svn, it can be found here .
  • Sept 25, JOOS grammar, if you are getting parse errors for your JOOS programs, remember that your can find the exact grammar of JOOS in bison form or sablecc form.
  • Sept 21, instructions for using Eclipse. Eclipse is an open source development environment, with some very nice features for developing Java projects. If you are interested in using Eclipse, you can get more information and download it from . Patrick has kindly provided the basic instructions on how to set up a project and use ant and cvs with that project. His directions are found here .
  • Sept 20, for all of you using SableCC, I suggest that you join the SableCC-user mailing list. You may post precise questions there, and you may review the prior postings. Since there is a current lack of documentation on SableCC3, posting relevant questions would be of benefit to other users and the SableCC3 developers. See for information on how to subscribe to the list and how to review the archives.
  • Sept 15, JJOOS for SableCC version 3 is all working now. Thanks to Etienne Gagnon for his help. Give SableCC 3 a try and see how you like it. Further instructions here .
  • Sept 15, I have gone through all of the course web site and updated links and software. I think everything should be ok now. Please let me know of any problems, or any links which might be interesting to add. LJH
  • Sept 13, Milestone 0 is due this Friday.
  • Sept 13, Make sure you put -lfl as the last argument for your compilation and linking of a flex scanner. For example, a simple scanner would be compiled by
    flex exp.l
    gcc lex.yy.c -o mylexer -lfl
    To see a sample makefile and small scanner and parser, refer to this directory . You can grab all required files in a tar bundle as exp.tar. If you use the tar file, be sure to extract it inside a new directory.
  • First class is Wednesday, Sept 1, ENGTR 2100, 11:35-12:25. Be sure to come on time and be ready to take some notes.

About this course

Official course description
Philosophy of the course


Lecturer (Laurie J. Hendren)
Teaching assistants

Printed Readings

Course Text (Readings)
Lecture Notes

Deadlines and Important Dates

Deliverables and milestones
Week by Week Schedule


The project description
The A- source code (flex/bison/C)
The A- source code (SableCC/Java)
The A+ project
The A+ binary
JOOS examples
JOOS library source
JOOS extern classes

How to run Java and JOOS programs at McGill
How to run Soot at McGill


The project description
Original WIG grammar
Yacc-style grammar, most conflicts solved
Sablecc-style grammar (version 2)
How to run SableCC
WIG examples
How to compile WIG programs

The <bigwig> project
The Mawl project

Peephole contest

Rules and prizes
Results and Winners

Online documentation

The flex scanner generator
The bison parser generator
The SableCC compiler generator
The Java language specification
The Java virtual machine
The Java API documentation

HTML User Guides
CGI Programming
The HTML 4.0 specification
The CGI specification

Under The Hood articles:

Week by week

Week 1: Introduction and Scanners

   September 2004
 S  M Tu  W Th  F  S
          1  2  3  4  
          *     *

Slides, 4-on-1
Plus, first 9 slides from week 2.


Reading 1: Louden, Chapter 1
Reading 2: Appel, Chapter 2
Reading 3: Flex

Students who do not have a background in regular languages and finite state automata should review this material on their own. A good online resource may be found here . This review should be done ASAP.

Week 2: Scanners and parsers

   September 2004
 S  M Tu  W Th  F  S
 5  6  7  8  9  10 11 
    H     *     *
Note that Monday, September 6, is a holiday, no lectures.
Also, note that Chris Pickett will be giving the lectures this week as Professor Hendren is out of town.

Slides, 4-on-1


Reading 4: Louden, Chapter 3
Reading 5: Appel, Chapter 3.2-3.5

Week 3: Abstract syntax trees and SableCC

   September 2004
 S  M Tu  W Th  F  S
12  13 14 15 16 17 18 
    *     *     * 

Slides, 4-on-1
SableCC Slides

Code for tiny expressions


Reading 6: Bison
Reading 7: SableCC, Gagnon, Chapters 3-6

WIG milestone: form groups and begin planning

Week 4:

   September 2004
 S  M Tu  W Th  F  S
    *     *     * 
19 20 21 22 23 24 25

Slides, 4-on-1


WIG milestone: Use your group's chosen toolset on a Tiny example

Week 5:

    September 2004
 S  M Tu  W Th  F  S
26 27 28 29 30 
    *    *

    October 2004
 S  M Tu  W Th  F  S
                1  2  

Slides, 4-on-1


JOOS deliverable: benchmark programs
JOOS deliverable: comments and desugaring

Reading 8: HTML
Reading 9: CGI

Week 6: Symbol tables

    October 2004
 S  M Tu  W Th  F  S
 3  4  5  6  7  8  9 
    *     *     *

Slides, 4-on-1


WIG milestone: CGI vs. WIG

Reading 10, Louden, Chapter 6.3

Week 7: Type checking

    October 2004
 S  M  Tu  W Th  F  S
10  11 12 13 14 15 16 
    H     *     *
Note that Monday, October 11, is a holiday, no lectures.

Slides, 4-on-1


WIG milestone: scanner and parser

Reading 11, Louden, Chapter 6.4

Week 8: Virtual machines

    October 2004
 S  M Tu  W Th  F  S
17  18 19 20 21 22 23
    *      *     **

Slides, 4-on-1


WIG milestone: symbol tables


This year it is a closed book midterm

Week 9: Code generation

   October 2004
 S  M Tu  W Th  F  S
24 25 26 27 28 29 30 
    *     *    *

Slides, 4-on-1


WIG milestone: type checking

Week 10: Optimization

   November 2004
 S  M Tu  W Th  F  S
    1  2  3  4  5  6  
    *     *     *

Slides, 4-on-1


JOOS deliverable: stack limits

Week 11: Garbage collection

   November 2004
 S  M Tu  W Th  F  S
 7  8  9  10 11 12 13 
    *     *     *

Slides, 4-on-1


Reading 12, Appel, Chapter 13

Week 12: Native code generation

   November 2004
 S  M Tu  W Th  F  S
14 15 16 17 18 19 20 
   **     *     *

Slides, 4-on-1

JOOS deliverable: peephole patterns

Note the deadline on MONDAY!

Week 13: Static analysis

   November 2004
 S  M Tu  W Th  F  S
21 22 23 24 25 26 27 
   *      *    * 

Slides, 4-on-1

Reading 13: Appel, Chapter 10

Week 14: Presenting your compilers

   November 2004
 S M Tu  W Th  F  S
28 29 30

   December 2004
 S  M Tu  W Th  F  S
          1  2  3  4       
Wig compiler and report due on Monday by noon
(Group meetings will be scheduled on Wednesday and Friday)
(No lectures)

Meetings of Groups

WIG deliverable: compiler
WIG deliverable: report

Maintained by Laurie J. Hendren Last modified Thu Sep 30 11:17:37 EDT 2004. [HOME]
Compiler research projects: Soot, a Java analysis, optimization and transformation toolkit ---- abc, an AspectJ compiler. (AspectJ)