C311 Spring 1998 Assignment 9: Scheme interpreter in Java

Due Wednesday April 8, 11:59pm


Add booleans and the conditional to our Scheme interpreter written in Java. The following file, Scheme.java, contains an interpreter supporting all the features that we've covered during the course: Compile Scheme.java by issuing the following command:
javac Scheme.java
That will generate several class files. There are two ways to run the interpreter. If you want to evaluate expressions interactively, type java Scheme. That will start the read-eval-print loop much like that of Chez Scheme. To evaluate expressions saved in a file in batch mode, type java Scheme filename. That will execute every expression in the file (provided they don't raise exceptions) and output their results.

Add the following features to the interpreter: #f and #t constants, the if form, and boolean primitives <, >, =, zero?, null?. (The places where to add the code handling primitives are indicated by the /* blank */ fragments.)

Parser code that handles booleans and conditionals is commented out at the moment (so that you can compile and run the interpreter as it is.) This code will provide hints on how to proceed with the assignment. You will have to uncomment it to test your work.

This file contains a couple of test cases for your interpreter test.ss. Try changing the constant in the second procedure from 1000 to 100000 and see what happens. Why?


Submission

As usual. (No automatic grading)