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
impl FlmDriver
Sourcepub fn new(
recovery: Recovery,
diagnostics_limit: Option<usize>,
standard_state: Arc<ParsingState<Flm>>,
) -> FlmDriver
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).
Sourcepub fn with_diagnostics_limit(self, limit: Option<usize>) -> FlmDriver
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).
Sourcepub fn with_standard_state(self, state: Arc<ParsingState<Flm>>) -> FlmDriver
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.
Sourcepub fn with_input_resolver(self, resolver: Arc<dyn InputResolver>) -> FlmDriver
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.
Sourcepub fn input_resolver(&self) -> Option<&dyn InputResolver>
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.
Sourcepub fn diagnostics_limit_setting(&self) -> Option<usize>
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 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.
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>>
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>>
Source§impl ParseDriver<Flm> for FlmDriver
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>>
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>
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>
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 isDollarMathDisabled. - For
%, the replacement isPercentForbidden. This condition gives the comment prefix of the parsing settings instate, 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>,
)
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>>
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\inputapplies 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>>
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
fn recovery(&self) -> Recovery
Source§fn diagnostics_limit(&self) -> Option<usize>
fn diagnostics_limit(&self) -> Option<usize>
None — the default — for the
standard cap (Diagnostics::DEFAULT_LIMIT). Read moreSource§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>>
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>>
Source§fn make_token_reader<'s>(
&'s self,
source: &'s Arc<Source<<L as Lang>::SourceOrigin>>,
) -> Box<dyn TokenReader<'s, L> + 's>
fn make_token_reader<'s>( &'s self, source: &'s Arc<Source<<L as Lang>::SourceOrigin>>, ) -> Box<dyn TokenReader<'s, L> + 's>
source through. Read moreSource§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>>
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>>
state without consuming
it, mapping a tokenizer error to the recovery policy. Read moreSource§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>>
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>>
Source§fn source_resolver(
&self,
) -> Option<&(dyn SourceResolver<<L as Lang>::SourceOrigin> + 'static)>
fn source_resolver( &self, ) -> Option<&(dyn SourceResolver<<L as Lang>::SourceOrigin> + 'static)>
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 moreSource§fn make_root_parser<'p>(
&'p self,
) -> Result<Box<dyn ConstructParser<L, Output = BuildId> + 'p>, ParseError<<L as Lang>::SourceOrigin>>
fn make_root_parser<'p>( &'p self, ) -> Result<Box<dyn ConstructParser<L, Output = BuildId> + 'p>, ParseError<<L as Lang>::SourceOrigin>>
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>>
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>>
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>>
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>>
GroupOpen token already consumed
and the rule it matched. Read moreSource§fn make_invocation_parser<'a>(
&'a self,
invocation: Invocation<'a, L>,
) -> Result<Box<dyn ConstructParser<L, Output = BuildId> + 'a>, ParseError<<L as Lang>::SourceOrigin>>
fn make_invocation_parser<'a>( &'a self, invocation: Invocation<'a, L>, ) -> Result<Box<dyn ConstructParser<L, Output = BuildId> + 'a>, ParseError<<L as Lang>::SourceOrigin>>
Auto Trait Implementations§
impl !RefUnwindSafe for FlmDriver
impl !UnwindSafe for FlmDriver
impl Forget for FlmDriver
impl Freeze for FlmDriverwhere
*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
impl Sync for FlmDriver
impl Unpin for FlmDriver
impl UnsafeUnpin for FlmDriverwhere
*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> 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<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CheckedAs for T
impl<T> CheckedAs for T
Source§fn checked_as<Dst>(self) -> Option<Dst>where
T: CheckedCast<Dst>,
fn checked_as<Dst>(self) -> Option<Dst>where
T: CheckedCast<Dst>,
Source§impl<Src, Dst> CheckedCastFrom<Src> for Dstwhere
Src: CheckedCast<Dst>,
impl<Src, Dst> CheckedCastFrom<Src> for Dstwhere
Src: CheckedCast<Dst>,
Source§fn checked_cast_from(src: Src) -> Option<Dst>
fn checked_cast_from(src: Src) -> Option<Dst>
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
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