07 — Compiler Architecture
Compiler Overview
Section Overview
What This Is
The Compiler Architecture specifies the three-phase transformation pipeline — Parse, Transform, Emit — and the plugin interface through which each phase is extended.
Why It Exists
The compiler operationalises every constraint and invariant declared throughout the specification. Without it, the spec is advisory. The compiler is the conformance authority.
How It Works
Parse converts source to AST. Transform resolves and validates. Emit generates artifacts. Plugins extend at phase boundaries only. Exit codes: 0 success, 1 warnings, 2 errors.
Plugin extension points exist at phase boundaries only. Core phase behaviour is not modifiable by plugins.
The IDL compiler transforms IDL source modules into platform-specific output artifacts. It is the sole normative authority for IDL conformance: a construct is conformant if and only if the compiler accepts it without error. The compiler operates in three phases — Parse, Transform, Emit — each of which is independently extensible via the plugin interface. Exit codes are standardised: 0 for success, 1 for warnings, 2 for errors.
Why the Compiler Is the Authority
Specifications without enforcement mechanisms are advisory. The IDL compiler operationalises every constraint, invariant, and rule declared throughout the specification. When a specification rule and the compiler's behavior appear to conflict, the compiler behavior is the reference implementation — the specification should be updated to match, via the RFC process.
Compilation Targets
A compilation target is a combination of a platform emitter and a configuration set (density level, theme, platform version). A single IDL source tree may be compiled against multiple targets in a single build, producing multiple artifact sets. Each target is independently validated during Transform; a constraint violation for one target does not affect the output of other targets.
Incremental Compilation
The compiler supports incremental compilation for large systems. When IDL source modules have not changed since the last compilation, their AST representations are cached and reused. The compiler determines the affected module set by analyzing the dependency graph from changed modules outward. Incremental compilation is guaranteed to produce identical output to full compilation for unchanged modules.