pub enum SyntaxDef {
Macro {
args: Vec<ArgDef>,
},
Environment {
args: Vec<ArgDef>,
body: BodyDef,
},
Inclusion {
args: Vec<ArgDef>,
},
Specials {
trigger: String,
args: Vec<ArgDef>,
},
Synthesized,
}Expand description
How an element is written in the source: as a macro, an environment, a file-inclusion macro, a special character sequence, or not at all.
Each form holds its list of argument declarations (ArgDef), and an
environment also holds a body declaration (BodyDef). A syntax the
standard argument kinds cannot express is still one of these forms: its
argument, or its body, holds a parser of the feature’s own
(FlmArgumentParser, FlmBodyParser), with its name, layout,
documentation, mode and scoped packages declared like any other. Only these
declarations reach techy: minting builds every specification from them.
Variants§
Macro
A macro taking the given arguments, registered under each of the declaration’s names.
Environment
An environment taking the given arguments, written after \begin{name},
and the given body; registered under each of the declaration’s names.
Fields
Inclusion
A macro that brings the content of another file into the document,
written \input{reference}. One of the given arguments must be named
REFERENCE_ARGUMENT; it holds
the reference as plain characters, and minting reports a declaration
without it as
MintError::NoReferenceArgument.
The macro is registered under each of the declaration’s names and
parsed by the language’s own inclusion parser (crate::lang::input),
which asks the input resolver on the
parse driver for the file and parses the
file’s content where the command is written.
Specials
A special character sequence with the given trigger and arguments. The declaration lists no name: the trigger is how the sequence is written.
Fields
Synthesized
No syntax: the element is never parsed, and only a rewrite or a lowering stage creates nodes of it, such as a heading’s number or a pointer to another node’s argument. The declaration lists no name.
Implementations§
Source§impl SyntaxDef
impl SyntaxDef
Sourcepub fn kind(&self) -> Option<CallableKind>
pub fn kind(&self) -> Option<CallableKind>
Returns the callable kind this syntax is registered under (a
file-inclusion macro is a macro); None for
SyntaxDef::Synthesized, which is not registered.
Sourcepub fn args(&self) -> &[ArgDef]
pub fn args(&self) -> &[ArgDef]
Returns the argument declarations of this syntax, in the order they are
written; empty for SyntaxDef::Synthesized, which takes none.
use flm_core::lang::mint::{ArgDef, SyntaxDef};
let syntax = SyntaxDef::Macro { args: vec![ArgDef::mandatory("text")] };
assert_eq!(syntax.args().len(), 1);
assert!(SyntaxDef::Synthesized.args().is_empty());Trait Implementations§
Auto Trait Implementations§
impl !RefUnwindSafe for SyntaxDef
impl !UnwindSafe for SyntaxDef
impl Forget for SyntaxDef
impl Freeze for SyntaxDefwhere
*const u8 is !null: Freeze,
PhantomData<ArgDef>: Freeze,
*const ArcInner<dyn FlmBodyParser> is !null: Freeze,
PhantomData<ArcInner<dyn FlmBodyParser>>: Freeze,
PhantomData<Name>: Freeze,
PhantomData<FlmEvent>: Freeze,
PhantomData<u8>: Freeze,
impl Move for SyntaxDef
impl Send for SyntaxDefwhere
RawVecInner: Send,
Arc<dyn FlmArgumentParser>: Send,
Arc<str>: Send,
Arc<dyn FlmBodyParser>: Send,
impl Sync for SyntaxDefwhere
RawVecInner: Sync,
Arc<dyn FlmArgumentParser>: Sync,
Arc<str>: Sync,
Arc<dyn FlmBodyParser>: Sync,
impl Unpin for SyntaxDef
impl UnsafeUnpin for SyntaxDefwhere
*const u8 is !null: UnsafeUnpin,
PhantomData<ArgDef>: UnsafeUnpin,
*const ArcInner<dyn FlmBodyParser> is !null: UnsafeUnpin,
PhantomData<ArcInner<dyn FlmBodyParser>>: UnsafeUnpin,
PhantomData<Name>: UnsafeUnpin,
PhantomData<FlmEvent>: UnsafeUnpin,
PhantomData<u8>: 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