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() -> Surface
pub fn new() -> Surface
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.
Trait Implementations§
Auto Trait Implementations§
impl !Freeze for Surface
impl RefUnwindSafe for Surface
impl Send for Surface
impl Sync for Surface
impl Unpin for Surface
impl UnsafeUnpin for Surface
impl UnwindSafe for Surface
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<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can
then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be
further downcast into Rc<ConcreteType> where ConcreteType implements Trait.§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.