Skip to main content

TypedParseError

Struct TypedParseError 

Source
pub struct TypedParseError<'a, G: TypedGrammar>(/* private fields */);
Expand description

Parse failure for a single statement in grammar G.

Designed for diagnostics:

  • Message text (message()).
  • Optional source location (offset(), length()).
  • Severity/recovery status (kind()).
  • Optional recovery tree (recovery_root()).

Recovery model:

  • Recovered: this statement is invalid, but the parser skipped ahead (usually to the next ;) so it can continue with later statements.
  • The returned recovery_root() can still be useful for diagnostics, but may contain error placeholders where input was skipped.
  • Fatal: the parser could not find a safe point to continue from.

Implementations§

Source§

impl<'a, G: TypedGrammar> TypedParseError<'a, G>

Source

pub fn kind(&self) -> ParseErrorKind

Whether parsing recovered to a statement boundary.

Source

pub fn is_recovered(&self) -> bool

True if this error was recovered and yielded a partial tree.

Source

pub fn is_fatal(&self) -> bool

True if this error is fatal (unrecoverable).

Source

pub fn message(&self) -> &str

Human-readable diagnostic text.

Source

pub fn offset(&self) -> Option<usize>

Returns the byte offset of the error token, or None if unknown.

Source

pub fn length(&self) -> Option<usize>

Returns the byte length of the error token, or None if unknown.

Source

pub fn recovery_root(&'a self) -> Option<G::Node<'a>>

The partial recovery tree, if error recovery produced one.

Source

pub fn parse_source(&self) -> &'a str

The source text bound to this result.

Source

pub fn tokens(&self) -> impl Iterator<Item = TypedParserToken<'a, G>>

Tokens collected during the (partial) parse, if collect_tokens was enabled.

Source

pub fn comments(&self) -> impl Iterator<Item = Comment<'a>>

Comments collected during the (partial) parse, if collect_tokens was enabled.

Trait Implementations§

Source§

impl<G: TypedGrammar> Debug for TypedParseError<'_, G>

Source§

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

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

impl<G: TypedGrammar> Display for TypedParseError<'_, G>

Source§

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

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

impl<G: TypedGrammar> Error for TypedParseError<'_, G>

1.30.0 · Source§

fn source(&self) -> Option<&(dyn Error + 'static)>

Returns the lower-level source of this error, if any. Read more
1.0.0 · Source§

fn description(&self) -> &str

👎Deprecated since 1.42.0:

use the Display impl or to_string()

1.0.0 · Source§

fn cause(&self) -> Option<&dyn Error>

👎Deprecated since 1.33.0:

replaced by Error::source, which can support downcasting

Source§

fn provide<'a>(&'a self, request: &mut Request<'a>)

🔬This is a nightly-only experimental API. (error_generic_member_access)
Provides type-based access to context intended for error reports. Read more

Auto Trait Implementations§

§

impl<'a, G> Freeze for TypedParseError<'a, G>

§

impl<'a, G> !RefUnwindSafe for TypedParseError<'a, G>

§

impl<'a, G> !Send for TypedParseError<'a, G>

§

impl<'a, G> !Sync for TypedParseError<'a, G>

§

impl<'a, G> Unpin for TypedParseError<'a, G>
where G: Unpin,

§

impl<'a, G> UnsafeUnpin for TypedParseError<'a, G>

§

impl<'a, G> !UnwindSafe for TypedParseError<'a, G>

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> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. Read more
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.