pub struct ParserRuleContext { /* private fields */ }Implementations§
Source§impl ParserRuleContext
impl ParserRuleContext
pub const fn new(rule_index: usize, invoking_state: isize) -> Self
pub const fn rule_index(&self) -> usize
pub const fn invoking_state(&self) -> isize
pub const fn alt_number(&self) -> usize
pub const fn set_alt_number(&mut self, alt_number: usize)
pub fn start(&self) -> Option<&CommonToken>
pub fn stop(&self) -> Option<&CommonToken>
pub fn set_start(&mut self, token: CommonToken)
pub fn set_stop(&mut self, token: CommonToken)
Sourcepub fn set_int_return(&mut self, name: impl Into<String>, value: i64)
pub fn set_int_return(&mut self, name: impl Into<String>, value: i64)
Stores a generated integer return value on this rule context.
Sourcepub fn int_return(&self, name: &str) -> Option<i64>
pub fn int_return(&self, name: &str) -> Option<i64>
Reads a generated integer return value from this rule context.
Sourcepub fn set_generated_attrs(&mut self, attrs: GeneratedAttrs)
pub fn set_generated_attrs(&mut self, attrs: GeneratedAttrs)
Seals the generated rule-attribute snapshot on this context.
Sourcepub fn generated_attrs<T: Any>(&self) -> Option<&T>
pub fn generated_attrs<T: Any>(&self) -> Option<&T>
Reads the typed generated rule-attribute snapshot, if sealed.
pub fn exception(&self) -> Option<&AntlrError>
pub fn set_exception(&mut self, error: AntlrError)
pub fn children(&self) -> &[ParseTree]
Sourcepub const fn child_count(&self) -> usize
pub const fn child_count(&self) -> usize
Returns the number of direct children in this context.
Sourcepub fn child_rule(&self, rule_index: usize) -> Option<&Self>
pub fn child_rule(&self, rule_index: usize) -> Option<&Self>
Finds the first direct child rule with rule_index.
Sourcepub fn child_rules(&self, rule_index: usize) -> impl Iterator<Item = &Self> + '_
pub fn child_rules(&self, rule_index: usize) -> impl Iterator<Item = &Self> + '_
Iterates over direct child rules with rule_index.
Sourcepub fn child_token(&self, token_type: i32) -> Option<&TerminalNode>
pub fn child_token(&self, token_type: i32) -> Option<&TerminalNode>
Finds the first direct token child with token_type.
Includes recovery error nodes, which ANTLR treats as terminal nodes for token-getter helpers.
Sourcepub fn child_rule_trees(
&self,
rule_index: usize,
) -> impl Iterator<Item = &ParseTree> + '_
pub fn child_rule_trees( &self, rule_index: usize, ) -> impl Iterator<Item = &ParseTree> + '_
Iterates over direct child subtrees whose root rule has rule_index.
Like Self::child_rules but yielding the full ParseTree child,
for generated $label.ctx reads and listener walks over a labeled
subtree.
Sourcepub fn child_tokens(
&self,
token_type: i32,
) -> impl Iterator<Item = &TerminalNode> + '_
pub fn child_tokens( &self, token_type: i32, ) -> impl Iterator<Item = &TerminalNode> + '_
Iterates over direct token children with token_type, including
recovery error nodes (ANTLR treats those as terminals for getters).
Sourcepub fn terminal_children(&self) -> impl Iterator<Item = &TerminalNode> + '_
pub fn terminal_children(&self) -> impl Iterator<Item = &TerminalNode> + '_
Iterates over all direct terminal children regardless of token type.
Sourcepub fn downcast_ref<T: FromRuleContext>(&self) -> Option<T>
pub fn downcast_ref<T: FromRuleContext>(&self) -> Option<T>
Downcast-style conversion to a generated typed context view.
Generated parsers implement FromRuleContext for each context type;
this mirrors ANTLR’s ((BinaryContext) $ctx) cast in test actions
($ctx.downcast_ref::<BinaryContext>()).
Sourcepub fn has_token(&self, token_type: i32) -> bool
pub fn has_token(&self, token_type: i32) -> bool
Returns whether this context has a direct token child with token_type.
pub fn add_child(&mut self, child: ParseTree)
Sourcepub const fn note_matched_child(&mut self)
pub const fn note_matched_child(&mut self)
Records that a child was matched without storing it (used when parse-tree
construction is disabled). Keeps has_matched_child accurate even though
children stays empty.
Sourcepub const fn has_matched_child(&self) -> bool
pub const fn has_matched_child(&self) -> bool
Whether this context has matched at least one child (token, rule, or error node) so far, regardless of whether parse-tree construction is enabled.
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 on a mid-rule $ctx.
Trait Implementations§
Source§impl Clone for ParserRuleContext
impl Clone for ParserRuleContext
Source§fn clone(&self) -> ParserRuleContext
fn clone(&self) -> ParserRuleContext
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more