pub enum ParseTree {
Rule(RuleNode),
Terminal(TerminalNode),
Error(ErrorNode),
}Variants§
Implementations§
Source§impl ParseTree
impl ParseTree
pub fn text(&self) -> String
pub fn to_string_tree_with_names<S: AsRef<str>>( &self, rule_names: &[S], ) -> String
Sourcepub fn to_string_tree<R: Recognizer>(&self, recognizer: Option<&R>) -> String
pub fn to_string_tree<R: Recognizer>(&self, recognizer: Option<&R>) -> String
Renders the LISP-style tree using rule names resolved through a
recognizer, matching ANTLR’s toStringTree(parser) shape used by
generated test actions (<tree>.to_string_tree(Some(self))).
Sourcepub fn first_rule(&self, rule_index: usize) -> Option<&Self>
pub fn first_rule(&self, rule_index: usize) -> Option<&Self>
Finds the first rule node with rule_index in a depth-first walk.
Sourcepub fn first_rule_stop(&self, rule_index: usize) -> Option<&CommonToken>
pub fn first_rule_stop(&self, rule_index: usize) -> Option<&CommonToken>
Finds the stop token for the first rule node with rule_index.
Sourcepub fn first_rule_int_return(
&self,
rule_index: usize,
name: &str,
) -> Option<i64>
pub fn first_rule_int_return( &self, rule_index: usize, name: &str, ) -> Option<i64>
Reads an integer return value from the first rule node with
rule_index, matching ANTLR’s $label.value resolution for labeled
rule references in the runtime testsuite.
Sourcepub fn rule_attrs<T: Any>(&self) -> Option<&T>
pub fn rule_attrs<T: Any>(&self) -> Option<&T>
Reads the typed attribute snapshot from this tree’s root rule node.
Generated parsers use this for $label.attr / $rule.attr reads on a
child subtree returned by a rule call.
Sourcepub fn first_error_token(&self) -> Option<&CommonToken>
pub fn first_error_token(&self) -> Option<&CommonToken>
Finds the first recovery error token in a depth-first walk.
Trait Implementations§
impl Eq for ParseTree
impl StructuralPartialEq for ParseTree
Auto Trait Implementations§
impl !RefUnwindSafe for ParseTree
impl !Send for ParseTree
impl !Sync for ParseTree
impl !UnwindSafe for ParseTree
impl Freeze for ParseTree
impl Unpin for ParseTree
impl UnsafeUnpin for ParseTree
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more