Skip to main content

TreeConstruct

Trait TreeConstruct 

Source
pub trait TreeConstruct<'t> {
    type Error;
    type Tree;

    // Required methods
    fn open_non_terminal(
        &mut self,
        name: &'static str,
        size_hint: Option<usize>,
    ) -> Result<(), Self::Error>;
    fn close_non_terminal(&mut self) -> Result<(), Self::Error>;
    fn add_token(&mut self, token: &Token<'t>) -> Result<(), Self::Error>;
    fn build(self) -> Result<Self::Tree, Self::Error>;
}
Expand description

A trait that a tree builder must implement.

Required Associated Types§

Source

type Error

The error type of the tree builder.

Source

type Tree

The type of the tree.

Required Methods§

Source

fn open_non_terminal( &mut self, name: &'static str, size_hint: Option<usize>, ) -> Result<(), Self::Error>

Creates a node from a non-terminal name.

Source

fn close_non_terminal(&mut self) -> Result<(), Self::Error>

Closes a non-terminal node.

Source

fn add_token(&mut self, token: &Token<'t>) -> Result<(), Self::Error>

Creates a token node.

Source

fn build(self) -> Result<Self::Tree, Self::Error>

Returns the tree.

Implementations on Foreign Types§

Source§

impl<'t, T> TreeConstruct<'t> for Builder<T, SynTreeFlavor>
where T: AstNode<'t>,

Source§

type Error = Error

Source§

type Tree = Tree<T, SynTreeFlavor>

Source§

fn open_non_terminal( &mut self, name: &'static str, _size_hint: Option<usize>, ) -> Result<(), <Builder<T, SynTreeFlavor> as TreeConstruct<'t>>::Error>

Source§

fn close_non_terminal( &mut self, ) -> Result<(), <Builder<T, SynTreeFlavor> as TreeConstruct<'t>>::Error>

Source§

fn add_token( &mut self, token: &Token<'t>, ) -> Result<(), <Builder<T, SynTreeFlavor> as TreeConstruct<'t>>::Error>

Source§

fn build( self, ) -> Result<<Builder<T, SynTreeFlavor> as TreeConstruct<'t>>::Tree, <Builder<T, SynTreeFlavor> as TreeConstruct<'t>>::Error>

Implementors§