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>
impl<ET: EngineTypes> EngineReferences<'_, ET>
Sourcepub fn expand(&mut self, token: ET::Token) -> TeXResult<(), ET>
pub fn expand(&mut self, token: ET::Token) -> TeXResult<(), ET>
expands the Token if it is expandable, otherwise requeues it
Sourcepub fn read_register_index(
&mut self,
skip_eq: bool,
in_token: &ET::Token,
) -> TeXResult<usize, ET>
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
Sourcepub fn mathfont_index(
&mut self,
skip_eq: bool,
in_token: &ET::Token,
) -> TeXResult<u8, ET>
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)
Sourcepub fn skip_argument(&mut self, token: &ET::Token) -> TeXResult<(), ET>
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.
Sourcepub fn read_csname(&mut self) -> TeXResult<ET::CSName, ET>
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)
Sourcepub fn read_file_index(&mut self, in_token: &ET::Token) -> TeXResult<u8, ET>
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)
Sourcepub fn read_filename_and_index(
&mut self,
prefix: &str,
in_token: &ET::Token,
) -> TeXResult<(u8, ET::File), ET>
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
\openinor\openout
Source§impl<ET: EngineTypes> EngineReferences<'_, ET>
impl<ET: EngineTypes> EngineReferences<'_, ET>
Sourcepub fn read_font(
&mut self,
skip_eq: bool,
token: &ET::Token,
) -> TeXResult<<ET::FontSystem as FontSystem>::Font, ET>
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>
impl<ET: EngineTypes> EngineReferences<'_, ET>
Sourcepub fn read_control_sequence(
&mut self,
in_token: &ET::Token,
) -> TeXResult<CSOrActiveChar<ET::Token>, ET>
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>
impl<ET: EngineTypes> EngineReferences<'_, ET>
Sourcepub 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>
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>
Yields Tokens from the input stream until and passes them on to cont until cont returns false.
Sourcepub fn requeue(&mut self, t: ET::Token) -> TeXResult<(), ET>
pub fn requeue(&mut self, t: ET::Token) -> TeXResult<(), ET>
Push the provided Token back onto the input stream.
Sourcepub 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>
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>
Sourcepub 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>
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.
Sourcepub fn get_next(
&mut self,
noexpand: bool,
) -> Result<Option<ET::Token>, GulletError<ET::Char>>
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.
Sourcepub fn need_next(
&mut self,
noexpand: bool,
in_token: &ET::Token,
) -> TeXResult<ET::Token, ET>
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.
Sourcepub fn read_int(
&mut self,
skip_eq: bool,
in_token: &ET::Token,
) -> TeXResult<<ET::Num as NumSet>::Int, ET>
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.
Sourcepub fn read_string(
&mut self,
skip_eq: bool,
target: &mut String,
in_token: &ET::Token,
) -> TeXResult<(), ET>
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.
pub fn read_maybe_braced_string( &mut self, skip_eq: bool, target: &mut String, in_token: &ET::Token, ) -> TeXResult<(), ET>
Sourcepub fn read_keyword(&mut self, kw: &[u8]) -> TeXResult<bool, ET>
pub fn read_keyword(&mut self, kw: &[u8]) -> TeXResult<bool, ET>
Check whether the input stream starts with the given keyword.
Sourcepub fn read_keywords<'a>(
&mut self,
kw: &'a [&'a [u8]],
) -> TeXResult<Option<&'a [u8]>, ET>
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.
Sourcepub fn read_charcode(
&mut self,
skip_eq: bool,
in_token: &ET::Token,
) -> TeXResult<ET::Char, ET>
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.
Sourcepub fn read_braced_string(
&mut self,
skip_ws: bool,
expand_protected: bool,
token: &ET::Token,
str: &mut String,
) -> TeXResult<(), ET>
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).
Sourcepub fn expand_until_bgroup(
&mut self,
allow_let: bool,
t: &ET::Token,
) -> TeXResult<(), ET>
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).
Sourcepub fn read_dim(
&mut self,
skip_eq: bool,
in_token: &ET::Token,
) -> TeXResult<ET::Dim, ET>
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.
Sourcepub fn read_skip(
&mut self,
skip_eq: bool,
in_token: &ET::Token,
) -> TeXResult<Skip<ET::Dim>, ET>
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.
Sourcepub fn read_muskip(
&mut self,
skip_eq: bool,
in_token: &ET::Token,
) -> TeXResult<MuSkip<ET::MuDim>, ET>
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.
Sourcepub fn read_mudim(
&mut self,
skip_eq: bool,
in_token: &ET::Token,
) -> TeXResult<ET::MuDim, ET>
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).
Sourcepub fn read_chars(
&mut self,
kws: &[u8],
) -> TeXResult<Either<u8, Option<ET::Token>>, ET>
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.
Sourcepub fn resolve(&self, token: &ET::Token) -> ResolvedToken<'_, ET>
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>
impl<ET: EngineTypes> EngineReferences<'_, ET>
Sourcepub fn push_file(&mut self, f: ET::File)
pub fn push_file(&mut self, f: ET::File)
Push a file to the Mouth (see Mouth::push_file).
Sourcepub fn push_every(&mut self, every: PrimitiveIdentifier)
pub fn push_every(&mut self, every: PrimitiveIdentifier)
Insert the value of a primitive token list (e.g. \everypar) into the Mouth.
Sourcepub fn preview(&self) -> String
pub fn preview(&self) -> String
Useful for debugging (see Mouth::preview).
Source§impl<ET: EngineTypes> EngineReferences<'_, ET>
impl<ET: EngineTypes> EngineReferences<'_, ET>
Sourcepub fn set_command(
&mut self,
name: &CSOrActiveChar<ET::Token>,
cmd: Option<TeXCommand<ET>>,
globally: bool,
)
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>
impl<ET: EngineTypes> EngineReferences<'_, ET>
Sourcepub fn read_box(
&mut self,
skip_eq: bool,
) -> TeXResult<Either<Option<TeXBox<ET>>, BoxInfo<ET>>, ET>
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
Sourcepub 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>
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>
impl<ET: EngineTypes> EngineReferences<'_, ET>
Source§impl<ET: EngineTypes> EngineReferences<'_, ET>
impl<ET: EngineTypes> EngineReferences<'_, ET>
Sourcepub fn trace_command<D: Display, F: FnOnce(&mut Self) -> D>(&mut self, f: F)
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§impl<ET: EngineTypes> EngineReferences<'_, ET>
impl<ET: EngineTypes> EngineReferences<'_, ET>
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> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
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 moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
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