This is a Typescript implementation of the Lox language tree-walking interpreter from Bob Nystrom's book Crafting Interpreters. I wrote this implementation while following along with the book mainly because the overhead of translating to TS made me pay a bit more attention to the examples rather than just copy and pasting the Java source. Because I wrote this while following along with the book, it isn't the most idiomatic typescript I've ever written. One major key difference between this implementation and jlox is the AST. I used tagged unions and POJOs rather than using code generation to make a visitor which makes walking the AST a bit cleaner.
git clone [email protected]:SawyerHood/lox-typescript.git
cd lox-typescript
yarn
# You can use `yarn start ${filename}` to run a file
# yarn start opens the repl
yarn start
fun addPair(a, b) {
return a + b;
}
fun identity(a) {
return a;
}
print identity(addPair)(1, 2); // Prints "3".