Programming Languages assignment 3

Due: Monday March 14th

  1. Write an interpreter for F♭ as defined in the book. You need to implement all features except for Let Rec, which is for extra credit only.
  2. Answer the problems in hw3.ml.

The F♭ Development Kit (FbDK)

We have provided you with the FbDK to make your job easier.

Hints

  1. For OcaIDE and Eclipse configuration instructions, see the course OcaIDE page.
  2. Use the F♭ operational semantics rules as the guidepost: all you are doing is implementing those rules.
  3. For a warm-up, get the numbers and booleans to evaluate properly, then tackle functions.
  4. You will need to write several auxiliary functions for performing substitution, etc.
  5. Declare and raise appropriate exceptions.
  6. The file .../src/Fb/fbexamples.ml in the distribution includes many F♭ examples.
  7. You will probably want to write at least three functions:
    1. eval, a stub for which is provided,
    2. subst, a function implementing variable substitution
    3. check_closed, a function which determines whether or not an expression is closed
    Remember that you must raise an exception if you are provided an expression which is not closed, such as Function x -> y.

Submission

For this part of the assignment, submit only the fbinterp.ml file that will "plug in" to the FbDK and build the interpreter and the hw3.ml file containing your F♭ answers. Use Blackboard for submission as usual.