Skip to content

simondoebele/scheme-interpreter

Repository files navigation


Scheme Interpreter

A scheme interpreter in Python.
Explore the docs »

Report Bug · Request Feature

REPL (For image credit and a quick introduction to interpreters, see here.)

Table of Contents
  1. About The Project
  2. Getting Started
  3. Contributing

About The Project

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.

(back to top)

Getting Started

Prerequisites

  • Python 3.6
  • Scheme R5RS

Usage

To start an interactive Scheme interpreter session, type:

python3 scheme.py

You could then perform some simple calculations, such as

scm> (* 3 4 (- 5 2) 1)
36

define new functions

scm> (define (square x) (* x x))
square

and much more.

Or use the Scheme interpreter to evaluate the expressions in an input file like so:

python3 scheme.py tests.scm

To exit the Scheme interpreter, press Ctrl-d or evaluate the exit procedure like so:

(exit)

(back to top)

Repository structure

  • 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

(back to top)

Contributing

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!

  1. Fork the Project
  2. Create your Feature Branch (git checkout -b feature/AmazingFeature)
  3. Commit your Changes (git commit -m 'Add some AmazingFeature')
  4. Push to the Branch (git push origin feature/AmazingFeature)
  5. Open a Pull Request

(back to top)

About

A Scheme interpreter written in Python.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors