CS 1102: Labs 5 and 6
Implementing Scheme


Lab Motivation and Goals

This lab is designed to show you how the techniques that we've been learning to implement application-specific languages also apply to implementing large, mainstream languages. To demonstrate this, over the next two labs we will implement a subset of Scheme.

At first, this assignment seems strange: why would we write a Scheme program to implement Scheme? The goal is to show you that our techniques for writing data definitions and interpreters let you implement ANY large language; on those grounds, we could in theory (but won't) write a Scheme program to implement Java. Similarly, you could write the interpreter in any language you choose. So the skills you practice here would let you implement Perl in Java, or Python in Scheme, or Java in COBOL (assuming you could find a reason to do the latter ...).

The way to think about this lab is to recall the set of concerns we've asked about with each new language design: what's the data, what are the operators? How do we create data definitions for each? How do we implement an interpreter that evaluates the operators? Think about these same questions as you work through the exercises.

NOTE: Those of you who are stopping with the languages material will continue to work on lab 5 next week for lab 6. Keep a copy of your work from lab 5 where you can access it for next week. Those of you who are continuing with new material will have the option of continuing this lab or getting practice with the new material we will be doing next week.


Exercises: Implementing Arithmetic

Work through the exercises on Evaluating Scheme in HTDP.

Everyone should be able to finish up through exercise 14.4.3 by the end of lab 5.

If you are doing well, you will be able to finish up through exercise 14.4.4 by the end of lab 5.

Exercises: Adding Functions

Work through the exercises on Evaluating Scheme, Part 2 in HTDP.

Everyone should be able to finish up through exercise 17.7.2 by the end of lab 6.

If you are doing well, you will be able to finish up through 17.7.3 by the end of lab 6.

If you are extremely well, you will be able to finish up through 17.7.4 by the end of lab 6.

Extra Exercises

Most of you won't get this far in the two weeks. If you do, however, here are some extensions you can consider making to your interpreter.