Skip to main content

TreeNode

Struct TreeNode 

Source
pub struct TreeNode<'input, 'arena, NodeKind, Tok = CommonToken<'input>>
where NodeKind: NodeKindType<'arena, Tok>, Tok: Token + 'input, 'input: 'arena,
{ pub node_tag: NodeKind, /* private fields */ }

Fields§

§node_tag: NodeKind

Implementations§

Source§

impl<'input, 'arena, NodeKind, Tok> TreeNode<'input, 'arena, NodeKind, Tok>
where NodeKind: NodeKindType<'arena, Tok>, Tok: Token + 'input, 'input: 'arena,

Source

pub fn create_token_node(arena: &'arena Arena, symbol: &'arena Tok) -> *mut Self

Source

pub fn create_error_node(arena: &'arena Arena, symbol: &'arena Tok) -> *mut Self

Source

pub fn node_tag(&self) -> NodeKind

Source

pub fn get_rule_context(&self) -> &dyn ParserRuleContext<'input, 'arena>

Return the ParserRuleContext object associated with this rule node.

Source

pub fn get_rule_context_mut( &mut self, ) -> &mut dyn ParserRuleContext<'input, 'arena>

Return mutable reference to the ParserRuleContext object associated with this rule node.

Source

pub fn ctx_ptr(&self) -> CtxPtr<'input, 'arena>

Source

pub fn as_rule_context<T>(&self) -> Option<&T>
where T: ParserRuleContext<'input, 'arena> + NodeInner<'input, 'arena, NodeKind, Tok>,

Attempt to downcast this node to specific ParserRuleContext type

Source

pub fn as_rule_context_mut<T>(&mut self) -> Option<&mut T>
where T: ParserRuleContext<'input, 'arena> + NodeInner<'input, 'arena, NodeKind, Tok>,

Attempt to downcast this node to specific ParserRuleContext type

Source

pub fn as_terminal_node(&self) -> Option<&TerminalNode<'input, 'arena, Tok>>

Downcast this node to terminal node, if the associated context is a terminal node

Source

pub fn as_terminal_node_mut( &mut self, ) -> Option<&mut TerminalNode<'input, 'arena, Tok>>

Downcast this node to terminal node, if the associated context is a terminal node

Source

pub fn as_error_node(&self) -> Option<&ErrorNode<'input, 'arena, Tok>>

Downcast this node to error node, if the associated context is an error node

Source

pub fn as_error_node_mut( &mut self, ) -> Option<&mut ErrorNode<'input, 'arena, Tok>>

Downcast this node to error node, if the associated context is an error node

Source

