Compiler Internals
Pipeline Overview
Catpile transforms .cat source code into CatWeb-compatible JSON through a multi-stage pipeline.
text
.cat source
│
▼
┌─────────────┐
│ Tokenizer │ Character-by-character → tokens (IDENT, NUMBER, STRING, etc.)
└──────┬──────┘
│
▼
┌─────────────┐
│ Parser │ Tokens → AST (Intermediate Representation)
│ (Taste) │ Handles indent-based or bracket-based syntax
└──────┬──────┘
│
▼
┌───────────────┐
│ RAWs │ (Built-in symbol definitions)
│ Interning │
└──────┬───────┘
│
▼
┌─────────────┐
│ Optimizer │ Dead code elimination, inlining, constant folding
│ (-O1/-O2) │ Loop unrolling, peephole optimization
└──────┬──────┘
│
▼
┌─────────────┐
│ UI Linker │ Resolves page. references → global IDs
│ │ Reads .catui for path→globalID mapping
└──────┬──────┘
│
▼
┌─────────────┐
│ Emitter │ IR → CatWeb JSON actions
│ │ Coordinate grid, ID gen, slot filling
└──────┬──────┘
│
▼
┌─────────────┐
│ Builder │ Merges scripts with UI tree
│ │ Generates {favicon, webcontent, ...} output
└──────┬──────┘
│
▼
CatWeb JSONCompiler Pipeline7 stages — click a stage to inspect
.cat sourceCatWeb JSON