Skip to main content

FlmDriver

Struct FlmDriver 

Source
pub struct FlmDriver { /* private fields */ }
Expand description

An FlmDriver is the parse driver of the FLM language. It stores the settings of a parse: the error recovery policy, the cap on the number of stored diagnostics, the standard state of the parse, and the input resolver that reads the files included with \input. The module documentation explains what a parse driver is.

You do not usually create a driver yourself. build_language creates the driver of a BuiltLang from the settings in its LangInputs, and BuiltLang::driver returns this driver. To parse with a different cap on diagnostics, a different standard state or a different input resolver, pass ParseOptions to parse_fragment.

Implementations§

Source§

impl FlmDriver

Source

pub fn new( recovery: Recovery, diagnostics_limit: Option<usize>, standard_state: Arc<ParsingState<Flm>>, ) -> FlmDriver

Returns a driver with the error recovery policy recovery, the cap diagnostics_limit on the number of stored diagnostics, the standard state standard_state, and no input resolver.

With Recovery::Tolerant, the parser reports a problem in the source as a diagnostic and continues the parse. With Recovery::Strict, the parse fails at the first problem. build_language always uses Recovery::Tolerant.

diagnostics_limit is the maximum number of diagnostics that a parse stores. With None, techy’s default cap applies (Diagnostics::DEFAULT_LIMIT). Diagnostics beyond the cap are not stored, but they are counted (Diagnostics::suppressed).

standard_state is the standard state of the parses that use this driver: the state that FlmEvent::StandardScope and FlmEvent::StandardState restore. build_language passes the initial state of the built language (BuiltLang::initial_state).

Source

pub fn with_diagnostics_limit(self, limit: Option<usize>) -> FlmDriver

Sets the cap on the number of diagnostics that a parse stores, and returns the driver. With None, techy’s default cap applies (Diagnostics::DEFAULT_LIMIT).

Source

pub fn with_standard_state(self, state: Arc<ParsingState<Flm>>) -> FlmDriver

Sets the standard state of the parse, and returns the driver: the state that FlmEvent::StandardScope and FlmEvent::StandardState restore. A parse with ParseOptions::standard_state set runs with a copy of the built language’s driver that carries it.

Source

pub fn with_input_resolver(self, resolver: Arc<dyn InputResolver>) -> FlmDriver

Sets the input resolver, and returns the driver. The input resolver finds and reads the file that an \input command includes; see crate::lang::input.

The library reads no files itself. Without an input resolver, each \input command is reported with the condition InputUnavailable and includes nothing. The flm command-line program sets an input resolver that reads files from the disk.

Source

pub fn input_resolver(&self) -> Option<&dyn InputResolver>

Returns the input resolver set with FlmDriver::with_input_resolver, or None if no input resolver is set.

Source

pub fn diagnostics_limit_setting(&self) -> Option<usize>

Returns the cap on the number of stored diagnostics that this driver was given. None means that techy’s default cap applies.

Trait Implementations§

Source§

impl Clone for FlmDriver

Source§

fn clone(&self) -> FlmDriver

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for FlmDriver

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl LatexlikeParseDriver<Flm> for FlmDriver

Uses the default implementation of every function of techy’s LatexlikeParseDriver. In particular, the changes of parsing state made inside the body of an environment do not apply after the end of the environment.

Source§

