pub struct Surface { /* private fields */ }Expand description
The surface environment: a stack of scopes, innermost last.
Implementations§
Source§impl Surface
impl Surface
Sourcepub fn new() -> Self
pub fn new() -> Self
A surface with nothing declared. The parse path it produces is byte-identical to having no surface at all, which is what keeps the extension point free when nobody uses it.
Sourcepub fn namespaces(&self) -> &Namespaces
pub fn namespaces(&self) -> &Namespaces
The namespace scope: what is current, what is open.
Sourcepub fn namespaces_mut(&mut self) -> &mut Namespaces
pub fn namespaces_mut(&mut self) -> &mut Namespaces
The namespace scope, to push and wind back a SCOPED opening — Open … in <command>, and a
declaration whose own name names the namespace it is written into.
Sourcepub fn enter_declaration(&mut self, declared: &Name) -> (String, ScopeMark)
pub fn enter_declaration(&mut self, declared: &Name) -> (String, ScopeMark)
Enter the scope a DECLARATION named declared elaborates in, and give back the absolute key
it declares. See Namespaces::enter_declaration; this is the door, because only the surface
knows how deep the section stack is, and that is what orders the two scope stacks.
Sourcepub fn is_empty(&self) -> bool
pub fn is_empty(&self) -> bool
Is anything declared? A surface with no notations and no macros is skipped entirely.
Sourcepub fn section_depth(&self) -> usize
pub fn section_depth(&self) -> usize
How many SECTIONS are open. The root scope is never pushed and never popped, so it is not one of them.
Sourcepub fn section_names(&self) -> Vec<String>
pub fn section_names(&self) -> Vec<String>
The open sections, outermost first \u{2014} what a document must close before it ends. An anonymous section is named AS one rather than as the empty string, so an unbalanced document reports something a reader can act on.
Sourcepub fn close_sections_to(&mut self, depth: usize)
pub fn close_sections_to(&mut self, depth: usize)
Close every section opened since depth. Only ever SHRINKS: a section already closed took
its notations with it and cannot be brought back, which is why an over-closing document is
reported rather than silently repaired.
Sourcepub fn declare(&mut self, decl: SurfaceDecl) -> Result<(), ParseError>
pub fn declare(&mut self, decl: SurfaceDecl) -> Result<(), ParseError>
Apply one surface declaration.
Sourcepub fn expand_macros(&self, text: &str) -> Result<String, ParseError>
pub fn expand_macros(&self, text: &str) -> Result<String, ParseError>
Rewrite every macro invocation in text until none remains.
Text in, text out, because an alternative may invoke the macro it is defining
(nested![$x, $xs] expands to a mycons applied to nested![$xs]) and that inner call
can only be matched once its argument is known. The step budget is a hard backstop: a
recursive rule that never reaches its base case FAILS rather than hangs.