/lisp-rs

Primary LanguageRustMIT LicenseMIT

lisp-rs

A simple Lisp interpreter/library in Rust. The interpreter/library was initially developed as a teaching aid to explain how Lisp interpreters work and how can they be implemented using the Rust programming language. However the interpreter seems to be taking life of it's own and has been ported to the web using WASM. The interpreter is available as a crate and can be used to embed a Lisp interpreter in your Rust projects. The WASM implementation uses the lisp-rs as a library to implement the online interpreter.

Dialect

The interpreter is based on a modified subset of Scheme. Following are the features supported by the interpreter

  • Variables and Constants
  • Functions (lambdas)
  • Functional constructs such as map, filter and reduce
  • Closures
  • Tail Call Optimization

More information about the dialect can be found at

Implementation

The interpreter has been implemented in three phases

  • Phase I: Complete interpreter and REPL implementation with support for basic data types (integers and boolean), variables, lambdas, and lambda calls (branch 0.0.1)
  • Phase II: Support for advanced data types (string, float, and lists) and functional constructs (branch 0.0.2)
  • Phase III: Support for tail call optimization (branch 0.0.3) and closures (branch 0.0.4)

For a detailed code-walkthrough about Phase-I implementation refer to the docs. For code-walkthrough of all the phases, get the e-book.

asciicast

REPL

cargo run --features="build-binary"

Test

cargo test

WASM

The interpreter has also been compiled to WASM so that it can run in a browser and is hosted here.