Skip to main content

Meta

Enum Meta 

pub enum Meta {
    Empty,
    Poisoned,
    Pending(Box<PendingMeta>),
    Positioned {
        span: MaybeSpan,
        container: MaybeSpan,
    },
}
Expand description

Node position info under propagate_positions. Not a generic Tree<M>.

A node has no positions (Empty/Poisoned), or a Positioned pair of spans whose fields may be individually unknown — lark stamps a positionless Token contribution as None positions with empty = False. (Before the Nullable variant was folded in, the 12 fields were set both-or-neither and the nullable case was a separate boxed variant.)

Variants§

§

Empty

§

Poisoned

Empty because the span scan hit an opaque transform value (a synchronous hook’s NodeValue::Foreign, or an Earley transform Handle) before both endpoints resolved: Lark might have stamped this node from the callback’s positioned result — undecidable in-engine and never resolved later (no drain exists for these values). Surfaces to every consumer exactly like Empty; it exists so an ancestor’s scan treats this node as endpoint-UNKNOWN (poison is transitive) instead of skipping it like a genuinely positionless child and stamping non-Lark values from a sibling. Since the batching binding resolves Handle spans exactly (Meta::Pending), this residual is core-only: no shipped binding produces mid-parse Foreigns under propagate_positions (Python is batching-only; WASM/C have no transformer), and Earley+transformer is rejected in every binding.

§

Pending(Box<PendingMeta>)

A LALR transform-mode meta whose endpoints depend on callback results still unfilled at reduce time: the binding resolves it — exactly lark’s PropagatePositions walk — once the slots are drained (resolve_pending_metas; at a crossing’s consuming drain or at parse finish). Unresolved Pending surfaces like Empty (defensive; a returned tree never carries one reachable).

§

Positioned

A resolved meta: the node’s own span plus the container span lark’s PropagatePositions widens.

Individual fields may be unknown (MaybePos is SentinelOption-backed), because lark stamps a positionless Token contribution as None positions with empty = False. That case used to be a separate Nullable variant holding a boxed [Option<u32>; 12] addressed by base-offset constants; folding it in here costs nothing (Meta is 56 bytes either way) and drops the box, since nullability is free in MaybeSpan.

Fields

§container: MaybeSpan

Implementations§

§

impl Meta

pub fn resolved_spans(&self) -> Option<(Span, Span)>

The plain and container spans with every field known, or None when this meta has no position at all (Empty/Poisoned/unresolved Pending) or any field is unknown.

This is the view the flat 12-field consumers want — marshals, canonicalisers, lark-attribute setters. None is exactly the set of metas they used to render as empty: true (the old Nullable variant included), so matching on it preserves their output verbatim.

Trait Implementations§

§

impl Clone for Meta

§

fn clone(&self) -> Meta

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 Meta

§

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

Formats the value using the given formatter. Read more
§

impl Eq for Meta

§

impl PartialEq for Meta

§

fn eq(&self, other: &Meta) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
§

impl StructuralPartialEq for Meta

Auto Trait Implementations§

§

impl Freeze for Meta

§

impl RefUnwindSafe for Meta

§

impl Send for Meta

§

impl Sync for Meta

§

impl Unpin for Meta

§

impl UnsafeUnpin for Meta

§

impl UnwindSafe for Meta

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.