strtok/marwood

An embeddable Scheme R7 Compiler & Runtime written in Rust

Rust

109

702 commits

updated Apr 28, 2026

See the code

README

λ Marwood   License Badge Test Badge Deploy Badge

Marwood is an embeddable Scheme R7RS implementation, featuring:

And these scheme language features:

  • most R7RS language and library features
  • Tail call optimization
  • First class continuations (call/cc)
  • Support for scheme's numerical tower, including rationals
  • Partial support for syntax-rules

Example

The adder example creates a procedure called make-adder, which given an argument x returns a procedure that adds its own argument y to x.

This example may be executed with cargo run --example adder.

Here's the scheme that will execute in the VM given the rust example:

(define make-adder 
    (lambda (x) 
        (lambda (y) (+ x y))))
(define add-1000 
    (make-adder 1000))
    
(add-1000 0)
(add-1000 1)
(add-1000 2)
(add-1000 3)
(add-1000 4)

And the rust code to execute the scheme above in marwood:

let mut vm = Vm::new();

vm.eval_text("(define make-adder (lambda (x) (lambda (y) (+ x y))))")
    .unwrap();
vm.eval_text("(define add-1000 (make-adder 1000))")
    .unwrap();

for it in 0..5 {
    match vm.eval(&list!["add-1000", it]) {
        Ok(result) => {
            println!("{} => {}", it, result);
            assert_eq!(result, cell![1000 + it])
        }
        Err(e) => error!("error: {}", e),
    }
}

License

Licensed under either of Apache License, Version 2.0 or MIT license.

compiler
interpreter
lisp
rust
scheme
scheme-compiler
scheme-evaluator
wasm

Contributors

strtok

696 commits

absurdhero

5 commits

strtok/marwood

An embeddable Scheme R7 Compiler & Runtime written in Rust

Rust

109

702 commits

updated Apr 28, 2026

See the code

README

λ Marwood   License Badge Test Badge Deploy Badge

Marwood is an embeddable Scheme R7RS implementation, featuring:

And these scheme language features:

  • most R7RS language and library features
  • Tail call optimization
  • First class continuations (call/cc)
  • Support for scheme's numerical tower, including rationals
  • Partial support for syntax-rules

Example

The adder example creates a procedure called make-adder, which given an argument x returns a procedure that adds its own argument y to x.

This example may be executed with cargo run --example adder.

Here's the scheme that will execute in the VM given the rust example:

(define make-adder 
    (lambda (x) 
        (lambda (y) (+ x y))))
(define add-1000 
    (make-adder 1000))
    
(add-1000 0)
(add-1000 1)
(add-1000 2)
(add-1000 3)
(add-1000 4)

And the rust code to execute the scheme above in marwood:

let mut vm = Vm::new();

vm.eval_text("(define make-adder (lambda (x) (lambda (y) (+ x y))))")
    .unwrap();
vm.eval_text("(define add-1000 (make-adder 1000))")
    .unwrap();

for it in 0..5 {
    match vm.eval(&list!["add-1000", it]) {
        Ok(result) => {
            println!("{} => {}", it, result);
            assert_eq!(result, cell![1000 + it])
        }
        Err(e) => error!("error: {}", e),
    }
}

License

Licensed under either of Apache License, Version 2.0 or MIT license.

compiler
interpreter
lisp
rust
scheme
scheme-compiler
scheme-evaluator
wasm

Contributors

strtok

696 commits

absurdhero

5 commits

Languages

Rust

95.2%

JavaScript

3.4%

Scheme

1.3%