Skip to main content

BailErrorStrategy

Struct BailErrorStrategy 

Source
pub struct BailErrorStrategy<'input, 'arena, TF, P>(/* private fields */)
where
    TF: TokenFactory<'input, 'arena> + 'arena,
    P: Parser<'input, 'arena, TF>,
    'input: 'arena;
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 dbt_antlr4::error_strategy::BailErrorStrategy;
myparser.err_handler = BailErrorStrategy::new();

*/

Implementations§

Source§

impl<'input, 'arena, TF, P> BailErrorStrategy<'input, 'arena, TF, P>
where TF: TokenFactory<'input, 'arena> + 'arena, P: Parser<'input, 'arena, TF>, 'input: 'arena,

Source

pub fn new() -> Self

Creates new instance of BailErrorStrategy

Trait Implementations§

Source§

impl<'input, 'arena, TF, P> Debug for BailErrorStrategy<'input, 'arena, TF, P>
where TF: TokenFactory<'input, 'arena> + 'arena + Debug, P: Parser<'input, 'arena, TF> + Debug, 'input: 'arena,

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<'input, 'arena, TF, P> Default for BailErrorStrategy<'input, 'arena, TF, P>
where TF: TokenFactory<'input, 'arena> + 'arena + Default, P: Parser<'input, 'arena, TF> + Default, 'input: 'arena,

Source§

fn default() -> BailErrorStrategy<'input, 'arena, TF, P>

Returns the “default value” for a type. Read more
Source§

impl<'input, 'arena, TF, P> ErrorStrategy<'input, 'arena, TF, P> for BailErrorStrategy<'input, 'arena, TF, P>
where TF: TokenFactory<'input, 'arena> + 'arena, P: Parser<'input, 'arena, TF>, 'input: 'arena,

Source§

fn reset(&mut self, recognizer: &mut P)

Reset the error handler state for the specified recognizer.
Source§

fn recover_inline( &mut self, recognizer: &mut P, ) -> Result<&'arena TF::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
Source§

fn recover( &mut self, recognizer: &mut P, e: &ANTLRError, ) -> Result<(), ANTLRError>

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.
Source§

fn sync(&mut self, _recognizer: &mut P) -> Result<(), ANTLRError>

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
Source§

fn in_error_recovery_mode(&mut self, recognizer: &mut P) -> bool

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
Source§

fn report_error(&mut self, recognizer: &mut P, e: &ANTLRError)

Report any kind of ANTLRError. This method is called by the default exception handler generated for a rule method.
Source§

fn report_match(&mut self, _recognizer: &mut P)

This method is called when the parser successfully matches an input symbol.

Auto Trait Implementations§

§

impl<'input, 'arena, TF, P> Freeze for BailErrorStrategy<'input, 'arena, TF, P>

§

impl<'input, 'arena, TF, P> RefUnwindSafe for BailErrorStrategy<'input, 'arena, TF, P>
where <P as Recognizer<'input, 'arena>>::Node: RefUnwindSafe, TF: RefUnwindSafe, P: RefUnwindSafe,

§

impl<'input, 'arena, TF, P> Send for BailErrorStrategy<'input, 'arena, TF, P>
where <P as Recognizer<'input, 'arena>>::Node: Sync, TF: Send, P: Send,

§

impl<'input, 'arena, TF, P> Sync for BailErrorStrategy<'input, 'arena, TF, P>
where <P as Recognizer<'input, 'arena>>::Node: Sync, TF: Sync, P: Sync,

§

impl<'input, 'arena, TF, P> Unpin for BailErrorStrategy<'input, 'arena, TF, P>
where TF: Unpin, P: Unpin,

§

impl<'input, 'arena, TF, P> UnwindSafe for BailErrorStrategy<'input, 'arena, TF, P>
where <P as Recognizer<'input, 'arena>>::Node: RefUnwindSafe, TF: UnwindSafe, P: UnwindSafe,

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

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

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.