Skip to main content

NodeValue

Enum NodeValue 

pub enum NodeValue {
    Token(TokenArenaIdx),
    Tree(Tree),
    None,
    Splice(Vec<NodeValue>, SpliceSpan),
    Foreign(ForeignValue),
    Handle(Handle),
}
Expand description

A parse-tree node value. Splice is a reduce-time intermediate produced and drained inside the LALR engine (LALR-private). The engine never returns onefinish_parse re-wraps a root Splice and a debug_assert guards it (lalr/state.rs). The variant is pub only because this enum is shared cross-engine; a hand-built ParsedTree containing a Splice is unsupported input that violates the tree walkers’ expectations (they may panic).

Variants§

§

Token(TokenArenaIdx)

§

Tree(Tree)

§

None

A maybe_placeholders hole — materializes to Lark’s None child.

§

Splice(Vec<NodeValue>, SpliceSpan)

Reduce-time intermediate for _-transparent left recursion (LALR-private; see the invariant above). The SpliceSpan carries the _-rule’s container span so the draining parent inherits it exactly as Lark reads the spliced Tree(_rule)’s meta; None in off-mode or when the _-rule is positionless.

§

Foreign(ForeignValue)

A binding-produced opaque value from a reduce-time ReduceCallback (Lark’s embedded transformer= returns arbitrary host objects, not trees). Present only under a transform parse; the default (tree-building) parse never produces one. It is an opaque leaf to the engine: it carries no position (propagate_positions treats it as None) and cannot be drained by a _-splice parent — a splice rule whose callback returns a Foreign is Lark’s AttributeError('... has no attribute children'), surfaced here as ParseError::Callback.

§

Handle(Handle)

A Copy placeholder a BATCHING ReduceCallback returns instead of a materialized value: the hook enqueued the reduction and will produce the real host value at a later drain; the payload is a binding-private slot index. The engine NEVER interprets it, with one sanctioned exception: a to_expand (_-splice) child position cannot be drained before the slot is filled, so drain_hook_return passes the handle through with Handle::with_splice_flag set — the binding expands that child’s .children at drain time (Lark’s filtered += child.children). Like Foreign, it is transform-only, positionless, and never appears in a returned tree (the binding resolves the root handle after its final flush). Payload is a u32 Handle, so the variant costs nothing in the 32-byte NodeValue layout.

Trait Implementations§

§

impl Clone for NodeValue

§

fn clone(&self) -> NodeValue

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

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

Performs copy-assignment from source. Read more
§

impl Debug for NodeValue

§

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

Formats the value using the given formatter. Read more

Auto Trait Implementations§

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 = !

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.