Trait chumsky::error::Error[][src]

pub trait Error<I>: Sized {
    type Span: Span;
    type Pattern;
    fn span(&self) -> Option<Self::Span>;
fn expected_token_found(
        span: Option<Self::Span>,
        expected: Vec<I>,
        found: Option<I>
    ) -> Self;
fn into_labelled<L: Into<Self::Pattern>>(self, label: L) -> Self; fn expected_label_found<L: Into<Self::Pattern>>(
        span: Option<Self::Span>,
        expected: L,
        found: Option<I>
    ) -> Self { ... }
fn merge(self, other: Self) -> Self { ... } }
Expand description

A trait that describes parser error types.

Associated Types

The type of spans to be used in the error.

The label used to describe tokens or a token pattern in error messages.

Commonly, this type has a way to represent both specific tokens and groups of tokens like ‘expressions’ or ‘statements’.

Required methods

The primary span that the error originated at, if one exists.

Create a new error describing a conflict between expected tokens and that which was actually found.

Using a None as found indicates that the end of input was reached, but was not expected.

Alter the error message to indicate that the given labelled pattern was expected.

Provided methods

Create a new error describing a conflict between an expected label and that the token that was actually found.

Using a None as found indicates that the end of input was reached, but was not expected.

Merge two errors together, combining their elements.

Note that when the errors originate from two different locations in the token stream (i.e: their span Span::end differs), the error error with the latest position should be preferred. When merging errors, unresolvable differences should favour self.

Implementors