[][src]Struct antlr_rust::parser::BaseParser

pub struct BaseParser<Ext: ParserRecog<Recog = Self> + 'static, T: ParseTreeListener + ?Sized + 'static = dyn ParseTreeListener> {
    pub ctx: Option<ParserRuleContextType>,
    pub build_parse_trees: bool,
    pub matched_eof: bool,
    pub input: Box<dyn TokenStream>,
    // some fields omitted
}

Fields

ctx: Option<ParserRuleContextType>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 but 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: boolinput: Box<dyn TokenStream>

Methods

impl<T: ?Sized, Ext> BaseParser<Ext, T> where
    T: ParseTreeListener + 'static,
    Ext: ParserRecog<Recog = Self> + 'static, 
[src]

pub fn new_base_parser(
    input: Box<dyn TokenStream>,
    interpreter: Arc<ParserATNSimulator>,
    ext: Ext
) -> BaseParser<Ext, T>
[src]

pub fn match_token(
    &mut self,
    ttype: isize,
    err_handler: &mut dyn ErrorStrategy
) -> Result<OwningToken, ANTLRError>
[src]

pub fn match_wildcard(
    &mut self,
    err_handler: &mut dyn ErrorStrategy
) -> Result<OwningToken, ANTLRError>
[src]

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

Adds parse listener for this parser returns listener_id that can be used later to get listener back

Example for listener usage:

todo

pub fn remove_parse_listener<L: Unsize<T>>(
    &mut self,
    listener_id: ListenerId<L>
) -> Box<L>
[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 wothout 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<dyn ParserRuleContext>,
    state: isize,
    _rule_index: usize
)
[src]

pub fn exit_rule(&mut self)[src]

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

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

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

pub fn unroll_recursion_context(
    &mut self,
    parent_ctx: Option<Rc<dyn ParserRuleContext>>
)
[src]

pub fn dump_dfa(&self)[src]

Trait Implementations

impl<T: ?Sized, Ext> Deref for BaseParser<Ext, T> where
    T: ParseTreeListener + 'static,
    Ext: ParserRecog<Recog = Self> + 'static, 
[src]

type Target = Ext

The resulting type after dereferencing.

impl<T: ?Sized, Ext> DerefMut for BaseParser<Ext, T> where
    T: ParseTreeListener + 'static,
    Ext: ParserRecog<Recog = Self> + 'static, 
[src]

impl<T: ?Sized, Ext> Parser for BaseParser<Ext, T> where
    T: ParseTreeListener + 'static,
    Ext: ParserRecog<Recog = Self> + 'static, 
[src]

impl<T: ?Sized, Ext> Recognizer for BaseParser<Ext, T> where
    T: ParseTreeListener + 'static,
    Ext: ParserRecog<Recog = Self> + 'static, 
[src]

Auto Trait Implementations

impl<Ext, T = dyn ParseTreeListener + 'static> !RefUnwindSafe for BaseParser<Ext, T>

impl<Ext, T = dyn ParseTreeListener + 'static> !Send for BaseParser<Ext, T>

impl<Ext, T = dyn ParseTreeListener + 'static> !Sync for BaseParser<Ext, T>

impl<Ext, T: ?Sized> Unpin for BaseParser<Ext, T> where
    Ext: Unpin

impl<Ext, T = dyn ParseTreeListener + 'static> !UnwindSafe for BaseParser<Ext, T>

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, 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.