Skip to main content

EngineReferences

Struct EngineReferences 

Source
pub struct EngineReferences<'et, ET: EngineTypes> {
    pub state: &'et mut ET::State,
    pub mouth: &'et mut ET::Mouth,
    pub gullet: &'et mut ET::Gullet,
    pub stomach: &'et mut ET::Stomach,
    pub filesystem: &'et mut ET::FileSystem,
    pub fontsystem: &'et mut ET::FontSystem,
    pub aux: &'et mut EngineAux<ET>,
    /* private fields */
}
Expand description

This struct combines all the necessary components for use in PrimitiveCommands. We use public fields instead of accessor methods to convince the borrow checker that all the components are independent, and avoid “Cannot borrow as mutable because already borrowed as immutable” errors.

Fields§

§state: &'et mut ET::State§mouth: &'et mut ET::Mouth§gullet: &'et mut ET::Gullet§stomach: &'et mut ET::Stomach§filesystem: &'et mut ET::FileSystem§fontsystem: &'et mut ET::FontSystem§aux: &'et mut EngineAux<ET>

Implementations§

Source§

impl<ET: EngineTypes> EngineReferences<'_, ET>

Source

pub fn expand(&mut self, token: ET::Token) -> TeXResult<(), ET>

expands the Token if it is expandable, otherwise requeues it

Source

pub fn read_register_index( &mut self, skip_eq: bool, in_token: &ET::Token, ) -> TeXResult<usize, ET>

reads an integer from the input stream and makes sure it’s in the range of a state register

Source

pub fn mathfont_index( &mut self, skip_eq: bool, in_token: &ET::Token, ) -> TeXResult<u8, ET>

reads an integer and makes sure it’s in the range of a math font index (0-15)

Source

pub fn skip_argument(&mut self, token: &ET::Token) -> TeXResult<(), ET>

expects a BeginGroup token, reads until the matching EndGroup token and discards everything in between.

Source

pub fn read_csname(&mut self) -> TeXResult<ET::CSName, ET>

reads the name of a control sequence until \endcsname and returns the corresponding CSName (i.e. what \csname and \ifcsname do)

Source

pub fn read_file_index(&mut self, in_token: &ET::Token) -> TeXResult<u8, ET>

reads a number from the input stream and makes sure it’s in the range of a file input/output stream index (0-255)

Source

pub fn read_filename_and_index( &mut self, prefix: &str, in_token: &ET::Token, ) -> TeXResult<(u8, ET::File), ET>

reads a number from the input stream, making sure it’s in the range of a file input/output stream index (0-255), and subsequently reads a filename

  • i.e. the first two steps of \openin or \openout
Source

pub fn do_the<F: FnMut(&mut EngineAux<ET>, &ET::State, &mut ET::Gullet, ET::Token) -> TeXResult<(), ET>>( &mut self, cont: F, ) -> TeXResult<(), ET>

\the, but using a continuation function; this is used for both the as well as in expand_until_endgroup to speed things up

Source

pub fn read_opt_delimiter( &mut self, in_token: &ET::Token, ) -> TeXResult<Option<Delimiter<ET>>, ET>

reads a Delimiter from the input stream; e.g. from \delimiter or the \delcode of the next character

Source§

impl<ET: EngineTypes> EngineReferences<'_, ET>

Source

pub fn read_font( &mut self, skip_eq: bool, token: &ET::Token, ) -> TeXResult<<ET::FontSystem as FontSystem>::Font, ET>

reads a font from the input stream (e.g. \font for the current font or a font defined via \font\foo=...).

Source§

impl<ET: EngineTypes> EngineReferences<'_, ET>

Source

pub fn read_control_sequence( &mut self, in_token: &ET::Token, ) -> TeXResult<CSOrActiveChar<ET::Token>, ET>

Reads a control sequence or active character from the Mouth and returns it as a CSOrActiveChar.

Source§

impl<ET: EngineTypes> EngineReferences<'_, ET>

Source

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

Yields Tokens from the input stream until and passes them on to cont until cont returns false.

Source

pub fn requeue(&mut self, t: ET::Token) -> TeXResult<(), ET>

Push the provided Token back onto the input stream.

Source

