SYSTEM ARCHITECTURE

The TKS v7.4 Compiler/VM Pipeline.

01

LEXING

Converts .tks source into a token stream with spans. Supports Unicode normalization and ordinal literal patterns.

02

PARSING

Generates AST with source locations. Supports v7.2 core grammar, v7.3 extensions (effects, transfinite, quantum), and canonical aliases.

03

DESUGARING

Normalizes aliases to canonical AST forms (e.g., expr^k -> Noetic(k, expr)) and canonicalizes effect rows.

04

RESOLUTION

Builds module graph, loads .tksi interfaces, and resolves identifiers, handler names, and extern symbols.

05

INFERENCE

Hindley-Milner type inference with row-polymorphic effects. Enforces effect boundary safety and ordinal constraints.

06

LOWERING

Converts to effect-aware ANF IR. Makes perform/handle/resume explicit and lowers transfinite loops/quantum ops.

07

CODEGEN

Emits .tkso bytecode with metadata. Encodes handler metadata, ordinal tables, and quantum constants.

08

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