#scripting #dsl


Building blocks for DSL scripting language interpreters that interact with native Rust code

1 unstable release

0.1.0 Mar 13, 2020

#2382 in Rust patterns

MIT license



Documentation crates.io build

Lightweight building blocks for implementing interpreters in Rust. Ideally for DSL use-cases.

Exmaple Languages

  • tinylang: A tiny language with S-exp syntax. It basically only implements lambda without even primitive types like bools, ints, or lists. Note those types can be built using lambda.
  • minilang: Extends tinylang with a richer standard library and types. Run cd examples/minilang-repl; cargo run to try it in an REPL.


  • Simple. The code should be simple to reason about.
  • Powerful. Use simple concepts to express powerful features. For example, lambda can be easily implemented and it is pretty powerful.
  • Easy-to-use.
    • Sharing data and functions between Rust and the DSL is easy and safe.
    • The DSL can easily opt-in a garbage colletor to make memory management easier.
  • Flexible. Things like syntax, AST internal representation, standard library functions, types, how to resolve a name, what is a function, and how to call a function, are all customizable.
  • Rust. This library is written in Rust and solves Rust problems. Not intened to be used in other languages via FFI.


  • Performance. Performance is a best-effort within the simplicity constraint. Practically, performance-critical code should be in native Rust.
  • Features. Feature-complete is not a goal, especially when it conflicts with simplicity.
    • Stackless. The Rust language natively uses the native stack when calling a function. Therefore a stackless is not simple in Rust. This means things like co-routine and call/cc are not out-of-box.
    • Multi-Thread. Right now it's not a goal because the gc library does not support it.


~13K SLoC