Skip to main content

Module token

Module token 

Source
Expand description

The Token and its Catcode

Structs§

FieldCover
A cover of a field’s stored value: the positions start..end (end exclusive) of one field (field, 0 = none) that an invocation consumed, its own position and its arguments. See field_cover_pending_merge.
FieldLedgerEntry
One entry of the field ledger (field_ledger_push): the cover of a box digested from a field token, and whether the structure the print is set in took the box instead of the document absorbing it (field_ledger_take).
FieldLedgerScope
A stretch of digestion the document never keeps (a rehearsal of a frontmatter field’s value, latexml_engine’s frontmatter observer), over which the field ledger records (field_ledger_live, even once the placement settled it) and after which it is as it was: the entries pushed meanwhile are dropped, the pending cover and the settled flag put back, and the gate of field stamping (document::field_prov_stamped: a \title the rehearsal stamps) as it was (on drop). Its serials are read while it is open (field_ledger_entry); a print the document makes later is numbered as if it had never run.
Token
The core immutable syntactic primitive resulting from TeX’s read-in and expansion process We allow the fields to be public, so that we can use builder macros such as

Enums§

Catcode
A Token category code, as in TeX
FieldInvocation
What a field token’s invocation did (FieldNotesHook), now that it read what it reads.

Constants§

AUTHOR_PROV_POS_MASK
The author field (2) is the top bit alone, the id 3 being none: its positions take 15 bits, so a call’s own positions (the frontmatter observer’s rehearsal of one author block, positions per call) reach 32,767 — a block of 559 names past the 16,383 the stamps take (2204.09614, 2404.06718). The stamps’ tokens below 16,384 read as before.
FIELD_PROV_POS_BITS
====================================================================== Accessors. The bits of a Token::prov below the field: the token’s position in the field’s stored value (saturating).
FIELD_PROV_POS_MASK
The largest position a field’s stamps take, cumulative per document (\lx@field@mark, \lx@field@stamp).
NOEXPAND_PREFIX
Name of the bare no-op control sequence \noexpand collapses to, and the prefix of every member of the no-expand family. See Token::is_noexpand_family.
NOEXPAND_SEP
Separator byte between the \special_relax prefix and the shadowed token’s text in a family token’s name. \x01 is never valid in a CS name or active char, so \special_relax\x01\foo is unambiguous and cannot collide with a real CS such as a (hypothetical) \special_relaxfoo.

Statics§

TOKEN_ALIGN
constant for an ALIGN “&” token
TOKEN_BEGIN
constant for a BEGIN “{” token
TOKEN_CR
constant for a CR “\n” token
TOKEN_END
constant for an END “}” token
TOKEN_ENDCSNAME
constant for T_CS(“\endcsname”)
TOKEN_EXPANDAFTER
constant for T_CS(“\expandafter”)
TOKEN_MATH
constant for a MATH “$” token
TOKEN_PARAM
constant for a PARAM “#” token
TOKEN_RELAX
constant for T_CS(“\relax”)
TOKEN_SPACE
constant for a SPACE “ “ token
TOKEN_SUB
constant for a SUB “_” token
TOKEN_SUPER
constant for a SUPER “^” token

Functions§

field_cover_pending
The pending cover of a boxless invocation (field_cover_pending_merge).
field_cover_pending_merge
Merge cover with the pending cover of a boxless invocation when they touch (the same field, cover starting inside or at the end of the pending one), clearing the pending cover either way: what a box digested from a field token covers of its stored value.
field_cover_set_pending
Leave cover pending for the next box of its field (field_cover_pending_merge), merged with the pending one it continues.
field_ledger_cover
The positions of field field’s value covered by the ledger entries with the serials in serials (inclusive first..=last intervals): sorted disjoint start..end intervals, merged where they touch.
field_ledger_entry
The entry the field ledger recorded with serial (field_ledger_push).
field_ledger_live
Is the field ledger recording (field_ledger_settle)? The stomach records a field token’s box only while it is.
field_ledger_push
Record the cover of a box digested from a field token (the field ledger); its serial, the box’s fieldSerial.
field_ledger_settle
Stop recording field covers: the frontmatter placement settled the field ink (no run is marked after it).
field_ledger_take
Note that the structure a print is set in took the box recorded with serial (an alignment’s row-end marker, a value’s \\): no run absorbs it, and the run its row ends may cover it (FieldLedgerEntry::taken).
field_notes_hook
The hook FieldNotesHook names, while one is set.
field_prov
The field provenance of the token at pos of field field’s stored value (field 1 or 2; 0 is no field).
field_prov_field
The field of a Token::prov (0 = none).
field_prov_pos
The position in its field’s stored value of a Token::prov.
inherit_field_prov
The expansion of a token with a field provenance (prov, Token::prov) is that field’s too: each of its tokens without a provenance of its own takes prov (an \and in \@author expands to ink of the author field). A no-op for prov 0, the case of every token outside a frontmatter field’s store.
noexpand_family
Build the no-expand family token shadowing shadowed — the per-token, dump-safe representation of \noexpand <shadowed> (faithful to TeX’s no_expand_flag: the shadowed identity is preserved in the name; the family resolves to \relax meaning). shadowed is an expandable/undefined CS or active token (the only things \noexpand wraps; see is_dont_expandable).
reset_field_cover_pending
Clear the pending field cover and the ledger, and record again (conversion start).
reset_noexpand_family_memo
Clear the Token::is_noexpand_family per-symbol memo. Companion to arena::reset() — symbol indices are reused after a reset, so stale entries would alias unrelated strings (same bug class as the REPORT-map fix, 7b64a48ad1). The storage is freed, not only emptied: a leaked per-thread static has no destructor, so what a reset keeps would outlive a thread that exits (the memo runs to megabytes, one byte per arena byte).
set_field_notes_hook
Set (or, with None, clear) the hook FieldNotesHook names.

Type Aliases§

FieldNotesHook
What runs on each field token’s invocation while a rehearsal takes notes on what its boxes do not hold (the frontmatter observer’s field_notes, in the engine): Token::prov’s test in the stomach, then this. All the core knows of them, so no line of theirs sits among the code the core’s hot path is inlined from (Z01: the same lines here cost a text document 0.17 % of instructions:u with no call made, a reshuffle of the crate’s codegen units).