Schython

You've seen how to implement a Scheme interpreter in Lesson 11 (mceval.scm). For this project, you will be helping us construct a Python interpreter called Schython (Scheme + Python = Schython).

To get the necessary project files and the spec, type the following into your interpreter:

cp -r ~cs61as/lib/schython/ .

You may replace the . with whichever directory you want to save your project in.

Project Files

Here's a breakdown of the files contained inside of schython/:

File Name Purpose
1.schython.text This is the spec for your Schython project.
2.start.scm The file that will load the files needed to test your code. Make sure it is in the same directory as the rest of your Schython files.
3.obj.scm The code for our object-oriented system. OOP is used to create and manipulate the line-object class in parser.scm. Do NOT make changes to this file.
4.parser.scm The parser for our Schython interpreter. This file breaks down lines of input into Python characters recognizable by the Scheme interpreter. You should edit this file.
5.py-meta.scm This file is responsible for evaluating parsed Python code from our parser.scm. You should edit this file.
6.py-primitives.scm This file contains all the Scheme representations of Python data types. You should edit this file.
7.primitives.py A file containing a list of Python functions. Do NOT make changes to this file.
8.memoize.py The file for your answer to Question 9. You should edit this file.
9.tests A directory containing some tests that you can run to test your code. They are taken from the examples in schython.text. Instructions on how to run these tests can be found in the README file in this directory. Your grades will be determined by how many of these test cases you pass.

To load the project, type the following into your interpreter:

(load "start.scm")

Scoring

Each partner will work on nine problems. Five of these (Questions 1, 2, 6, 8, and 9) are common to both partners; the others (Questions 3, 4, 5, and 7) should be completed separately.

Groups will hand in a single completed copy of the project, with one answer for each question. Partners will receive the same score for the common exercises and different scores for the separate questions.

There will be points (indicated in schython.text) where partners should combine their work. This is necessary in order to move on to the next sections of the project.

If you cannot find a partner and/or wish to work alone, please talk to a TA.

More About Python

Python is a modern and very popular language used for teaching introductory CS courses, and is the language used in CS 61A. We will go over the basics of the Python language necessary to write the Schython interpreter in the spec. But, if you are interested (this is not at all required for this project), you can take a look at Python's documentation for a more comprehensive breakdown of the language.

Project 4 - Python Interpreter