fn environment_after_effects( &self, invocation: &EnvironmentInvocation<'_, LLL>, spec: &Arc<dyn CallableSpec<LLL>>, initial: &Arc<ParsingState<LLL>>, exit: &Arc<ParsingState<LLL>>, record: Option<Box<ParsingStateDelta<LLL>>>, ) -> Result<Option<Box<ParsingStateDelta<LLL>>>, ParseError<<LLL as Lang>::SourceOrigin>>

Decides which state changes made inside an environment’s body survive the environment, and reach the content around it. Read more
Source§

impl ParseDriver<Flm> for FlmDriver

Source§

fn resolve_command( &self, state: &ParsingState<Flm>, token: &Token<Flm>, tokens: &dyn TokenReader<'_, Flm>, ) -> Result<CommandResolution<Flm>, ParseError<FlmOrigin>>

Resolves the command name of token as a macro, in the scopes of the parsing state state, from the innermost scope outwards.

\begin and \end are resolved like any other command name. They resolve to techy’s built-in specifications of \begin and \end, which then resolve the environment name. A name that is not defined in any package is resolved by the fallback provider (FlmFallbackProvider) at the bottom of the scope stack.

§Errors

Never returns an error.

Source§

fn make_paragraph_break_node( &self, state: &ParsingState<Flm>, break_span: &SourceSpan<FlmOrigin>, ) -> NodeKind<Flm>

Returns the node created for a paragraph break: a callable node with techy’s standard paragraph-break specification (ParagraphBreakStyle::Specials). Nodes of this form have the element flm.parbreak, and the block-structure rewrite pass splits paragraphs at these nodes.

Source§

fn refine_diagnostic( &self, data: Box<dyn DiagnosticData>, state: &ParsingState<Flm>, ) -> Box<dyn DiagnosticData>

Replaces the condition reported for a forbidden $ or % with an FLM condition whose message contains the syntax to write instead.

  • For $, the replacement is DollarMathDisabled.
  • For %, the replacement is PercentForbidden. This condition gives the comment prefix of the parsing settings in state, which are the parsing settings of the file in which the % appears.

Every other condition is returned unchanged.

Source§

fn observe_parse_start( &self, source: &Arc<Source<FlmOrigin>>, initial_state: &Arc<ParsingState<Flm>>, diagnostics: &mut Diagnostics<FlmOrigin>, )

Calls Flm::check_parse_start at the start of a parse. FLM uses the default implementation of this function, which performs no check.

Source§

fn resolve_state_event( &self, event: &FlmEvent, stack: &ParsingStateStack<Flm>, ) -> Result<Option<ParsingStateDelta<Flm>>, ParseError<FlmOrigin>>

Returns the change of parsing state that replaces event, from the enclosing parsing states in stack (the current state first) and from the standard state of the parse (FlmDriver::new).

  • FlmEvent::ExitMathContext: the change that restores the innermost enclosing parsing state that is not in math mode, for instance at the argument of \text, as techy’s preset computes it.
  • FlmEvent::StandardScope: one scope operation, which replaces the scope stack by that of the standard state.
  • FlmEvent::StandardState: the change that gives the state the scope stack, the tokenizer rules, the mode and the data (FlmStateExt) of the standard state under the parsing settings of the file being read. These settings are those that the current state records (FlmStateExt::parsing). When they are those of the standard state, the change restores the standard state. When the file being read has settings of its own, the change restores the standard state with these settings applied, as the parser of \input applies them (FlmParsing::state_delta). The temporary group rules and the expected group close of the current state are kept.
§Errors

Never returns an error.

Source§

fn group_interior_delta( &self, base: &ParsingState<Flm>, rule: &Arc<GroupRule<Flm>>, ) -> Option<ParsingStateDelta<Flm>>

Returns the change of parsing state that the parser applies inside a group.

For a math group, the parser applies this change so that the parsing state inside the group is in math mode and has no group rules that open math. For any other group, returns None, and the parser applies only techy’s standard change.

Source§

fn recovery(&self) -> Recovery

The recovery policy this driver parses under: abort at the first problem, or record it and continue. Read more
Source§

fn diagnostics_limit(&self) -> Option<usize>

How many diagnostics one parse retains, or None — the default — for the standard cap (Diagnostics::DEFAULT_LIMIT). Read more
Source§

fn recover( &self, session: &mut ParserSession<L>, state: &ParsingState<L>, data: Box<dyn DiagnosticData>, span: SourceSpan<<L as Lang>::SourceOrigin>, ) -> Result<(), ParseError<<L as Lang>::SourceOrigin>>

Decides what happens when a construct parser detects a problem: record it and continue, or end the parse. Read more
Source§

fn make_token_reader<'s>( &'s self, source: &'s Arc<Source<<L as Lang>::SourceOrigin>>, ) -> Box<dyn TokenReader<'s, L> + 's>

Builds the token reader one parse reads source through. Read more
Source§

fn probe_token<'s>( &self, tokens: &mut dyn TokenReader<'s, L>, session: &ParserSession<L>, state: &Arc<ParsingState<L>>, ) -> Result<Option<<<L as Lang>::Tokenization as Tokenization<L>>::Token>, ParseError<<L as Lang>::SourceOrigin>>

Looks at the token at the reader’s position under state without consuming it, mapping a tokenizer error to the recovery policy. Read more
Source§

fn observe_transition( &self, ext: &mut <L as Lang>::SessionExt, diagnostics: &mut Diagnostics<<L as Lang>::SourceOrigin>, prev: &ParsingState<L>, new: &ParsingState<L>, delta: &ParsingStateDelta<L>, ) -> Result<(), ParseError<<L as Lang>::SourceOrigin>>

Records what a state transition did, without being able to change it. Read more
Source§

fn source_resolver( &self, ) -> Option<&(dyn SourceResolver<<L as Lang>::SourceOrigin> + 'static)>

The driver’s SourceResolver for \input-like external source references, if one is configured. The default is None: this language resolves nothing — no lookup, no I/O; an \input-style construct then diagnoses every use instead of resolving it. Read more
Source§

fn make_root_parser<'p>( &'p self, ) -> Result<Box<dyn ConstructParser<L, Output = BuildId> + 'p>, ParseError<<L as Lang>::SourceOrigin>>

Builds the parser that runs at the root of one parse, over the whole source. Read more
Source§

fn make_nodes_parser<'p>( &'p self, stop: StopSpec<'p, L>, child_states: ChildStateSpec<'p, L>, ) -> Result<Box<dyn ConstructParser<L, Output = NodesOutcome<L>> + 'p>, ParseError<<L as Lang>::SourceOrigin>>

