pub struct BaseParser<S> { /* private fields */ }Implementations§
Source§impl<S> BaseParser<S>where
S: TokenSource,
impl<S> BaseParser<S>where
S: TokenSource,
Sourcepub const fn new(input: CommonTokenStream<S>, data: RecognizerData) -> Self
pub const fn new(input: CommonTokenStream<S>, data: RecognizerData) -> Self
Creates a parser base over a buffered token stream and recognizer metadata.
pub const fn input(&mut self) -> &mut CommonTokenStream<S>
pub fn la(&mut self, offset: isize) -> i32
pub fn consume(&mut self)
Sourcepub fn set_int_member(&mut self, member: usize, value: i64)
pub fn set_int_member(&mut self, member: usize, value: i64)
Sets a generated integer member value used by target-template tests.
Sourcepub fn int_member(&self, member: usize) -> Option<i64>
pub fn int_member(&self, member: usize) -> Option<i64>
Reads a generated integer member value.
Sourcepub fn add_int_member(&mut self, member: usize, delta: i64) -> i64
pub fn add_int_member(&mut self, member: usize, delta: i64) -> i64
Adds delta to a generated integer member and returns the new value.
Sourcepub fn match_token(&mut self, token_type: i32) -> Result<ParseTree, AntlrError>
pub fn match_token(&mut self, token_type: i32) -> Result<ParseTree, AntlrError>
Matches and consumes the current token when it has the expected token type.
On success the consumed token is wrapped as a terminal parse-tree node. On mismatch the error carries vocabulary display names so diagnostics are stable across literal and symbolic token naming.
pub fn match_eof(&mut self) -> Result<ParseTree, AntlrError>
pub const fn rule_node(&self, context: ParserRuleContext) -> ParseTree
Sourcepub fn parse_atn_rule(
&mut self,
atn: &Atn,
rule_index: usize,
) -> Result<ParseTree, AntlrError>
pub fn parse_atn_rule( &mut self, atn: &Atn, rule_index: usize, ) -> Result<ParseTree, AntlrError>
Parses a generated rule by interpreting the parser ATN from the rule’s start state to its stop state.
The recognizer backtracks across alternatives and loop exits using token stream indices instead of committing to input consumption immediately. Once a viable ATN path is found, the parser commits the accepted token interval and returns a rule node whose children mirror every grammar rule invocation reached on that path, matching ANTLR’s parse-tree shape.
Sourcepub fn parse_atn_rule_with_actions(
&mut self,
atn: &Atn,
rule_index: usize,
) -> Result<(ParseTree, Vec<ParserAction>), AntlrError>
pub fn parse_atn_rule_with_actions( &mut self, atn: &Atn, rule_index: usize, ) -> Result<(ParseTree, Vec<ParserAction>), AntlrError>
Parses a generated rule and returns semantic actions reached on the selected ATN path.
This slower path preserves action ordering and token intervals for generated code that replays target-specific action templates after the recognizer has chosen one viable parse path.
Sourcepub fn parse_atn_rule_with_action_inits(
&mut self,
atn: &Atn,
rule_index: usize,
init_action_rules: &[usize],
) -> Result<(ParseTree, Vec<ParserAction>), AntlrError>
pub fn parse_atn_rule_with_action_inits( &mut self, atn: &Atn, rule_index: usize, init_action_rules: &[usize], ) -> Result<(ParseTree, Vec<ParserAction>), AntlrError>
Parses a generated rule and emits ATN actions plus selected rule-init actions reached on the chosen path.
Generated parsers use this when a grammar contains rule-level @init
templates that must run for nested rule invocations. The runtime keeps
the action list path-sensitive, so init templates are replayed only for
rules that were actually entered by the selected parse.
Sourcepub fn parse_atn_rule_with_action_options(
&mut self,
atn: &Atn,
rule_index: usize,
init_action_rules: &[usize],
track_alt_numbers: bool,
) -> Result<(ParseTree, Vec<ParserAction>), AntlrError>
pub fn parse_atn_rule_with_action_options( &mut self, atn: &Atn, rule_index: usize, init_action_rules: &[usize], track_alt_numbers: bool, ) -> Result<(ParseTree, Vec<ParserAction>), AntlrError>
Parses a generated rule with optional semantic-action replay features.
track_alt_numbers is used by grammars that opt into ANTLR’s
alt-numbered context behavior. It keeps ordinary parse-tree rendering
unchanged for grammars that do not request that target template.
Sourcepub fn parse_atn_rule_with_runtime_options(
&mut self,
atn: &Atn,
rule_index: usize,
options: ParserRuntimeOptions<'_>,
) -> Result<(ParseTree, Vec<ParserAction>), AntlrError>
pub fn parse_atn_rule_with_runtime_options( &mut self, atn: &Atn, rule_index: usize, options: ParserRuntimeOptions<'_>, ) -> Result<(ParseTree, Vec<ParserAction>), AntlrError>
Parses a generated rule with action replay and parser predicate support.
predicates maps serialized (rule_index, pred_index) coordinates to
target-template predicate semantics emitted by the generator. Missing
entries are treated as true so unsupported predicate-free grammars keep
the previous unconditional transition behavior.
Sourcepub fn parse_interpreted_rule(
&mut self,
rule_index: usize,
) -> Result<ParseTree, AntlrError>
pub fn parse_interpreted_rule( &mut self, rule_index: usize, ) -> Result<ParseTree, AntlrError>
Temporary parser entry used by generated parser methods while the parser ATN simulator is being implemented.
This keeps generated parser crates buildable and gives us a stable method surface for every grammar rule. It intentionally accepts all remaining tokens into one rule context; it is not the final parser semantics.
Sourcepub fn text_interval(&mut self, start: usize, stop: Option<usize>) -> String
pub fn text_interval(&mut self, start: usize, stop: Option<usize>) -> String
Returns token text for a buffered token interval used by generated
$text actions.
ANTLR treats EOF as a range boundary rather than printable input text, even when an action interval explicitly stops at the EOF token.
Sourcepub fn expected_tokens_at_state(&self, atn: &Atn, state_number: usize) -> String
pub fn expected_tokens_at_state(&self, atn: &Atn, state_number: usize) -> String
Formats the tokens expected from an ATN state using ANTLR display names.
Sourcepub fn token_display_at(&mut self, index: usize) -> Option<String>
pub fn token_display_at(&mut self, index: usize) -> Option<String>
Formats a buffered token in ANTLR’s diagnostic token display form.