CS451/CS651 Compilers
Bill Campbell
Spring 2009

This document is available at http://www.cs.umb.edu/~wrc/cs651/spr09/.On the department's Unix file system you can find the documents for this course at ~wrc/cs651.

Hi, my name is Bill Campbell.  This course is about compilers, programs that translate programs written in some high level programming language like Java to some (low-level) target machine language like that for the Java Virtual Machine (JVM) or the Intel 386 family of computers.

Our study of compilers will involve both theory and practice. There will be many exercises similar to those found in CS 420. When it comes to theory we shall be following the textbook closely and we'll take many of our exercises from there. We shall also write many programs; indeed we shall write ourselves a compiler, albeit in pieces. We will start from a compiler for a subset of Java called j-- and extend that to add new language features. Of course, you should be proficient in Java before taking this course.

Our compiler will translate programs written in a non-trivial subset of Java to .class files, which can be executed on the JVM. So that we don't have to deal with the intricacies of properly constructing .class files, we'll use a tool that Swami Iyer has implemented to create the class files; we call this the emitter.

An old friend, Bruce Knobe, has always argued that Compilers was always a software engineering course. Bruce is correct because it's probably the first course in which each programming assignment must make use of the programs written in all previous programming assignments. Moreover we end up writing a program composed of many components. It is assumed that you are proficient in Java.

Like many programming courses, this one requires time. Indeed this course has a reputation for eating up lots of time. After all we're doing lots of theoretical exercises and writing a compiler! Do not be surprised if you find yourself spending 20 hours per week on this course. If you cannot spend a lot of time here then I suggest you consider withdrawing right now. If you stick it out, I think you will have a lot of fun. 

To do now:

1.     Join the Google group cs451-cs651-umb at http://groups.google.com/group/cs451-cs651-umb, which I have set up for discussions in this course.  You will need to get a gmail address to do so if you haven’t already. All announcements will be made to this group, and all questions to me or to your classmates should be posed on this group.

2.     Obtain and install Eclipse on your home computer. Download and import the code tree at http://www.cs.umb.edu/~wrc/j--/j--.zip. See Chapter 1 and Appendix A of the text (below) for help in doing this.

3.     “Apply” for a cs651 Unix account.

4.     Read Chapter 1 of the text (below).

5.     Do the first programming assignment (below)

Syllabus

Text Books

Readings and exercises will be assigned from the following required text, which I will distribute in class.

Another books, which you may find useful, are

Sun Microsystems has a good set of online documents about Java, specifically

·       An index to the Java SE Platform

·       Java Language Specification, Third Edition

This will be our Bible when it comes to deciding how the various components of our compiler should deal with Java.

·       Java 2 Platform, Standard Edition, 6.0 API Specification

·       The Java Virtual Machine (JVM) Specification

Chapters of the text will be distributed in class.  These include:

·      Chapter 1: Compilation

·      Chapter 2: j--, the CLEmitter and the JVM Instruction Set

·      Chapter 3: Lexical Analysis

·      Chapter 4: Parsing

·      Chapter 5: Type Analysis

·      Chapter 6: Code Generation

·      Chapter 7: Extensions to j--

·      Appendix A: Setting up and running j--

·      Appendix B: j-- Syntax

·      Appendix C: Java Syntax

·      Appendix D: The CLEmitter and the JVM instruction set

The j-- code tree is available at http://www.cs.umb.edu/~wrc/j--/j--.zip

Assignments and Grading

Your grade will be determined as follows:

Two important things here:

         A narrative describing how you went about designing and writing your program, the problems you faced, alternative solutions, and a discussion as to why you chose the solutions you did should accompany every assignment. I should have a pretty good idea of what your program looks like from reading your narrative.

         Your work must be your own. If someone gives you an idea, acknowledge it in your narrative.

          

         Assignment 1: Compiling Additional Operators

         Assignment 2: Scanning

         Assignment 3: Parsing

         Assignment 4: Parsing with JavaCC

         Assignment 5: Analysis and Code Generation I

         Assignment 6: Analysis and Code Generation II

·      Midterm Examination (Wednesday, March 25) (sample) 15%

·      Final Examination 25%

Reaching Me

My office is S-3-183; it is just behind the department office. My office hours are in my .plan. My office telephone number is 617-287-6449; my home telephone number is 617-547-2738. Please do not telephone me at home before 9am or after 10pm. My email address is william.campbell@umb.edu; I read my email regularly.

If you have a question about something you don’t understand outside of class, use the cs451/cs651 group in the CS Forums at http://forums.cs.umb.edu/forums/.  Perhaps one of your classmates will answer it.  Perhaps one of us (me or Swami) will.  If your question is of a strictly personal nature, e.g. about a grade or a request for a face-to-face meeting, by all means use email.  But beware: should your question be of the sort that the entire class may want the answer to, I’ll ask you to repost it on the CS Forums site.  Get used to this site; it’s a good way to hold discussions over the internet.

A Few Important Notes

Should you have any problems or questions, contact me early; don't let small problems become big ones! Telephone me, visit me at my office or stop by after class to set up an appointment. Also, I encourage questions in class; if you don't understand something, there is a good chance that others don't. I like questions.