Implementation of the Lox language VM interpreter from Crafting Interpreters in the C3 language. Nearly a direct port from the book that uses a few features from C3.
You'll need to install the C3 compiler as well as its prerequisites for your environment and ensure its on your path.
The default build is the optimized build without debug information.
$ c3c build
This produces the lox
interpreter executable under the build
directory.
To produce a debug build.
$ c3c build loxd
This produces the enables debug information as well as debug feature flags
DEBUG_PRINT_CODE
and DEBUG_TRACE_EXECUTION
enabled. These assist in debugging the VM instructions during execution and are implemented in the book. There are also feature flags DEBUG_LOG_GC
and DEBUG_STRESS_GC
to debug the garbage collector from the book available that can be added in the project.json
file used by the C3 compiler.
Pass a lox file to the executable.
$ ./build/lox test.lox
or enter REPL mode by executing without any arguments.
$ ./build/lox
To leave the REPL type exit
./build/lox
> exit
There are example files located in the examples directory that you can use to get started.
This project is licensed under the Unlicense - see the LICENSE file for details