#>compiler_pipelines
AST IR code generation

Software / Translation Surfaces

From Source to Executable Form

Compilers are structured translation systems. They take a readable source, project it through [syntax trees], stabilize it in (intermediate representations), and emit <target code> that a runtime can actually carry. In Spw terms, this is where authored frames become executable surfaces.

^"pipeline"{

Compilation Pipeline

The compiler earns trust by preserving differentiation as it moves from one layer to the next. Tokens remain tokens, trees remain trees, and lowered instructions still point back to the authored intent that produced them.

parse

Lexing and Parsing

Source text is segmented, ordered, and shaped into an AST. This is the first threshold where a linear document becomes addressable structure.

ir

Lowering and IR

Intermediate representations preserve enough semantics to optimize while shedding details that belong to the surface syntax alone.

emit

Code Generation

The final pass chooses a target form: JavaScript, bytecode, machine code, or a structured artifact that another system can continue compiling.

#>compilation_pipeline
#!runtime/translation

^"passes"{
  source: ~"./surface.spw"
  parse: ?[ast]
  lower: ^"ir"{ form: "ssa" }
  emit: !["javascript"]
}
$["optimization"]

Optimization Surfaces

Control-Flow Clarity

Optimization starts by naming structure correctly. Basic blocks, dominance, and data-flow analysis are ways of making control visible enough to transform without erasing intent.

Incremental Rebuilds

For authoring tools, full recompilation is often the wrong default. Stable handles and partial invalidation matter more than absolute throughput.

Readable Lowering

Spw benefits from compiler thinking when projections stay explainable. A transformed surface should still let the author trace how one form became another.