Skip to main content

Module parser

Module parser 

Source
Expand description

The lexer, the event-stream parser, and the green-tree builder.

The pipeline follows rust-analyzer: lex produces a flat token stream, the parser emits a flat list of [events::Event]s, and [tree_builder::build_tree] turns tokens + events into a rowan green tree, re-attaching trivia along the way.

Re-exports§

pub use core::Parse;
pub use core::SyntaxError;
pub use core::parse;
pub use core::parse_with_flavor;
pub use core::reconstruct;
pub use lexer::LatexFlavor;
pub use lexer::LexConfig;
pub use lexer::Token;
pub use lexer::lex;

Modules§

core
The parser entry point and its output type.
lexer
A total, lossless lexer for LaTeX surface syntax.

Functions§

is_def_prefix_command
The TeX \def-family primitives, whose next token is always the control sequence being (re)defined. A control-symbol name would otherwise be misparsed as live syntax — \def\[{…}/\def\]{…} (a document class restyling display math, stacks-project issue #65) reads as a math opener, \def\\{…} as a line break — so [Parser::command] consumes it as a plain token inside the \def’s node. A control-word name already parses benignly as a generic command and keeps its current shape. A closed, curated set read as a static fact, mirroring [is_definition_body_command]; the definition is never executed.