Trait combine::ParseError
[−]
[src]
pub trait ParseError<Item, Range, Position>: Sized + PartialEq { type StreamError: StreamError<Item, Range>; fn empty(position: Position) -> Self; fn from_error(position: Position, err: Self::StreamError) -> Self; fn set_position(&mut self, position: Position); fn add(&mut self, err: Self::StreamError); fn set_expected<F>(self_: &mut Tracked<Self>, info: Self::StreamError, f: F)
where
F: FnOnce(&mut Tracked<Self>); fn into_other<T>(self) -> T
where
T: ParseError<Item, Range, Position>; fn merge(self, other: Self) -> Self { ... } fn add_expected(&mut self, info: Info<Item, Range>) { ... } fn add_unexpected(&mut self, info: Info<Item, Range>) { ... } fn add_message(&mut self, info: Info<Item, Range>) { ... } }
Trait which defines a gluon parse error.
A parse error is composed of one or more StreamError
s
Associated Types
type StreamError: StreamError<Item, Range>
Required Methods
fn empty(position: Position) -> Self
Constructs an empty error.
An empty error is expected to be cheap to create as it is frequently created and discarded.
fn from_error(position: Position, err: Self::StreamError) -> Self
Creates a ParseError
from a single Self::StreamError
fn set_position(&mut self, position: Position)
Sets the position of this ParseError
fn add(&mut self, err: Self::StreamError)
Adds a StreamError
to self
.
It is up to each individual error type to define what adding an error does, some may push
it to a vector while others may only keep self
or err
to avoid allocation
fn set_expected<F>(self_: &mut Tracked<Self>, info: Self::StreamError, f: F) where
F: FnOnce(&mut Tracked<Self>),
F: FnOnce(&mut Tracked<Self>),
Sets info
as the only Expected
error of self
fn into_other<T>(self) -> T where
T: ParseError<Item, Range, Position>,
T: ParseError<Item, Range, Position>,
Does a best-effort conversion of self
into another ParseError
Provided Methods
fn merge(self, other: Self) -> Self
Merges two errors. If they exist at the same position the errors of other
are
added to self
(using the semantics of add
). If they are not at the same
position the error furthest ahead are returned, ignoring the other ParseError
.
fn add_expected(&mut self, info: Info<Item, Range>)
fn add_unexpected(&mut self, info: Info<Item, Range>)
fn add_message(&mut self, info: Info<Item, Range>)
Implementors
impl<Item, Range, Position> ParseError<Item, Range, Position> for UnexpectedParse where
Position: Default, type StreamError = Self;impl<Item, Range, Position> ParseError<Item, Range, Position> for StringStreamError where
Position: Default, type StreamError = Self;impl<Item, Range, Position> ParseError<Item, Range, Position> for Error<Item, Range> where
Item: PartialEq,
Range: PartialEq,
Position: Default, type StreamError = Self;impl<Item, Range, Position> ParseError<Item, Range, Position> for Errors<Position, Item, Range> where
Item: PartialEq,
Range: PartialEq,
Position: Ord, type StreamError = Error<Item, Range>;