[ROLE & OPERATIONAL MODE] You are a Principal Compiler Archi...
Prompt
[ROLE & OPERATIONAL MODE] You are a Principal Compiler Architect and Distributed Systems Runtime Engineer. OBJECTIVE: Design, implement, and fully verify a production-grade, complete systems language named "Aether" that strictly supersedes Go (Golang) in latency, type safety, and concurrency correctness, while preserving sub-second compilation and syntactic minimalism. MANDATORY DIRECTIVES & ZERO-PLACEHOLDER INVARIANTS: 1. NO OMISSIONS: Do not emit `// TODO`, `...`, `pass`, `# Add parser logic here`, or simulated mock logs. Every class, state machine, lexer token, parsing method, and concurrency primitive must be fully written in runnable code. 2. EXPLICIT GO FAULT RESOLUTION: - Eliminate Stop-The-World/Tracing GC: Use compile-time lexical region arenas and affine/linear ownership transfer. - Eliminate Goroutine Leaks & Orphan Deadlocks: Implement structured task nurseries (lexical nursery blocks that forbid exit until all child tasks resolve or cancel). - Eliminate Nil-Pointers & Dynamic Panics: Implement algebraic tagged unions (Sum types) with exhaustive pattern matching and strict non-nullability. - Eliminate `if err != nil` Overhead: Implement a `Result[T, E]` type with postfix `?` propagation and exhaustive failure matching. - Eliminate Channel-Shared Race Conditions: Channel sends transfer linear ownership (`Tx` / `Rx` split handles); use-after-send must fail at compile/static check. --- ### PART 1: FORMAL ARCHITECTURE & ASCII DEPENDENCY GRAPH 1. Provide an ASCII Directed Acyclic Graph (DAG) mapping compilation passes: [Source Stream] -> [Lexical Scanner] -> [AST Parser] -> [Static Semantics & Move Checker] -> [Tree-Walking Runtime Engine with Nurseries & Typed MPSC Channels]. 2. Define the formal EBNF/PEG grammar slice specifying: - Module declarations & Functions - Sum Types: `type Option = Some(v) | None` and `type Result = Ok(v) | Err(e)` - Structured Concurrency: `nursery <id> { spawn ... }` - Split Channels: `let (tx, rx) = chan[Type](capacity)` - Postfix Operators: postfix error unwrap (`?`) and unwrap-or-panic (`!!`). --- ### PART 2: THE SELF-REFINING VERIFICATION MATRIX Produce a markdown comparison matrix detailing how Aether mitigates Go's failure modes across 6 dimensions: 1. Heap Allocation & GC Pauses 2. Goroutine Lifecycle & Leak Prevention 3. Channel Deadlock Scenarios (Zero-capacity / Abandoned sender) 4. Null Pointer Dereferences 5. Error Propagation Verbosity 6. Compile-time Safety vs. Runtime Assertions --- ### PART 3: THE COMPLETE EXECUTABLE IMPLEMENTATION (`aether.py`) Provide a single, complete, copy-pasteable, self-contained Python 3 script named `aether.py`. It must include: 1. COMPILER FRONTEND: - `Lexer`: Full tokenizer handling Identifiers, Integers, Strings, Keywords (`fn`, `let`, `mut`, `type`, `match`, `nursery`, `spawn`, `select`, `chan`, `return`), and Operators (`->`, `=>`, `?`, `!!`, `==`, `!=`, `<=`, `>=`). - `AST Nodes`: Complete dataclasses for all language constructs (no abstract shells). - `Parser`: Full recursive-descent parser producing a validated AST from source text. 2. STATIC SEMANTIC & OWNERSHIP CHECKER: - Static exhaustiveness validator verifying all arms of a `match` expression cover declared type variants. - Linear capability tracker: Tracks moved variables (specifically channel endpoints and linear payloads) and flags compile-time `MoveFault` on use-after-move. 3. CONCURRENCY RUNTIME ENGINE: - `TaskNursery`: Native thread-backed or coroutine-backed nursery that enforces join invariants, collects aggregated task failures, and supports cascading cancellation tokens. - `Channel`: Thread-safe, capability-split channel (`Tx` sender, `Rx` receiver) with explicit close propagation, capacity limits, and deadlock prevention. - `RuntimeEvaluator`: Visitor/Interpreter that executes the parsed AST directly with lexical environment scoping. 4. END-TO-END VERIFICATION TEST SUITE (EMBEDDED IN `main()`): The embedded test suite must parse and run this exact embedded Aether program: - Define a telemetry data pipeline with `type Status = Healthy(val) | Critical(code)`. - Initialize a channel with split capabilities `(tx, rx)`. - Open a structured nursery `pipeline`. - Spawn a producer task that iterates and transmits 3 `Result[Status, Str]` packets, then explicitly closes `tx`. - Spawn a consumer task that drains `rx`, unrolls the `Result` with `?` logic, and exhaustively pattern-matches `Status`. - Enforce nursery clean exit (verifying 0 lingering tasks, 0 leaks, 0 deadlocks). - Inject a deliberate test case proving that a double-use after move of `tx` or an unhandled variant in `match` triggers a rejection before execution. Output the complete, uninterrupted, runnable code file.
Response not available
Response not available