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.
Implementations§
§impl Meta
impl Meta
pub fn resolved_spans(&self) -> Option<(Span, Span)>
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.