Stmt

Enum Stmt 

Source
pub enum Stmt<'a> {
Show 53 variants Let { var: Symbol, ty: Option<&'a TypeExpr<'a>>, value: &'a Expr<'a>, mutable: bool, }, Set { target: Symbol, value: &'a Expr<'a>, }, Call { function: Symbol, args: Vec<&'a Expr<'a>>, }, If { cond: &'a Expr<'a>, then_block: Block<'a>, else_block: Option<Block<'a>>, }, While { cond: &'a Expr<'a>, body: Block<'a>, decreasing: Option<&'a Expr<'a>>, }, Repeat { pattern: Pattern, iterable: &'a Expr<'a>, body: Block<'a>, }, Return { value: Option<&'a Expr<'a>>, }, Assert { proposition: &'a LogicExpr<'a>, }, Trust { proposition: &'a LogicExpr<'a>, justification: Symbol, }, RuntimeAssert { condition: &'a Expr<'a>, }, Give { object: &'a Expr<'a>, recipient: &'a Expr<'a>, }, Show { object: &'a Expr<'a>, recipient: &'a Expr<'a>, }, SetField { object: &'a Expr<'a>, field: Symbol, value: &'a Expr<'a>, }, StructDef { name: Symbol, fields: Vec<(Symbol, Symbol, bool)>, is_portable: bool, }, FunctionDef { name: Symbol, params: Vec<(Symbol, &'a TypeExpr<'a>)>, body: Block<'a>, return_type: Option<&'a TypeExpr<'a>>, is_native: bool, native_path: Option<Symbol>, is_exported: bool, export_target: Option<Symbol>, }, Inspect { target: &'a Expr<'a>, arms: Vec<MatchArm<'a>>, has_otherwise: bool, }, Push { value: &'a Expr<'a>, collection: &'a Expr<'a>, }, Pop { collection: &'a Expr<'a>, into: Option<Symbol>, }, Add { value: &'a Expr<'a>, collection: &'a Expr<'a>, }, Remove { value: &'a Expr<'a>, collection: &'a Expr<'a>, }, SetIndex { collection: &'a Expr<'a>, index: &'a Expr<'a>, value: &'a Expr<'a>, }, Zone { name: Symbol, capacity: Option<usize>, source_file: Option<Symbol>, body: Block<'a>, }, Concurrent { tasks: Block<'a>, }, Parallel { tasks: Block<'a>, }, ReadFrom { var: Symbol, source: ReadSource<'a>, }, WriteFile { content: &'a Expr<'a>, path: &'a Expr<'a>, }, Spawn { agent_type: Symbol, name: Symbol, }, SendMessage { message: &'a Expr<'a>, destination: &'a Expr<'a>, }, AwaitMessage { source: &'a Expr<'a>, into: Symbol, }, MergeCrdt { source: &'a Expr<'a>, target: &'a Expr<'a>, }, IncreaseCrdt { object: &'a Expr<'a>, field: Symbol, amount: &'a Expr<'a>, }, DecreaseCrdt { object: &'a Expr<'a>, field: Symbol, amount: &'a Expr<'a>, }, AppendToSequence { sequence: &'a Expr<'a>, value: &'a Expr<'a>, }, ResolveConflict { object: &'a Expr<'a>, field: Symbol, value: &'a Expr<'a>, }, Check { subject: Symbol, predicate: Symbol, is_capability: bool, object: Option<Symbol>, source_text: String, span: Span, }, Listen { address: &'a Expr<'a>, }, ConnectTo { address: &'a Expr<'a>, }, LetPeerAgent { var: Symbol, address: &'a Expr<'a>, }, Sleep { milliseconds: &'a Expr<'a>, }, Sync { var: Symbol, topic: &'a Expr<'a>, }, Mount { var: Symbol, path: &'a Expr<'a>, }, LaunchTask { function: Symbol, args: Vec<&'a Expr<'a>>, }, LaunchTaskWithHandle { handle: Symbol, function: Symbol, args: Vec<&'a Expr<'a>>, }, CreatePipe { var: Symbol, element_type: Symbol, capacity: Option<u32>, }, SendPipe { value: &'a Expr<'a>, pipe: &'a Expr<'a>, }, ReceivePipe { var: Symbol, pipe: &'a Expr<'a>, }, TrySendPipe { value: &'a Expr<'a>, pipe: &'a Expr<'a>, result: Option<Symbol>, }, TryReceivePipe { var: Symbol, pipe: &'a Expr<'a>, }, StopTask { handle: &'a Expr<'a>, }, Select { branches: Vec<SelectBranch<'a>>, }, Theorem(TheoremBlock<'a>), Escape { language: Symbol, code: Symbol, span: Span, }, Require { crate_name: Symbol, version: Symbol, features: Vec<Symbol>, span: Span, },
}
Expand description

