Module texlang::parse

source ·
Expand description

Logic for parsing elements of the TeX grammar from token streams.

This parsing module is based around the Parsable trait, which is the most important type in the module. This trait is implemented by Rust types that correspond to elements of the TeX grammar. The trait implementation provides a way to parse grammar elements out of the input stream.

The module contains implementations of Parsable for tuples where each element is parsable. This allows expressions like <integer><relation><integer> to be parsed by one invocation of Parsable::parse, in this case on the type (i32, std::cmp::Ordering, i32).

The second most important thing is the collection of custom Rust types like OptionalBy and FileLocation which correspond to Rust grammar elements.

Finally this module contains some functions for special situation like parsing lists of tokens.

Structs

  • Representation of a file location in TeX
  • When parsed, this type consumes an optional by keyword from the input stream.
  • When parsed, this type consumes an optional equals from the token stream.
  • When parsed, this type consumes an optional equals from the token stream without performing expansion.
  • When parsed, this type consumes an arbitrary number of spaces from the unexpanded input stream
  • When parsed, this type consumes a required to keyword from the input stream.

Traits

  • Implementations of this trait are elements of the TeX grammar than can be parsed from a stream of tokens.

Functions