Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/braheezy/gravlax
Interpreter for Lox
https://github.com/braheezy/gravlax
go lox
Last synced: 2 days ago
JSON representation
Interpreter for Lox
- Host: GitHub
- URL: https://github.com/braheezy/gravlax
- Owner: braheezy
- Created: 2024-05-25T01:36:52.000Z (8 months ago)
- Default Branch: main
- Last Pushed: 2024-10-15T05:49:15.000Z (3 months ago)
- Last Synced: 2024-11-10T13:35:25.707Z (2 months ago)
- Topics: go, lox
- Language: Go
- Homepage:
- Size: 38.1 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# gravlax
A Go implementation of an interpreter for the educational Lox programming language as taught in the book [Crafting Interpreters](https://craftinginterpreters.com/).
The second half of the book covers a bytecode VM approach to implementing Lox. I did that in Zig [here](https://github.com/braheezy/zig-lox).
## Usage
You need Go 1.21.9+.Clone the code and get inside the directory:
```bash
git clone https://github.com/braheezy/gravlax
cd gravlax
```Run the REPL (Ctrl+D to exit):
```bash
$ go run main.go
> print("hey there");
hey there
> (ctrl+d)
bye!
```
Or run a file:```bash
$ echo 'print("hey there");' > hello.lox
$ go run main.go hello.lox
hey there
```
## Notes
The tutorial book covers `jlox`, a Java implementation using a tree-walk interpreter approach to executing Lox programs. `gravlax` is the same thing, but in Go.Of note, this implementation:
- supports block comments
- the `break` keyword