Kotlin implementation of https://craftinginterpreters.com
The part 3 (building a compiler and a vm) can be found here
The project can be loaded with IntellIJ and run from the IDE. But it also has maven configured so you can run it without any IDE with the following commands.
mvn package
This includes unit tests and Ktlint test for style checking
mvn verify
./lox [filename]
- Unlike the original code, this one does not use the visitor pattern. Instead,
this code implements a "pattern matching"-like approach using
when
statements and sealed classes. As result, the code makes a linear search across all the subtypes of Expr (instead of the constant indirection in the visitor pattern), but removes a lot of boilerplate and code generation.