pub struct Gullet {
pub runtime: Option<MouthRuntime>,
pub mouthstack: VecDeque<MouthRuntime>,
pub pending_comments: VecDeque<Token>,
pub token_limit: Option<usize>,
pub pushback_limit: Option<usize>,
pub progress: usize,
pub cycle_guard_activate: usize,
pub cycle_guard: CycleGuard,
pub ctx_serial: u64,
/* private fields */
}Fields§
§runtime: Option<MouthRuntime>§mouthstack: VecDeque<MouthRuntime>§pending_comments: VecDeque<Token>§token_limit: Option<usize>§pushback_limit: Option<usize>§progress: usize§cycle_guard_activate: usizeToken-progress floor above which cycle_guard
engages. Defaults to CYCLE_GUARD_ACTIVATE (20M). Graphics packages
whose healthy expansion legitimately runs to 100M+ tokens (pgf/tikz/xy)
raise it via raise_cycle_guard_activate so their streams stay out of
the per-token fingerprint regime; the 400M token_limit remains the hard
backstop. #[derive(Default)] would zero this (guard-always-on), so it is
set explicitly in the constructor and the per-conversion reset.
cycle_guard: CycleGuardWindowed cycle detector over the expansion (read-token) stream — catches
small-period infinite expansion loops (\def\x{a\x} etc.) far earlier
and more cheaply than token_limit/pushback_limit. Gated on a high
progress so normal documents never touch it. See crate::cycle_guard.
ctx_serial: u64Reading-context serial, mixed into every cycle-guard fingerprint so that
windows never match ACROSS reading_from_mouth contexts: a cycle is only
a cycle within one expansion context. Each reading_from_mouth entry
allocates a fresh serial (from ctx_next) and restores the outer one on
exit (ctx_stack), so (a) consecutive IDENTICAL short expansions — the
math0402448 xymatrix per-cell get_xmarg_id stream — get distinct
serials and can never concatenate into a pseudo-periodic window (the
false positive an earlier blanket reset() suppressed), while (b) an
OUTER loop’s tokens keep their serial across inner expansions, so a
runaway whose body calls do_expand each iteration (~164 call sites)
remains detectable — the blind spot the blanket reset had (PR #249
review P2-7).