CLox
is a compiler frontend and virtual machine implementation for running the Lox language, as described in the Crafting Interpreters book. It is written in C and follows the structure laid out in the book.
Warning: This implementation of Lox is intended for educational purposes only and should not be used as a production language. It lacks many features and optimizations necessary for production environments, such as comprehensive error handling, security measures, and performance optimizations.
The following instructions have been tested on macOS. If you encounter issues on other operating systems or machines, please let me know.
- A C compiler (such as
clang
orgcc
) - CMake
- Make
Once you have the necessary dependencies installed, you can compile CLox
using the following command:
make clean cmake
After a successful compilation, the CLox
binary will be located in the ./build/
folder of the cloned repository.
You can run the compiler in two modes: REPL mode and File Compilation mode.
To start an interactive REPL session, run:
./build/CLox
The Lox compiler can also take a file path as input. Currently, it only supports single-file execution and does not yet support modules.
./build/CLox <path-to-file>