Imperative statement AST (LOGOS §15.0.0).

Stmt is the primary AST node for imperative code blocks like ## Main and function bodies. The Assert variant bridges to the Logic Kernel.

Variants§

§

Let

Variable binding: Let x be 5. or Let x: Int be 5.

Fields

§ty: Option<&'a TypeExpr<'a>>
§value: &'a Expr<'a>
§mutable: bool
§

Set

Mutation: Set x to 10.

Fields

§target: Symbol
§value: &'a Expr<'a>
§

Call

Function call as statement: Call process with data.

Fields

§function: Symbol
§args: Vec<&'a Expr<'a>>
§

If

Conditional: If condition: ... Otherwise: ...

Fields

§cond: &'a Expr<'a>
§then_block: Block<'a>
§else_block: Option<Block<'a>>
§

While

Loop: While condition: ... or While condition (decreasing expr): ...

Fields

§cond: &'a Expr<'a>
§body: Block<'a>
§decreasing: Option<&'a Expr<'a>>

Optional decreasing variant for termination proof.

§

Repeat

Iteration: Repeat for x in list: ... or Repeat for i from 1 to 10: ...

Fields

§pattern: Pattern
§iterable: &'a Expr<'a>
§body: Block<'a>
§

Return

Return: Return x. or Return.

Fields

§value: Option<&'a Expr<'a>>
§

Assert

Bridge to Logic Kernel: Assert that P.

Fields

§proposition: &'a LogicExpr<'a>
§

Trust

Documented assertion with justification. Trust that P because "reason". Semantics: Documented runtime check that could be verified statically.

Fields

§proposition: &'a LogicExpr<'a>
§justification: Symbol
§

RuntimeAssert

Runtime assertion with imperative condition Assert that condition. (for imperative mode)

Fields

§condition: &'a Expr<'a>
§

Give

Ownership transfer (move): Give x to processor. Semantics: Move ownership of object to recipient.

Fields

§object: &'a Expr<'a>
§recipient: &'a Expr<'a>
§

Show

Immutable borrow: Show x to console. Semantics: Immutable borrow of object passed to recipient.

Fields

§object: &'a Expr<'a>
§recipient: &'a Expr<'a>
§

SetField

Field mutation: Set p's x to 10.

Fields

§object: &'a Expr<'a>
§field: Symbol
§value: &'a Expr<'a>
§

StructDef

Struct definition for codegen.

Fields

§name: Symbol
§fields: Vec<(Symbol, Symbol, bool)>
§is_portable: bool
§

FunctionDef

Function definition.

Fields

§name: Symbol
§params: Vec<(Symbol, &'a TypeExpr<'a>)>
§body: Block<'a>
§return_type: Option<&'a TypeExpr<'a>>
§is_native: bool
§native_path: Option<Symbol>

Rust path for user-defined native functions (e.g., “reqwest::blocking::get”). None for system native functions (read, write, etc.) which use map_native_function().

§is_exported: bool

Whether this function is exported for FFI (C ABI or WASM).

§export_target: Option<Symbol>

