Skip to content
Back to the catalog
Project mini-compilerLanguagesExpertComing soon

Build your own compiler

Build a compiler from scratch. Turn source code into bytecode with lexing, an AST, semantic analysis, code generation and a virtual machine.

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.

Guide language

The stage guides read in this language. Only languages this project is fully translated into show up here; the interface language does not change.

What this project is about

Project in preparation: we are completing and verifying the implementation path and its tests. The capabilities below describe the project goal; starting the project is not enabled yet.

This is the longest challenge in the catalog and the one that brings the most together: your own language, with its compiler and its virtual machine, built end to end.

You'll go from text to tokens, from tokens to a tree, from the tree to a type-checked representation, from there to bytecode and, finally, to a stack machine that executes it. You'll finish running programs written in a language you designed yourself.

Roadmap

16 stages across 4 phases. Every stage comes with its guide and its tests: you move on when they pass.

  1. Phase 15 stages

    The frontend

    Lexer, a parser with precedence, and the language's syntax tree.

  2. Phase 24 stages

    Understanding the program

    Name resolution, scopes, type checking and useful errors.

  3. Phase 34 stages

    Generating bytecode

    Instruction set, constants, jumps, and compiling the tree.

  4. Phase 43 stages

    Running it

    Stack virtual machine, call frames, functions and optimisations.

Before you start

A complete compiler and its runtime: a lexer, a parser with operator precedence, a syntax tree, name resolution and type checking, bytecode generation, a stack virtual machine with call frames, first-class functions, and a couple of measurable optimisations.

  • lisp-interpreter
    Coming soon

    Build your own Lisp interpreter

    Build a Lisp interpreter from scratch. Write a tokenizer, parser and evaluator, then add closures to discover how a language executes your code.

    Advanced11 stages~16 hLanguages
    parsingASTclosures+1

    Python · JavaScript · TypeScript

  • regex-engine
    Beta

    Build your own regex engine

    Build a regex engine from scratch. Turn expressions into automata with backtracking, groups and character classes without using a regex library.

    Advanced8 stages~11 hLanguages
    automataparsingbacktracking

    TypeScript · Python · Rust

  • json-parser
    Coming soon

    Build your own JSON parser

    Build a JSON parser from scratch. Tokenize input, parse the grammar, construct a syntax tree and report useful errors for invalid JSON.

    Beginner7 stages~6 hLanguages
    tokenizerparsingrecursion

    TypeScript · Python · Go · Java