Skip to main content

Module stomach

Module stomach 

Source
Expand description

The stomach is an abstraction responsible for digesting Tokens and Registers prepared by the Gullet into Boxes

Structs§

Stomach
The Stomach is responsible for digesting tokens into boxes, lists, etc.

Statics§

STOMACH

Functions§

apply_memory_ceiling
Apply the single --max-memory ceiling (MiB) to this thread’s cooperative soft fuse, so the one knob means the same thing on every conversion path.
begin_mode
Begin processing in mode; one of “text”, “display-math” or “inline-math”. This also begins a new level of grouping and switches to a font appropriate for the mode. If noframe is true, skip pushing a stack frame (e.g. for \begin{document}). Perl: sub beginMode (Stomach.pm lines 474-517)
begin_mode_opt
Like begin_mode, but with an explicit noframe option. When noframe is true, no stack frame is pushed (the caller already did bgroup).
begingroup
Begin a new level of binding by pushing a new stack frame.
bgroup
Begin a new level of binding by pushing a new stack frame, and a new level of boxing the digested output.
check_timeout
Check if conversion has timed out. Returns Err if deadline exceeded.
clone_box_list
current_frame_message
explain the current frame
digest
Digest a list of tokens independent from any current Gullet. Typically used to digest arguments to primitives or constructors. Returns a List containing the digested material.
digest_next_body
Return the digested List after reading and digesting a body from the its Gullet. The body extends until the current level of boxing or environment is closed.
egroup
End a level of binding by popping the last stack frame, undoing whatever bindings appeared there, and also decrementing the level of boxing.
end_mode
End processing in mode; an error is signalled if stomach is not currently in mode. This also ends a level of grouping. Perl: sub endMode (Stomach.pm lines 522-541)
end_mode_opt
Like end_mode, but with an explicit noframe option. When noframe is true, executeBeforeAfterGroup is run but the stack frame is not popped.
endgroup
End a level of binding by popping the last stack frame, undoing whatever bindings appeared there.
enter_horizontal
Switch to horizontal mode without stacking the mode. Can only switch from vertical|internal_vertical to horizontal. Perl: sub enterHorizontal
execute_before_after_group
Execute tokens stored on beforeAfterGroup (if any); done before popping a stack frame. Perl: sub executeBeforeAfterGroup (Stomach.pm lines 286-295)
expire_local_box_list
extend_box_list
fragment_yield_count
How many times digestion has yielded since the budget was last set.
get_boxing_level
get the current boxing level
get_script_level
ScriptLevel is similar to boxing level, but relative to current Math mode’s level
initialize_stomach
Initialize various stomach parameters, preload, etc.
invoke_token
Invoke a token
last_sampled_rss_kb
The most recent sampled RSS in KiB (0 until the first sample).
leave_horizontal
Resume vertical mode by executing \par, in TeX-like fashion. Perl: sub leaveHorizontal
leave_horizontal_internal
Resume vertical mode internally: reset mode without firing \par. Used within argument digestion, e.g. endMode for vertical modes. Perl: sub leaveHorizontal_internal
new_local_box_list
pop_box_list
pop_stack_frame
Removes the last/current stack frame, ending a TeX group
push_box_list
push_stack_frame
Adds a new stack frame for a TeX group.
raw_tex
a convenience function for including chunks of raw TeX (or LaTeX) code It is useful for copying portions of the normal implementation that can be handled simply using macros and primitives.
regurgitate
steal the previously digested boxes from the current level.
repack_horizontal
Repack recently digested horizontal items into single horizontal List. Note that TeX would have done paragraph line-breaking, resulting in essentially a vertical list. Perl: sub repackHorizontal (Stomach.pm lines 440-454)
resolve_rss_cap
Resolve the effective soft-RSS budget: None = disabled (no ceiling), Some(n) = abort above n bytes. Precedence: the explicit set_memory_cap override, else LATEXML_RSS_CAP_BYTES, else the 4.5 GB default. A cap of 0 from EITHER source resolves to None, so --max-memory=0 / LATEXML_RSS_CAP_BYTES=0 mean “no limit” — not “abort immediately” (a literal 0 compared as rss_bytes > 0 is always true).
salvage_pending_box_lists
Recover the boxes a failed digest_next_body left stranded, in document order, and reset the accumulation stack.
set_fragment_yield_budget
Ask digestion to yield at legal fragment seams once budget boxes have accumulated at the current level (None restores eager digestion). Set by the streaming pass-1 driver; the budget is a box COUNT — the driver derives it from the byte ceiling via the measured per-box footprint, the same basis as the box-list guards.
set_fragment_yield_rss_soft_kb
Set (or clear) the soft-RSS yield threshold, in KiB.
set_memory_cap
Override the cooperative soft-RSS memory budget, in bytes. Some(0) disables the budget; Some(n) caps at n bytes; None restores the LATEXML_RSS_CAP_BYTES env / built-in default. Mirrors the --max-memory CLI convention where 0 means “no limit”. See resolve_rss_cap (private) for the precedence order.
set_mode
Sets the mode without doing any grouping (NOR does it stack the modes!!)
set_soft_yield_min_boxes
Minimum boxes that must accumulate before the soft-RSS yield branch may fire (the box-budget branch is unaffected and still yields on its own).
set_stomach
set_timeout
Set a conversion timeout (seconds from now). 0 = no timeout.
soft_cap_from_ceiling
Derive the cooperative soft-RSS budget (bytes) from the hard --max-memory ceiling (MiB). The soft fuse sits at 75% of the ceiling, leaving ~25% headroom for the post-processing phase (libxml DOM + XSLT) that runs above digestion and which this cooperative guard cannot see. 0 in → 0 out (disabled), so --max-memory=0 disables the whole memory limit. This keeps --max-memory the single knob: the hard Watchdog rides the ceiling, this fuse rides a fixed fraction below it — no independent second number.
soft_yield_min_boxes
Cached: this sits on the per-seam yield predicate, which the 131 MB witness evaluates tens of millions of times — an std::env::var there would be its own hotspot.
spill_watermark_bytes
The RAM watermark, in bytes, at which streaming pass 1 begins spilling closed subtrees to disk — the second derived quantity of the single --max-memory knob, and deliberately NOT a flag of its own (a watermark a user could raise above the fuse would Fatal before it ever spilled).
take_fragment_yielded
Did the last digest_next_body return because of the yield budget (rather than EOF / terminal / depth-drop)? Read-and-clear.
with_box_list
with_box_list_mut
with_box_list_mut_vec
Access to the current box_list as a &mut Vec — allows push/pop operations.