Expand description
Lossless lexer for LaTeX surface syntax.
The lexer recognizes only bounded modes whose delimiters are visible in the source, including verbatim regions and explicit catcode toggles.
Structs§
- LexConfig
- The lexer’s per-parse mode.
flavorfixes the initial catcode regime (a.sty/.clsstarts under an implicit\makeatletter), whiledtxis an orthogonal axis: when set, the lexer runs the bounded line-oriented docstrip mode for a.dtxfile — line-leading%margins becomeDOC_MARGINtrivia, line-leading%<…>guards becomeGUARDtrivia, andmacrocodebodies lex as ordinary code (AGENTS.mddecision #1). The two axes are independent because a.dtx’s catcode regime varies by layer (its documentation isDocument-flavored, itsmacrocodePackage-flavored), sodtxcannot be folded into aLatexFlavorvariant. - Parse
Ctx - Per-parse facts discovered from definitions or project declarations.
- Token
- A single lexed token: its kind plus the exact source slice it covers.
Enums§
- Expl
Toggle - An expl3 lexer-mode transition.
- Latex
Flavor - The LaTeX file flavor, fixing the lexer’s initial catcode regime. A
document (
.tex) starts in the ordinary regime; a package or class (.sty/.cls) is loaded under an implicit\makeatletter, so@is a letter from the first byte. A trailing explicit\makeatotherstill applies.
Functions§
- expl_
toggle - Returns the expl3 transition named by a control word.
- is_
control_ word_ name - Returns whether
namecan be a control word in any supported mode. - is_
word_ char - Returns whether
cbelongs to an ordinary text token. - lex
- Lexes a document into a lossless token stream.
- lex_
with - Lexes with per-parse facts and an explicit file configuration.