pub fn read_until_endgroup<F: FnMut(&mut EngineAux<ET>, &ET::State, ET::Token) -> TeXResult<(), ET>>( &mut self, in_token: &ET::Token, cont: F, ) -> TeXResult<ET::Token, ET>

Yields Tokens from the input stream until an EndGroup-token is encountered. If the input stream is empty, returns a “File ended while scanning use of in_token” error.

Source

pub fn expand_until_endgroup<Fn: FnMut(&mut EngineAux<ET>, &ET::State, ET::Token) -> TeXResult<(), ET>>( &mut self, expand_protected: bool, edef_like: bool, token: &ET::Token, cont: Fn, ) -> TeXResult<(), ET>

Yields Tokens from the input stream until an EndGroup-token is encountered, expanding all expandable tokens along the way. If expand_protected is true, protected tokens are expanded as well. If edef_like is true, the expansion is done in \edef-mode, i.e. tokens expanded from \the are not expanded further and Parameter-tokens expanded from \the are doubled.

Source

pub fn get_next( &mut self, noexpand: bool, ) -> Result<Option<ET::Token>, GulletError<ET::Char>>

Yields the next Token from the input stream. If noexpand is true, \cr, \crcr and & are not expanded.

Source

pub fn need_next( &mut self, noexpand: bool, in_token: &ET::Token, ) -> TeXResult<ET::Token, ET>

Yields the next Token from the input stream. If noexpand is true, \cr, \crcr and & are not expanded. If the input stream is empty, returns a “File ended while scanning use of in_token” error.

Source

pub fn read_int( &mut self, skip_eq: bool, in_token: &ET::Token, ) -> TeXResult<<ET::Num as NumSet>::Int, ET>

Read an integer value from the input stream.

Source

pub fn read_string( &mut self, skip_eq: bool, target: &mut String, in_token: &ET::Token, ) -> TeXResult<(), ET>

Read a string from the input stream.

Source

pub fn read_maybe_braced_string( &mut self, skip_eq: bool, target: &mut String, in_token: &ET::Token, ) -> TeXResult<(), ET>

Source

pub fn read_keyword(&mut self, kw: &[u8]) -> TeXResult<bool, ET>

Check whether the input stream starts with the given keyword.

Source

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

Check whether the input stream starts with one of the given keywords.

Source

pub fn read_charcode( &mut self, skip_eq: bool, in_token: &ET::Token, ) -> TeXResult<ET::Char, ET>

Read a character code from the input stream.

Source

pub fn read_braced_string( &mut self, skip_ws: bool, expand_protected: bool, token: &ET::Token, str: &mut String, ) -> TeXResult<(), ET>

Read a braced string from the input stream (unlike read_string which does not require braces). Compare e.g. \message{Hello World} (which would use read_braced_string) and \input myfile.tex (which would use read_string).

Source

pub fn expand_until_bgroup( &mut self, allow_let: bool, t: &ET::Token, ) -> TeXResult<(), ET>

Expand expandable tokens until a BeginGroup is found. Throws a TeXError if any unexpandable other token is encountered. If allow_let is true, other Tokens which have been \let to a BeginGroup are also accepted (e.g. \bgroup).

Source

pub fn read_dim( &mut self, skip_eq: bool, in_token: &ET::Token, ) -> TeXResult<ET::Dim, ET>

Read a dimension value from the input stream.

Source

pub fn read_skip( &mut self, skip_eq: bool, in_token: &ET::Token, ) -> TeXResult<Skip<ET::Dim>, ET>

Read a skip value from the input stream.

Source

pub fn read_muskip( &mut self, skip_eq: bool, in_token: &ET::Token, ) -> TeXResult<MuSkip<ET::MuDim>, ET>

Read a muskip value from the input stream.

Source

pub fn read_mudim( &mut self, skip_eq: bool, in_token: &ET::Token, ) -> TeXResult<ET::MuDim, ET>

Read a mudim value from the input stream (for \mkern).

Source

pub fn read_chars( &mut self, kws: &[u8], ) -> TeXResult<Either<u8, Option<ET::Token>>, ET>

Check whether the next character is one of the provided ones. Returns the character if so, otherwise returns the inspected Token to be further processed or Self::requeued.

