neural/rune/rs/ast/lib.rs

/// A Nox noun โ€” the universal data type.
/// Atom = unsigned integer. Cell = ordered pair.
/// Both registers parse to Expr which lowers to Noun.
#[derive(Debug, Clone, PartialEq, Eq)]
pub enum Noun {
    Atom(u64),
    Cell(Box<Noun>, Box<Noun>),
}

impl Noun {
    pub fn cell(head: Noun, tail: Noun) -> Self {
        Noun::Cell(Box::new(head), Box::new(tail))
    }
}

/// Chunk-noun ABI โ€” the wire between rune result nouns and prysm/tape chunks.
///
/// A prysm element is a noun `[tag payload]` where `tag` is one of these small
/// atoms. `rune-lower` emits these from `text(..)`/`button(..)`/`col(..)` builtins;
/// `rune-prysm::noun_to_chunks` decodes them into `tape::Chunk`s, which prysm's
/// `dispatch` renders. This is the only contract between the two; rune never
/// touches Bevy.
pub mod tag {
    /// `[0 e1 [e2 ... 0]]` โ€” a column/list of elements (null-terminated).
    pub const LIST:   u64 = 0;
    /// `[1 <tape>]` โ€” body text โ†’ `(#, t)` HAX/TEXT
    pub const TEXT:   u64 = 1;
    /// `[2 <tape>]` โ€” annotation โ†’ `(~, t)` SIG/TEXT
    pub const ANNO:   u64 = 2;
    /// `[3 <tape>]` โ€” error โ†’ `(!, e)` ZAP/ERROR
    pub const ERROR:  u64 = 3;
    /// `[4 <tape>]` โ€” log line โ†’ `(., l)` DOT/LOG
    pub const LOG:    u64 = 4;
    /// `[5 [<label-tape> <target-tape>]]` โ€” action โ†’ `(!, c)` ZAP/COMPONENT
    pub const BUTTON: u64 = 5;
}

/// Act ABI โ€” the world-touching effects a runtime requests through the ward.
///
/// An act is encoded as opcode-16: `[16 [act-tag args-f] cont]`. The interpreter
/// (`eval_with_host`) reads `~caps` (axis 30), hands `(act, args, caps)` to a
/// `Host`, splices the result, and continues `cont`. Pure `eval` no-ops acts.
/// Non-act opcode-16 tags remain hints (event parking). See `cyb/root/ward.md`.
pub mod act {
    /// Act tags live in a high reserved window, clear of user hint tags
    /// (small ints / string-hash tags won't realistically land here).
    pub const BASE: u64 = 0xAC75_0000_0000_0000;
    pub const EMIT:      u64 = BASE + 1; // render prysm chunks to a surface
    pub const QUERY:     u64 = BASE + 2; // read the cybergraph (one-shot)
    pub const LINK:      u64 = BASE + 3; // write a cyberlink
    pub const SEAL:      u64 = BASE + 4; // finalize an intent
    pub const SUBSCRIBE: u64 = BASE + 5; // stream graph events
    pub const HOST:      u64 = BASE + 6; // invoke another runtime

    /// The subject slot holding the requester's capabilities.
    pub const CAPS_AXIS: u64 = 30;

    /// True if `tag` names an act (vs an ordinary hint).
    pub fn is_act(tag: u64) -> bool {
        (BASE..=BASE + 0xFF).contains(&tag)
    }
}

