A Zig implementation of a bytecode VM for the educational Lox programming language as taught in the book Crafting Interpreters.
The first half of the book covers a purely interpreted approach to implementing Lox. I did that in Go here.
> echo 'print 1 + 1;' | zig-lox --eval
2
You need Zig. The .devcontainer
can be used to easily provide that.
Helpful commands:
# Build an executable: zig-out/bin/zig-lox
zig build --summary all
# Run all tests
zig build test --summary all
# Run a file
zig-out/bin/zig-lox test.lox
# Or run the repl
zig-out/bin/zig-lox
# Or eval an expression over stdin
echo '1 + 1' | zig-out/bin/zig-lox --eval