pub fn set_exception(&self, _e: ANTLRError, _arena: &'arena Arena)

Source

pub fn set_invoking_state(&mut self, s: i32)

Sets internal parser state

Source

pub fn set_alt_number(&mut self, _alt_number: i32)

Source

pub fn set_start(&mut self, t: Option<&'arena Tok>)

Source

pub fn set_stop(&mut self, t: Option<&'arena Tok>)

Source

pub fn remove_last_child(&mut self)

Source

pub fn add_child(&mut self, _child: &'arena Self)

Source

pub fn set_parent(&mut self, parent: Option<&'arena Self>)

Source

pub fn enter_rule( &self, listener: &mut NodeKind::Listener, ) -> Result<(), ANTLRError>

Source

pub fn exit_rule( &self, listener: &mut NodeKind::Listener, ) -> Result<(), ANTLRError>

Trait Implementations§

Source§

impl<'input, 'arena, NodeKind, Tok> Debug for TreeNode<'input, 'arena, NodeKind, Tok>
where NodeKind: NodeKindType<'arena, Tok> + Debug, Tok: Token + 'input + Debug, 'input: 'arena,

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<'input, 'arena, Node, Tok> ParseTree<'input, 'arena> for TreeNode<'input, 'arena, Node, Tok>
where Node: NodeKindType<'arena, Tok>, Tok: Token, 'input: 'arena,

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 Read more
Source§

impl<'input, 'arena, Node, Tok> ParserRuleContext<'input, 'arena> for TreeNode<'input, 'arena, Node, Tok>
where Node: NodeKindType<'arena, Tok>, Tok: Token, 'input: 'arena,

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 Read more
Source§

fn get_child_count(&self) -> usize

Source§

fn start(&self) -> &'arena dyn Token

Get the initial token in this context. Read more
Source§

fn stop(&self) -> &'arena dyn Token

Get the final token in this context. Read more
Source§

fn get_parent_ctx( &self, ) -> Option<&'arena dyn ParserRuleContext<'input, 'arena>>

Source§

fn get_child_ctx( &self, i: usize, ) -> Option<&'arena dyn ParserRuleContext<'input, 'arena>>

Source§

fn iter_children<'a>( &'a self, ) -> Box<dyn Iterator<Item = &'arena dyn ParserRuleContext<'input, 'arena>> + 'a>
where 'input: 'a, 'arena: 'a,

Source§

fn get_token(&self, _ttype: i32, _pos: usize) -> Option<&dyn Token>

Source§

fn get_tokens(&self, _ttype: i32) -> Vec<&dyn Token>

Source§

fn to_string_tree(&self, rule_names: &[&str]) -> 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.
Source§

impl<'input, 'arena, NodeKind, Tok> RuleContext<'arena> for TreeNode<'input, 'arena, NodeKind, Tok>
where NodeKind: NodeKindType<'arena, Tok>, Tok: Token, 'input: 'arena,

Source§

fn get_rule_index(&self) -> usize

Rule index that corresponds to this context type
Source§

fn get_alt_number(&self) -> i32

Source§

fn get_invoking_state(&self) -> i32

Internal parser state
Source§

fn get_parent_ctx(&self) -> Option<&'arena dyn RuleContext<'arena>>

Get parent context
Source§

fn get_node_text(&self, rule_names: &[&str]) -> String

Returns text representation of current node type, rule name for context nodes and token text for terminal nodes
Source§

fn is_empty(&self) -> bool

A context is empty if there is no invoking state; meaning nobody called current context. Which is usually true for the root of the syntax tree
Source§

impl<'input, 'arena, NodeKind, Tok> Tree<'arena> for TreeNode<'input, 'arena, NodeKind, Tok>
where NodeKind: NodeKindType<'arena, Tok>, Tok: Token + 'input, 'input: 'arena,

Source§

fn get_parent(&self) -> Option<&'arena Self>

Source§

fn has_parent(&self) -> bool

Source§

fn get_child(&self, i: usize) -> Option<&'arena Self>

Source§

fn get_child_count(&self) -> usize

Source§

fn get_children<'a>(&'a self) -> Box<dyn Iterator<Item = &'arena Self> + 'a>

Source§

fn get_payload(&self) -> Box<dyn Any>

Auto Trait Implementations§

§

impl<'input, 'arena, NodeKind, Tok = TokenImpl<'input, &'input str>> !Send for TreeNode<'input, 'arena, NodeKind, Tok>

§

impl<'input, 'arena, NodeKind, Tok = TokenImpl<'input, &'input str>> !Sync for TreeNode<'input, 'arena, NodeKind, Tok>

§

impl<'input, 'arena, NodeKind, Tok> Freeze for TreeNode<'input, 'arena, NodeKind, Tok>
where NodeKind: Freeze,

§

impl<'input, 'arena, NodeKind, Tok> RefUnwindSafe for TreeNode<'input, 'arena, NodeKind, Tok>
where NodeKind: RefUnwindSafe, Tok: RefUnwindSafe,

§

impl<'input, 'arena, NodeKind, Tok> Unpin for TreeNode<'input, 'arena, NodeKind, Tok>
where NodeKind: Unpin,

§

impl<'input, 'arena, NodeKind, Tok> UnsafeUnpin for TreeNode<'input, 'arena, NodeKind, Tok>
where NodeKind: UnsafeUnpin,

§

impl<'input, 'arena, NodeKind, Tok> UnwindSafe for TreeNode<'input, 'arena, NodeKind, Tok>
where NodeKind: UnwindSafe, Tok: RefUnwindSafe,

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.