Start of a custom error.
This commit is contained in:
parent
4c09c390fa
commit
4a9bb31aed
@ -32,6 +32,7 @@ use nom::combinator::peek;
|
|||||||
use nom::combinator::recognize;
|
use nom::combinator::recognize;
|
||||||
use nom::error::ErrorKind;
|
use nom::error::ErrorKind;
|
||||||
use nom::error::ParseError;
|
use nom::error::ParseError;
|
||||||
|
use nom::error::VerboseError;
|
||||||
use nom::multi::many1;
|
use nom::multi::many1;
|
||||||
use nom::multi::many_till;
|
use nom::multi::many_till;
|
||||||
use nom::sequence::tuple;
|
use nom::sequence::tuple;
|
||||||
@ -274,3 +275,30 @@ fn flat_link<'s, 'r>(context: Context<'r, 's>, i: &'s str) -> Res<&'s str, Link<
|
|||||||
let ret = Link { contents: captured };
|
let ret = Link { contents: captured };
|
||||||
Ok((remaining, ret))
|
Ok((remaining, ret))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub struct MyError<I>(I);
|
||||||
|
|
||||||
|
impl<I> ParseError<I> for MyError<I> {
|
||||||
|
fn from_error_kind(input: I, kind: ErrorKind) -> Self {
|
||||||
|
// MyError((input, kind))
|
||||||
|
todo!()
|
||||||
|
}
|
||||||
|
|
||||||
|
fn append(input: I, kind: ErrorKind, mut other: Self) -> Self {
|
||||||
|
// Doesn't do append like VerboseError
|
||||||
|
other
|
||||||
|
}
|
||||||
|
|
||||||
|
fn from_char(input: I, c: char) -> Self {
|
||||||
|
// MyError((input, c))
|
||||||
|
todo!()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Err(nom::Err::Error(nom::error::Error::from_error_kind(input, nom::error::ErrorKind::Char)))
|
||||||
|
|
||||||
|
|
||||||
|
fn test_parser<'a>(i: &'a str) -> IResult<&'a str, &'a str, VerboseError<&'a str>> {
|
||||||
|
Err(nom::Err::Error(MyError(i)))?;
|
||||||
|
tag("sdjfisdfjisudfjuwiefweufefefjwef")(i)
|
||||||
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user