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§
Functions§
- apply_
memory_ ceiling - Apply the single
--max-memoryceiling (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. Ifnoframeis 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 explicitnoframeoption. Whennoframeis 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
Listafter 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 ifstomachis not currently inmode. This also ends a level of grouping. Perl: sub endMode (Stomach.pm lines 522-541) - end_
mode_ opt - Like
end_mode, but with an explicitnoframeoption. Whennoframeis 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 abovenbytes. Precedence: the explicitset_memory_capoverride, elseLATEXML_RSS_CAP_BYTES, else the 4.5 GB default. A cap of0from EITHER source resolves toNone, so--max-memory=0/LATEXML_RSS_CAP_BYTES=0mean “no limit” — not “abort immediately” (a literal0compared asrss_bytes > 0is always true). - salvage_
pending_ box_ lists - Recover the boxes a failed
digest_next_bodyleft stranded, in document order, and reset the accumulation stack. - set_
fragment_ yield_ budget - Ask digestion to yield at legal fragment seams once
budgetboxes have accumulated at the current level (Nonerestores 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 atnbytes;Nonerestores theLATEXML_RSS_CAP_BYTESenv / built-in default. Mirrors the--max-memoryCLI convention where0means “no limit”. Seeresolve_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-memoryceiling (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.0in →0out (disabled), so--max-memory=0disables the whole memory limit. This keeps--max-memorythe 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::varthere 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-memoryknob, 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_bodyreturn 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.