Compiler Pipeline
Source → Lexer → Parser → Semantic Analyzer → IR Lowering → (Plugin System)
│ │ │ │ │
▼ ▼ ▼ ▼ ▼
Tokens AST Validated AST IrModule IrPass / Backend
- Lexer: Tokenizes source with
logos. - Parser: Builds AST from tokens with
chumsky(Pratt precedence). - Semantic Analyzer: 6-pass validation (Pass 0 resolves modules, Passes
1–5 build symbol tables, resolve types, validate expressions, validate
traits, detect cycles). Inference, validation, and the per-function
scratch state (
local_let_bindings,inference_scope_stack) operate onSemType, a structural type representation. There are no string sentinels ("Unknown","InferredEnum","Nil") inside the analyzer; callers gate onSemType::Unknown/is_indeterminate()directly. TheSymbolTable::LetInfo::inferred_typeslot is the only string-typed storage that remains — it is the public boundary with IR lowering and external consumers (LSP queries, downstream tooling). - IR Lowering: Converts the validated AST + symbol table into a
fully type-resolved
IrModule. Module nesting is flattened in the per-type vectors: inlinemod foo { struct Bar { ... } }lowers to a top-levelIrStruct { name: "foo::Bar", ... }, so backends that don't care about source structure see a flat list of definitions keyed by qualified name. A parallelIrModule.modules: Vec<IrModuleNode>tree mirrors the sourcemodhierarchy with per-module ID lists for backends that need namespaced output. - Plugin System: External
IrPasstransforms andBackendemitters composed throughPipeline: see Plugin System.
Compiler Outputs
| Output | Type | Use case |
|---|---|---|
| AST | File | Syntax analysis, source-level tooling, LSP |
| IR | IrModule | Code generation, type-aware analysis |
See the AST Reference and IR Reference for the data shapes each phase produces.