Skip to content

michaelmillar/desugar

Repository files navigation

desugar

A browser-native workbench for building your own programming language.
Implement each stage yourself, inspect every intermediate representation live, export a standalone Rust project.


demo.mp4

What it does

desugar is a language implementation workbench. You build a working interpreter from raw text to evaluated output, one pass at a time, inside a browser studio that visualises every intermediate representation as you write it.

Each lesson adds one pass. The pipeline viewer updates live:

Source            Tokens              Parse Tree           Evaluation
let x = 1 + 2;   Let   "let"         LetBinding           Integer(3)
                  Ident "x"             name: "x"
                  Equal "="             value: BinOp
                  Int   "1"               left:  IntLit(1)
                  Plus  "+"               op:    "+"
                  Int   "2"               right: IntLit(2)
                  Semi  ";"

You name your language, give it a file extension, and choose a CLI name. When you finish, you eject the result as a standalone Rust project with a working CLI, test suite, and sample programmes.

Quick start

cargo run -p desugar

Open http://127.0.0.1:4001 in your browser.

How it works

  1. Create a profile. Name your language, pick a file extension, choose a CLI name.
  2. desugar generates a working Rust workspace for your language.
  3. Work through three lessons in the browser. Each lesson adds one implementation pass.
  4. The pipeline viewer shows every intermediate representation as you edit.
  5. Run tests, reveal hints if stuck, benchmark your implementation against tiers.
  6. When done, eject your language into exports/ as a standalone project.

Three lessons, one growing codebase

Lesson 1: Tokenise. Turn raw source text into a stream of tokens. The pipeline viewer shows the token table.

Lesson 2: Parse. Turn the token stream into an expression tree. The viewer adds the AST panel.

Lesson 3: Evaluate. Walk the tree and compute a result. The viewer shows the full pipeline from source to value.

Each lesson builds on the previous. Your language is one codebase that grows.

What the ejected project contains

exports/aster/
  Cargo.toml
  compiler/
    Cargo.toml
    src/lib.rs
    tests/
  cli/
    Cargo.toml
    src/main.rs
  samples/
    hello.ast
  README.md

A real Rust workspace with your language name, your file extension, your CLI binary, and passing tests.

How it compares

Most language implementation education stays academic or drops you into a half-built codebase. desugar takes a different path: you build everything from raw text in a live workbench that visualises every pass.

Where desugar is stronger. You build a named, ejectable language. The pipeline viewer gives immediate visual feedback on every implementation pass. Test-driven milestones, progressive hints, and benchmark tiers make progress tangible.

Where desugar is weaker. It covers one language family (expression-based). It does not yet teach type checking, optimisation passes, or backend code generation. Crafting Interpreters covers more ground if you want breadth.

What is included

  • Browser workbench with lesson progression, guided editing, hints, and scoring
  • Live pipeline viewer showing tokens, AST, and evaluation for each pass
  • Learner onboarding that creates a personalised language workspace
  • Per-test reruns with save, reset, and run-all
  • Quality checks (cargo fmt, clippy) with feedback
  • Benchmark tiers with bonus points
  • Progress persistence across sessions
  • Export of the finished language as a standalone repo

Status

Working today: full three-lesson arc, pipeline viewer, workspace generation, quality checks, scoring, persistence, export with CLI.

Not yet implemented:

  • Type checking pass
  • Name resolution pass
  • Module system
  • Backend code generation (bytecode VM or Wasm)
  • Multiple language tracks beyond expression-based
  • Gallery for sharing ejected languages

Licence

MIT

About

Browser-native workbench for building your own programming language, one pass at a time

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors