Skip to content
Back to the catalog
Project json-parserLanguagesBeginnerBeta

A JSON parser

Your first contact with lexers and grammars. Tokenize, build the tree and fail with useful errors.

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

JSON is the most boring format in the world, and that's exactly why it's the best place to learn to write parsers: its grammar fits on a napkin, yet it contains every idea you'll reuse later on real languages.

You'll build the parser in the two classic steps — tokenize, then assemble the tree — and finish it off with what separates an exercise from a usable tool: error messages that say what broke and on which line.

Roadmap

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

  1. Phase 13 stages

    From text to tokens

    Walk the input character by character and emit tokens: braces, commas, literals.

    1. 01Before you start: the parser map
    2. 02The three literal values
    3. 03Numbers without shortcuts
  2. Phase 22 stages

    From tokens to a tree

    A recursive descent parser for objects, arrays and nested values.

    1. 01Strings, escapes and Unicode
    2. 02The first recursive structure
  3. Phase 32 stages

    The full specification

    Unicode escapes, scientific notation, and errors with line and column.

    1. 01Objects and complete documents
    2. 02Useful errors and hardening

Before you start

A library that turns JSON text into your language's data structures: a tokenizer, a recursive descent parser, full coverage of the specification (numbers, strings with escapes and \uXXXX, nesting) and errors with line, column and context.

  • lisp-interpreter
    Beta

    A Lisp interpreter

    Tokenizer, parser, evaluator and closures. Discover how a language runs your code, step by step.

    Advanced11 stages~16 hLanguages
    parsingastclosures+1

    Python · JavaScript · TypeScript

  • regex-engine
    Beta

    A regular expression engine

    From the expression to the automaton. Backtracking, groups and character classes without your language's regex.

    Advanced8 stages~11 hLanguages
    autómatasparsingbacktracking

    TypeScript · Python · Rust

  • mini-compiler
    Beta

    A mini compiler to bytecode

    From source code to runnable bytecode. Lexing, AST, semantic analysis, code generation and a VM that runs it.

    Expert16 stages~30 hLanguages
    lexerastbytecode+1

    Rust · C++ · TypeScript