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.
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 .
EmIly
programThe 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).
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.
declem.astvisitor.TranslatingVisitor
, which
produces a String of an equivalent BoolEm program.
em.astvisitor.TranslatingVisitor
, which
produces a String of an equivalent DeclEm program.
listem.astvisitor.TranslatingVisitor
, which
produces a String of an equivalent Em program.
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.