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
n
is a number, x
is a
variable, and ...
means zero or more of the previous
parenthesis-balanced item. In the abstract syntax,
formals
is a list of symbols; and
bindings
is a list of two-lists, where the car of
each two list is a symbol and the cadr is an abstract expression.
Use define-record
to
build procedures for constructing abstract syntax.
(unparse (parse e)) = e (parse (unparse A)) = Afor
A
some 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-case
convenient for your unparser.
free-vars
and bound-vars
that 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.