You'll need your copy of EOPL for this lab!!
This lab uses the interpreter used in class so far, covering features discussed in EOPL Sections 3.1 and 3.2. Refer to those sections if you have questions about how the pieces of the interpreter fit together.
Once you catch on, this lab is quite easy. But, please ask us for help if you are confused about what goes where.
You will need to grab a copy of init-interp.scm. Load the file into DrScheme and invoke the interpreter:
(read-eval-print)To try out the interpreter, type the following expressions (one at a time) to the "
-->" prompt:
3 v add1(v) *(add1(6),-(7,sub1(v)))To get out of the interpreter loop, force an error. For example, type
hazzah
For each of the problems below, you will need to modify the definitions of:
the-grammar
apply-primitive
in init-interp.scm. Additionally, in problem 3 you will also have to modify:
init-env
All the other definitions you should leave alone.
Scheme has built in output primitives write, display, and newline, which you will find essential for problem 1.
Also begin is a Scheme primitive that lets you sequence statements.
Examples of all of these procedures appear in the code
for read-eval-print in Figure 3.5 in EOPL.
EOPL 3.5
EOPL 3.6
EOPL 3.7