organic/src/parser/error.rs

26 lines
576 B
Rust
Raw Normal View History

2022-12-15 23:09:40 -05:00
use nom::error::ErrorKind;
use nom::error::ParseError;
2022-12-18 02:59:41 -05:00
use nom::IResult;
pub type Res<T, U> = IResult<T, U, CustomError<T>>;
2022-12-15 23:09:40 -05:00
#[derive(Debug, PartialEq)]
pub enum CustomError<I> {
MyError(MyError<I>),
Nom(I, ErrorKind),
}
#[derive(Debug, PartialEq)]
pub struct MyError<I>(pub I);
2022-12-15 23:09:40 -05:00
impl<I> ParseError<I> for CustomError<I> {
fn from_error_kind(input: I, kind: ErrorKind) -> Self {
CustomError::Nom(input, kind)
}
fn append(input: I, kind: ErrorKind, mut other: Self) -> Self {
// Doesn't do append like VerboseError
other
}
}