--- title: Compiler Architecture description: High-level pipeline overview of the Mist compiler and crate organization. icon: Building2 --- ### Pipeline Overview The Mist compiler operates in distinct phases: ``` Source (.mist) │ ▼ ┌─────────────┐ │ Lexer │ (pest PEG grammar) │ & Parser │ └─────────────┘ │ AST ▼ ┌─────────────┐ │ Semantics │ (field init checking) └─────────────┘ │ ▼ ┌─────────────┐ │ Codegen │ (AST → Rust source) └─────────────┘ │ .rs + .map.json ▼ ┌─────────────┐ │ cargo │ (Rust compilation) └─────────────┘ │ ▼ Binary / Library ``` ### Crate Organization The compiler is written in Rust and Mist itself, organized into four main crates: | Crate | Language | Role | |-------|----------|------| | **mist-parser** | Rust | PEG parsing via pest, AST construction, semantic checks, position mapping | | **mist-codegen** | Rust | AST → Rust source code generation | | **mist-analyzer** | Rust | Language server bridging mist-editor ↔ rust-analyzer | | **mist-api** | Mist | Orchestrates transpilation, module tree building, cargo invocation, error remapping |