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.
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
- Chapter 4: Scanning ·
chap04_scanning - Chapter 6: Parsing Expressions ·
chap06_parsing - Chapter 7: Evaluating Expressions ·
chap07_evaluating - Chapter 8: Statements and State ·
chap08_statements - Chapter 9: Control Flow ·
chap09_control - Chapter 10: Functions ·
chap10_functions - Chapter 11: Resolving and Binding ·
chap11_resolving - Chapter 12: Classes ·
chap12_classes - Chapter 13: Inheritance ·
chap13_inheritance