~sgeisenh/craftinginterpreters

Implementations of the Lox programming language

refs

main
browse  log 

clone

read-only
https://git.sr.ht/~sgeisenh/craftinginterpreters
read/write
git@git.sr.ht:~sgeisenh/craftinginterpreters

You can also use your local clone with git send-email.

A handful of implementations of Lox with varying levels of completeness and compliance.

#SMLox

A mostly finished implementation of a treewalk interpreter in Standard ML.

I used this to revisit Standard ML after several years. It's a wonderful language for this sort of work: it is wonderfully expressive with a fairly minimal set of features. There are some quality of life features missing, but the good stuff is all there.

Best of all, mlkit includes SMLtoJs which can be used to compile Standard ML to JavaScript. With a few adjustments, SMLox runs in the browser!

#cpplox

A complete implementation of a bytecode interpreter in C++.

I wanted to follow along with the book but I didn't want to copy the code verbatim. I tried to convert the book's implementation to modern C++ where possible, though it proved to be challenging since many of the later chapters rely on implementations from earlier chapters.

This was still a great experience and it was enjoyable to get my hands dirty with some low-level C++.

#IronLox

The start of a treewalk interpreter in Rust.

I used this to start learning Rust. I haven't touched this in a while, but it should be straightforward to continue on from where I left off.

I really want to explore alternative memory-management styles with this. In particular, using an arena should enable better performance than JLox and enums tend to be a better fit than visitors for writing language implementations.

At some point, it would be fun to use the lexer and parser from IronLox to create a multi-pass bytecode interpreter.