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

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
}
Expand description

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

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

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

Removes all added parse listeners without returning them

Text representation of generated DFA for debugging purposes

Trait Implementations

The resulting type after dereferencing.

Dereferences the value.

Mutably dereferences the value.

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Performs the conversion.

Performs the conversion.

Returns text representation of current node type, rule name for context nodes and token text for terminal nodes Read more

Returns type id of the type of self Read more

Returns type id of this type

Returns true if type behind self is equal to the type of T.

Attempts to downcast self to T behind reference

Attempts to downcast self to T behind mutable reference

Attempts to downcast self to T behind Rc pointer

Attempts to downcast self to T behind Arc pointer

Attempts to downcast self to T behind Box pointer

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.