1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
mod parser;
mod scanner;
mod source;

pub use parser::*;
pub use scanner::*;
pub use source::*;

/// The result of parsing some source input
pub enum ParseResult<R, E> {
    /// Hard error, cannot proceed
    Fail(E),
    /// Soft error, can proceed, but may fail at a later stage
    Warn(E, R),
    /// Success
    Ok(R),
}
impl<R, E> ParseResult<R, E>
where
    E: std::error::Error,
{
    pub fn unwrap(self) -> R {
        match self {
            Self::Fail(err) => {
                panic!("{err}");
            }
            Self::Warn(_err, res) => res,
            Self::Ok(res) => res,
        }
    }
}