Start of a custom error.

This commit is contained in:
Tom Alexander 2022-12-15 22:38:28 -05:00
parent 4c09c390fa
commit 4a9bb31aed
Signed by: talexander
GPG Key ID: D3A179C9A53C0EDE
1 changed files with 28 additions and 0 deletions

View File

@ -32,6 +32,7 @@ use nom::combinator::peek;
use nom::combinator::recognize;
use nom::error::ErrorKind;
use nom::error::ParseError;
use nom::error::VerboseError;
use nom::multi::many1;
use nom::multi::many_till;
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 };
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)
}