pub enum Node<'a> {
Tag(Tag<'a>),
Ident(Ann<Atom<'a>>),
Enclosure(Ann<Enclosure<'a, Node<'a>>>),
String(Ann<Atom<'a>>),
InvalidToken(Ann<Atom<'a>>),
}
Variants§
Tag(Tag<'a>)
The parser doesn’t emit AST Tag
nodes. This is done in a later
processing phase.
Ident(Ann<Atom<'a>>)
Some identifier that may or may not be followed by square parentheses
and/or a curly brace enclosure. E.g. \name
.
Enclosure(Ann<Enclosure<'a, Node<'a>>>)
An enclosure can be a multitude of things:
- Some syntactic enclosure:
- Curly braces
- Parentheses
- Square parentheses
- Some error with it’s invalid start & end token (i.e. a opening
[
and closing}
) - Additionally, after parsing, an enclosure can also be a fragment (i.e. a list of AST nodes)
String(Ann<Atom<'a>>)
Some string of arbitrary characters or a single special token.
InvalidToken(Ann<Atom<'a>>)
Some unbalanced token that isn’t associated with an enclosure. In Subscript, enclosure symbols must be balanced. If the author must use such in their publications, then use the tag version.
Implementations§
Source§impl<'a> Node<'a>
impl<'a> Node<'a>
Sourcepub fn new_tag(name: Ann<&'a str>, children: Vec<Node<'a>>) -> Self
pub fn new_tag(name: Ann<&'a str>, children: Vec<Node<'a>>) -> Self
Some tag with no parameters and just children.
pub fn new_ident(str: Ann<&'a str>) -> Self
pub fn new_enclosure( range: CharRange, kind: EnclosureKind<'a>, children: Vec<Node<'a>>, ) -> Self
pub fn new_string(str: Ann<&'a str>) -> Self
pub fn unannotated_tag(name: &'a str, children: Vec<Node<'a>>) -> Self
pub fn unannotated_tag_(name: &'a str, child: Node<'a>) -> Self
pub fn unannotated_ident(str: &'a str) -> Self
pub fn unannotated_enclosure( kind: EnclosureKind<'a>, children: Vec<Node<'a>>, ) -> Self
pub fn unannotated_str(str: &'a str) -> Self
pub fn unannotated_string(str: String) -> Self
pub fn new_fragment(nodes: Vec<Self>) -> Self
pub fn is_whitespace(&self) -> bool
pub fn is_tag(&self) -> bool
pub fn is_ident(&self) -> bool
pub fn is_enclosure(&self) -> bool
pub fn is_string(&self) -> bool
pub fn is_any_enclosure(&self) -> bool
pub fn is_enclosure_of_kind(&self, k: EnclosureKind<'_>) -> bool
pub fn is_named_block(&self, name: &str) -> bool
pub fn get_string(&'a self) -> Option<Ann<Atom<'a>>>
pub fn get_enclosure_children( &self, kind: EnclosureKind<'_>, ) -> Option<&Vec<Node<'a>>>
pub fn unblock(self) -> Vec<Self>
Sourcepub fn into_fragment(self) -> Vec<Self>
pub fn into_fragment(self) -> Vec<Self>
Unpacks an Node::Enclosure
with the Fragment
kind or
returns a singleton vec.
pub fn unwrap_tag(&self) -> Option<&Tag<'a>>
pub fn unwrap_tag_mut(&mut self) -> Option<&mut Tag<'a>>
pub fn unwrap_ident<'b>(&'b self) -> Option<&'b Ann<Atom<'a>>>
pub fn unwrap_enclosure<'b>( &'b self, ) -> Option<&'b Ann<Enclosure<'a, Node<'a>>>>
pub fn unwrap_curly_brace<'b>(&'b self) -> Option<&'b Vec<Node<'a>>>
pub fn unwrap_string<'b>(&'b self) -> Option<&'b Ann<Atom<'a>>>
pub fn unwrap_string_mut<'b>(&'b mut self) -> Option<&'b mut Ann<Atom<'a>>>
pub fn into_tag(self) -> Option<Tag<'a>>
Sourcepub fn transform<F: Fn(NodeEnvironment<'a>, Node<'a>) -> Node<'a>>(
self,
env: NodeEnvironment<'a>,
f: Rc<F>,
) -> Self
pub fn transform<F: Fn(NodeEnvironment<'a>, Node<'a>) -> Node<'a>>( self, env: NodeEnvironment<'a>, f: Rc<F>, ) -> Self
Bottom up ‘node to ndoe’ transformation.
pub fn transform_mut<F: FnMut(NodeEnvironment<'a>, Node<'a>) -> Node<'a>>( self, env: NodeEnvironment<'a>, f: Rc<RefCell<F>>, ) -> Self
Sourcepub fn transform_children<F>(self, f: Rc<F>) -> Self
pub fn transform_children<F>(self, f: Rc<F>) -> Self
Bottom up transformation of AST child nodes within the same enclosure.
Sourcepub fn into_highlight_ranges(
self,
nesting: Vec<Atom<'a>>,
binder: Option<Atom<'a>>,
) -> Vec<Highlight<'a>>
pub fn into_highlight_ranges( self, nesting: Vec<Atom<'a>>, binder: Option<Atom<'a>>, ) -> Vec<Highlight<'a>>
For syntax highlighting VIA the compiler frontend.
pub fn syntactically_equal(&self, other: &Self) -> bool
Sourcepub fn push_child(self, child: Self) -> Self
pub fn push_child(self, child: Self) -> Self
Push to a fragment or tag node.
TODO: Should we also push to any EnclosureKind
?