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>;
7
8#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
10#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
11pub enum ClojureTokenType {
12 Token,
14 List,
16 Vector,
18 Map,
20 Set,
22 AnonFn,
24 Root,
26 SourceFile,
28 Error,
30 ListStart,
33 ListEnd,
35 VectorStart,
37 VectorEnd,
39 MapStart,
41 MapEnd,
43 SetStart,
45 AnonFnStart,
47 Quote,
49 Unquote,
51 UnquoteSplice,
53 Meta,
55 Whitespace,
57 Comment,
59 StringLiteral,
61 CharacterLiteral,
63 NumberLiteral,
65 KeywordLiteral,
67 Dispatch,
69 RegexLiteral,
71 Symbol,
73}
74
75impl TokenType for ClojureTokenType {
76 type Role = UniversalTokenRole;
77 const END_OF_STREAM: Self = Self::Error;
78
79 fn is_ignored(&self) -> bool {
80 false
81 }
82
83 fn role(&self) -> Self::Role {
84 match self {
85 Self::Error => UniversalTokenRole::Error,
86 _ => UniversalTokenRole::None,
87 }
88 }
89}