Struct hime_redist::ast::Ast
source · pub struct Ast<'a> { /* private fields */ }
Expand description
Represents a simple AST with a tree structure The nodes are stored in sequential arrays where the children of a node are an inner sequence. The linkage is represented by each node storing its number of children and the index of its first child.
Implementations§
source§impl<'a> Ast<'a>
impl<'a> Ast<'a>
sourcepub fn new(
tokens: TokenRepository<'a>,
variables: &'static [Symbol],
virtuals: &'static [Symbol],
data: &'a AstImpl
) -> Ast<'a>
pub fn new(
tokens: TokenRepository<'a>,
variables: &'static [Symbol],
virtuals: &'static [Symbol],
data: &'a AstImpl
) -> Ast<'a>
Creates a new AST proxy structure
sourcepub fn new_mut(
variables: &'static [Symbol],
virtuals: &'static [Symbol],
data: &'a mut AstImpl
) -> Ast<'a>
pub fn new_mut(
variables: &'static [Symbol],
virtuals: &'static [Symbol],
data: &'a mut AstImpl
) -> Ast<'a>
Creates a new AST proxy structure
sourcepub fn get_variables(&self) -> &'static [Symbol]
pub fn get_variables(&self) -> &'static [Symbol]
Gets the grammar variables for this AST
sourcepub fn get_virtuals(&self) -> &'static [Symbol]
pub fn get_virtuals(&self) -> &'static [Symbol]
Gets the grammar virtuals for this AST
sourcepub fn find_node_for(&self, token: &Token<'a>) -> Option<AstNode<'_>>
pub fn find_node_for(&self, token: &Token<'a>) -> Option<AstNode<'_>>
Gets the AST node (if any) that has the specified token as label
sourcepub fn find_node_at_index(&self, index: usize) -> Option<AstNode<'_>>
pub fn find_node_at_index(&self, index: usize) -> Option<AstNode<'_>>
Gets the AST node (if any) that has a token label that contains the specified index in the input text
sourcepub fn find_node_at_position(
&self,
position: TextPosition
) -> Option<AstNode<'_>>
pub fn find_node_at_position(
&self,
position: TextPosition
) -> Option<AstNode<'_>>
Gets the AST node (if any) that has a token label that contains the specified index in the input text
sourcepub fn find_parent_of(&self, node: usize) -> Option<AstNode<'_>>
pub fn find_parent_of(&self, node: usize) -> Option<AstNode<'_>>
Gets the parent of the specified node, if any
sourcepub fn store(&mut self, nodes: &Vec<AstCell>, index: usize, count: usize) -> usize
pub fn store(&mut self, nodes: &Vec<AstCell>, index: usize, count: usize) -> usize
Stores some children nodes in this AST
sourcepub fn store_root(&mut self, node: AstCell)
pub fn store_root(&mut self, node: AstCell)
Stores the root of this tree