[lambdaheads]Program 3

[Programming][Languages]

Consider the language AFun!Exp, which is AFunExp extended with assignment:

<L> := ... 
     | (set <id> <L>)
where ids are represented by symbols. Your parser must map this syntax to values of the following datatype:
(define-datatype AFun!Exp AFun!Exp?
  [numE (n number?)]
  [funE (var symbol?) (body AFun!Exp?)]
  [varE (v symbol?)]
  [appE (fun AFun!Exp?) (arg AFun!Exp?)]
  [setE (var symbol?) (body AFun!Exp?)])

Write an eager interpreter for AFun!Exp. Your interpreter must model state in the language L without relying on Scheme's implementation of state. That is, you may not use set! or boxes or any other such constructs. You will be penalized for any violations of the spirit of this assignment, so don't expend energy trying to find what you think are loopholes (such as hash-tables, or using external procedures so you can exploit some other language's implementation of state).

You may assume that programs are closed. Use an environment. Your interpreter does not need to deal with type errors.

Turn in all the code needed to run programs in AFun!Exp (parser, interpreter, libraries, etc). Your code is due by 11am on 2000-09-29. You must also turn in the test suite you used to validate your solution. (Each test case in a test suite consists of an input and its expected output.) Your grade will take into account the quality of your test cases! Tip: You will find it useful to add primitives such as + and * to the definition of L to create better test cases. Include these in your test suite.