Essentials of Programming Languages (EOPL): Sections 3.1 and 3.2.
You may work singly or in pairs on this assignment.
Be sure you mark (via comments) each change you make
to the LET interpreter files.
(See the Homework Policy
for more details.)
A copy of the source code of each file modified.
DO NOT turn in the source code from files you did not modify.
A run of your code that verifies that it passes all the tests in your test harness.
If you have more than one file to submit, bundle them into a zip or tar archive.
Click on
this
electronic-submission link,
and use your NetID and password for authorization.
Important: Make sure you select CIS 352 as the course
for which you're submitting.
For the following, build on the extensions you did for Lab 5.
(25 points) EOPL Exercise 3.9
(25 points) EOPL Exercise 3.10
(25 points) EOPL Exercise 3.16
(25 points) EOPL Exercise 3.17
Handy trick: Suppose you have an
environment, env, and a list of
expressions, args =
(e1 e2 … ek)
and you want to compute a list of values of the form:
((value-of e1 env) (value-of e2 env) …
(value-of ek env))
Then try:
(map (lambda (e) (value-of e env)) args)
To handle list values, I have updated
⇓ Use these updated files for this homework!!! ⇓
expval
now includes emptylist-val and
pair-val cases.
expval->car and
expval->cdr respectively extract
the car and cdr fields from a pair-val.
init-env now
includes emptylist which is
set to (emptylist-val).
extend-env*
is now included — this will be very handy
for one of the problems.
sloppy->expval
(a procedure used by run-all)
now handles the list-values.
⇑ Use these updated files for this homework!!! ⇑
Use drscheme-init.scm, interp.scm, lang.scm, and tests.scm from the previous homework.
You will have to add productions to the-grammar
for: car, cdr, null?,
cons, list, and let*.
You will also have to add cases for each of these
in value-of
Also, for the revision of let, you
will have to change its production in the-grammar
and its case in value-of.
list:
list production
for the-grammar.
(See page 389 in EOPL for an explaination of
what separated-list does.)
(expression ;; Hw 5, exercise 3.10
("list" "(" (separated-list expression ",") ")")
list-exp)
list-exp case for
value-of:
;; Homework 5, exercise 3.10 (list-exp (args) … )
let:
let production
for the-grammar,
which is similar to the production for code in
Homework 4.
(expression ;; Addition for Homework 5
("let" (arbno identifier "=" expression) "in" expression)
let-exp)
let-exp case for
value-of:
;; HW 5, Exercise 3.17 (let-exp (vars exps body) … )
Be sure to include the following tests. (Yes, you need more tests than these.)
(list-1 "list()" () ) (list-2 "list(1,2,3,4)" (1 2 3 4) ) (list-3 "list(1,list(2,3,list(4)),5)" (1 (2 3 (4)) 5) ) (multi-let-1 "let in 17" 17 ) (multi-let-2 "let x = 30 in let x = -(x,1) y = -(x,2) in -(x,y)" 1 ) (multi-let*-1 "let* in 17" 17 ) (multi-let*-2 "let x = 30 in let* x = -(x,1) y = -(x,2) in -(x,y)" 2 ) ;; My first version of multi-let*-2 had a typo