1use oak_core::{ElementType, TokenType, UniversalElementRole, UniversalTokenRole};
2use serde::{Deserialize, Serialize};
3
4#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Serialize, Deserialize)]
5pub enum TclSyntaxKind {
6 Root,
8 SourceFile,
9 Module,
10
11 VariableDeclaration,
13 FunctionDeclaration,
14 ClassDeclaration,
15 InterfaceDeclaration,
16 TypeAliasDeclaration,
17 EnumDeclaration,
18 NamespaceDeclaration,
19 ImportDeclaration,
20 ExportDeclaration,
21
22 BinaryExpression,
24 UnaryExpression,
25 ConditionalExpression,
26 CallExpression,
27 NewExpression,
28 MemberExpression,
29 ArrayExpression,
30 ObjectExpression,
31 FunctionExpression,
32 ArrowFunction,
33 TemplateExpression,
34 TaggedTemplateExpression,
35 AsExpression,
36 TypeAssertionExpression,
37 NonNullExpression,
38
39 ExpressionStatement,
41 BlockStatement,
42 IfStatement,
43 WhileStatement,
44 ForStatement,
45 ForInStatement,
46 ForOfStatement,
47 DoWhileStatement,
48 SwitchStatement,
49 CaseClause,
50 DefaultClause,
51 TryStatement,
52 CatchClause,
53 FinallyClause,
54 ThrowStatement,
55 ReturnStatement,
56 BreakStatement,
57 ContinueStatement,
58 DebuggerStatement,
59 WithStatement,
60
61 BindingPattern,
63 ArrayBindingPattern,
64 ObjectBindingPattern,
65 BindingElement,
66
67 TypeReference,
69 TypeLiteral,
70 FunctionType,
71 ConstructorType,
72 ArrayType,
73 TupleType,
74 UnionType,
75 IntersectionType,
76 ConditionalType,
77 MappedType,
78 IndexedAccessType,
79 TypeQuery,
80 TypePredicate,
81
82 Error,
84
85 If,
87 Else,
88 ElseIf,
89 For,
90 While,
91 ForEach,
92 Proc,
93 Return,
94 Break,
95 Continue,
96 Set,
97 Unset,
98 Global,
99 Upvar,
100 Variable,
101
102 Plus,
104 Minus,
105 Star,
106 Slash,
107 Percent,
108 StarStar,
109
110 Less,
112 Greater,
113 LessEqual,
114 GreaterEqual,
115 EqualEqual,
116 NotEqual,
117 EqualEqualEqual,
118 NotEqualEqual,
119
120 AmpersandAmpersand,
122 PipePipe,
123 Exclamation,
124
125 Ampersand,
127 Pipe,
128 Caret,
129 Tilde,
130 LeftShift,
131 RightShift,
132 UnsignedRightShift,
133
134 Equal,
136 PlusEqual,
137 MinusEqual,
138 StarEqual,
139 SlashEqual,
140 PercentEqual,
141 StarStarEqual,
142 LeftShiftEqual,
143 RightShiftEqual,
144 UnsignedRightShiftEqual,
145 AmpersandEqual,
146 PipeEqual,
147 CaretEqual,
148 AmpersandAmpersandEqual,
149 PipePipeEqual,
150 QuestionQuestionEqual,
151
152 PlusPlus,
154 MinusMinus,
155
156 Question,
158 QuestionQuestion,
159 QuestionDot,
160 Arrow,
161 Dollar,
162
163 LeftParen,
165 RightParen,
166 LeftBrace,
167 RightBrace,
168 LeftBracket,
169 RightBracket,
170 Semicolon,
171 Comma,
172 Dot,
173 DotDotDot,
174 Colon,
175
176 StringLiteral,
178 NumericLiteral,
179 Number,
180 BigIntLiteral,
181 TemplateString,
182 RegexLiteral,
183
184 Identifier,
186 IdentifierName,
187
188 Comment,
190 LineComment,
191 BlockComment,
192 Whitespace,
193 Newline,
194
195 Eof,
197}
198
199impl TokenType for TclSyntaxKind {
200 const END_OF_STREAM: Self = Self::Eof;
201 type Role = UniversalTokenRole;
202
203 fn role(&self) -> Self::Role {
204 match self {
205 TclSyntaxKind::Whitespace | TclSyntaxKind::Newline => UniversalTokenRole::Whitespace,
206 TclSyntaxKind::Comment | TclSyntaxKind::LineComment | TclSyntaxKind::BlockComment => UniversalTokenRole::Comment,
207 Self::Eof => UniversalTokenRole::Eof,
208 _ => UniversalTokenRole::None,
209 }
210 }
211}
212
213impl ElementType for TclSyntaxKind {
214 type Role = UniversalElementRole;
215
216 fn role(&self) -> Self::Role {
217 match self {
218 Self::Error => UniversalElementRole::Error,
219 _ => UniversalElementRole::None,
220 }
221 }
222}