Skip to main content

parse

Function parse 

Source
pub fn parse(input: &str) -> Parse
Expand description

Parse LaTeX source into a lossless CST.

A bounded two-pass parse handles user-defined verbatim-argument commands (\newcommand/xparse definitions that other a special char’s catcode — see crate::semantic::define): the lexer needs to know such commands before it tokenizes their call sites, but they are only discoverable from the parsed tree. So pass 1 parses with built-in verbatim knowledge only, scans the result for catcode-verbatim definitions, and — only when it finds any — pass 2 re-parses with those commands fed into the lexer so their arguments become opaque VERB tokens. Two passes is a conservative bound: a definition visible only after the second pass’s re-tokenization is a tolerated false negative. The common case is a single parse.