Mid-semester Project - Deliverables


Part I Deliverables

Translation by Hand - (15 minutes)
To make sure you understand what we expect your project to do, we want you to show us what the Java code that will be generated by your final project would look like for the following SLAT declaration of a tree:

tree ::= leaf (int)
       | node (String tree tree)
You may want to look at the code for the ilist example to get you started.

Write the Parser - (60 minutes)
You are going to have to parse SLAT abstract syntax declarations.  Using the information in the section on writing the parser, complete the parser.  When applied to the SLAT code for a tree:
tree ::= leaf (int)
       | node (String tree tree)

The parser should produce an abstract syntax tree that looks like the diagram to the right.

You can download a SLAT tree printer.   It will print out the SLAT abstract syntax tree you generated.  It should help you visualize the abstract syntax tree.  (DISCLAIMER: it does not print out exactly like the picture to the right)


Part II Deliverables

Hand Translation to Java Abstract Syntax - (30 minutes)
Translate the SLAT delcaration for tree (below) into an abstract syntax tree for Java.

tree ::= leaf (int)
       | node (String tree tree)
Run your abstract syntax trees (there will be three of them) through the Java unparser and ensure that the code it generates compiles.  This will give you an idea of what your translator has to produce.
 

Write the Translator - (90-120 minutes)
Write a Scheme function called translate that translates SLAT abstract syntax into the equivalent Java abstract syntax.  You will write scheme functions that do these two things:

  1. Create the Java abstract syntax representing the parent class.
  2. Create the Java abstract syntax representing each child class, including the constructor, member fields, etc.

The function translate should return a list of Java abstract syntax records (i.e. java-decls).

Here are simplifying assumptions:

Use Your Generated Code - (45 minutes)
Use your parser and translator, together with the unparser we supply, to translate the SLAT declaration of a tree given above into Java code describing the tree declaration.  Write a leaf-sum program in Java that uses the generated code.  Show that it works by compiling and executing the Java code.  You can use this example as a template for your function.  As with everything written for this project, include in your submission your generated code, your leaf-sum program, and the results of running the leaf-sum program.


Passing Off

To pass off part I, you need to show the part I deliverables to a TA.
To pass off part II, you need to create one big file that has all of your deliverables for part I & part II in it.  Comment out the stuff that is not scheme code, and then submit the file as Homework 20 using the submit option on the webpage.

The header should be as follows:

#|
[name]
HW-20
[email address]
|#
#|
[partner's name]
HW-20
[partner's email address]