Project 7: Translating from OJay to RecJay

The goal of this project is for you to devise a way to interpret an OJay program by encoding it in the RecJay language. This is one way of specifying the semantics of classes and objects.

1. Set up

This project will involve both Java and ML code, but you will be writing only ML. I am giving you an interpreter for RecJay (in Java), and you will complete an OJay-to-RecJay translator (in ML). A script will feed the results of your translator into the RecJay interpreter.

All this is archived in a tar file. Copy the file from the class directory and untar it.

cp /cslab/class/cs365/proj7.tar .
tar xvf proj7.tar

2. Your task

Your task is to write complete the code in ojay2recjay.sml. This file contains a bunch of functions for "printing" OJay constructs. You, of course, do not want to pretty-print OJay but instead print equivalent code in RecJay. Currently this file contains a few of the functions you'll need, but all it does it print out a blank program ("void main() {}").

Take note: this file does not currently contain the stubs of all the functions you'll need. For example, I'm not providing stubs for printing expressions. Don't just fill in the functions I give you; you need to add other functions.

Also note that this does not print the result to the screen but rather returns a string (maybe print wasn't the best choice of function name...). It's possible that some of your functions will need to add to different parts of the program (for example, printClass may need to add something to both the Classes part and the Method part of the RecJay program. You may wish printClass to return a pair of strings, then rather than a single string.

As with Project 5, your translation need not be pretty.

3. Testing your code

There are two driver scripts:

OJay-print will print your RecJay translation to the screen, for debugging purposes. Usage:

./OJay-print somefile.ojay

OJay-run will execute your RecJay translation. Usage:

./OJay-run somefile.ojay

4. Turn in

To turn in this project, please copy your ojay2recjay.sml to the turn-in directory I will prepare for you:

/cslab/class/cs365/turnin/proj7/xxxxxx

where "xxxxxx" is [andy|david|tyler|yelemis]. I will grade your project by running it against a collection of test files.

DUE: Monday Mar 31, 5:00 pm.


Thomas VanDrunen
Last modified: Mon Mar 24 11:14:55 CDT 2008