Struct antlr_rust::error_strategy::BailErrorStrategy [−][src]
pub struct BailErrorStrategy<'input, Ctx: ParserNodeType<'input>>(_);
Expand description
This implementation of ANTLRErrorStrategy
responds to syntax errors
by immediately canceling the parse operation with a
ParseCancellationException
. The implementation ensures that the
ParserRuleContext.exception
field is set for all parse tree nodes
that were not completed prior to encountering the error.
This error strategy is useful in the following scenarios.
- Two-stage parsing: This error strategy allows the first
stage of two-stage parsing to immediately terminate if an error is
encountered, and immediately fall back to the second stage. In addition to
avoiding wasted work by attempting to recover from errors here, the empty
implementation of
sync
improves the performance of the first stage. - Silent validation: When syntax errors are not being
reported or logged, and the parse result is simply ignored if errors occur,
the
BailErrorStrategy
avoids wasting work on recovering from errors when the result will be ignored either way.
Usage
use antlr_rust::error_strategy::BailErrorStrategy;
myparser.err_handler = BailErrorStrategy::new();
*/
Implementations
Trait Implementations
Returns the “default value” for a type. Read more
Reset the error handler state for the specified recognizer
.
fn recover_inline(
&mut self,
recognizer: &mut T
) -> Result<<T::TF as TokenFactory<'a>>::Tok, ANTLRError>
fn recover_inline(
&mut self,
recognizer: &mut T
) -> Result<<T::TF as TokenFactory<'a>>::Tok, ANTLRError>
This method is called when an unexpected symbol is encountered during an
inline match operation, such as Parser::match
. If the error
strategy successfully recovers from the match failure, this method
returns the Token
instance which should be treated as the
successful result of the match. Read more
This method is called to recover from error e
. This method is
called after ErrorStrategy::reportError
by the default error handler
generated for a rule method. Read more
This method provides the error handler with an opportunity to handle syntactic or semantic errors in the input stream before they result in a error. Read more
Tests whether or not {@code recognizer} is in the process of recovering
from an error. In error recovery mode, Parser::consume
will create
ErrorNode
leaf instead of TerminalNode
one Read more
Report any kind of ANTLRError
. This method is called by
the default exception handler generated for a rule method. Read more
This method is called when the parser successfully matches an input symbol. Read more
impl<'input, Ctx: ParserNodeType<'input>> TidAble<'input> for BailErrorStrategy<'input, Ctx> where
Ctx: TidAble<'input>,
Auto Trait Implementations
impl<'input, Ctx> RefUnwindSafe for BailErrorStrategy<'input, Ctx> where
<Ctx as ParserNodeType<'input>>::Type: RefUnwindSafe,
impl<'input, Ctx> !Send for BailErrorStrategy<'input, Ctx>
impl<'input, Ctx> !Sync for BailErrorStrategy<'input, Ctx>
impl<'input, Ctx> Unpin for BailErrorStrategy<'input, Ctx>
impl<'input, Ctx> UnwindSafe for BailErrorStrategy<'input, Ctx> where
<Ctx as ParserNodeType<'input>>::Type: RefUnwindSafe,
Blanket Implementations
Mutably borrows from an owned value. Read more
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