Compiler Architecture
The AodhML compiler follows a traditional multi-pass design optimized for fast compilation and excellent error messages.
Pipeline Overview
Source Code
|
v
+-----------+
| Lexer | → Tokens
+-----------+
|
v
+-----------+
| Parser | → AST
+-----------+
|
v
+-----------+
| Semantic | → Annotated AST
| Analysis |
+-----------+
|
v
+-----------+
| Type | → Typed AST
| Checker |
+-----------+
|
v
+-----------+
| IR | → Intermediate Representation
| Generator|
+-----------+
|
v
+-----------+
| Runtime | → Execution
| / Backend|
+-----------+
Design Principles
- Fast compilation: Single-pass parsing where possible, incremental type checking
- Great diagnostics: Every error includes line, column, source excerpt, and suggestion
- Modular: Each phase is independently testable and reusable
- Extensible: New backends (GPU, WebAssembly) plug into the IR layer
Project Structure
aodhml/
├── compiler/
│ ├── lexer/ # Tokenizer
│ ├── parser/ # Recursive descent parser
│ ├── ast/ # AST definitions
│ ├── semantic/ # Name resolution, scope analysis
│ ├── types/ # Type checker
│ ├── ir/ # Intermediate representation
│ └── diagnostics/ # Error reporting
├── runtime/
│ ├── vm/ # Bytecode interpreter
│ ├── memory/ # Memory management
│ └── stdlib/ # Standard library runtime
├── cli/ # Command-line interface
└── docs/ # Documentation