Recursive descent
Turn tokens into answers with a recursive descent parser: one function per rule of a grammar, precedence that falls out of which function calls which, brackets, unary minus and the remainder operator.
Open it in the simulatorWrite Orbit, a small language for a mission control panel, in Python on a Raspberry Pi: tokenizer, recursive descent parser, AST, evaluator, scope, functions and real error messages, ending in a REPL that lights real lamps.
0 of 8 done
8 lessons in 4 chapters, about 6 hours on a simulated Raspberry Pi 4 Model B. Free, in your browser, every step checked by the simulator.
Turn tokens into answers with a recursive descent parser: one function per rule of a grammar, precedence that falls out of which function calls which, brackets, unary minus and the remainder operator.
Open it in the simulatorOrbit grows statements: a program is a list of statement nodes, and a run loop carries each one out, printing, switching real lamps on the Pi and waiting, until a launch sequence written in your own language counts down on the panel.
Open it in the simulatordef, calls and return in your own language: functions as values in the environment, return as an exception that unwinds the interpreter, the difference between lexical and dynamic scope proved on one program, and recursion with if.
Open it in the simulatorFinish Orbit 1.0: a read-eval-print loop on the Serial Monitor that remembers between lines, reads multi-line blocks, survives errors and Ctrl-C, has built-in math, and flies a launch sequence on the Pi's lamps typed live.
Open it in the simulatorEach lesson opens when the one before it is done, and each chapter ends in a project.
Text into tokens, tokens into answers: the front end of every language.
Start Orbit, a language for a mission control panel: a tokenizer that turns text into numbers, names, strings and symbols, one character at a time, the first stage of every compiler and interpreter there is.
0 of 5 steps
Turn tokens into answers with a recursive descent parser: one function per rule of a grammar, precedence that falls out of which function calls which, brackets, unary minus and the remainder operator.
0 of 5 steps
A tree in the middle, and an evaluator that walks it to drive the board.
Split understanding from doing: the parser builds an abstract syntax tree out of tuples, and small recursive functions draw it, evaluate it and turn it into reverse Polish notation.
0 of 5 steps
Orbit grows statements: a program is a list of statement nodes, and a run loop carries each one out, printing, switching real lamps on the Pi and waiting, until a launch sequence written in your own language counts down on the panel.
0 of 5 steps
Variables, environments, functions and closures.
Variables, assignment and repeat blocks, then the idea that decides where a name can be seen: environments chained to their parents, so a block gets names of its own and the outside world stays safe.
0 of 5 steps
def, calls and return in your own language: functions as values in the environment, return as an exception that unwinds the interpreter, the difference between lexical and dynamic scope proved on one program, and recursion with if.
0 of 6 steps
Errors that point at the mistake, then Orbit 1.0 with a REPL on the Serial Monitor.
The difference between a toy and a tool: tokens that know their line and column, one error type for the whole language, a caret under the exact spot, and runtime errors like division by zero and adding text to a number caught before Python sees them.
0 of 5 steps
Finish Orbit 1.0: a read-eval-print loop on the Serial Monitor that remembers between lines, reads multi-line blocks, survives errors and Ctrl-C, has built-in math, and flies a launch sequence on the Pi's lamps typed live.
0 of 7 steps
All 8 lessons, in order, each with what it covers. Any of them opens in the editor right away.
Build a programming language is part of the maker track, a ladder of courses from zero to expert.
Follow the starter kit you already own, then build a claw machine, a balance bot, a handheld console or an LED cube, each a short course checked by the simulator.
See every course on the trackEvery lesson runs in the simulator with nothing to buy. When you want the real thing, these kits have the parts.
Pick the starter kit you own and run every lesson in its manual with the same parts on the same pins.
See every kitYes. All 8 lessons of Build a programming language are free and run in your browser, with nothing to install and no parts to buy before you start.
No. Every lesson runs on a simulated Raspberry Pi 4 Model B with its parts on the canvas, and the simulator checks each step as you go. When you want to build it for real, the same wiring and code work on a real board.
About 6 hours: 8 lessons in 4 chapters, each one a few short steps. Your progress is kept, so you can stop after any lesson and pick up where you left off.
Each chapter ends in a project that puts it together: Recursive descent, Evaluating, Functions and Boss: a calculator language on a board.
With "Tokens", and each lesson builds on the one before it. New to circuits? Electronics basics is the course that starts from zero.