Struct hime_redist::parsers::subtree::SubTree
[−]
[src]
pub struct SubTree { /* fields omitted */ }
Represents a sub-tree in an AST
A sub-tree is composed of a root with its children.
The children may also have children.
The maximum depth of a sub-tree is 2 (root, children and children's children), in which case the root is always a replaceable node.
The internal representation of a sub-tree is based on arrays.
The organization is that a node's children are immediately following it in the array.
For example, the tree A(B(CD)E(FG))
is represented as [ABCDEFG]
.
Methods
impl SubTree
[src]
pub fn new(size: usize) -> SubTree
[src]
Creates a new sub-tree with the expected size
pub fn get_label_at(&self, index: usize) -> TableElemRef
[src]
Gets the label of the node at the given index
pub fn set_label_at(&mut self, index: usize, label: TableElemRef)
[src]
Sets the label of the node at the given index
pub fn get_action_at(&self, index: usize) -> TreeAction
[src]
Gets the tree action applied onto the node at the given index
pub fn set_action_at(&mut self, index: usize, action: TreeAction)
[src]
Sets the tree action applied onto the node at the given index
pub fn get_children_count_at(&self, index: usize) -> usize
[src]
Gets the number of children of the node at the given index
pub fn set_children_count_at(&mut self, index: usize, count: usize)
[src]
Sets the number of children of the node at the given index
pub fn get_size(&self) -> usize
[src]
Gets the total number of nodes in this sub-tree
pub fn setup_root(&mut self, symbol: TableElemRef, action: TreeAction)
[src]
Initializes the root of this sub-tree
pub fn copy_to(&self, destination: &mut SubTree) -> usize
[src]
Copy the content of this sub-tree to the given sub-tree's buffer beginning at the given index This methods only applies in the case of a depth 1 sub-tree (only a root and its children). The results of this method in the case of a depth 2 sub-tree is undetermined.
pub fn copy_children_to(&self, destination: &mut SubTree) -> usize
[src]
Copy the root's children of this sub-tree to the given sub-tree's buffer beginning at the given index This methods only applies in the case of a depth 2 sub-tree.
pub fn commit_children_of(&mut self, index: usize, ast: &mut Ast)
[src]
Commits the children of a sub-tree in this buffer to the final ast If the index is 0, the root's children are committed, assuming this is a depth-1 sub-tree. If not, the children of the child at the given index are committed.
pub fn commit(&mut self, ast: &mut Ast)
[src]
Commits this buffer to the final ast
pub fn push(&mut self, symbol: TableElemRef, action: TreeAction) -> usize
[src]
Pushes a new node into this buffer
pub fn move_node(&mut self, from: usize, to: usize)
[src]
Moves an item within the buffer
pub fn move_range(&mut self, from: usize, to: usize, length: usize)
[src]
Moves a range of items within the buffer