[−][src]Struct antlr_rust::BaseParser
Main underlying Parser struct
It is a member of generated parser struct, so almost always you don't need to create it yourself. Generated parser hides complexity of this struct and expose required flexibility via generic parameters
Fields
ctx: Option<Rc<Ctx::Type>>
Rule context parser is currently processing
build_parse_trees: bool
Track the {@link ParserRuleContext} objects during the parse and hook them up using the {@link ParserRuleContext#children} list so that it forms a parse tree. The {@link ParserRuleContext} returned from the start rule represents the root of the parse tree.
Note that if we are not building parse trees, rule contexts only point upwards. When a rule exits, it returns the context bute that gets garbage collected if nobody holds a reference. It points upwards but nobody points at it.
When we build parse trees, we are adding all of these contexts to {@link ParserRuleContext#children} list. Contexts are then not candidates for garbage collection.
Returns {@code true} if a complete parse tree will be constructed while parsing, otherwise {@code false}
matched_eof: bool
true if parser reached EOF
input: I
Token stream that is currently used by this parser
Implementations
impl<'input, Ext, I, Ctx, T: ?Sized> BaseParser<'input, Ext, I, Ctx, T> where
Ext: ParserRecog<'input, Self> + 'static,
I: TokenStream<'input>,
Ctx: ParserNodeType<'input, TF = I::TF>,
T: ParseTreeListener<'input, Ctx>,
Ctx::Type: Listenable<T>,
Rc<TerminalNode<'input, Ctx>>: CoerceUnsized<Rc<Ctx::Type>>,
Rc<ErrorNode<'input, Ctx>>: CoerceUnsized<Rc<Ctx::Type>>,
[src]
Ext: ParserRecog<'input, Self> + 'static,
I: TokenStream<'input>,
Ctx: ParserNodeType<'input, TF = I::TF>,
T: ParseTreeListener<'input, Ctx>,
Ctx::Type: Listenable<T>,
Rc<TerminalNode<'input, Ctx>>: CoerceUnsized<Rc<Ctx::Type>>,
Rc<ErrorNode<'input, Ctx>>: CoerceUnsized<Rc<Ctx::Type>>,
pub fn new_base_parser(
input: I,
interpreter: Arc<ParserATNSimulator>,
ext: Ext
) -> Self
[src]
input: I,
interpreter: Arc<ParserATNSimulator>,
ext: Ext
) -> Self
pub fn match_token(
&mut self,
ttype: isize,
err_handler: &mut impl ErrorStrategy<'input, Self>
) -> Result<<I::TF as TokenFactory<'input>>::Tok, ANTLRError>
[src]
&mut self,
ttype: isize,
err_handler: &mut impl ErrorStrategy<'input, Self>
) -> Result<<I::TF as TokenFactory<'input>>::Tok, ANTLRError>
pub fn match_wildcard(
&mut self,
err_handler: &mut impl ErrorStrategy<'input, Self>
) -> Result<<I::TF as TokenFactory<'input>>::Tok, ANTLRError>
[src]
&mut self,
err_handler: &mut impl ErrorStrategy<'input, Self>
) -> Result<<I::TF as TokenFactory<'input>>::Tok, ANTLRError>
pub fn add_parse_listener<L>(&mut self, listener: Box<L>) -> ListenerId<L> where
Box<L>: CoerceUnsized<Box<T>>,
[src]
Box<L>: CoerceUnsized<Box<T>>,
Adds parse listener for this parser
returns listener_id
that can be used later to get listener back
Embedded listener currently must outlive 'input
. If you need to have arbitrary listener use ParseTreeWalker.
Example for listener usage:
todo
pub fn remove_parse_listener<L>(&mut self, listener_id: ListenerId<L>) -> Box<L> where
Box<L>: CoerceUnsized<Box<T>>,
[src]
Box<L>: CoerceUnsized<Box<T>>,
Removes parse listener with corresponding listener_id
, casts it back to user type and returns it to the caller.
listener_id
is returned when listener is added via add_parse_listener
pub fn remove_parse_listeners(&mut self)
[src]
Removes all added parse listeners without returning them
pub fn trigger_enter_rule_event(&mut self)
[src]
pub fn trigger_exit_rule_event(&mut self)
[src]
pub fn enter_rule(
&mut self,
localctx: Rc<Ctx::Type>,
state: isize,
_rule_index: usize
)
[src]
&mut self,
localctx: Rc<Ctx::Type>,
state: isize,
_rule_index: usize
)
pub fn exit_rule(&mut self)
[src]
pub fn enter_outer_alt(
&mut self,
new_ctx: Option<Rc<Ctx::Type>>,
alt_num: isize
)
[src]
&mut self,
new_ctx: Option<Rc<Ctx::Type>>,
alt_num: isize
)
pub fn enter_recursion_rule(
&mut self,
localctx: Rc<Ctx::Type>,
state: isize,
_rule_index: usize,
precedence: isize
)
[src]
&mut self,
localctx: Rc<Ctx::Type>,
state: isize,
_rule_index: usize,
precedence: isize
)
pub fn push_new_recursion_context(
&mut self,
localctx: Rc<Ctx::Type>,
state: isize,
_rule_index: usize
)
[src]
&mut self,
localctx: Rc<Ctx::Type>,
state: isize,
_rule_index: usize
)
pub fn unroll_recursion_context(&mut self, parent_ctx: Option<Rc<Ctx::Type>>)
[src]
pub fn dump_dfa(&self)
[src]
Text representation of generated DFA for debugging purposes
Trait Implementations
impl<'input, Ext, I, Ctx, T: ?Sized> Deref for BaseParser<'input, Ext, I, Ctx, T> where
Ext: ParserRecog<'input, Self> + 'static,
I: TokenStream<'input>,
Ctx: ParserNodeType<'input, TF = I::TF>,
T: ParseTreeListener<'input, Ctx>,
[src]
Ext: ParserRecog<'input, Self> + 'static,
I: TokenStream<'input>,
Ctx: ParserNodeType<'input, TF = I::TF>,
T: ParseTreeListener<'input, Ctx>,
impl<'input, Ext, I, Ctx, T: ?Sized> DerefMut for BaseParser<'input, Ext, I, Ctx, T> where
Ext: ParserRecog<'input, Self> + 'static,
I: TokenStream<'input>,
Ctx: ParserNodeType<'input, TF = I::TF>,
T: ParseTreeListener<'input, Ctx>,
[src]
Ext: ParserRecog<'input, Self> + 'static,
I: TokenStream<'input>,
Ctx: ParserNodeType<'input, TF = I::TF>,
T: ParseTreeListener<'input, Ctx>,
impl<'input, Ext, I, Ctx, T: ?Sized> Parser<'input> for BaseParser<'input, Ext, I, Ctx, T> where
Ext: ParserRecog<'input, Self> + 'static,
I: TokenStream<'input>,
Ctx: ParserNodeType<'input, TF = I::TF>,
T: ParseTreeListener<'input, Ctx>,
Ctx::Type: Listenable<T>,
Rc<TerminalNode<'input, Ctx>>: CoerceUnsized<Rc<Ctx::Type>>,
Rc<ErrorNode<'input, Ctx>>: CoerceUnsized<Rc<Ctx::Type>>,
[src]
Ext: ParserRecog<'input, Self> + 'static,
I: TokenStream<'input>,
Ctx: ParserNodeType<'input, TF = I::TF>,
T: ParseTreeListener<'input, Ctx>,
Ctx::Type: Listenable<T>,
Rc<TerminalNode<'input, Ctx>>: CoerceUnsized<Rc<Ctx::Type>>,
Rc<ErrorNode<'input, Ctx>>: CoerceUnsized<Rc<Ctx::Type>>,
pub fn get_interpreter(&self) -> &ParserATNSimulator
[src]
pub fn get_token_factory(&self) -> &'input Self::TF
[src]
pub fn get_parser_rule_context(&self) -> &Rc<Ctx::Type>
[src]
pub fn consume(&mut self, err_handler: &mut impl ErrorStrategy<'input, Self>)
[src]
pub fn precpred(&self, _localctx: Option<&Ctx::Type>, precedence: isize) -> bool
[src]
pub fn get_input_stream_mut(
&mut self
) -> &mut dyn TokenStream<'input, TF = Self::TF>
[src]
&mut self
) -> &mut dyn TokenStream<'input, TF = Self::TF>
pub fn get_input_stream(&self) -> &dyn TokenStream<'input, TF = Self::TF>
[src]
pub fn get_current_token(&self) -> &<Self::TF as TokenFactory<'input>>::Tok
[src]
pub fn get_expected_tokens(&self) -> IntervalSet
[src]
pub fn add_error_listener(
&mut self,
listener: Box<dyn ErrorListener<'input, Self>>
)
[src]
&mut self,
listener: Box<dyn ErrorListener<'input, Self>>
)
pub fn notify_error_listeners(
&self,
msg: String,
offending_token: Option<isize>,
err: Option<&ANTLRError>
)
[src]
&self,
msg: String,
offending_token: Option<isize>,
err: Option<&ANTLRError>
)
pub fn get_error_lister_dispatch<'a>(
&'a self
) -> Box<dyn ErrorListener<'input, Self> + 'a>
[src]
&'a self
) -> Box<dyn ErrorListener<'input, Self> + 'a>
pub fn is_expected_token(&self, _symbol: isize) -> bool
[src]
pub fn get_precedence(&self) -> isize
[src]
pub fn get_state(&self) -> isize
[src]
pub fn set_state(&mut self, v: isize)
[src]
pub fn get_rule_invocation_stack(&self) -> Vec<String>
[src]
impl<'input, Ext: 'static, I: TokenStream<'input>, Ctx: ParserNodeType<'input, TF = I::TF>, T: ParseTreeListener<'input, Ctx> + ?Sized> TidAble<'input> for BaseParser<'input, Ext, I, Ctx, T> where
I: TidAble<'input>,
Ctx: TidAble<'input>,
T: TidAble<'input>,
[src]
I: TidAble<'input>,
Ctx: TidAble<'input>,
T: TidAble<'input>,
Auto Trait Implementations
impl<'input, Ext, I, Ctx, T = dyn ParseTreeListener<'input, Ctx> + 'static> !RefUnwindSafe for BaseParser<'input, Ext, I, Ctx, T>
[src]
impl<'input, Ext, I, Ctx, T = dyn ParseTreeListener<'input, Ctx> + 'static> !Send for BaseParser<'input, Ext, I, Ctx, T>
[src]
impl<'input, Ext, I, Ctx, T = dyn ParseTreeListener<'input, Ctx> + 'static> !Sync for BaseParser<'input, Ext, I, Ctx, T>
[src]
impl<'input, Ext, I, Ctx, T: ?Sized> Unpin for BaseParser<'input, Ext, I, Ctx, T> where
Ext: Unpin,
I: Unpin,
[src]
Ext: Unpin,
I: Unpin,
impl<'input, Ext, I, Ctx, T = dyn ParseTreeListener<'input, Ctx> + 'static> !UnwindSafe for BaseParser<'input, Ext, I, Ctx, T>
[src]
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
pub fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> NodeText for T
[src]
impl<'a, T> Tid<'a> for T where
T: TidAble<'a> + ?Sized,
[src]
T: TidAble<'a> + ?Sized,
impl<'a, X> TidExt<'a> for X where
X: Tid<'a> + ?Sized,
[src]
X: Tid<'a> + ?Sized,
pub fn is<T>(&self) -> bool where
T: Tid<'a>,
[src]
T: Tid<'a>,
pub fn downcast_ref<T>(&'b self) -> Option<&'b T> where
T: Tid<'a>,
[src]
T: Tid<'a>,
pub fn downcast_mut<T>(&'b mut self) -> Option<&'b mut T> where
T: Tid<'a>,
[src]
T: Tid<'a>,
pub fn downcast_rc<T>(self: Rc<X>) -> Result<Rc<T>, Rc<X>> where
T: Tid<'a>,
[src]
T: Tid<'a>,
pub fn downcast_arc<T>(self: Arc<X>) -> Result<Arc<T>, Arc<X>> where
T: Tid<'a>,
[src]
T: Tid<'a>,
pub fn downcast_box<T>(
self: Box<X, Global>
) -> Result<Box<T, Global>, Box<X, Global>> where
T: Tid<'a>,
[src]
self: Box<X, Global>
) -> Result<Box<T, Global>, Box<X, Global>> where
T: Tid<'a>,
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
pub fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,