Search

Inside the Draft Compiler

A deep dive into Draft's compilation pipeline: from lexer to native code generation.

Draft Team1 min read

Inside the Draft Compiler

A deep dive into Draft’s compilation pipeline: from lexer to native code generation.

Compilation Pipeline

Draft source code passes through several stages:

  1. Lexer — Tokenizes the source code into a stream of tokens
  2. Parser — Builds an Abstract Syntax Tree (AST) from the tokens
  3. Type Checker — Validates types and ensures type safety
  4. IR Generation — Produces a compact intermediate representation
  5. Code Generation — Compiles to the selected target (native, WASM, web, etc.)

Why Rust?

The Draft compiler is built in Rust for safety, performance, and a single standalone binary distribution.

Open Source

Every stage of compilation is inspectable and debuggable. The compiler is fully open source.