This is my Java 17 implementation of Lox - a small programming language for scripting - from the book Crafting Interpreters.
One big difference between the
reference implementation of jlox
and this one is, whereas the reference implementation generates the Expr
and Stmt
classes by concatenating strings together, this implementation uses
JavaPoet, a Java library for generating Java
source files in a more type-safe way.
- Install a distribution of Java 17. One way to do this is:
- Install asdf-vm.
- Run
asdf plugin add java
. - Now, when you "cd" into this directory and run
asdf install
, runningjava
will use the asdf-managed version specified in.tool-versions
.
- Setup your favourite IDE or text editor to use this distribution of Java 17.
./gradlew build
java -jar lox/build/libs/lox-0.1.0-SNAPSHOT.jar
Alternatively, run the Java file com.craftinginterpreters.lox.Lox
in your IDE of
choice.
java -jar lox/build/libs/lox-0.1.0-SNAPSHOT.jar <path-to-lox-program>