Export target: None = C ABI (#[no_mangle] extern “C”), Some(“wasm”) = #[wasm_bindgen].

§

Inspect

Pattern matching on sum types.

Fields

§target: &'a Expr<'a>
§arms: Vec<MatchArm<'a>>
§has_otherwise: bool
§

Push

Push to collection: Push x to items.

Fields

§value: &'a Expr<'a>
§collection: &'a Expr<'a>
§

Pop

Pop from collection: Pop from items. or Pop from items into y.

Fields

§collection: &'a Expr<'a>
§

Add

Add to set: Add x to set.

Fields

§value: &'a Expr<'a>
§collection: &'a Expr<'a>
§

Remove

Remove from set: Remove x from set.

Fields

§value: &'a Expr<'a>
§collection: &'a Expr<'a>
§

SetIndex

Index assignment: Set item N of X to Y.

Fields

§collection: &'a Expr<'a>
§index: &'a Expr<'a>
§value: &'a Expr<'a>
§

Zone

Memory arena block (Zone). “Inside a new zone called ‘Scratch’:” “Inside a zone called ‘Buffer’ of size 1 MB:” “Inside a zone called ‘Data’ mapped from ‘file.bin’:”

Fields

§name: Symbol

The variable name for the arena handle (e.g., “Scratch”)

§capacity: Option<usize>

Optional pre-allocated capacity in bytes (Heap zones only)

§source_file: Option<Symbol>

Optional file path for memory-mapped zones (Mapped zones only)

§body: Block<'a>

The code block executed within this memory context

§

Concurrent

Concurrent execution block (async, I/O-bound). “Attempt all of the following:” Semantics: All tasks run concurrently via tokio::join! Best for: network requests, file I/O, waiting operations

Fields

§tasks: Block<'a>

The statements to execute concurrently

§

Parallel

Parallel execution block (CPU-bound). “Simultaneously:” Semantics: True parallelism via rayon::join or thread::spawn Best for: computation, data processing, number crunching

Fields

§tasks: Block<'a>

The statements to execute in parallel

§

ReadFrom

Read from console or file. Read input from the console. or Read data from file "path.txt".

Fields

§source: ReadSource<'a>
§

WriteFile

Write to file. Write "content" to file "output.txt".

Fields

§content: &'a Expr<'a>
§path: &'a Expr<'a>
§

Spawn

Spawn an agent. Spawn a Worker called "w1".

Fields

§agent_type: Symbol
§name: Symbol
§

SendMessage

Send message to agent. Send Ping to "agent".

Fields

§message: &'a Expr<'a>
§destination: &'a Expr<'a>
§

AwaitMessage

Await response from agent. Await response from "agent" into result.

Fields

§source: &'a Expr<'a>
§into: Symbol
§

MergeCrdt

Merge CRDT state. Merge remote into local. or Merge remote's field into local's field.

Fields

§source: &'a Expr<'a>
§target: &'a Expr<'a>
§

IncreaseCrdt

Increment GCounter. Increase local's points by 10.

Fields

§object: &'a Expr<'a>
§field: Symbol
§amount: &'a Expr<'a>
§

DecreaseCrdt

Decrement PNCounter (Tally). Decrease game's score by 5.

Fields

§object: &'a Expr<'a>
§field: Symbol
§amount: &'a Expr<'a>
§

AppendToSequence

Append to SharedSequence (RGA). Append "Hello" to doc's lines.

Fields

§sequence: &'a Expr<'a>
§value: &'a Expr<'a>
§

ResolveConflict

Resolve MVRegister conflicts. Resolve page's title to "Final".

Fields

§object: &'a Expr<'a>
§field: Symbol
§value: &'a Expr<'a>
§

Check

Security check - mandatory runtime guard. Check that user is admin. Check that user can publish the document. Semantics: NEVER optimized out. Panics if condition is false.

Fields

§subject: Symbol

The subject being checked (e.g., “user”)

§predicate: Symbol

The predicate name (e.g., “admin”) or action (e.g., “publish”)

§is_capability: bool

True if this is a capability check (can [action])

§object: Option<Symbol>

For capabilities: the object being acted on (e.g., “document”)

§source_text: String

Original English text for error message

§span: Span

Source location for error reporting

§

Listen

Listen on network address. Listen on "/ip4/127.0.0.1/tcp/8000". Semantics: Bind to address, start accepting connections via libp2p

Fields

§address: &'a Expr<'a>
§

ConnectTo

Connect to remote peer. Connect to "/ip4/127.0.0.1/tcp/8000". Semantics: Dial peer via libp2p

Fields

§address: &'a Expr<'a>
§

LetPeerAgent

Create PeerAgent remote handle. Let remote be a PeerAgent at "/ip4/127.0.0.1/tcp/8000". Semantics: Create handle for remote agent communication

Fields

§address: &'a Expr<'a>
§

Sleep

Sleep for milliseconds. Sleep 1000. or Sleep delay. Semantics: Pause execution for N milliseconds (async)

Fields

§milliseconds: &'a Expr<'a>
§

Sync

Sync CRDT variable on topic. Sync x on "topic". Semantics: Subscribe to GossipSub topic, auto-publish on mutation, auto-merge on receive

Fields

§topic: &'a Expr<'a>
§

Mount

Mount persistent CRDT from journal file. Mount counter at "data/counter.journal". Semantics: Load or create journal, replay operations to reconstruct state

Fields

§var: Symbol

The variable name for the mounted value

§path: &'a Expr<'a>

The path expression for the journal file

§

LaunchTask

Launch a fire-and-forget task (green thread). Launch a task to process(data). Semantics: tokio::spawn with no handle capture

Fields

§function: Symbol

The function to call

§args: Vec<&'a Expr<'a>>

Arguments to pass

§

LaunchTaskWithHandle

Launch a task with handle for control. Let worker be Launch a task to process(data). Semantics: tokio::spawn returning JoinHandle

Fields

§handle: Symbol

Variable to bind the handle

§function: Symbol

The function to call

§args: Vec<&'a Expr<'a>>

Arguments to pass

§

CreatePipe

Create a bounded channel (pipe). Let jobs be a new Pipe of Int. Semantics: tokio::sync::mpsc::channel(32)

Fields

§var: Symbol

Variable for the pipe

§element_type: Symbol

Type of values in the pipe

§capacity: Option<u32>

Optional capacity (defaults to 32)

§

SendPipe

Blocking send into pipe. Send value into pipe. Semantics: pipe_tx.send(value).await

Fields

§value: &'a Expr<'a>

The value to send

§pipe: &'a Expr<'a>

The pipe to send into

§

ReceivePipe

Blocking receive from pipe. Receive x from pipe. Semantics: let x = pipe_rx.recv().await

Fields

§var: Symbol

Variable to bind the received value

§pipe: &'a Expr<'a>

The pipe to receive from

§

TrySendPipe

Non-blocking send (try). Try to send value into pipe. Semantics: pipe_tx.try_send(value) - returns immediately

Fields

§value: &'a Expr<'a>

The value to send

§pipe: &'a Expr<'a>

The pipe to send into

§result: Option<Symbol>

Variable to bind the result (true/false)

§

TryReceivePipe

Non-blocking receive (try). Try to receive x from pipe. Semantics: pipe_rx.try_recv() - returns Option

Fields

§var: Symbol

Variable to bind the received value (if any)

§pipe: &'a Expr<'a>

The pipe to receive from

§

StopTask

Cancel a spawned task. Stop worker. Semantics: handle.abort()

Fields

§handle: &'a Expr<'a>

The handle to cancel

§

Select

Select on multiple channels/timeouts. Await the first of: Receive x from ch: ... After 5 seconds: ... Semantics: tokio::select! with auto-cancel

Fields

§branches: Vec<SelectBranch<'a>>

The branches to select from

§

Theorem(TheoremBlock<'a>)

Theorem block. ## Theorem: Name Given: Premise. Prove: Goal. Proof: Auto.

§

Escape

Escape hatch: embed raw foreign code. Escape to Rust: followed by an indented block of raw code.

Variables from the enclosing LOGOS scope are available in the escape block as their generated Rust types. The raw code is emitted verbatim inside a { ... } block in the generated Rust.

Fields

§language: Symbol

Target language (“Rust” for now, forward-compatible with “Python”, “WGSL”, etc.)

§code: Symbol

Raw foreign code, captured verbatim with base indentation stripped.

§span: Span

Source span covering the entire escape block (header + body).

§

Require

Dependency declaration from ## Requires block. The “serde” crate version “1.0” with features “derive”.

Fields

§crate_name: Symbol
§version: Symbol
§features: Vec<Symbol>
§span: Span

Trait Implementations§

Source§

impl<'a> Clone for Stmt<'a>

Source§

fn clone(&self) -> Stmt<'a>

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<'a> Debug for Stmt<'a>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl<'a> Freeze for Stmt<'a>

§

impl<'a> RefUnwindSafe for Stmt<'a>

§

impl<'a> Send for Stmt<'a>

§

impl<'a> Sync for Stmt<'a>

§

impl<'a> Unpin for Stmt<'a>

§

impl<'a> UnwindSafe for Stmt<'a>

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

§

fn vzip(self) -> V