Loading...

Build your own Interpreter

Learn about tokenization, ASTs, tree-walk interpreters and more.

Start Building
interpreter
Go
interpreter
Python
interpreter
Rust
interpreter
Kotlin
interpreter
Gleam
interpreter
OCaml
interpreter
Zig
This challenge is free to try when it's in beta. We keep challenges in beta for a few weeks to gather feedback.

This challenge follows the book Crafting Interpreters by Robert Nystrom.

In this challenge you'll build an interpreter for Lox, a simple scripting language. Along the way, you'll learn about tokenization, ASTs, tree-walk interpreters and more.

Before starting this challenge, make sure you've read the "Welcome" part of the book that contains these chapters:

These chapters don't involve writing code, so they won't be covered in this challenge. This challenge will start from chapter 4, Scanning.

Stages

Scanning: Empty file
Login via GitHub to view this stage
Scanning: Parentheses
Login via GitHub to view this stage
Scanning: Braces
Login via GitHub to view this stage
Scanning: Other single-character tokens
Login via GitHub to view this stage
Scanning: Lexical errors
Login via GitHub to view this stage
Scanning: Assignment & equality Operators
Login via GitHub to view this stage
Scanning: Negation & inequality operators
Login via GitHub to view this stage
Scanning: Relational operators
Login via GitHub to view this stage
Scanning: Division operator & comments
Login via GitHub to view this stage
Scanning: Whitespace
Login via GitHub to view this stage
Scanning: Multi-line errors
Login via GitHub to view this stage
Scanning: String literals
Login via GitHub to view this stage
Scanning: Number literals
Login via GitHub to view this stage
Scanning: Identifiers
Login via GitHub to view this stage
Scanning: Reserved words
Login via GitHub to view this stage

Parsing Expressions

Booleans & Nil
Login via GitHub to view this stage
Number literals
Login via GitHub to view this stage
String literals
Login via GitHub to view this stage
Parentheses
Login via GitHub to view this stage
Unary Operators
Login via GitHub to view this stage
Arithmetic operators (1/2)
Login via GitHub to view this stage
Arithmetic operators (2/2)
Login via GitHub to view this stage
Comparison operators
Login via GitHub to view this stage
Equality operators
Login via GitHub to view this stage
Syntactic errors
Login via GitHub to view this stage

Evaluating Expressions

Literals: Booleans & Nil
Login via GitHub to view this stage
Literals: Strings & Numbers
Login via GitHub to view this stage
Parentheses
Login via GitHub to view this stage
Unary Operators: Negation & Not
Login via GitHub to view this stage
Arithmetic Operators (1/2)
Login via GitHub to view this stage
Arithmetic Operators (2/2)
Login via GitHub to view this stage
String Concatenation
Login via GitHub to view this stage
Relational Operators
Login via GitHub to view this stage
Equality Operators
Login via GitHub to view this stage
Runtime Errors: Unary Operators
Login via GitHub to view this stage
Runtime Errors: Binary Operators (1/2)
Login via GitHub to view this stage
Runtime Errors: Binary Operators (2/2)
Login via GitHub to view this stage
Runtime Errors: Relational Operators
Login via GitHub to view this stage