C++ port of jlox, a reference tree-walk interpreter for Bob Nystrom's Lox programming language.
loxpp is designed to be interface-compliant with jlox. In addition to standard Lox syntax and semantics, loxpp supports additional features such as:
Lambda expressions commit
loxpp adds support for anonymous/lambda functions, using the following syntax:
lambda (args...) { body }
See examples of lambda usage here.
Multi-line comments commit
C++ (Clang) style non-nested multi-line comments are supported:
/* Multi
* line
* comment 1 */
var x = "Multiline comments!";
/* Il$$3g^l
charac%ers '\ */
print x;
Requirements:
- A C++11 compiler (can be set via the
CC
option in Makefile) - Python, if you wish to run functional tests
Using the provided Makefile:
make # builds the loxpp executable at ./bin
make test # runs functional tests
Using CMake:
CMakeLists.txt
is also provided, but for building the executable only.
./bin/loxpp # enter REPL
./bin/loxpp <file> # run file
The biggest divergence from jlox is when it comes to memory management - jlox relies on the JVM for loose object cleanup, but I haven't gotten around to implementing a garbage collector for loxpp. Other than that, error messages are slightly different, and the native clock
function is not yet implemented.