Skip to content

pin3da/CraftingInterpreters

Repository files navigation

CraftingInterpreters

actions status

Kotlin implementation of https://craftinginterpreters.com

The part 3 (building a compiler and a vm) can be found here

Compiling, testing and runing

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.

Compile

mvn package

Test

This includes unit tests and Ktlint test for style checking

mvn verify

Run

./lox [filename]

Notes

  • 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.