Skip to main content

ParserError

Enum ParserError 

Source
pub enum ParserError {
    SyntaxError,
    TooManyErrors,
    Irrecoverable,
    ExtraSymbol,
    UnexpectedEOS,
    UnexpectedError,
    EncounteredErrors,
    AbortRequest,
}
Expand description

Code of the error that occurred during the parsing, returned by the parse_stream(…) method of the parser.

Variants§

§

SyntaxError

A syntax error was met. Either

  • The next terminal of the parsed text doesn’t match the expected one in the current rule alternative; for example, a rule assign -> "let" Id "=" expr ";"; has just successfully scanned the terminal "let", but the next one isn’t Id.
  • The next symbol doesn’t correspond to any correct option for the next nonterminal ( in other words, there is no entry in the parsing table for that combination). For example, in the same rule as above, the terminal "=" has just been scanned successfully, but expr doesn’t begin with the next one.

This error is returned only when the parser doesn’t try to recover from syntax errors; this option is set with the set_try_recover(…) method and is enabled by default.

See also ParserError::TooManyErrors.

§

TooManyErrors

Too many syntax errors were met, either

This error is returned only when the parser tries to recover from syntactic or lexical errors; this option is set with the set_try_recover(…) method and is enabled by default.

See also ParserError::SyntaxError.

§

Irrecoverable

The parser has reached an irrecoverable error, after trying to recover from a syntax error and encountering the end of the text.

§

ExtraSymbol

The parser has reached the end of the top rule, but there are still terminals coming from the lexer.

Note that if the text is expected to contain something else after the part that must be parsed, it is possible to tell the parser to conclude the parsing without looking any further. This can be done in the listener with the [check_abort_request(…)] performed regularly by the parser. See the [examples/terminate] parser to see how it can be used.

§

UnexpectedEOS

The parser has encountered the end of the text, but the top rule hasn’t been fully parsed.

§

UnexpectedError

This is an internal error that isn’t supposed to happen.

§

EncounteredErrors

The text has been fully parsed, but syntax errors were encountered by the parser (and could be recovered from).

See also ParserError::SyntaxError.

§

AbortRequest

An Abort was returned by the [check_abort_request(…)] method of the listener.

Trait Implementations§

Source§

impl Debug for ParserError

Source§

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

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

impl Display for ParserError

Source§

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

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

impl PartialEq for ParserError

Source§

fn eq(&self, other: &ParserError) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl StructuralPartialEq for ParserError

Auto Trait Implementations§

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<S> BuildFrom<S> for S

Source§

fn build_from(source: S) -> S

Converts to this type from the input type.
Source§

impl<S, T> BuildInto<T> for S
where T: BuildFrom<S>,

Source§

fn build_into(self) -> T

Calls T::from(self) to convert a S into a T.

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<S, T> TryBuildInto<T> for S
where T: TryBuildFrom<S>,

Source§

type Error = <T as TryBuildFrom<S>>::Error

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

fn try_build_into(self) -> Result<T, <T as TryBuildFrom<S>>::Error>

Performs the conversion.
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.