Struct RouteSet
pub struct RouteSet { /* private fields */ }Expand description
Which reductions still call the user’s ReduceCallback vs. build natively
— a transform pays the callback (host-boundary) cost only for rules the user
customized; the rest build as a plain parse. Keyed by display (a rule’s
callback identity — aliased alternatives get their own; design A1), not rule
id. A hooked display fires the callback; the rest take the native
BuildTree/splice arms in apply_shape — no hook call (children still build,
into the arena or a Splice). Built once by RouteSet::build; fetched per
parse via ReduceCallback::routes (None = all hooked, today’s behavior).
It also carries the per-terminal token-callback mask (hooked_tokens),
so the shift anchor ([ParserState::shift_token]) can gate
ReduceCallback::token_shifted off the same fetched object. The mask is
routing-independent — it can be non-empty while every display is un-hooked —
so a binding must install the RouteSet whenever either is non-trivial
(see all_hooked).
Implementations§
§impl RouteSet
impl RouteSet
pub fn build(
table: &ParseTable,
user_hooked: &[bool],
hooked_tokens: &[bool],
) -> RouteSet
pub fn build( table: &ParseTable, user_hooked: &[bool], hooked_tokens: &[bool], ) -> RouteSet
Build the route mask (core owns grammar-shape knowledge): seed hooked
from user_hooked, and carry the token-callback mask verbatim.
user_hooked[display_id]: a user callable resolves (or__default__overridden — then alltrue). Never a splice display: the binding rejects user attributes on those at construction (ConfigurationError, ruling 2026-07-12); a violation isdebug_asserted here.hooked_tokens[token_id]: a token callback for this terminal. It fires at the SHIFT anchor (seeRouteSet/ReduceCallback::token_shifted), NOT by forcing a routing crossing, so it does not touchhooked— it is stored and read per shift. (Before the shift-time move it demoted any display keeping the terminal onto the callback path; that scheme, and its all-hooked fallback for a token callback landing inside a_-rule, are gone — the token’s Handle now flows through the native splice/build arms untouched.)
With user_hooked the only seed of hooked, a splice display is never
hooked (hooked && splice is unreachable), so the debug guards below hold
unconditionally.
pub fn all_hooked_with_token_mask(
n_displays: usize,
hooked_tokens: &[bool],
) -> RouteSet
pub fn all_hooked_with_token_mask( n_displays: usize, hooked_tokens: &[bool], ) -> RouteSet
The all-hooked routing carrying only the shift-anchor token mask — the
__default__-overridden case. Every display fires the hook (the mask is
all-true, so Self::is_hooked is true everywhere and no display is
native), routing identically to routes == None
([crate::lalr]’s transform_is_hooked); the only difference is that
hooked_tokens rides along so terminal callbacks still reach the shift
anchor. Unlike Self::build it seeds no per-display mask and runs no
no-hooked-splice check — all-hooked legitimately fires splice displays,
which build’s assert (and the binding’s construction-time rejection)
forbid for the per-display path. Self::is_inert is false iff the mask
is non-empty, so a binding installs it only when a callback exists.
pub fn is_hooked(&self, display_id: DisplayId) -> bool
pub fn is_hooked(&self, display_id: DisplayId) -> bool
Does display_id’s reduce fire the hook? Out-of-range ids (the Earley
ambiguity sentinels can never reach a transform parse, but defensively)
stay hooked.
pub fn all_hooked(&self) -> bool
pub fn all_hooked(&self) -> bool
true when every display is hooked (the display route table is inert —
every reduce fires the hook regardless). Display-only by design; a live
token mask does not affect it. Use Self::is_inert to decide whether
the whole RouteSet can be dropped.
pub fn is_inert(&self) -> bool
pub fn is_inert(&self) -> bool
true when the object carries no information a parse needs — every
display hooked AND no terminal callback. A binding may skip installing
the RouteSet iff this holds; installing on !is_inert() keeps the
shift anchor’s token mask alive even when all_hooked() (e.g.
__default__ overridden with a token callback present).
pub fn hooked_tokens(&self) -> &[bool]
pub fn hooked_tokens(&self) -> &[bool]
The per-terminal token-callback mask — the shift anchor
([ParserState::shift_token]) gates ReduceCallback::token_shifted on
hooked_tokens()[type_id].