https://github.com/braheezy/zig-lox
Bytecode VM for Lox
https://github.com/braheezy/zig-lox
lox zig
Last synced: about 1 year ago
JSON representation
Bytecode VM for Lox
- Host: GitHub
- URL: https://github.com/braheezy/zig-lox
- Owner: braheezy
- Created: 2024-10-21T04:52:36.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2024-11-18T02:43:10.000Z (over 1 year ago)
- Last Synced: 2025-02-07T13:54:10.069Z (over 1 year ago)
- Topics: lox, zig
- Language: Zig
- Homepage:
- Size: 102 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# zig-lox
A Zig implementation of a bytecode VM for the educational Lox programming language as taught in the book [Crafting Interpreters](https://craftinginterpreters.com).
The first half of the book covers a purely interpreted approach to implementing Lox. I did that in Go [here](https://github.com/braheezy/gravlax).
```console
> echo 'print 1 + 1;' | zig-lox --eval
2
```
## Usage
You need Zig. The `.devcontainer` can be used to easily provide that.
Helpful commands:
```bash
# 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
```