pub struct FlmFallbackProvider { /* private fields */ }Expand description
The fallback provider: the specification provider that resolves a macro or
an environment that no declaration defines, according to the fallbacks
(FallbackDef) declared for the current parsing mode.
techy’s own fallback provider cannot be restricted to parsing modes, so
minting builds this provider instead. The language build puts it at the
bottom of the scope stack, so every defined name shadows it. It returns
specifications from the techy package it holds
(FlmFallbackProvider::package).
The fallbacks are consulted in declaration order, with the language’s own
two last, so a feature’s fallback for a mode applies in that mode. In a
mode no feature’s fallback covers, the language’s own fallbacks apply: the
command is reported and its node carries flm.unknown.macro or
flm.unknown.environment. Text mode therefore reports unknown commands,
while mathematics mode, with a mathematics feature registered, does not.
It resolves any name, so it cannot list its entries; the package
beside it is therefore listed separately in BuiltLang::providers.
Implementations§
Source§impl FlmFallbackProvider
impl FlmFallbackProvider
Sourcepub fn package(&self) -> &Arc<Package<Flm>> ⓘ
pub fn package(&self) -> &Arc<Package<Flm>> ⓘ
Returns the techy package holding the fallback specifications, which their provenance stamps refer to. It is never on the scope stack.
Sourcepub fn entries(
&self,
) -> impl Iterator<Item = (&FeatureName, &[Mode], FallbackKind)> + '_
pub fn entries( &self, ) -> impl Iterator<Item = (&FeatureName, &[Mode], FallbackKind)> + '_
Returns the installed fallbacks as (owner, modes, kind), in the order
they are consulted: declaration order, with the language’s own two last
(owned by LANGUAGE_OWNER). A fallback reported as a
MintError::Clash is not among them.
Sourcepub fn answers(&self, kind: FallbackKind, mode: Mode) -> bool
pub fn answers(&self, kind: FallbackKind, mode: Mode) -> bool
Returns whether some fallback applies to kind in mode. It always
returns true, since the language’s own two fallbacks apply to both
kinds in every mode.
Sourcepub fn spec_for(
&self,
kind: FallbackKind,
mode: Mode,
) -> Option<&Arc<dyn CallableSpec<Flm>>>
pub fn spec_for( &self, kind: FallbackKind, mode: Mode, ) -> Option<&Arc<dyn CallableSpec<Flm>>>
Returns the specification for kind in mode: that of the first
installed fallback that covers them.
Trait Implementations§
Source§impl Debug for FlmFallbackProvider
impl Debug for FlmFallbackProvider
Source§impl DeserializableObject<Flm> for FlmFallbackProvider
Looked up among the reading session’s providers (techy’s KnownProviders
in its user data): the gate registered under the written name.
impl DeserializableObject<Flm> for FlmFallbackProvider
Looked up among the reading session’s providers (techy’s KnownProviders
in its user data): the gate registered under the written name.
Source§type Output = Arc<dyn SpecsProvider<Flm>>
type Output = Arc<dyn SpecsProvider<Flm>>
deserialize_object produces.Source§fn deserialize_object(
value: &SerialValue,
cx: &mut DeserializeContext<'_, Flm>,
) -> Result<Self::Output, DeserializeError>
fn deserialize_object( value: &SerialValue, cx: &mut DeserializeContext<'_, Flm>, ) -> Result<Self::Output, DeserializeError>
value. Read moreSource§impl SerializableObject<Flm> for FlmFallbackProvider
Written by identity as {name} under FALLBACK_GATE_IDENTIFIER: the gate
belongs to the reading language, as a package does. The specifications it
returns are held in the fallback package, which is written by identity
separately.
impl SerializableObject<Flm> for FlmFallbackProvider
Written by identity as {name} under FALLBACK_GATE_IDENTIFIER: the gate
belongs to the reading language, as a package does. The specifications it
returns are held in the fallback package, which is written by identity
separately.
Source§fn serialize_object(
&self,
cx: &mut SerializeContext<'_, Flm>,
) -> Result<SerialEntry, SerializeError>
fn serialize_object( &self, cx: &mut SerializeContext<'_, Flm>, ) -> Result<SerialEntry, SerializeError>
SerialEntry. Read moreSource§impl SpecsProvider<Flm> for FlmFallbackProvider
impl SpecsProvider<Flm> for FlmFallbackProvider
Source§fn name(&self) -> &str
fn name(&self) -> &str
ScopeOp::Define routing),
and how it appears in diagnostics (the miss detail of
ScopeStack::searched_providers, the provider context of a
ScopeStackError). Names need not be unique on a stack; name-targeted ops
address the innermost match.Source§fn retrieve_spec(
&self,
query: &CallableQuery<'_, Flm>,
state: &ParsingState<Flm>,
) -> Result<Option<Arc<dyn CallableSpec<Flm>>>, ProviderError>
fn retrieve_spec( &self, query: &CallableQuery<'_, Flm>, state: &ParsingState<Flm>, ) -> Result<Option<Arc<dyn CallableSpec<Flm>>>, ProviderError>
query in this provider: Ok(Some(spec)) on a hit, Ok(None) for “not
defined here — continue outward” (which includes “not visible here”: per-mode
visibility is the provider’s own business, checked against
state.mode(); the stack is visibility-blind). Err means
the provider itself failed — an operational error that stops the search over the
stack, never a panic.Source§fn scan_specials(
&self,
state: &ParsingState<L>,
content: &str,
pos: usize,
) -> Result<Option<SpecialsMatch<L>>, SpecialsScanError>
fn scan_specials( &self, state: &ParsingState<L>, content: &str, pos: usize, ) -> Result<Option<SpecialsMatch<L>>, SpecialsScanError>
content[pos..]? Same contract as the
Lang::scan_specials hook it feeds through
the ScopeStack::scan_specials search — including the SpecialsMatch::end
obligations and the recovery-token protocol (the TokenResult shape is
deliberate: a scanning provider keeps the tokenizer’s recoverable-failure
channel, which a ProviderError could not express). Implementations should return their longest match at pos.
The default recognizes nothing. Read moreSource§fn specials_trigger_chars(&self) -> TriggerChars
fn specials_trigger_chars(&self) -> TriggerChars
ScopeStack::specials_trigger_chars) into the
per-state filter. Must be a conservative superset of the first characters of
every trigger scan_specials can match,
regardless of state (there is deliberately no state parameter: the union is
cached on frozen states — a mode-invisible provider’s chars stay in the filter
and its scan declines instead). The default: no specials.Source§fn with_definitions(
&self,
ops: &[DefinitionOp<L>],
) -> Result<Arc<dyn SpecsProvider<L>>, ProviderError>
fn with_definitions( &self, ops: &[DefinitionOp<L>], ) -> Result<Arc<dyn SpecsProvider<L>>, ProviderError>
ops,
leaving self untouched. This is the copy-on-write mechanism (Arc::make_mut
does not exist for dyn types): the stack replaces its entry with the returned
Arc, and outer states keep holding the old one — scoped reversion stays
structural. Atomic per call: on Err, no partial application may be observable. Read moreSource§fn iter_symbols(
&self,
callable_type: <L as Lang>::CallableTypeId,
mode: <L as Lang>::ModeId,
) -> Option<Box<dyn Iterator<Item = SymbolEntry<'_, L>> + '_>>
fn iter_symbols( &self, callable_type: <L as Lang>::CallableTypeId, mode: <L as Lang>::ModeId, ) -> Option<Box<dyn Iterator<Item = SymbolEntry<'_, L>> + '_>>
callable_type
that are visible under mode.
Visibility is the provider’s own business, exactly as in
retrieve_spec — and since visibility is
mode-determined at every grain, the mode alone is passed, not a full state. Read moreAuto Trait Implementations§
impl !RefUnwindSafe for FlmFallbackProvider
impl !UnwindSafe for FlmFallbackProvider
impl Forget for FlmFallbackProvider
impl Freeze for FlmFallbackProvider
impl Move for FlmFallbackProvider
impl Send for FlmFallbackProvider
impl Sync for FlmFallbackProvider
impl Unpin for FlmFallbackProvider
impl UnsafeUnpin for FlmFallbackProviderwhere
*const str is !null: UnsafeUnpin,
PhantomData<str>: UnsafeUnpin,
*const ArcInner<Package<Flm>> is !null: UnsafeUnpin,
PhantomData<ArcInner<Package<Flm>>>: UnsafeUnpin,
*const u8 is !null: UnsafeUnpin,
PhantomData<FallbackEntry>: 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> 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