198:415 Compilers
Spring 1999
Professor Barbara G. Ryder

Programming Assignment 1
Straight-line Program Interpreter

due: 6pm Monday, February 1, 1999

This assignment is explained in detail in your textbook in Chapter 1. It is to famliarize yourselves with how to use Java to perform tree walks, since trees are a common internal representation in a compiler. As explained in lecture 1, your job is to write a Java program that traverses a tree constructed from productions in a simple language grammar. During traversal, this program will calculate the values of expressions and bind those values to identifiers in assignment statements. You also will write a function that calculates the numbers of arguments of print statements.

A skeleton .java file containing the classes describing the expression and statement objects (see Chapter 1 in text) is already provided for you on remus in /usr/local/class/cs415/sp99/tiger/chap1/slp.java. A sample tree to use to test your program can be found in /usr/local/class/cs415/sp99/tiger/chap1/prog.java. An incomplete template of your interpreter can be found in /usr/local/class/cs415/sp99/tiger/chap1/interp.java.

How to proceed?

For organizing your cs415 work, you should create a new subdirectory for every new assignment. All assignment directories and files should be read and write protected so that only you can read or write the directory and its files.

To begin, you should create a working directory for Assignment 1 and then copy the files mentioned above to your new directory.

We will be using the handin program for this and all subsequent programming assignments. More information on its use will be provided later.

For this assignment you only need to turn in your code (i.e., the expanded version of interp.java that you wrote, not the code in slp.java unless you changed something in that file) and the output of the list of bindings calculated for the sample tree.

Last updated by Barbara Ryder at 5:12pm on January 25, 1999.