Skip to main content

Module expl3

Module expl3 

Source
Expand description

The expl3 call-site model: argspec arity for expl3 function names, and the statement segmentation built on it.

Two halves, both semantics layered on the syntax tree (like define’s definition scan): expl3_slots derives per-slot arity from the letters after the final : in \cs_new:Npn, \tl_if_empty:nTF, …, and segment_expl_statements applies it to an in-region element stream to produce the statement model the formatter’s expl3 layout consumes. Neither builds Ir or touches layout policy — a wrong answer here can only produce ugly formatting downstream, never a wrong tree or a lost byte.

Like xparse, the argspec is parsed rather than executed: each letter describes an argument’s call-site shape. No signature database is involved: the name string alone carries the spec, so there is nothing to curate and nothing to drift. Only meaningful inside an expl3 region, where :/_ are catcode-11 and the whole name lexes as one CONTROL_WORD — callers of the segmentation guarantee the stream is in-region (out-of-region, colon names lex split and everything degrades to the fallback).

The letter-by-letter model (interface3’s argument specifiers):

  • N, VExpl3Slot::SingleToken: one token, typically a control sequence (V differs from N only in expansion, not call-site shape).
  • n, c, v, o, x, e, fExpl3Slot::Group: one braced {…} group (again, the letters differ only in how the material is processed, which we never model).
  • T, FExpl3Slot::Branch: a braced conditional branch. Sanctioned only as a trailing run — in a standard argspec T/F are always last, so a mid-spec T/F is treated as unknown.
  • pExpl3Slot::ParameterText: TeX parameter text (#1#2…), which has no fixed token count but a static end: TeX’s own rule that the parameter text runs to the first explicit {. The consumer scans by that shape.
  • w (arbitrary delimiters) and D (kernel primitive) have no lexically derivable call-site shape → the whole name is unrecognized (None), as is any unknown letter (including one added to expl3 after this list was written — new letters degrade to unrecognized, never to a wrong arity).

Structs§

Expl3Unit
The span and conditional branches of one parsed expl3 unit.
StatementMap
Statement boundaries and attachment flags for an expl3 element stream.

Enums§

Expl3Slot
The call-site shape of one expl3 argument slot, derived from an argspec letter.

Functions§

conditional_branches
The number of trailing T/F branch arguments of an expl3 conditional, read from the command name’s argspec (the substring after the final :). \tl_if_empty:nTFSome(2), \bool_if:nT/:nFSome(1); None for any name without a :-argspec ending in T/F — a non-conditional expl3 function (\seq_new:N), or a LaTeX2e command with no colon (\@ifpackageloaded). In an expl3 argspec T/F denote only the true/false branch slots, so a trailing T/F run is exactly the branch count.
expl3_slots
The argument slots of an expl3 function name, read from its argspec suffix (the substring after the final :), or None when the name has no derivable call-site arity.
expl3_unit
Resolves the expl3 unit beginning at head_idx.
segment_expl_statements
Segments an expl3 element stream into statements.