Working on a Scheme interpreter written in Rust

I am working on a Scheme interpreter written in Rust, which you can find here.

It is very incomplete, and doesn't even compile yet. Pretty much all I can say is that the GC works (according to one test case).

Nevertheless, I would love suggestions and/or contributions from anyone who can help.

Here is the plan so far:

  • Bytecode compiler and VM.
  • Compiler written in Scheme (except for the reader) – this allows it to manipulate Scheme source (which is just Scheme data structures) easily, and allows me to use a macro expander written by somebody else (which is written in Scheme). Already started, but very incomplete.
  • VM is accumulator-based: instructions can reference any of the top 256 elements of the stack, but mostly push their result on the stack. Again, the VM is very incomplete.
  • Reader: non-recursive (like the rest of the VM). Written in Rust. Skeleton already written.
  • Embedding API: not yet started, but the plan is for Rust code to create interpreter instances, manipulate Scheme objects, store Rust data structures as Scheme objects, and both provide and call Scheme functions, all in safe code. This will also be how Scheme code can access the outside world.

I absolutely :heart: interpreters! Have written a small self interpreter this weekend: GitHub - matklad/s :slight_smile:

Do you have any suggestions for how to go about finishing my project? Specifically, any thoughts on what the interpreter I am writing would need to have to be practically useful for actual projects?

No, I have not implemented anything production quality myself. I would suggest to talk to Piston folks, they have their own scripting language, but a lisp might be a nice alternative.

1 Like