1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
use std::fmt::Debug;

use super::*;

#[derive(Debug)]
/// Information about the error which occured when the [Lexer::lex] failed.
pub struct Error<'code> {
    pub buffer: Buffer<'code>,
    /// This is included not just for debug information, but also to allow [lexerus_derive::Lexer]
    /// to obtain some basic information about how many tokens were matched before the program
    /// failed. This is useful when debugging `enum` because it would not be immediately obvious
    /// which match pattern failed.
    pub matched: usize,
    pub kind: Kind,
}

#[derive(Debug)]
/// Describes the type of error found.
pub enum Kind {
    /// This means that the token was not found
    NotFound(&'static str),
    /// This means that an unexpected token was encountered.
    UnexpectedToken(&'static str),
}