Skip to main content

Gullet

Trait Gullet 

Source
pub trait Gullet<ET: EngineTypes> {
Show 28 methods // Required methods fn new( aux: &mut EngineAux<ET>, state: &mut ET::State, mouth: &mut ET::Mouth, ) -> Self; fn push_align(&mut self, ad: AlignData<ET::Token, ET::Dim>); fn pop_align(&mut self) -> Option<AlignData<ET::Token, ET::Dim>>; fn get_align_data(&mut self) -> Option<&mut AlignData<ET::Token, ET::Dim>>; fn get_conditional(&self) -> Option<ActiveConditional<ET::Int>>; fn get_conditionals(&mut self) -> &mut Vec<ActiveConditional<ET::Int>>; fn csnames(&mut self) -> &mut usize; fn do_macro( engine: &mut EngineReferences<'_, ET>, m: Macro<ET::Token>, token: ET::Token, ) -> TeXResult<(), ET>; // Provided methods fn iterate<R, E, F: FnMut(&mut EngineAux<ET>, &ET::State, ET::Token) -> TeXResult<Option<R>, ET>>( &mut self, mouth: &mut ET::Mouth, aux: &mut EngineAux<ET>, state: &ET::State, cont: F, eof: E, ) -> TeXResult<R, ET> where E: Fn(&EngineAux<ET>, &ET::State, &mut ET::Mouth) -> TeXResult<(), ET> { ... } fn get_next( &mut self, mouth: &mut ET::Mouth, aux: &mut EngineAux<ET>, state: &ET::State, noexpand: bool, ) -> Result<Option<ET::Token>, GulletError<ET::Char>> { ... } fn read_until_endgroup<E, F: FnMut(&mut EngineAux<ET>, &ET::State, ET::Token) -> TeXResult<(), ET>>( &mut self, mouth: &mut ET::Mouth, aux: &mut EngineAux<ET>, state: &ET::State, cont: F, eof: E, ) -> TeXResult<ET::Token, ET> where E: Fn(&EngineAux<ET>, &ET::State, &mut ET::Mouth) -> TeXResult<(), ET> { ... } fn requeue( &mut self, aux: &EngineAux<ET>, state: &ET::State, mouth: &mut ET::Mouth, t: ET::Token, ) -> TeXResult<(), ET> { ... } fn read_int( engine: &mut EngineReferences<'_, ET>, skip_eq: bool, in_token: &ET::Token, ) -> TeXResult<ET::Int, ET> { ... } fn read_dim( engine: &mut EngineReferences<'_, ET>, skip_eq: bool, in_token: &ET::Token, ) -> TeXResult<ET::Dim, ET> { ... } fn read_skip( engine: &mut EngineReferences<'_, ET>, skip_eq: bool, in_token: &ET::Token, ) -> TeXResult<Skip<ET::Dim>, ET> { ... } fn read_muskip( engine: &mut EngineReferences<'_, ET>, skip_eq: bool, in_token: &ET::Token, ) -> TeXResult<MuSkip<ET::MuDim>, ET> { ... } fn read_mudim( engine: &mut EngineReferences<'_, ET>, skip_eq: bool, in_token: &ET::Token, ) -> TeXResult<ET::MuDim, ET> { ... } fn read_string( engine: &mut EngineReferences<'_, ET>, skip_eq: bool, target: &mut String, in_token: &ET::Token, ) -> TeXResult<(), ET> { ... } fn read_maybe_braced_string( engine: &mut EngineReferences<'_, ET>, skip_eq: bool, target: &mut String, in_token: &ET::Token, ) -> TeXResult<(), ET> { ... } fn read_keyword( engine: &mut EngineReferences<'_, ET>, kw: &[u8], ) -> TeXResult<bool, ET> { ... } fn read_keywords<'a>( engine: &mut EngineReferences<'_, ET>, kw: &'a [&'a [u8]], ) -> TeXResult<Option<&'a [u8]>, ET> { ... } fn read_chars( engine: &mut EngineReferences<'_, ET>, kws: &[u8], ) -> TeXResult<Either<u8, Option<ET::Token>>, ET> { ... } fn resolve<'a>( state: &'a ET::State, token: &ET::Token, ) -> ResolvedToken<'a, ET> { ... } fn char_or_primitive( state: &ET::State, token: &ET::Token, ) -> Option<CharOrPrimitive<ET>> { ... } fn do_expandable( engine: &mut EngineReferences<'_, ET>, name: PrimitiveIdentifier, token: ET::Token, f: fn(&mut EngineReferences<'_, ET>, &mut Vec<ET::Token>, ET::Token) -> TeXResult<(), ET>, ) -> TeXResult<(), ET> { ... } fn do_simple_expandable( engine: &mut EngineReferences<'_, ET>, name: PrimitiveIdentifier, token: ET::Token, f: fn(&mut EngineReferences<'_, ET>, ET::Token) -> TeXResult<(), ET>, ) -> TeXResult<(), ET> { ... } fn do_conditional( engine: &mut EngineReferences<'_, ET>, name: PrimitiveIdentifier, token: ET::Token, f: fn(&mut EngineReferences<'_, ET>, ET::Token) -> TeXResult<bool, ET>, unless: bool, ) -> TeXResult<(), ET> { ... } fn expand_until_endgroup<Fn: FnMut(&mut EngineAux<ET>, &ET::State, ET::Token) -> TeXResult<(), ET>>( engine: &mut EngineReferences<'_, ET>, expand_protected: bool, edef_like: bool, token: &ET::Token, cont: Fn, ) -> TeXResult<(), ET> { ... }
}
Expand description

