Read Section 3.4 of EOPL for background.
e ::= n (make-Const n) | #t (make-Const #t) | #f (make-Const #f) | () (make-Const ()) | (quote x) (make-Const x) | x (make-Var x) | (if e e e) (make-If test then else) | (lambda (x ...) e) (make-Lam formals body) | (let ((x e) ...) e) (make-Let bindings body) | (let* ((x e) ...) e) (make-Let* bindings body) | (letrec ((x e) ...) e) (make-Letrec bindings body) | (e e ...) (make-Ap fun args)where
nis a number,
xis a variable, and
...means zero or more of the previous parenthesis-balanced item. In the abstract syntax,
formalsis a list of symbols; and
bindingsis a list of two-lists, where the car of each two list is a symbol and the cadr is an abstract expression. Use
define-recordto build procedures for constructing abstract syntax.
(unparse (parse e)) = e (parse (unparse A)) = Afor
Asome abstract expression. (The appropriate notion of equality here is
equal?.) Show with some examples in your test transcript that the functions satisfy these equations! You may find
variant-caseconvenient for your unparser.
bound-varsthat take an abstract expression and yield its sets of free and bound variables respectively. You may use this implementation of sets if you wish. Again, include some examples in your transcript.