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 one — finish_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)
Index into ParsedTree::token_arena.
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.