oak_clojure/lexer/
token_type.rs1use oak_core::{Source, Token, TokenType, UniversalElementRole, UniversalTokenRole};
2#[cfg(feature = "serde")]
3use serde::{Deserialize, Serialize};
4
5pub type ClojureToken = Token<ClojureTokenType>;
6
7#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
8#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
9pub enum ClojureTokenType {
10 Token,
11 List,
12 Vector,
13 Map,
14 Set,
15 AnonFn,
16 Root,
17 SourceFile,
18 Error,
19 ListStart,
21 ListEnd,
22 VectorStart,
23 VectorEnd,
24 MapStart,
25 MapEnd,
26 SetStart,
27 AnonFnStart,
28 Quote,
29 Unquote,
30 UnquoteSplice,
31 Meta,
32 Whitespace,
33 Comment,
34 StringLiteral,
35 CharacterLiteral,
36 NumberLiteral,
37 KeywordLiteral,
38 Dispatch,
39 RegexLiteral,
40 Symbol,
41}
42
43impl TokenType for ClojureTokenType {
44 type Role = UniversalTokenRole;
45 const END_OF_STREAM: Self = Self::Error;
46
47 fn is_ignored(&self) -> bool {
48 false
49 }
50
51 fn role(&self) -> Self::Role {
52 match self {
53 Self::Error => UniversalTokenRole::Error,
54 _ => UniversalTokenRole::None,
55 }
56 }
57}