Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Architecture: Six Modules

The surface compiler is a Rust toolchain library, not a monolithic binary. Six modules, three consumers.

The Modules

ModulePurposeCrate location
ReaderS-expression text → generic treelykn-lang/reader
ClassifierGeneric tree → typed surface ASTlykn-lang/classifier
Macro expanderThree-pass expansion pipelinelykn-lang/expander
AnalysisExhaustiveness, overlap, scopelykn-lang/analysis
EmitterSurface AST → kernel formslykn-lang/emitter
DiagnosticsError messages with source locationslykn-lang/diagnostics

The Consumers

ConsumerUses
lykn compileAll six modules → JavaScript output
lykn checkReader + classifier + analysis → diagnostics only
lykn fmtReader → reformatted source
lykn runAll six modules → execute via Deno
lykn testAll six modules → compile tests, run via Deno

The key insight: the compiler, linter, and formatter share the same reader and classifier. A bug found by lykn check uses the same AST as lykn compile. This is the DD-20 architecture — a modular library, not a monolithic tool.