SYSTEM ARCHITECTURE
The TKS v7.4 Compiler/VM Pipeline.
LEXING
Converts .tks source into a token stream with spans. Supports Unicode normalization and ordinal literal patterns.
PARSING
Generates AST with source locations. Supports v7.2 core grammar, v7.3 extensions (effects, transfinite, quantum), and canonical aliases.
DESUGARING
Normalizes aliases to canonical AST forms (e.g., expr^k -> Noetic(k, expr)) and canonicalizes effect rows.
RESOLUTION
Builds module graph, loads .tksi interfaces, and resolves identifiers, handler names, and extern symbols.
INFERENCE
Hindley-Milner type inference with row-polymorphic effects. Enforces effect boundary safety and ordinal constraints.
LOWERING
Converts to effect-aware ANF IR. Makes perform/handle/resume explicit and lowers transfinite loops/quantum ops.
CODEGEN
Emits .tkso bytecode with metadata. Encodes handler metadata, ordinal tables, and quantum constants.
EXECUTION
TKSVM loads .tkso, resolves imports, and executes on the v7.3 VM state model.
CRATE LAYOUT
- tkscore/ : Lexer, Parser, AST, Desugar
- tkstypes/ : Types, Effects, Inference
- tksir/ : IR, ANF Transform
- tksbytecode/ : Bytecode Model, Encoder/Decoder
- tksvm/ : VM Runtime, Heap, Handlers
- tksc/ : Compiler CLI
- tks/ : Runner + REPL