[][src]Struct antlr_rust::BaseParser

pub struct BaseParser<'input, Ext: 'static, I: TokenStream<'input>, Ctx: ParserNodeType<'input, TF = I::TF>, T: ParseTreeListener<'input, Ctx> + ?Sized = dyn ParseTreeListener<'input, Ctx>> {
    pub ctx: Option<Rc<Ctx::Type>>,
    pub build_parse_trees: bool,
    pub matched_eof: bool,
    pub input: I,
    // some fields omitted
}

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]

pub fn new_base_parser(
    input: I,
    interpreter: Arc<ParserATNSimulator>,
    ext: Ext
) -> Self
[src]

pub fn match_token(
    &mut self,
    ttype: isize,
    err_handler: &mut impl ErrorStrategy<'input, Self>
) -> Result<<I::TF as TokenFactory<'input>>::Tok, ANTLRError>
[src]

pub fn match_wildcard(
    &mut self,
    err_handler: &mut impl ErrorStrategy<'input, Self>
) -> Result<<I::TF as TokenFactory<'input>>::Tok, ANTLRError>
[src]

pub fn add_parse_listener<L>(&mut self, listener: Box<L>) -> ListenerId<L> where
    Box<L>: CoerceUnsized<Box<T>>, 
[src]

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]

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]

pub fn exit_rule(&mut self)[src]

pub fn enter_outer_alt(
    &mut self,
    new_ctx: Option<Rc<Ctx::Type>>,
    alt_num: isize
)
[src]

pub fn enter_recursion_rule(
    &mut self,
    localctx: Rc<Ctx::Type>,
    state: isize,
    _rule_index: usize,
    precedence: isize
)
[src]

pub fn push_new_recursion_context(
    &mut self,
    localctx: Rc<Ctx::Type>,
    state: isize,
    _rule_index: usize
)
[src]

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]

type Target = Ext

The resulting type after dereferencing.

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]

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]

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]

type Static = __BaseParserinputExtICtxT_should_never_exist<Ext, I::Static, Ctx::Static, T::Static>

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]

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]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> NodeText for T[src]

impl<'a, T> Tid<'a> for T where
    T: TidAble<'a> + ?Sized
[src]

impl<'a, X> TidExt<'a> for X where
    X: Tid<'a> + ?Sized
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

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

The type returned in the event of a conversion error.