Submit: Turn in your
hw3.scm
source file using the turnin command
on morbius.mscsnet.mu.edu or one of the
other Systems
Lab machines.
Work is to be completed in teams of two. Be certain to include both teammates names in the file. You may submit multiple times, but only the last turnin will be kept. The automatic submission system will not accept work after the deadline.
Include a comment block at the very top of each file that contains the following:
; COSC 3410 - Project [#]
; Explain briefly the functionality of the program.
; @authors [your names]
; Instructor [your instructor]
; TA-BOT:MAILTO [your email addresses]
Your source file should be in the EoPL dialect ("#lang eopl" at top of file) supported by DrRacket, and should not make use of non-standard features like comment boxes that produce an XML file rather than a flat text .scm file.
At the bottom of your hw3.scm
, please include the line:
(provide parse-expression unparse-lc-exp occurs-free? occurs-bound?)
Build a parser that converts λ-calculus expressions from the grammar given in EoPL Exercises 2.29 into abstract syntax trees. You may start with the define-datatype given on EoPL p.46, and modify it to account for λ expressions with multiple parameters. The parse-expression function on EoPL p.53 is an excellent starting point.
parse-expression : SchemeVal → LcExpDefine a function "unparse-lc-exp", ala EoPL Exercise 2.28, which takes an abstract syntax tree from your parse-expression function above and returns a Scheme value for the original concrete syntax.
unparse-lc-exp : LcExp → SchemeVal
Note that unparse-lc-exp performs the inverse operation
of parse-expression. For any well-formed
λ-calculus expression "e", (unparse-lc-exp
(parse-expression e))
should return e.
The code for unparse-lc-exp on EoPL p.53 is an excellent starting point for this problem.
EoPL Exercises 2.23 and 2.30. Add code to your parse-expression implementation to make it more robust against ill-formed input. Generally speaking, your implementation should not crash and should print an appropriate error message no matter what kind of expression it is asked to parse.
Adapt the code for occurs-free? on EoPL p.46 to work with the expanded grammar from EoPL 2.29.
occurs-free? : Sym x LcExp → BoolBuild a new function occurs-bound?.
occurs-bound? : Sym x LcExp → BoolNote that occurs-bound? is not simply the opposite of occurs-free?. It is possible for both functions to return false for a given expression (the variable does not occur at all,) and it is also possible for both functions to return true for a given expression (a variable occurs both free and bound in different places.)
[Revised 2021 Feb 05 11:32 DWB]