Builds the parser for one run of content: a group interior, an environment body, or the top level. Read more
Source§

fn make_group_parser<'p>( &'p self, open: &<<L as Lang>::Tokenization as Tokenization<L>>::Token, rule: Arc<GroupRule<L>>, child_states: ChildStateSpec<'p, L>, ) -> Result<Box<dyn ConstructParser<L, Output = BuildId> + 'p>, ParseError<<L as Lang>::SourceOrigin>>

Builds the parser for one group, given the GroupOpen token already consumed and the rule it matched. Read more
Source§

fn make_invocation_parser<'a>( &'a self, invocation: Invocation<'a, L>, ) -> Result<Box<dyn ConstructParser<L, Output = BuildId> + 'a>, ParseError<<L as Lang>::SourceOrigin>>

Builds the parser for one invocation of a callable. Read more

Auto Trait Implementations§

§

impl !RefUnwindSafe for FlmDriver

§

impl !UnwindSafe for FlmDriver

§

impl Forget for FlmDriver

§

impl Freeze for FlmDriver
where *const ArcInner<ParsingState<Flm>> is !null: Freeze, PhantomData<ArcInner<ParsingState<Flm>>>: Freeze, *const ArcInner<dyn InputResolver> is !null: Freeze, PhantomData<ArcInner<dyn InputResolver>>: Freeze, *const ArcInner<Placements> is !null: Freeze, PhantomData<ArcInner<Placements>>: Freeze,

§

impl Move for FlmDriver

§

impl Send for FlmDriver
where Arc<ParsingState<Flm>>: Send, Arc<dyn InputResolver>: Send, Arc<Placements>: Send,

§

impl Sync for FlmDriver
where Arc<ParsingState<Flm>>: Sync, Arc<dyn InputResolver>: Sync, Arc<Placements>: Sync,

§

