Jay Interpreter Programming Project:
A major programming project for this quarter will be to implement a Jay interpreter in Haskell. The interpreter program (which is a function, of course) should return the final state of the Jay program's environment. The program's input should be a parse tree of the form that will be / has been presented in class. The sample syntax for interpreter parse trees (aka the syntax for the intermediate representation of Jay programs) is available from the following link:
JayFibSampleParseTree.hs
The TestSuiteSupportModule is available from the following link:
TestSuiteSupportModule.hs
Part 1
The first step will be to implement a way of representing state, which we have simplistically defined for our own purposes as a set of {Name, Value} pairs (or {Name, Value} bindings), where Name is a variable name (identifier for a memory location) and Value is the value bound to the identifier. We have left the actual locations out of the equation, meaning, if you think about it, that our language does not support aliases. An explanation of the data type definitions used by this program for representing state, and a file containing function signatures for accessing and modifying state, with associated test cases, are available from the following links:JayValueStateIntro.txt
ValuesAndState.hs
Part 2
The next step will be to write code to interpret Jay declarations expressed in our intermediate language. The data types definitions and function signatures for representing interpreting declarations, and the associated test cases, are available from the following link:
JayDecls.hs
(Note: although it's not required yet, I would strongly encourage
you to look ahead and implement enough of Part 3 to allow you to
create assignment statements assigning a constant value to a
variable. This will allow you to see the code you wrote in Parts 1
and 2 in action.)
Part 3
You may wish to keep things simple for your next step, implementing the very simplest of expressions (e.g., constants and variables) and the simplest of statements (the empty statement and assignment statement) first so that you can test them together. Or you may wish to implement and test all expression types before going on to statements. The data types definitions and function signatures for representing expressions, and the associated test cases, are available from the following link:
JayExpressions.hs
Note: for division, you want to use the "div" operator in Haskell rather than the "/" operator, since the former does integer division.
Part 4
The final step is to implement the semantics for various types of statements and then implement the function that interprets a Jay program expressed in our intermediate parse tree format. The data types definitions and function signatures for representing statements, and the associated test cases, are available from the following link:
JayStatements.hs
The file for the program as a whole is:
JayInterpreter.hs
The file for the sample fibonacci program from p. 43 of Tucker and Noonan (1st Ed.) is:
JayFibSampleParseTree.hs