A scheme interpreter in Python.
Explore the docs »
Report Bug
·
Request Feature
(For image credit and a quick introduction to interpreters, see here.)
Table of Contents
This is a interpreter for a subset of the Scheme language in Python. It was a project as part of the course CS61A at the University of California, Berkeley. The overarching purpose of the project was to learn about the idea of abstraction.
- Python 3.6
- Scheme R5RS
To start an interactive Scheme interpreter session, type:
python3 scheme.pyYou could then perform some simple calculations, such as
scm> (* 3 4 (- 5 2) 1)
36define new functions
scm> (define (square x) (* x x))
squareand much more.
Or use the Scheme interpreter to evaluate the expressions in an input file like so:
python3 scheme.py tests.scmTo exit the Scheme interpreter, press Ctrl-d or evaluate the exit procedure like so:
(exit)- buffer.py: implements the Buffer class, used in scheme_reader.py; it assists in iterating through lines and tokens.
- questions.scm: contains some helper functions written in scheme
- scheme.py: implements the REPL (Read-Eval-Print-Loop) and evaluates Scheme expressions
- scheme_primitives.py: implements the primitives of the Scheme language
- scheme_reader.py: implements the reader for Scheme input
- scheme_tokens.py: implements the tokenizer for Scheme input
- tests.scm: a collection of test cases written in Scheme
- ucb.py: utility functions
- tests: a directory of tests written in Python
If you have a suggestion that would make this better, please fork the repo and create a pull request. You can also simply open an issue with the tag "enhancement". Don't forget to give the project a star! Thanks again!
- Fork the Project
- Create your Feature Branch (
git checkout -b feature/AmazingFeature) - Commit your Changes (
git commit -m 'Add some AmazingFeature') - Push to the Branch (
git push origin feature/AmazingFeature) - Open a Pull Request