A Gullet is the part of the engine that reads tokens from the input stream and expands them; including conditionals etc. Additionally, it takes care of reading keywords, strings (e.g. filenames in \input), integers, dimensions, skips… Basically, all processing of Tokens that does not result in scoped State changes or nodes in the Stomach. The canonical implementation of a Gullet is DefaultGullet.

As part of that, it has to do some bookkeeping already when reading Tokens from the Mouth and therefore implements wrapper methods around its methods as well.

Note that we do not require ET:EngineTypes<Gullet=Self> - this allows for implementing your own Gullet by just wrapping an existing implementation in a new wrapper struct and pass on functionality to the inner Gullet, which would otherwise fail since ET::Gullet would be the outer wrapper struct, not the inner one.

Required Methods§

Source

fn new( aux: &mut EngineAux<ET>, state: &mut ET::State, mouth: &mut ET::Mouth, ) -> Self

Instantiate a new Gullet

Source

fn push_align(&mut self, ad: AlignData<ET::Token, ET::Dim>)

Push a new AlignData onto the stack, i.e. on \halign or \valign

Source

fn pop_align(&mut self) -> Option<AlignData<ET::Token, ET::Dim>>

Pop the last AlignData from the stack, i.e. at the end of \halign or \valign

Source

fn get_align_data(&mut self) -> Option<&mut AlignData<ET::Token, ET::Dim>>

Inspect the current AlignData, if any (i.e. if we are in an \halign or \valign)

Source

fn get_conditional(&self) -> Option<ActiveConditional<ET::Int>>

Inspect the current ActiveConditional, if any (i.e. if we are in an \if or similar)

Source

fn get_conditionals(&mut self) -> &mut Vec<ActiveConditional<ET::Int>>

Get a mutable reference to the stack of ActiveConditionals

Source

fn csnames(&mut self) -> &mut usize

Get a mutable reference to the counter for the number of \csnames we are currently in

Source

