Skip to content

braheezy/gravlax

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

23 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

gravlax

A Go implementation of an interpreter for the educational Lox programming language as taught in the book Crafting Interpreters.

The second half of the book covers a bytecode VM approach to implementing Lox. I did that in Zig here.

Usage

You need Go 1.21.9+.

Clone the code and get inside the directory:

git clone https://github.com/braheezy/gravlax
cd gravlax

Run the REPL (Ctrl+D to exit):

$ go run main.go
> print("hey there");
hey there
> (ctrl+d)
bye!

Or run a file:

$ 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

About

Interpreter for Lox

Topics

Resources

Stars

Watchers

Forks

Languages