1use glsl_lang_pp::types;
4
5use lang_util::{
6 position::{LexerPosition, NodeSpan},
7 TextSize,
8};
9
10pub mod str;
11
12#[derive(Debug, Clone, PartialEq, Eq)]
14pub enum LexicalError {
15 Token {
17 kind: types::token::ErrorKind,
19 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}