fn do_macro( engine: &mut EngineReferences<'_, ET>, m: Macro<ET::Token>, token: ET::Token, ) -> TeXResult<(), ET>

Expand the given Macro with its given expansion function.

Provided Methods§

Source

fn iterate<R, E, F: FnMut(&mut EngineAux<ET>, &ET::State, ET::Token) -> TeXResult<Option<R>, ET>>( &mut self, mouth: &mut ET::Mouth, aux: &mut EngineAux<ET>, state: &ET::State, cont: F, eof: E, ) -> TeXResult<R, ET>
where E: Fn(&EngineAux<ET>, &ET::State, &mut ET::Mouth) -> TeXResult<(), ET>,

Wrapper around Mouth::iterate that, in case we are in an \halign or \valign, make sure to replace &, \cr etc. with the appropriate tokens. See also EngineReferences::iterate.

Source

fn get_next( &mut self, mouth: &mut ET::Mouth, aux: &mut EngineAux<ET>, state: &ET::State, noexpand: bool, ) -> Result<Option<ET::Token>, GulletError<ET::Char>>

Wrapper around Mouth::get_next that, in case we are in an \halign or \valign, make sure to replace &, \cr etc. with the appropriate tokens. If noexpand is true, \cr, \crcr and & are not expanded. See also EngineReferences::get_next.

Source

fn read_until_endgroup<E, F: FnMut(&mut EngineAux<ET>, &ET::State, ET::Token) -> TeXResult<(), ET>>( &mut self, mouth: &mut ET::Mouth, aux: &mut EngineAux<ET>, state: &ET::State, cont: F, eof: E, ) -> TeXResult<ET::Token, ET>
where E: Fn(&EngineAux<ET>, &ET::State, &mut ET::Mouth) -> TeXResult<(), ET>,

Wrapper around Mouth::read_until_endgroup that, in case we are in an \halign or \valign, make sure to replace &, \cr etc. with the appropriate tokens. See also EngineReferences::read_until_endgroup.

Source

fn requeue( &mut self, aux: &EngineAux<ET>, state: &ET::State, mouth: &mut ET::Mouth, t: ET::Token, ) -> TeXResult<(), ET>

Wrapper around Mouth::requeue that makes sure to update the AlignData if we are in an \halign or \valign. See also EngineReferences::requeue.

Source

fn read_int( engine: &mut EngineReferences<'_, ET>, skip_eq: bool, in_token: &ET::Token, ) -> TeXResult<ET::Int, ET>

Read an integer from the input stream. See also EngineReferences::read_int.

Source

fn read_dim( engine: &mut EngineReferences<'_, ET>, skip_eq: bool, in_token: &ET::Token, ) -> TeXResult<ET::Dim, ET>

Read a dimension value from the input stream. See also EngineReferences::read_dim.

Source

fn read_skip( engine: &mut EngineReferences<'_, ET>, skip_eq: bool, in_token: &ET::Token, ) -> TeXResult<Skip<ET::Dim>, ET>

Read a skip value from the input stream. See also EngineReferences::read_skip.

Source

fn read_muskip( engine: &mut EngineReferences<'_, ET>, skip_eq: bool, in_token: &ET::Token, ) -> TeXResult<MuSkip<ET::MuDim>, ET>

Read a muskip value from the input stream. See also EngineReferences::read_muskip.

Source

fn read_mudim( engine: &mut EngineReferences<'_, ET>, skip_eq: bool, in_token: &ET::Token, ) -> TeXResult<ET::MuDim, ET>

Read a mudim value from the input stream (for \mkern). See also EngineReferences::read_mudim.

Source

fn read_string( engine: &mut EngineReferences<'_, ET>, skip_eq: bool, target: &mut String, in_token: &ET::Token, ) -> TeXResult<(), ET>

Read a string from the input stream. See also EngineReferences::read_string.

Source

fn read_maybe_braced_string( engine: &mut EngineReferences<'_, ET>, skip_eq: bool, target: &mut String, in_token: &ET::Token, ) -> TeXResult<(), ET>

Source

fn read_keyword( engine: &mut EngineReferences<'_, ET>, kw: &[u8], ) -> TeXResult<bool, ET>

Check whether the input stream starts with the given keyword. See also EngineReferences::read_keyword.

Source

fn read_keywords<'a>( engine: &mut EngineReferences<'_, ET>, kw: &'a [&'a [u8]], ) -> TeXResult<Option<&'a [u8]>, ET>

Check whether the input stream starts with one of the given keywords. See also EngineReferences::read_keywords.

Source

fn read_chars( engine: &mut EngineReferences<'_, ET>, kws: &[u8], ) -> TeXResult<Either<u8, Option<ET::Token>>, ET>

Check whether the next character is one of the provided ones. See also EngineReferences::read_chars.

Source

fn resolve<'a>(state: &'a ET::State, token: &ET::Token) -> ResolvedToken<'a, ET>

Inspect the given Token and return its current definition, if any. See also EngineReferences::resolve.

Source

fn char_or_primitive( state: &ET::State, token: &ET::Token, ) -> Option<CharOrPrimitive<ET>>

Inspects the Token and returns either the PrimitiveIdentifier or the Character and CommandCode or None if the token is neither a primitive nor a character. Useful for e.g. quick checks in an \halign whether the token is a specific primitive (\cr,\crcr,\span) or a character (&, space).

Source

fn do_expandable( engine: &mut EngineReferences<'_, ET>, name: PrimitiveIdentifier, token: ET::Token, f: fn(&mut EngineReferences<'_, ET>, &mut Vec<ET::Token>, ET::Token) -> TeXResult<(), ET>, ) -> TeXResult<(), ET>

Expand the given expandable Token with its given expansion function. See also Expandable.

Source

fn do_simple_expandable( engine: &mut EngineReferences<'_, ET>, name: PrimitiveIdentifier, token: ET::Token, f: fn(&mut EngineReferences<'_, ET>, ET::Token) -> TeXResult<(), ET>, ) -> TeXResult<(), ET>

Expand the given expandable Token with its given simple expansion function. See also SimpleExpandable.

Source

fn do_conditional( engine: &mut EngineReferences<'_, ET>, name: PrimitiveIdentifier, token: ET::Token, f: fn(&mut EngineReferences<'_, ET>, ET::Token) -> TeXResult<bool, ET>, unless: bool, ) -> TeXResult<(), ET>

Expand the given conditional. See also Conditional

Source

fn expand_until_endgroup<Fn: FnMut(&mut EngineAux<ET>, &ET::State, ET::Token) -> TeXResult<(), ET>>( engine: &mut EngineReferences<'_, ET>, expand_protected: bool, edef_like: bool, token: &ET::Token, cont: Fn, ) -> TeXResult<(), ET>

Expand Tokens until encountering an EndGroup-token. See also EngineReferences::expand_until_endgroup.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§