Combine the error types.

This commit is contained in:
Tom Alexander
2023-04-21 18:36:01 -04:00
parent 04dfffc000
commit a1724dae52
23 changed files with 57 additions and 68 deletions

View File

@@ -1,25 +0,0 @@
use nom::error::ErrorKind;
use nom::error::ParseError;
use nom::IResult;
pub type Res<T, U> = IResult<T, U, CustomError<T>>;
#[derive(Debug, PartialEq)]
pub enum CustomError<I> {
MyError(MyError<I>),
Nom(I, ErrorKind),
}
#[derive(Debug, PartialEq)]
pub struct MyError<I>(pub I);
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
}
}

View File

@@ -1,5 +1,4 @@
mod diff;
mod error;
mod parse;
mod sexp;
mod util;

View File

@@ -1,3 +1,6 @@
use crate::error::CustomError;
use crate::error::MyError;
use crate::error::Res;
use std::collections::HashMap;
use nom::branch::alt;
@@ -16,8 +19,6 @@ use nom::sequence::delimited;
use nom::sequence::preceded;
use nom::sequence::tuple;
use super::error::Res;
#[derive(Debug)]
pub enum Token<'s> {
Atom(&'s str),