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>
impl<'a, G: TypedGrammar> TypedParseError<'a, G>
Sourcepub fn kind(&self) -> ParseErrorKind
pub fn kind(&self) -> ParseErrorKind
Whether parsing recovered to a statement boundary.
Sourcepub fn is_recovered(&self) -> bool
pub fn is_recovered(&self) -> bool
True if this error was recovered and yielded a partial tree.
Sourcepub fn offset(&self) -> Option<usize>
pub fn offset(&self) -> Option<usize>
Returns the byte offset of the error token, or None if unknown.
Sourcepub fn length(&self) -> Option<usize>
pub fn length(&self) -> Option<usize>
Returns the byte length of the error token, or None if unknown.
Sourcepub fn recovery_root(&'a self) -> Option<G::Node<'a>>
pub fn recovery_root(&'a self) -> Option<G::Node<'a>>
The partial recovery tree, if error recovery produced one.
Sourcepub fn parse_source(&self) -> &'a str
pub fn parse_source(&self) -> &'a str
The source text bound to this result.
Sourcepub fn tokens(&self) -> impl Iterator<Item = TypedParserToken<'a, G>>
pub fn tokens(&self) -> impl Iterator<Item = TypedParserToken<'a, G>>
Tokens collected during the (partial) parse, if collect_tokens was enabled.
Trait Implementations§
Source§impl<G: TypedGrammar> Debug for TypedParseError<'_, G>
impl<G: TypedGrammar> Debug for TypedParseError<'_, G>
Source§impl<G: TypedGrammar> Display for TypedParseError<'_, G>
impl<G: TypedGrammar> Display for TypedParseError<'_, G>
Source§impl<G: TypedGrammar> Error for TypedParseError<'_, G>
impl<G: TypedGrammar> Error for TypedParseError<'_, G>
1.30.0 · Source§fn source(&self) -> Option<&(dyn Error + 'static)>
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
fn description(&self) -> &str
👎Deprecated since 1.42.0:
use the Display impl or to_string()
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> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more