pub struct FlmStateExt {
pub structural: Arc<StructuralElements>,
pub restricted_interior: RestrictedInterior,
pub parsing: Arc<FlmParsing>,
}Expand description
The state extension: the data FLM attaches to every parsing state, which applies at the point where a node is built.
It holds the structural elements, from which every node that is not a declared callable takes its element; the restricted-interior policy; and the parsing settings of the file being read.
The value never changes in place. A different extension is installed by
deriving a new parsing state with it (ParsingStateDelta::new().ext(…)):
crate::lang::build installs the registry’s structural elements that way,
and the parse of a template switches to the
Template policy that way.
Fields§
§structural: Arc<StructuralElements>The structural elements that apply: the elements of the nodes that are not declared callables.
restricted_interior: RestrictedInteriorWhat the interior of a restricted argument (a characters-only group or a verbatim region) recognizes.
parsing: Arc<FlmParsing>The parsing settings under which the current file is read.
In the document’s primary file, these are the document’s settings, which
the initial state of a built language carries. In a file included with
\input, they are the settings that apply where the command is written,
with the included file’s own settings on top (crate::lang::input).
The language’s initial parsing state, from which no document is parsed,
carries the defaults.
The tokenizer rules of the state are derived from these settings; this
field records which settings they came from, for the code that needs
them during the parse: \input passes them to the embedding program
(InputResolver::resolve), and
the diagnostic for a lone %
(PercentForbidden) states from them how
to start a comment.
Implementations§
Source§impl FlmStateExt
impl FlmStateExt
Sourcepub fn new(structural: Arc<StructuralElements>) -> FlmStateExt
pub fn new(structural: Arc<StructuralElements>) -> FlmStateExt
Returns an extension carrying structural, with the
Document restricted-interior policy and
the default parsing settings.
Sourcepub fn with_parsing(self, parsing: FlmParsing) -> FlmStateExt
pub fn with_parsing(self, parsing: FlmParsing) -> FlmStateExt
Builder: sets the parsing settings of the file being read
(parsing). It only records them and changes no
tokenizer rule: the caller applies the matching rules
(FlmParsing::state_delta or FlmParsing::token_rules_overrides) in
the same derivation of the parsing state.
Sourcepub fn with_restricted_interior(self, policy: RestrictedInterior) -> FlmStateExt
pub fn with_restricted_interior(self, policy: RestrictedInterior) -> FlmStateExt
Builder: sets the restricted-interior policy
(restricted_interior).
§Examples
use flm_core::lang::{FlmStateExt, RestrictedInterior};
let ext = FlmStateExt::default()
.with_restricted_interior(RestrictedInterior::Template(Default::default()));
assert!(ext.restricted_interior.is_template());Trait Implementations§
Source§impl Clone for FlmStateExt
impl Clone for FlmStateExt
Source§impl Debug for FlmStateExt
impl Debug for FlmStateExt
Source§impl Default for FlmStateExt
impl Default for FlmStateExt
Source§fn default() -> FlmStateExt
fn default() -> FlmStateExt
Source§impl DeserializableValue<Flm> for FlmStateExt
The structural elements are read back as the reading language’s own shared
set (ReadEnvironment::structural), so every state read in one session
shares it. The serialized names are first checked against that set, and a
mismatch is a read error, never a silent substitution.
impl DeserializableValue<Flm> for FlmStateExt
The structural elements are read back as the reading language’s own shared
set (ReadEnvironment::structural), so every state read in one session
shares it. The serialized names are first checked against that set, and a
mismatch is a read error, never a silent substitution.
Source§fn deserialize_value(
value: &SerialValue,
cx: &mut DeserializeContext<'_, Flm>,
) -> Result<Self, DeserializeError>
fn deserialize_value( value: &SerialValue, cx: &mut DeserializeContext<'_, Flm>, ) -> Result<Self, DeserializeError>
cx gives the call access to the
state of the deserialization in progress. Read moreSource§fn deserialize_field(
name: &'static str,
value: Option<&SerialValue>,
cx: &mut DeserializeContext<'_, L>,
) -> Result<Self, DeserializeError>where
L: SerializableLang,
fn deserialize_field(
name: &'static str,
value: Option<&SerialValue>,
cx: &mut DeserializeContext<'_, L>,
) -> Result<Self, DeserializeError>where
L: SerializableLang,
name of a structure whose fields are read by
name (a type with #[derive(DeserializableValue)]): value is the field’s
value, or None when the key is missing from the map. The default requires
the key and reads its value with deserialize_value;
Option<T> reads a missing key as None. The counterpart of
SerializableValue::is_absent_field: a type overriding one overrides both. Read moreSource§impl SerializableValue<Flm> for FlmStateExt
A state extension is written as {structural, restricted_interior, parsing}, where structural is the list of structural element names in
their fixed order and parsing the parsing settings under their field
names. The elements are written by name only, because a state refers to
elements and does not own them.
impl SerializableValue<Flm> for FlmStateExt
A state extension is written as {structural, restricted_interior, parsing}, where structural is the list of structural element names in
their fixed order and parsing the parsing settings under their field
names. The elements are written by name only, because a state refers to
elements and does not own them.
Source§fn serialize_value(
&self,
cx: &mut SerializeContext<'_, Flm>,
) -> Result<SerialValue, SerializeError>
fn serialize_value( &self, cx: &mut SerializeContext<'_, Flm>, ) -> Result<SerialValue, SerializeError>
cx gives the call access to the state
of the serialization in progress — a value that refers to a table object
(a span’s source, say) interns it through cx and embeds the position. Read moreSource§fn is_absent_field(&self) -> boolwhere
L: SerializableLang,
fn is_absent_field(&self) -> boolwhere
L: SerializableLang,
#[derive(SerializableValue)]), is left out of the structure’s map
entirely — no key at all, rather than a key with a null value. The default is
false; Option<T> is absent when it is None. Read moreAuto Trait Implementations§
impl !RefUnwindSafe for FlmStateExt
impl !UnwindSafe for FlmStateExt
impl Forget for FlmStateExt
impl Freeze for FlmStateExtwhere
*const ArcInner<StructuralElements> is !null: Freeze,
PhantomData<ArcInner<StructuralElements>>: Freeze,
*const u8 is !null: Freeze,
PhantomData<TemplateCommandRule>: Freeze,
*const ArcInner<FlmParsing> is !null: Freeze,
PhantomData<ArcInner<FlmParsing>>: Freeze,
impl Move for FlmStateExt
impl Send for FlmStateExt
impl Sync for FlmStateExt
impl Unpin for FlmStateExt
impl UnsafeUnpin for FlmStateExtwhere
*const ArcInner<StructuralElements> is !null: UnsafeUnpin,
PhantomData<ArcInner<StructuralElements>>: UnsafeUnpin,
*const u8 is !null: UnsafeUnpin,
PhantomData<TemplateCommandRule>: UnsafeUnpin,
*const ArcInner<FlmParsing> is !null: UnsafeUnpin,
PhantomData<ArcInner<FlmParsing>>: 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