Giter Site home page Giter Site logo

rusty_scheme's Introduction

RustyScheme

A toy Scheme interpreter written in Rust, loosely based on the R5RS Specification with a bit of Racket thrown in as well.

It supports a small number of standard library functions, as well as:

  • Function and variable definition
  • Quote, Quasiquote/unquote
  • Apply & Eval
  • Macros (not hygenic yet)
  • Let expressions
  • Tail-call optimization
  • Continuations, Call-with-current-continuation
  • Unicode
  • REPL, with history

There are two versions of the interpreter:

  • A straight-forward AST-walking interpreter, which uses the Rust stack and heap, and uses vectors to represent Scheme lists.
  • A continuation-passing style interpreter, which supports tail-call optimization and continuations, uses the Rust stack and heap, and uses a linked list to represent Scheme lists.

In the future, I may develop an interpreter that manages its own stack and/or heap, and possibly a bytecode VM & compiler as well for comparison.

Requirements

  • Rust 1.0-beta or later

Usage

Download and install Rust 1.0 from http://www.rust-lang.org/install.html.

To start a REPL using the default CPS interpreter:

cargo run

To execute a Scheme file using the default CPS interpreter:

cargo run examples/printing.scm

To start a REPL using the AST-walking interpreter:

cargo run -- -t ast_walk

To execute a Scheme file using the AST-walking interpreter:

cargo run -- -t ast_walk examples/printing.scm

To run the test suite:

cargo test

To watch for changes and auto-rebuild (on OS X):

gem install kicker -s http://gemcutter.org
./watch

rusty_scheme's People

Contributors

cjcole avatar kenpratt avatar shannonsands avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

rusty_scheme's Issues

getopts complier error

this is an error in getopts library, not rusty_scheme, but it breaks this build so...

After:

git clone https://github.com/kenpratt/rusty_scheme.git
cd rusty_scheme
cargo run

This is the error I get ...

$ cargo run
   Compiling getopts v0.2.11
error[E0503]: cannot use `state` because it was mutably borrowed
   --> /home/sean/.cargo/registry/src/github.com-1ecc6299db9ec823/getopts-0.2.11/src/lib.rs:974:33
    |
921 |     let mut machine = |cont: &mut bool, (i, c): (usize, char)| {
    |                       ---------------------------------------- borrow of `state` occurs here
...
925 |         state = match (state, whitespace, limit) {
    |         ----- borrow occurs due to use of `state` in closure
...
974 |     while cont && match state { B | C => true, A => false } {
    |                                 ^ use of borrowed `state`
975 |         machine(&mut cont, (fake_i, ' '));
    |         ------- borrow later used here

For more information about this error, try `rustc --explain E0503`.
error: could not compile `getopts` due to previous error

License?

I'm using your interpreter as "inspiration" for some stuff I'm doing. It'd be great if you could attach a license to it.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.