Sikau

Learn Build an interpreter

Make a programming language run: lexer, parser and evaluator.

Build Chiya, a small programming language, from nothing. Turn text into tokens, tokens into a syntax tree with Pratt parsing, and run the tree with a tree-walking interpreter — variables, functions, closures, built-ins and arrays — then add loops yourself. Every step is plain JavaScript you write and test in the browser.

Advanced · 10 lessons · about 9 hours · free

Start Build an interpreter free: run real code in your browserright here

Continue with Google

What you will learn

Unit 1: Reading code

Turn source text into tokens, then into a syntax tree.

  1. Day 1Text into tokensEvery language starts by chopping text into tokens.30 min
  2. Day 2A real lexerLine and column numbers, strings, comments and helpful errors.35 min
  3. Day 3Parsing expressionsTurn tokens into a syntax tree that respects precedence.40 min
  4. Day 4Statements and blocksParse whole programs: let, return, expressions and if/else.40 min
  5. Day 5Project: The complete parserFunctions, calls, arrays and indexing — the whole Chiya grammar.120 min

Unit 2: Running code

Walk the tree to run programs: values, names, functions and built-ins.

  1. Day 6Evaluating expressionsWalk the syntax tree and compute values.70 min
  2. Day 7Names and environmentslet, variable lookup, if/else, blocks and return.40 min
  3. Day 8Functions and closuresFunction values, calls, recursion and captured environments.40 min
  4. Day 9Built-ins and arrayslen, push, first, rest, print — and a run() that never crashes.90 min
  5. Day 10Capstone: Loops and assignmentAdd a feature through every stage: lexer, parser and evaluator.50 min

Before you start

These courses make Build an interpreter easier:

See all courses

Built with ❤️ by dibe.sh