impl Unpin for FlmDriver
where Arc<ParsingState<Flm>>: Unpin, Arc<dyn InputResolver>: Unpin, Arc<Placements>: Unpin,

§

impl UnsafeUnpin for FlmDriver
where *const ArcInner<ParsingState<Flm>> is !null: UnsafeUnpin, PhantomData<ArcInner<ParsingState<Flm>>>: UnsafeUnpin, *const ArcInner<dyn InputResolver> is !null: UnsafeUnpin, PhantomData<ArcInner<dyn InputResolver>>: UnsafeUnpin, *const ArcInner<Placements> is !null: UnsafeUnpin, PhantomData<ArcInner<Placements>>: UnsafeUnpin,

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> Az for T

Source§

fn az<Dst>(self) -> Dst
where T: Cast<Dst>,

Casts the value.
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<Src, Dst> CastFrom<Src> for Dst
where Src: Cast<Dst>,

Source§

fn cast_from(src: Src) -> Dst

Casts the value.
Source§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> CheckedAs for T

Source§

fn checked_as<Dst>(self) -> Option<Dst>
where T: CheckedCast<Dst>,

Casts the value.
Source§

impl<Src, Dst> CheckedCastFrom<Src> for Dst
where Src: CheckedCast<Dst>,

Source§

fn checked_cast_from(src: Src) -> Option<Dst>

Casts the value.
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> DynClone for T
where T: Clone,

Source§

fn __clone_box(&self, _: Private) -> *mut ()

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

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<Src, Dst> LosslessTryInto<Dst> for Src
where Dst: LosslessTryFrom<Src>,

Source§

fn lossless_try_into(self) -> Option<Dst>

Performs the conversion.
Source§

impl<Src, Dst> LossyInto<Dst> for Src
where Dst: LossyFrom<Src>,

Source§

fn lossy_into(self) -> Dst

Performs the conversion.
Source§

impl<T> OverflowingAs for T

Source§

fn overflowing_as<Dst>(self) -> (Dst, bool)
where T: OverflowingCast<Dst>,

Casts the value.
Source§

impl<Src, Dst> OverflowingCastFrom<Src> for Dst
where Src: OverflowingCast<Dst>,

Source§

fn overflowing_cast_from(src: Src) -> (Dst, bool)

Casts the value.
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

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

Initializes a with the given initializer. Read more
Source§

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

Dereferences the given pointer. Read more
Source§

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

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

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

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> SaturatingAs for T

Source§

fn saturating_as<Dst>(self) -> Dst
where T: SaturatingCast<Dst>,

Casts the value.
Source§

impl<Src, Dst> SaturatingCastFrom<Src> for Dst
where Src: SaturatingCast<Dst>,

Source§

fn saturating_cast_from(src: Src) -> Dst

Casts the value.
Source§

impl<T> StrictAs for T

Source§

fn strict_as<Dst>(self) -> Dst
where T: StrictCast<Dst>,

Casts the value.
Source§

impl<Src, Dst> StrictCastFrom<Src> for Dst
where Src: StrictCast<Dst>,

Source§

fn strict_cast_from(src: Src) -> Dst

Casts the value.
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

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

Source§

type Error = !

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

fn try_from(value: U) -> Result<T, !>

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.
Source§

impl<T> UnwrappedAs for T

Source§

fn unwrapped_as<Dst>(self) -> Dst
where T: UnwrappedCast<Dst>,

Casts the value.
Source§

impl<Src, Dst> UnwrappedCastFrom<Src> for Dst
where Src: UnwrappedCast<Dst>,

Source§

fn unwrapped_cast_from(src: Src) -> Dst

Casts the value.
Source§

impl<T> WrappingAs for T

Source§

fn wrapping_as<Dst>(self) -> Dst
where T: WrappingCast<Dst>,

Casts the value.
Source§

impl<Src, Dst> WrappingCastFrom<Src> for Dst
where Src: WrappingCast<Dst>,

Source§

fn wrapping_cast_from(src: Src) -> Dst

Casts the value.