Project 9: Functional programming

In this project, you will write an interpreter for the Em family of languages-- a single program that will interpret any BoolEm, DeclEm, Em, or ListEm program.

1. Set-up.

The parsers, syntax tree classes, visitors, and other pieces are provided for you, and can be found in a tar file.

cp /cslab/class/cs365/proj9.tar .

2. The EmIly program

The class EmIly (for "Em Family"; it's not named after anyone) looks at a file's suffix to determine what to do with it. It straight interprets a BoolEm program; any other kind of program it translates to the next smallest language. It also takes two flags, -p and -pp, to print the translation and to print all translations, respectively.. For example

java EmIly program.em

... will translate from Em to DeclEm and from DeclEm to BoolEm, and interpret the resulting BoolEm program.

java EmIly program.em -pp

...will translate from Em to DeclEm and from DeclEm to BoolEm, and print all those translations (but not interpret anything).

java EmIly program.em -p

...will translate from Em to DeclEm, print the resulting DeclEm program, and stop.

When a program reduces to a value, the result should be that the BoolEm interpreter will (pretty-)print that final expression. However, if the original language is ListEm and the final value is a list, we want to print that as a list rather than a messy bunch of abstractions, so the program will also do a "ListEm" printing of the final BoolEm expression (so it appears as a list).

3. Things to do.

There are three things that need to be done. You'll want to do them in the order described below and test at each step.

In the spring 06 semester, this project also required writing the BoolEm interpreter and the the final ListEm-printer for BoolEm, but I am supplying this for you.

Due: Apr 23, 5:00 pm.


Thomas VanDrunen
Last modified: Wed Apr 9 15:53:33 CDT 2008