Source

pub fn resolve(&self, token: &ET::Token) -> ResolvedToken<'_, ET>

Inspect the given Token and return its current definition, if any.

Source§

impl<ET: EngineTypes> EngineReferences<'_, ET>

Source

pub fn push_file(&mut self, f: ET::File)

Push a file to the Mouth (see Mouth::push_file).

Source

pub fn push_every(&mut self, every: PrimitiveIdentifier)

Insert the value of a primitive token list (e.g. \everypar) into the Mouth.

Source

pub fn preview(&self) -> String

Useful for debugging (see Mouth::preview).

Source§

impl<ET: EngineTypes> EngineReferences<'_, ET>

Source

pub fn set_command( &mut self, name: &CSOrActiveChar<ET::Token>, cmd: Option<TeXCommand<ET>>, globally: bool, )

Set the current definition of the provided control sequence name or active character

Source§

impl<ET: EngineTypes> EngineReferences<'_, ET>

Source

pub fn read_box( &mut self, skip_eq: bool, ) -> TeXResult<Either<Option<TeXBox<ET>>, BoxInfo<ET>>, ET>

read a box from the current input stream

Source

pub fn read_char_or_math_group<S, F1: FnOnce(S, &mut Self, MathChar<ET>) -> TeXResult<(), ET>, F2: FnOnce(S) -> ListTarget<ET, MathNode<ET, UnresolvedMathFontStyle<ET>>>>( &mut self, in_token: &ET::Token, f: F1, tp: F2, s: S, ) -> TeXResult<(), ET>

read a math char or group from the current input stream. Assumes we are in math mode. (e.g. \mathop X or \mathop{ \alpha + \beta }). In the latter case a new list is opened and processed “asynchronously”. When the list is closed, the second continuation is called with the list as argument.

Source§

impl<ET: EngineTypes> EngineReferences<'_, ET>

Source

pub fn shipout(&mut self, n: VNode<ET>) -> TeXResult<(), ET>

ships out the VNode, passing it on to the provided continuation.

§Errors

On LaTeX errors in Whatsits (e.g. non-immediate \writes)

Source§

impl<ET: EngineTypes> EngineReferences<'_, ET>

Source

pub fn trace_command<D: Display, F: FnOnce(&mut Self) -> D>(&mut self, f: F)

Runs the provided closure and prints the result to \write-1 iff \tracingcommands > 0.

Source

pub fn top_loop(&mut self) -> TeXResult<(), ET>

Entry point for compilation. This function is called by TeXEngine::do_file_default.

§Errors

On TeX errors

Source§

impl<ET: EngineTypes> EngineReferences<'_, ET>

Source

pub fn general_error(&mut self, msg: String) -> TeXResult<(), ET>

§Errors

because that’s what it’s supposed to do

Auto Trait Implementations§

§

impl<'et, ET> Freeze for EngineReferences<'et, ET>

§

impl<'et, ET> !RefUnwindSafe for EngineReferences<'et, ET>

§

impl<'et, ET> !Send for EngineReferences<'et, ET>

§

impl<'et, ET> !Sync for EngineReferences<'et, ET>

§

impl<'et, ET> Unpin for EngineReferences<'et, ET>

§

impl<'et, ET> UnsafeUnpin for EngineReferences<'et, ET>

§

impl<'et, ET> !UnwindSafe for EngineReferences<'et, ET>

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T> Instrument for T

§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided [Span], returning an Instrumented wrapper. Read more
§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<ET, Err, A> IntoErr<ET, Err> for A
where ET: EngineTypes, Err: From<A>,

Source§

fn into_err( self, _aux: &EngineAux<ET>, _state: &<ET as EngineTypes>::State, ) -> Err

§

impl<T> Pointable for T

§

const ALIGN: usize

The alignment of pointer.
§

type Init = T

The type for initializers.
§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
§

impl<T> PolicyExt for T
where T: ?Sized,

§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns [Action::Follow] only if self and other return Action::Follow. Read more
§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns [Action::Follow] if either self or other returns Action::Follow. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
§

impl<T> WithSubscriber for T

§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a [WithDispatch] wrapper. Read more
§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a [WithDispatch] wrapper. Read more