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
32
33
34
use litcheck::diagnostics::{Diagnostic, SourceSpan};

#[derive(Debug, Diagnostic, thiserror::Error, Clone)]
pub enum LexerError {
    #[error("invalid CHECK-COUNT")]
    #[diagnostic()]
    BadCount {
        #[label("the count value for this directive was invalid: {error}")]
        span: SourceSpan,
        #[source]
        error: core::num::ParseIntError,
    },
    #[error("invalid number")]
    #[diagnostic()]
    InvalidNumber {
        #[label("this numeric value could not be parsed: {error}")]
        span: SourceSpan,
        #[source]
        error: core::num::ParseIntError,
    },
    #[error("invalid identifier")]
    #[diagnostic()]
    InvalidIdentifier {
        #[label("this identifier has characters outside the allowed alphabet")]
        span: SourceSpan,
    },
    #[error("unexpected character '{unexpected}'")]
    #[diagnostic()]
    UnexpectedCharacter {
        #[label("'{unexpected}' is not valid here")]
        span: SourceSpan,
        unexpected: char,
    },
}