Running the interpreter
To start an interactive Scheme interpreter session, type:
python scheme.py
Currently, your Scheme interpreter can handle a few simple expressions, such as:
scm> 1
1
scm> 42
42
scm> true
#t
To exit the Scheme interpreter, press Ctrl-d
or evaluate the exit
procedure (after completing problems 3 and 4):
scm> (exit)
You can use your Scheme interpreter to evaluate the expressions in an input file by passing the file name as a command-line argument to scheme.py
:
python scheme.py tests.scm
The tests.scm
file contains a long list of sample Scheme expressions and their expected values. Many of these examples are from Chapters 1 and 2 of Structure and Interpretation of Computer Programs, the textbook from which Composing Programs is adapted.