glsl_lang_lexer/
min.rs

1//! glsl-lang-pp/min based lexer
2
3use glsl_lang_pp::types;
4
5use lang_util::{
6    position::{LexerPosition, NodeSpan},
7    TextSize,
8};
9
10pub mod str;
11
12/// Lexical analysis error
13#[derive(Debug, Clone, PartialEq, Eq)]
14pub enum LexicalError {
15    /// Invalid token in lexical analysis
16    Token {
17        /// Type of invalid token error
18        kind: types::token::ErrorKind,
19        /// Location of the error
20        pos: NodeSpan,
21    },
22}
23
24impl std::fmt::Display for LexicalError {
25    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
26        match self {
27            LexicalError::Token { kind, .. } => write!(f, "{}", kind),
28        }
29    }
30}
31
32impl std::error::Error for LexicalError {}
33
34impl lang_util::error::LexicalError for LexicalError {
35    fn location(&self) -> (LexerPosition, TextSize) {
36        match self {
37            LexicalError::Token { pos, .. } => (pos.start(), pos.len()),
38        }
39    }
40}