pub struct Declarations {
pub commands: CommandDecls,
pub environments: EnvironmentDecls,
}Expand description
Every declaration a project makes, as authored — unresolved and unvalidated.
BTreeMap rather than HashMap so iteration order is deterministic:
resolution reports errors in the order the user reads them, and the value
ends up on a salsa input whose equality must not depend on hash order.
Fields§
§commands: CommandDeclsThe [commands.<name>] semantic aliases.
environments: EnvironmentDeclsThe [environments.<name>] entries.
Implementations§
Source§impl Declarations
impl Declarations
Sourcepub fn is_empty(&self) -> bool
pub fn is_empty(&self) -> bool
Whether the project declares nothing at all — the overwhelmingly common case, and the one the parse must not pay anything for.
Sourcepub fn resolve(&self) -> Result<ResolvedDeclarations, DeclarationError>
pub fn resolve(&self) -> Result<ResolvedDeclarations, DeclarationError>
Check every rule and project the declarations into a
ResolvedDeclarations: an environment signature per like, and the
delimiter spellings as opener and closer alias entries.
Environment behavior and delimiter aliases resolve into a SignatureDb
so they fold into the existing scope machinery. Command aliases stay in a
separate deterministic map because they must not become parser or
formatter signatures.
Every failure is an error, never a silent no-op. A declaration that
quietly does nothing is the worst outcome available here: the user sees
unchanged output and has no way to tell a typo from an unimplemented
feature. Errors surface in key order (the map is a BTreeMap), so the
message is stable across runs.
An entry that declares behavior alone is unrestricted — like = "lstlisting" is exactly how a project names a verbatim environment the
definition scan cannot find. The extra restrictions below apply only to
an entry that declares delimiter spellings, since those are the ones a
command has to stand in for. An entry that declares nothing is the
one shape rejected for saying too little rather than too much.
One side alone is fine (issue #117): the literal \begin{X}/\end{X} is
a spelling of each side too, so begin = ['\bsplit'] with no end
declares an opener the written-out \end{split} closes. This used to be
two errors, on the reasoning that a half-declared pair could never pair.
Trait Implementations§
Source§impl Clone for Declarations
impl Clone for Declarations
Source§fn clone(&self) -> Declarations
fn clone(&self) -> Declarations
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more