1use oak_core::{ElementType, TokenType, UniversalElementRole, UniversalTokenRole};
2use serde::Serialize;
3
4#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Serialize)]
5pub enum PurescriptSyntaxKind {
6 Whitespace,
8 Newline,
9 Comment,
10
11 Ado,
13 Case,
14 Class,
15 Data,
16 Derive,
17 Do,
18 Else,
19 False,
20 Forall,
21 Foreign,
22 If,
23 Import,
24 In,
25 Infix,
26 Infixl,
27 Infixr,
28 Instance,
29 Let,
30 Module,
31 Newtype,
32 Of,
33 Then,
34 True,
35 Type,
36 Where,
37
38 Arrow, FatArrow, Backslash, Pipe, Equal, ColonColon, Dot, DotDot, Plus, Minus, Star, Slash, Percent, Caret, EqualEqual, NotEqual, Less, Greater, LessEqual, GreaterEqual, And, Or, Append, Compose, ComposeFlipped, Apply, ApplyFlipped, Bind, BindFlipped, LeftParen, RightParen, LeftBrace, RightBrace, LeftBracket, RightBracket, Comma, Semicolon, Colon, Question, Exclamation, At, Underscore, Backtick, IntLiteral,
87 NumberLiteral,
88 StringLiteral,
89 CharLiteral,
90 BooleanLiteral,
91
92 Identifier,
94 UpperIdentifier,
95 Operator,
96 QualifiedIdentifier,
97
98 Root,
100 SourceFile,
101 Error,
102 Eof,
103}
104
105impl TokenType for PurescriptSyntaxKind {
106 const END_OF_STREAM: Self = Self::Eof;
107 type Role = UniversalTokenRole;
108
109 fn role(&self) -> Self::Role {
110 match self {
111 Self::Whitespace | Self::Newline => UniversalTokenRole::Whitespace,
112 Self::Comment => UniversalTokenRole::Comment,
113 Self::Eof => UniversalTokenRole::Eof,
114 _ => UniversalTokenRole::None,
115 }
116 }
117}
118
119impl ElementType for PurescriptSyntaxKind {
120 type Role = UniversalElementRole;
121
122 fn role(&self) -> Self::Role {
123 match self {
124 Self::Root | Self::SourceFile => UniversalElementRole::Root,
125 Self::Error => UniversalElementRole::Error,
126 _ => UniversalElementRole::None,
127 }
128 }
129}