1use oak_core::{ElementType, TokenType, UniversalElementRole, UniversalTokenRole};
2use serde::{Deserialize, Serialize};
3
4#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Serialize, Deserialize)]
6pub enum JavaScriptSyntaxKind {
7 Root,
9 Program,
10 Statement,
11 Expression,
12 Declaration,
13 FunctionDeclaration,
14 VariableDeclaration,
15 ClassDeclaration,
16 ImportDeclaration,
17 ExportDeclaration,
18 IfStatement,
19 WhileStatement,
20 ForStatement,
21 BlockStatement,
22 ExpressionStatement,
23 ReturnStatement,
24 BreakStatement,
25 ContinueStatement,
26 ThrowStatement,
27 TryStatement,
28 CatchClause,
29 FinallyClause,
30 SwitchStatement,
31 CaseClause,
32 DefaultClause,
33
34 BinaryExpression,
36 UnaryExpression,
37 AssignmentExpression,
38 CallExpression,
39 MemberExpression,
40 ConditionalExpression,
41 ArrayExpression,
42 ObjectExpression,
43 FunctionExpression,
44 ArrowFunctionExpression,
45 NewExpression,
46 UpdateExpression,
47 LogicalExpression,
48 SequenceExpression,
49 ThisExpression,
50 Identifier,
51 Literal,
52 TemplateLiteral,
53 TaggedTemplateExpression,
54
55 ObjectPattern,
57 ArrayPattern,
58 RestElement,
59 AssignmentPattern,
60 Property,
61
62 ErrorNode,
64
65 Abstract,
67 As,
68 Async,
69 Await,
70 Break,
71 Case,
72 Catch,
73 Class,
74 Const,
75 Continue,
76 Debugger,
77 Default,
78 Delete,
79 Do,
80 Else,
81 Enum,
82 Export,
83 Extends,
84 False,
85 Finally,
86 For,
87 Function,
88 If,
89 Implements,
90 Import,
91 In,
92 Instanceof,
93 Interface,
94 Let,
95 New,
96 Null,
97 Package,
98 Private,
99 Protected,
100 Public,
101 Return,
102 Static,
103 Super,
104 Switch,
105 This,
106 Throw,
107 True,
108 Try,
109 Typeof,
110 Undefined,
111 Var,
112 Void,
113 While,
114 With,
115 Yield,
116
117 Plus, Minus, Star, Slash, Percent, StarStar, PlusPlus, MinusMinus, LeftShift, RightShift, UnsignedRightShift, Less, Greater, LessEqual, GreaterEqual, EqualEqual, NotEqual, EqualEqualEqual, NotEqualEqual, Ampersand, Pipe, Caret, Exclamation, Tilde, AmpersandAmpersand, PipePipe, Question, QuestionQuestion, QuestionDot, Equal, PlusEqual, MinusEqual, StarEqual, SlashEqual, PercentEqual, StarStarEqual, LeftShiftEqual, RightShiftEqual, UnsignedRightShiftEqual, AmpersandEqual, PipeEqual, CaretEqual, AmpersandAmpersandEqual, PipePipeEqual, QuestionQuestionEqual, LeftParen, RightParen, LeftBrace, RightBrace, LeftBracket, RightBracket, Semicolon, Comma, Dot, DotDotDot, Colon, Arrow, StringLiteral,
182 NumericLiteral,
183 BigIntLiteral,
184 RegexLiteral,
185 TemplateString,
186 TemplateHead,
187 TemplateMiddle,
188 TemplateTail,
189
190 IdentifierName,
192
193 LineComment,
195 BlockComment,
196 Whitespace,
197 Newline,
198
199 Eof,
201 Error,
202}
203
204impl TokenType for JavaScriptSyntaxKind {
205 const END_OF_STREAM: Self = Self::Eof;
206 type Role = UniversalTokenRole;
207
208 fn role(&self) -> Self::Role {
209 match self {
210 Self::Whitespace | Self::Newline => UniversalTokenRole::Whitespace,
211 Self::LineComment | Self::BlockComment => UniversalTokenRole::Comment,
212 Self::Eof => UniversalTokenRole::Eof,
213 _ => UniversalTokenRole::None,
214 }
215 }
216}
217
218impl ElementType for JavaScriptSyntaxKind {
219 type Role = UniversalElementRole;
220
221 fn role(&self) -> Self::Role {
222 match self {
223 Self::Error => UniversalElementRole::Error,
224 _ => UniversalElementRole::None,
225 }
226 }
227}