Source: https://mokxi.com/learn/path/build-an-interpreter
Updated: 2026-11-20

All paths

# Build a programming language

Write 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.

Raspberry Pi 4 Model B Free 8 lessons 6 h 4 chapters 3,136 XP Coding · Advanced +250 XP

0 of 8 done

Start the course free Tokens Lesson plan for teachers

What you will build

## 4 projects, built step by step

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.

Chapter 1 project

### 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 simulator

Chapter 2 project

### Evaluating

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.
Open it in the simulator

Chapter 3 project

### Functions

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.
Open it in the simulator

Chapter 4 project

### Boss: a calculator language on a board

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.
Open it in the simulator

The map

## Chapter by chapter

Each lesson opens when the one before it is done, and each chapter ends in a project.

Chapter 1

## Reading code

Text into tokens, tokens into answers: the front end of every language.

Open 250 XP

### Tokens

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

Start What is in it

Project Locked 500 XP

### 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.

0 of 5 steps

4 questions, graded as you go.

Chapter 2

## Running code

A tree in the middle, and an evaluator that walks it to drive the board.

Locked 250 XP

### An AST

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

Project Locked 454 XP

### Evaluating

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

4 questions, graded as you go.

Chapter 3

## Names

Variables, environments, functions and closures.

Locked 250 XP

### Scope

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

Project Locked 576 XP

### Functions

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

4 questions, graded as you go.

Chapter 4

## Ship it

Errors that point at the mistake, then Orbit 1.0 with a REPL on the Serial Monitor.

Locked 250 XP

### Errors

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

Project Locked 606 XP

### Boss: a calculator language on a board

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

4 questions, graded as you go.

Syllabus

## Every lesson in the course

All 8 lessons, in order, each with what it covers. Any of them opens in the editor right away.

Chapter 1

### Reading code

- Tokens 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.
- 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.

Chapter 2

### Running code

- An AST 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.
- Evaluating 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.

Chapter 3

### Names

- Scope 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.
- Functions 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.

Chapter 4

### Ship it

- Errors 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.
- Boss: a calculator language on a board 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.

Keep going

## The rest of your track

Build a programming language is part of the maker track, a ladder of courses from zero to expert.

Track

### Maker track

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 track

Kits

## Build it on your bench too

Every lesson runs in the simulator with nothing to buy. When you want the real thing, these kits have the parts.

Have a kit already?

### Find your kit

Pick the starter kit you own and run every lesson in its manual with the same parts on the same pins.
See every kit

Questions

## About Build a programming language

Is Build a programming language free?

Yes. 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.

Do I need a real Raspberry Pi 4 Model B?

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.

How long does Build a programming language take?

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.

What will I build?

Each chapter ends in a project that puts it together: Recursive descent, Evaluating, Functions and Boss: a calculator language on a board.

Where do I start?

With "Tokens", and each lesson builds on the one before it. New to circuits? Electronics basics is the course that starts from zero.
