Trait ParseTree

Source
pub trait ParseTree<'input>: Tree<'input> {
    // Provided methods
    fn get_source_interval(&self) -> Interval { ... }
    fn get_text(&self) -> String { ... }
    fn to_string_tree(
        &self,
        r: &dyn Recognizer<'input, TF = Self::TF, Node = Self::Ctx>,
    ) -> String { ... }
}
Expand description

Tree that knows about underlying text

Provided Methods§

Source

fn get_source_interval(&self) -> Interval

Return an {@link Interval} indicating the index in the {@link TokenStream} of the first and last token associated with this subtree. If this node is a leaf, then the interval represents a single token and has interval i..i for token index i.

Source

fn get_text(&self) -> String

Return combined text of this AST node. To create resulting string it does traverse whole subtree, also it includes only tokens added to the parse tree

Since tokens on hidden channels (e.g. whitespace or comments) are not added to the parse trees, they will not appear in the output of this method.

Source

fn to_string_tree( &self, r: &dyn Recognizer<'input, TF = Self::TF, Node = Self::Ctx>, ) -> String

Print out a whole tree, not just a node, in LISP format (root child1 .. childN). Print just a node if this is a leaf. We have to know the recognizer so we can get rule names.

Implementors§

Source§

impl<'input, Ctx: CustomRuleContext<'input> + TidAble<'input>> ParseTree<'input> for BaseParserRuleContext<'input, Ctx>

Source§

impl<'input, ExtCtx: CustomRuleContext<'input>> ParseTree<'input> for BaseRuleContext<'input, ExtCtx>

Source§

impl<'input, Node: ParserNodeType<'input>, T: 'static> ParseTree<'input> for LeafNode<'input, Node, T>

Source§

impl<'input, T, I> ParseTree<'input> for T
where T: DerefSeal<Target = I> + 'input + Debug + Tid<'input>, I: ParserRuleContext<'input> + 'input + ?Sized,