pub struct ElementDef {
pub owner: FeatureName,
pub names: Vec<Name>,
pub syntax: SyntaxDef,
pub element: Arc<ElementSpec>,
pub docs: String,
pub modes: Vec<Mode>,
}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.
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.
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].
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 ElementDef
impl Move for ElementDef
impl Send for ElementDef
impl Sync for ElementDef
impl Unpin for ElementDef
impl UnsafeUnpin for ElementDef
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