A Lisp interpreter
Tokenizer, parser, evaluator and closures. Discover how a language runs your code, step by step.
Python · JavaScript · TypeScript
Your first contact with lexers and grammars. Tokenize, build the tree and fail with useful errors.
Build it in your language
The tester treats your program as a black box: any language works. These are just the most convenient ones for this project.
JSON is the most boring format in the world, and that's exactly why it's the best place to learn to write parsers: its grammar fits on a napkin, yet it contains every idea you'll reuse later on real languages.
You'll build the parser in the two classic steps — tokenize, then assemble the tree — and finish it off with what separates an exercise from a usable tool: error messages that say what broke and on which line.
7 stages across 3 phases. Every stage comes with its guide and its tests: you move on when they pass.
Walk the input character by character and emit tokens: braces, commas, literals.
A recursive descent parser for objects, arrays and nested values.
Unicode escapes, scientific notation, and errors with line and column.
Tokenizer, parser, evaluator and closures. Discover how a language runs your code, step by step.
Python · JavaScript · TypeScript
From the expression to the automaton. Backtracking, groups and character classes without your language's regex.
TypeScript · Python · Rust
From source code to runnable bytecode. Lexing, AST, semantic analysis, code generation and a VM that runs it.
Rust · C++ · TypeScript