lexerus/
error.rs

1use std::fmt::Debug;
2
3use super::*;
4
5#[derive(Debug)]
6/// Information about the error which occured when the [Lexer::lex] failed.
7pub struct Error<'code> {
8    pub buffer: Buffer<'code>,
9    /// This is included not just for debug information, but also to allow [lexerus_derive::Lexer]
10    /// to obtain some basic information about how many tokens were matched before the program
11    /// failed. This is useful when debugging `enum` because it would not be immediately obvious
12    /// which match pattern failed.
13    pub matched: usize,
14    pub kind: Kind,
15}
16
17#[derive(Debug, PartialEq, Eq)]
18/// Describes the type of error found.
19pub enum Kind {
20    /// This means that the token was not found
21    NotFound(&'static str),
22    /// This means that an unexpected token was encountered.
23    UnexpectedToken(&'static str),
24}