Added 2/20/2004: Having trouble with the Makefile on unix machines? Try this version.
Added 2/16/2004: A new version of eoplLexer.mll that corrects the 0 problem.
The archive hw3.tar contains the ML implementation of an
environment-based interpreter, similar to that defined in Sections
3.1-3.6 of EOPL.
The concrete language is not Mini-Scheme, but a variant with fewer
parentheses. However, each parenthesis in this language is significant so you will
have to be very careful when you design examples for testing. The BNF
for this language is scattered through out chapter 3, so I've reprinted it
below. In the notation below, "{<exp>}," is any number of expressions
separated by commas ( {<var>}, is a similar notation for variables).
prim ::= + | - | * | add1 | sub1 | and | or | not
exp ::= <number>
| <var>
| <prim> ( {<exp>}, )
| if <exp> then <exp> else <exp>
| let { <var> = <exp> } in <exp>
| proc ( {<var>}, ) <exp>
| ( <exp> {<exp>} )
The following problems ask you to make five changes to the program in
eval.ml. When you test your program, you probably do not want to make
all five changes at once. However, you should submit a modified version
of eval.ml with all of the
changes made, each change marked in the comments. You
should not need to change any other file in the assignment.
| Concrete Syntax | Abstract Syntax | Description |
| zero? | Zero | Tests if number is zero |
| < | LT | Tests if one number is less than another |
| > | GT | Tests if one number is greater than another |
| = | Equal | Test if two numbers are equal |
let a = 2
in let p = proc (x) +(x,a)
a = 5
in *(a,(p 2))
Evaluates to 5 under dynamic scoping, not 3.
let a = 3
p = proc () a
in let f = proc (x) (p)
a = 5
in (f 2)
let a = 3
p = proc () a
in let f = proc (a) (p)
a = 5
in (f 2)
(Put the answer to this question in the comments at the end of the file.)