pub struct ElementDef {
pub owner: FeatureName,
pub names: Vec<Name>,
pub syntax: SyntaxDef,
pub element: Arc<ElementSpec>,
pub docs: String,
pub modes: Vec<Mode>,
pub weak: bool,
}Expand description
An element declaration: the plain data a feature gives for an element, the syntax it is written in (macro, environment or special character sequence), its arguments (each with a parser, a layout, a parsing mode and the scoped packages available inside it) and its body.
Besides the syntax (SyntaxDef), the declaration holds the feature that
declares it, the names the element is written under, the element value its
nodes carry, the parsing modes it is available in, and documentation. A
feature passes it to
FeatureBuilder::element,
or places it in a ScopedPackageDef.
A declaration is available in text mode unless it lists its parsing modes
with ElementDef::modes: a feature that defines a command of mathematics
lists [Mode::Math], and one that defines a command for both modes lists
both. Two declarations of one name whose modes do not overlap never clash,
whether they come from one feature or from two: a text-mode \textbf and
a mathematics-mode \textbf are two different commands. A declaration
with no syntax (SyntaxDef::Synthesized) carries the field and ignores
it.
A declaration is ordinary unless it is marked weak with
ElementDef::weak. A weak declaration of a name applies in a parsing
mode only where no feature gives that name an ordinary declaration in that
mode, whatever the order of the features: a mathematics processor declares
its notation weakly, so that a package or a document that defines \ket
replaces the processor’s \ket without naming the processor in a feature
order. The module documentation of minting states the
rule. A declaration in a ScopedPackageDef may not be weak
(MintError::WeakInScopedPackage),
and a declaration with no syntax ignores the mark.
Fields§
§owner: FeatureNameThe feature that declares the element. Error messages identify the
declaration by it, and the symbol table
(MintedProviders::symbols) records
it. The feature builder sets it to the feature being built, so a
feature need not set it; a caller of
build_language that builds the
declarations by hand sets it here.
names: Vec<Name>The names this element is written under, without the escape
character. Several names may share one element value: the headings
feature, for instance, declares all the commands of one heading kind
under one element value. Empty for a special
character sequence and for an element with no syntax
(SyntaxDef::Synthesized).
syntax: SyntaxDefHow the element is written.
element: Arc<ElementSpec>The element value every node of this declaration carries.
docs: StringDocumentation of the declaration. The library does not act on it; the
registry keeps it with the declaration
(FlmRegistry::declarations)
for a program that describes what an author may write.
modes: Vec<Mode>The parsing modes the declaration is available in: [Mode::Text]
unless the feature lists others with ElementDef::modes. Ignored for
SyntaxDef::Synthesized, which no document writes.
weak: boolWhether the declaration is weak: it then applies in a parsing mode only
where no feature declares the name ordinarily in that mode. Off unless
the feature sets it with ElementDef::weak. Ignored for
SyntaxDef::Synthesized, which no document writes.
Implementations§
Source§impl ElementDef
impl ElementDef
Sourcepub fn new(
owner: impl Into<FeatureName>,
names: impl IntoIterator<Item = impl Into<Name>>,
syntax: SyntaxDef,
element: Arc<ElementSpec>,
) -> ElementDef
pub fn new( owner: impl Into<FeatureName>, names: impl IntoIterator<Item = impl Into<Name>>, syntax: SyntaxDef, element: Arc<ElementSpec>, ) -> ElementDef
Creates the declaration, by owner, that element is written as
syntax under names, with no documentation and available in text
mode only.
Sourcepub fn docs(self, docs: impl Into<String>) -> ElementDef
pub fn docs(self, docs: impl Into<String>) -> ElementDef
Builder: sets the declaration’s documentation.
Sourcepub fn modes(self, modes: impl IntoIterator<Item = Mode>) -> ElementDef
pub fn modes(self, modes: impl IntoIterator<Item = Mode>) -> ElementDef
Builder: sets the parsing modes the declaration is available in,
replacing the default, text mode. A feature that defines a command of
mathematics passes [Mode::Math]; one that defines a command for both
modes passes [Mode::Text, Mode::Math].
Sourcepub fn weak(self) -> ElementDef
pub fn weak(self) -> ElementDef
Builder: marks the declaration weak. In each of its parsing modes, it then applies only where no feature declares the same name ordinarily in that mode, whatever the order of the features; where several features declare the name weakly and none ordinarily, the feature order decides among the weak declarations as among ordinary ones (see the module documentation of minting).
Trait Implementations§
Source§impl Clone for ElementDef
impl Clone for ElementDef
Auto Trait Implementations§
impl !RefUnwindSafe for ElementDef
impl !UnwindSafe for ElementDef
impl Forget for ElementDef
impl Freeze for ElementDefwhere
*const ArcInner<str> is !null: Freeze,
PhantomData<ArcInner<str>>: Freeze,
*const u8 is !null: Freeze,
PhantomData<Name>: Freeze,
PhantomData<ArgDef>: Freeze,
*const ArcInner<dyn FlmBodyParser> is !null: Freeze,
PhantomData<ArcInner<dyn FlmBodyParser>>: Freeze,
PhantomData<FlmEvent>: Freeze,
PhantomData<u8>: Freeze,
*const ArcInner<ElementSpec> is !null: Freeze,
PhantomData<ArcInner<ElementSpec>>: Freeze,
PhantomData<Mode>: Freeze,
impl Move for ElementDef
impl Send for ElementDefwhere
Arc<str>: Send,
RawVecInner: Send,
Arc<dyn FlmArgumentParser>: Send,
Arc<dyn FlmBodyParser>: Send,
Arc<ElementSpec>: Send,
impl Sync for ElementDefwhere
Arc<str>: Sync,
RawVecInner: Sync,
Arc<dyn FlmArgumentParser>: Sync,
Arc<dyn FlmBodyParser>: Sync,
Arc<ElementSpec>: Sync,
impl Unpin for ElementDefwhere
Arc<str>: Unpin,
*const u8 is !null: Unpin,
Arc<dyn FlmArgumentParser>: Unpin,
Arc<dyn FlmBodyParser>: Unpin,
Arc<ElementSpec>: Unpin,
impl UnsafeUnpin for ElementDefwhere
*const ArcInner<str> is !null: UnsafeUnpin,
PhantomData<ArcInner<str>>: UnsafeUnpin,
*const u8 is !null: UnsafeUnpin,
PhantomData<Name>: UnsafeUnpin,
PhantomData<ArgDef>: UnsafeUnpin,
*const ArcInner<dyn FlmBodyParser> is !null: UnsafeUnpin,
PhantomData<ArcInner<dyn FlmBodyParser>>: UnsafeUnpin,
PhantomData<FlmEvent>: UnsafeUnpin,
PhantomData<u8>: UnsafeUnpin,
*const ArcInner<ElementSpec> is !null: UnsafeUnpin,
PhantomData<ArcInner<ElementSpec>>: UnsafeUnpin,
PhantomData<Mode>: 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