/// High-level expression AST โ€” shared between classic and pure registers.
/// Both registers parse to this; lowering produces a Noun.
#[derive(Debug, Clone)]
pub enum Expr {
    /// Unsigned integer literal
    Atom(u64),
    /// UTF-8 text literal โ€” lowers to a `tape` noun (null-terminated byte list)
    Text(String),
    /// Name reference โ€” resolved against the subject
    Sym(String),
    /// Ordered pair
    Cell(Box<Expr>, Box<Expr>),
    /// Gate definition: sample type + body
    Gate { sample: Box<Expr>, body: Box<Expr> },
    /// Let binding: name, value, continuation
    Let { name: String, mold: Option<Box<Expr>>, value: Box<Expr>, body: Box<Expr> },
    /// Function call
    Call { gate: Box<Expr>, args: Vec<Expr> },
    /// Conditional
    If { cond: Box<Expr>, yes: Box<Expr>, no: Box<Expr> },
    /// Pattern match (switch)
    Match { subject: Box<Expr>, arms: Vec<(Expr, Expr)> },
    /// Trap: loop with `$` as recur point
    Trap(Box<Expr>),
    /// Recur to enclosing trap
    Loop,
    /// Rebind a subject slot and continue
    Rebind { slot: String, value: Box<Expr>, body: Box<Expr> },
    /// Compose: evaluate right against left
    Compose(Box<Expr>, Box<Expr>),
    /// Cast to mold
    Cast { mold: Box<Expr>, expr: Box<Expr> },
    /// Increment (Nox pattern 4)
    Inc(Box<Expr>),
    /// Equality test (Nox pattern 9)
    Eq(Box<Expr>, Box<Expr>),
    /// Field addition (Nox pattern 5)
    Add(Box<Expr>, Box<Expr>),
    /// Field subtraction (Nox pattern 6)
    Sub(Box<Expr>, Box<Expr>),
    /// Field multiplication (Nox pattern 7)
    Mul(Box<Expr>, Box<Expr>),
    /// Evaluate formula against subject (Nox pattern 2 / `.*`)
    Eval { subject: Box<Expr>, formula: Box<Expr> },
    /// Scry โ€” read from the cybergraph (`.^`)
    Scry { mold: Box<Expr>, path: Box<Expr> },
    /// Hint: event-reactive yield
    Hint { tag: String, selector: Box<Expr>, body: Box<Expr> },
    /// Host call: escape to WASM / wGPU / glia
    Host { target: String, args: Box<Expr> },
    /// Arm definition (within a door/core)
    Arm { name: String, body: Box<Expr> },
    /// Door: multi-arm core
    Door(Vec<Expr>),
    /// Method call on a door: obj.method(args)
    MethodCall { obj: String, method: String, args: Vec<Expr> },
    /// A cybermark address embedded in expression context
    Address(Address),
}

/// A cybermark address โ€” any sigil form resolves to a subject slot or graph lookup.
#[derive(Debug, Clone)]
pub enum Address {
    /// `#path/to/concept` or `#QmHash` โ€” particle reference
    Particle(String),
    /// `@alice` or `@QmNeuron` โ€” neuron reference
    Neuron(String),
    /// `~name` or `~/@alice/name` โ€” named particle
    Name(String),
    /// `/path/segment` โ€” explicit path
    Path(Vec<String>),
    /// `$TOKEN` โ€” token reference
    Token(String),
    /// `^concept` โ€” abstract root concept
    Abstract(String),
    /// `~/` โ€” home namespace root
    Home,
}

Homonyms

