Assignment 4
The files for this assignment can be found in h4.tar. Download this file and extract the
files. (They will be extracted to a directory called h4)
Commands to extract, compile, and run are the same as for the
previous assignment.
Assignment
The relevent files for the assignment are:
- mlexer.mll - the specification of the lexical analyzer
- mparser.mly - the specification of the parser
- absyn.ml - contains the grammar for abstract syntax of expressions to be manipulated
- main.ml - the top level
- util.ml - a file with one trivial general function
- Makefile - the makefile
- tests - a few simple test cases
- interpret.ml - contains the beginnings of your solution
- interpret.mli - interface file for your solution
- sinterpret.ml - contains the beginnings of the store-passing solution
- sinterpret.mli - interface file for store-passing solution
This program will evaluate simple scheme expressions. As in the
previous assignment, your code will start with the output of the
parser. See absyn.ml for the type information of these
expressions.
The interface file, interpret.mli, gives the types of the
procedures used in interpret.ml. Examine this file, but do
not modify it.
For this assignment, you should do the following.
- Finish the code for
eval
, the static scope interpreter.
- Write the code for set!, set-car!, set-cdr!, and eq?.
- Write a store-passing version of eval.
You may use the solution to the previous assignment to start this assignment.
Submission
Turn in the files interpret.ml and sinterpret on the electronic
submission page.