Out: Wednesday, 30 January 2008
Due: 5 PM Friday, 8 February 2008
Submission: Partners
This assignment is to be done in pairs. If you cannot find a partner, please contact your instructor.
The main goal of this assignment is to give you a simple introduction to environments, abstract syntax trees, and interpreters.
calculate
that
takes one argument exp, which belongs to
the arithmetic-exp
datatype (see below)
but contains no variable references,
and calculates and returns the numerical value of
exp.
value-of
that
takes two arguments exp and env,
where
arithmetic-exp
datatype (see below)parse-prefix-list
. Its one
argument is a Prefix-list as defined
in exercise 2.31, and its result is a
prefix-exp
as defined in exercise
2.31 and in mp3-data-structures.scm
(see below).
Hint:
Observe that every Prefix-list is a
Listof[Prefix-exp],
but not every Listof[Prefix-exp] is a
Prefix-list.
Use a help procedure that takes a nonempty
Listof[Prefix-exp]
as its one argument input and returns two results:
(1) the prefix-exp
t obtained by parsing
the first Prefix-exp in the input, and (2) the
Listof[Prefix-exp] that is left over after
that first Prefix-exp has been
removed from the input.
You are given the following files:
mp3-test.scm
is a woefully incomplete prototype of the
mp3-test.scm
you will modify
and submit as your second deliverable.
mp3-data-structures.scm
defines and provides the prefix-exp
and
arithmetic-exp
datatypes
you will use for tasks 2, 3, and 4 above.
It also defines and provides a parser that
translates a concrete syntax for arithmetic
expressions into the arithmetic-exp
representation of abstract syntax trees.
You should not modify mp3-data-structures.scm
.
drscheme-init.scm
is the usual initialization file required by
mp3-test.scm
.
You should not modify drscheme-init.scm
.
mp3.scm
.
This module should be written in the language
(lib "eopl.ss" "eopl")
, and should
provide the 8 procedures you wrote for tasks 1 through 4.
(You may define help procedures as well, but they
should not be provided.)
mp3-test.scm
.
The module should be written in the language
(lib "eopl.ss" "eopl")
, require
the modules drscheme-init.scm
,
mp3.scm
, and
mp3-data-structures.scm
,
and should test all 8 procedures provided by
mp3.scm
.
Your mp3-test.scm
file should be derived
from the one given you by the course staff (see above).
You will need to add more tests to that file, of course.
mp3-test
module,
in a plain text file named mp3-test-output.txt
.
Last modified: 3 February 2008