cyb/optica/src/lib.rs
soft3/strata/src/lib.rs
cyb/honeycrisp/src/lib.rs
warriors/trisha/honeycrisp/lib.rs
warriors/trisha/wgpu/lib.rs
soft3/glia/import/lib.rs
soft3/foculus/src/lib.rs
soft3/nox/rs/lib.rs
soft3/cybergraph/src/lib.rs
soft3/tru/rs/lib.rs
soft3/mudra/src/lib.rs
soft3/glia/run/lib.rs
cyb/prysm/rs/lib.rs
warriors/trisha/rs/lib.rs
cyb/src-tauri/src/lib.rs
soft3/mir/src/lib.rs
soft3/lens/src/lib.rs
neural/trident/src/lib.rs
neural/rune/rs/subject/lib.rs
cyb/cyb/cyb-services/src/lib.rs
soft3/strata/nebu/rs/lib.rs
soft3/lens/core/src/lib.rs
neural/rs/mir-format/src/lib.rs
soft3/zheng/rs/src/lib.rs
neural/rune/rs/interp/lib.rs
soft3/radio/iroh-willow/src/lib.rs
neural/rune/rs/parse/lib.rs
neural/eidos/rs/src/lib.rs
neural/rs/darwin-sys/src/lib.rs
soft3/radio/iroh-gossip/src/lib.rs
soft3/radio/iroh-ffi/src/lib.rs
soft3/radio/iroh-car/src/lib.rs
soft3/radio/iroh-relay/src/lib.rs
soft3/bbg/rs/src/lib.rs
soft3/radio/iroh-docs/src/lib.rs
soft3/lens/ikat/src/lib.rs
neural/rune/rs/lex/lib.rs
cyb/honeycrisp/aruminium/src/lib.rs
soft3/hemera/rs/src/lib.rs
soft3/radio/iroh-blobs/src/lib.rs
cyb/honeycrisp/acpu/src/lib.rs
soft3/lens/porphyry/src/lib.rs
cyb/honeycrisp/rane/src/lib.rs
neural/rune/rs/compile/lib.rs
neural/rune/rs/parse-pure/lib.rs
neural/rs/codegen/src/lib.rs
soft3/lens/binius/src/lib.rs
neural/rune/rs/prysm/lib.rs
neural/rs/link/src/lib.rs
neural/rune/rs/mold/lib.rs
soft3/strata/proof/src/lib.rs
soft3/lens/brakedown/src/lib.rs
soft3/strata/kuro/rs/lib.rs
soft3/lens/assayer/src/lib.rs
neural/rs/core/src/lib.rs
neural/rs/macros/src/lib.rs
soft3/radio/cyber-bao/src/lib.rs
soft3/strata/compute/src/lib.rs
soft3/radio/iroh-base/src/lib.rs
soft3/radio/iroh-dns-server/src/lib.rs
neural/rune/rs/lower/lib.rs
soft3/strata/ext/src/lib.rs
soft3/strata/core/src/lib.rs
soft3/hemera/wgsl/src/lib.rs
soft3/radio/iroh/src/lib.rs
cyb/honeycrisp/unimem/src/lib.rs
cyb/evy/crates/evy_engine_tasks/src/lib.rs
cyb/evy/crates/evy_dialect/src/lib.rs
cyb/wysm/crates/wasi/src/lib.rs
cyb/wysm/crates/fuzz/src/lib.rs
soft3/strata/genies/rs/src/lib.rs
cyb/evy/crates/evy_platform_caps/src/lib.rs
neural/inf/rs/oracle/src/lib.rs
soft3/strata/jali/wgsl/src/lib.rs
cyb/evy/forks/bevy_transform/src/lib.rs
soft3/tape/impl/rust/src/lib.rs
cyb/wysm/crates/wasmi/src/lib.rs
cyb/evy/forks/bevy_render/src/lib.rs
cyb/evy/crates/evy_ecs_storage/src/lib.rs
cyb/evy/forks/naga/src/lib.rs
soft3/strata/trop/wgsl/src/lib.rs
cyb/wysm/crates/c_api/artifact/lib.rs
cyb/evy/forks/bevy_ecs/src/lib.rs
cyb/wysm/crates/ir/src/lib.rs
cyb/evy/forks/bevy_animation/src/lib.rs
cyb/evy/forks/bevy_sprite_render/src/lib.rs
cyb/wysm/crates/c_api/src/lib.rs
neural/inf/rs/parse/src/lib.rs
soft3/strata/trop/rs/src/lib.rs
soft3/strata/kuro/wgsl/src/lib.rs
neural/trident/editor/zed/src/lib.rs
cyb/evy/forks/bevy_mesh/src/lib.rs
cyb/evy/crates/evy_radio/src/lib.rs
cyb/evy/forks/bevy_anti_alias/src/lib.rs
soft3/strata/jali/rs/src/lib.rs
cyb/wysm/crates/wast/src/lib.rs
neural/inf/rs/plan/src/lib.rs
neural/rs/tests/macro-integration/src/lib.rs
soft3/radio/iroh-ffi/iroh-js/src/lib.rs
cyb/evy/forks/bevy_image/src/lib.rs
cyb/evy/forks/bevy_post_process/src/lib.rs
neural/inf/rs/source/src/lib.rs
cyb/wysm/crates/core/src/lib.rs
cyb/evy/crates/evy_diagnostic/src/lib.rs
cyb/evy/crates/evy_engine_dispatch/src/lib.rs
cyb/evy/forks/bevy_pbr/src/lib.rs
cyb/evy/forks/bevy_gizmos/src/lib.rs
cyb/evy/forks/bevy_gizmos_render/src/lib.rs
soft3/radio/iroh/bench/src/lib.rs
neural/inf/rs/lex/src/lib.rs
neural/inf/rs/ast/src/lib.rs
soft3/strata/genies/wgsl/src/lib.rs
soft3/strata/nebu/wgsl/src/lib.rs
cyb/wysm/crates/collections/src/lib.rs
neural/inf/rs/lower/src/lib.rs
cyb/evy/forks/bevy_sprite/src/lib.rs
cyb/evy/forks/bevy_diagnostic/src/lib.rs
neural/inf/rs/eval/src/lib.rs
cyb/wysm/crates/c_api/macro/lib.rs
cyb/evy/forks/bevy_tasks/src/lib.rs
cyb/evy/forks/bevy_core_pipeline/src/lib.rs
cyb/evy/crates/evy_prysm_core/src/lib.rs
neural/inf/rs/value/src/lib.rs
cyb/evy/crates/evy_engine_core/src/lib.rs
soft3/radio/tests/integration/src/lib.rs
bootloader/go-cyber/cw/packages/cyber-std-test/src/lib.rs
bootloader/go-cyber/cw/contracts/std-test/src/lib.rs
bootloader/go-cyber/cw/contracts/graph-filter/src/lib.rs
bootloader/go-cyber/cw/packages/cyber-std/src/lib.rs

Graph