1. Racket Interpreter

An interpreter written for Racket, more specifically the student languages which are (almost) a subset of the language. These student languages are what first-semester, computer-science students at Northeastern learn to program in. The end goal of this project is to successfully interpret the code I wrote for a homework assignment regarding graphs.

build status codecov PyPI version license version


1.1. Getting Started

There is no IDE nor does the interpreter read from a text file… yet. That being said, here are the steps to set up and get the interpreter running.

1.1.1. Prerequisites

The only prerequisite is to have Python 3.8+. The tests are only run on Python 3.8, but there is no reason to believe that they would not pass on more recent versions.

1.1.2. Installing

The package can be installed using pip.

$ pip install racketinterpreter

Try interpreting some Racket code

$ python
>>> import racketinterpreter
>>> result = racketinterpreter.interpret('(define x 1) x')
>>> print(result.output)
['1']

1.2. Contributing

1.2.1. Downloading

Clone the repository locally.

$ git clone https://github.com/ZibingZhang/racket-interpreter.git

There is an example of the interpreter in the example.py file which can be run.

$ python example.py

To change the code that is being interpreted, change the value of code.

1.2.2. Generating the Documentation

These are the steps to transpile the documentation to an easily readable HTML format.

$ pip install -u sphinx
$ pip install -u sphinx-rtd-theme
$ sphinx-apidoc -eo apidoc/ racketinterpreter/ --templatedir docs/templates
$ make html

The homepage for the documentation can be found at _build/html/index.html.

If the documention needs to be regenerated for any reason, some directories need to be deleted first.

$ rm -r _build
$ rm -r apidoc
$ sphinx-apidoc -eo apidoc/ racketinterpreter/ --templatedir docs/templates
$ make html

1.2.3. Running the Example

There is an example of using the interpreter in example.py which can be run with the following command.

$ python example.py

1.2.4. Testing

At the moment there are only unit tests.

All the tests can be run at once,

$ python -m unittest

or file by file.

$ python -m unittest tests/test_errors.py

1.3. Licence

This project is licensed under the MIT license.


1.4. Acknowledgments

This initially started as an adaptation of Ruslan Spivak’s tutorial for writing an interpreter. Most of the structure of this codebase come from the tutorial, but as I’ve begun to understand his design decisions better I’ve been able to change and adapt them to fit this project. This template has also been helpful in understanding how to format a README and what I should include.