Work through the book chapter by chapter to build a fully working scripting language interpreter in Java or C, with tests to verify your work at each stage.
Use the included test suite to check your own Lox interpreter written in a different language against the reference implementation.
Study the C source code for a real bytecode virtual machine to understand how scripting languages compile and execute programs under the hood.
Building the full book site requires Dart, a C compiler, and Java, running just the interpreter code needs only a C compiler or Java.
Crafting Interpreters is a free online book that walks readers through building two complete programming language interpreters from scratch. The language being built is called Lox, and the book covers it twice: first in Java, producing an interpreter called jlox, and then in C, producing a faster, bytecode-based interpreter called clox. Both full implementations are included in this repository. The book is aimed at people who want to understand how programming languages actually work under the hood. No prior experience with compilers or interpreters is assumed. The author takes readers step by step through lexing, parsing, evaluating expressions, handling variables, functions, closures, and classes, explaining each concept in plain terms before showing the code that implements it. This repository contains not just the finished interpreter code but also the Markdown source for every chapter of the book, along with a custom build system that weaves prose and code together into the final website at craftinginterpreters.com. The build is driven by Dart scripts and a Makefile. Running it locally requires Dart, a C compiler, and Java. There is also a full test suite for both interpreters. The tests can be run against any chapter's version of the code, not only the final build. This lets readers verify that the interpreter is working correctly even midway through the book. The test runner also accepts custom interpreter executables, so anyone who writes their own Lox implementation in another language can use the same tests to check it. If you find a typo or error in the book, you can file a GitHub issue or send a pull request. A community wiki page lists Lox implementations written in other languages by readers who worked through the material.
← munificent on gitmyhub — every repo by this author, as a profile.
Verify against the repo before relying on details.