Free tool

Lox playground

Lox, the language you build in Crafting Interpreters, running in your browser. Pick a chapter and it behaves like jlox at the end of that chapter: tokens at 4, a syntax tree at 6, one expression at 7, then statements, control flow, functions, the resolver, classes and inheritance.

All of jlox: statements, control flow, functions, closures, classes and inheritance.

Output
Run the code to see what it prints.

jlox from Crafting Interpreters by Robert Nystrom, ported to TypeScript (MIT).

Check your own jlox against it

The engine is a TypeScript port of jlox that passes every test in the book's suite for chapters 4 to 13, with the same error messages and exit behavior. When your interpreter and the playground disagree on a program, one of you has a bug, and it is a short program to step through.

Runs on your device; nothing you type is sent anywhere. Long loops stop after 20 million steps or 3 seconds, deep recursion reports a stack overflow.

The chapters