Assignment 5

Fall 2011

A Lexical-Address Calculator, Part 2

Assigned: Tue, Nov 22
Due: Thu, Dec 1

Description

The original assignment 4 was split into two: this assignment includes both pair/unpair and letrec

For this problem, you will extend the lexical-address calculator discussed in lecture 4, and which may be copied (and renamed) under your CS account from the command prompt as follows:

$ cp -r /home/cs235/interps/lecture04/lexaddr-lang ./
$ mv lexaddr-lang/ assign4/

Each problem is worth 5 points.

  1. Extend your system to handle “pair” and “unpair” from Assignment 3.
  2. Extend your system to handle letrec (Exercise 3.40). You will have to add both letrec-exp and nameless-letrec-exp. You will have to write something like extend-nameless-env-recursively, and in this procedure you may use the same kinds of Scheme primitives that were used for this in the lecture notes.
    Here’s the full statement of Exercise 3.40 from the text:
    Exercise 3.40 [**] Extend the lexical address translator and interpreter to handle 
    letrec. Do this by modifying the context argument to translation-of so that 
    it keeps track of not only the name of each bound variable, but also whether it was 
    bound by letrec or not. For a reference to a variable that was bound by a letrec, 
    generate a new kind of reference, called a nameless-letrec-var-exp. You can 
    then continue to use the nameless environment representation above, and the 
    interpreter can do the right thing with a nameless-letrec-var-exp.



As in the notes, the output of your translator should be a program with no identifiers in it, and your interpreter should be able to evaluate the output of your translator.

Test your solution by running it on the tests in tests.scm, plus the tests you added for “pair” and “unpair”, as well as the “letrec” tests from Assignment 3.

Turn in a single package with all of your new specification rules, your extensions, and your tests.

Electronic submission:

  • submit your assignment electronically via the submit235 script
  • do not print out your assignment (save the trees!)
courses/cs235-201103/assigns/assign5.txt · Last modified: 2011/11/26 17:16 by mlsmith
VCCS Top Events Extended Site Search Login Vassar Science Web Vassar Home Driven by DokuWiki Valid XHTML 1.0