1use oak_core::Token;
2use serde::{Deserialize, Serialize};
3
4pub type JasmToken = Token<JasmSyntaxKind>;
5
6#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Serialize, Deserialize)]
8pub enum JasmSyntaxKind {
9 Root,
11 Class,
12 Method,
13 Field,
14 Instruction,
15 IdentifierNode,
16 StringNode,
17 NumberNode,
18 ErrorNode,
19
20 ClassKw,
22 VersionKw,
23 MethodKw,
24 FieldKw,
25 StringKw,
26 SourceFileKw,
27 StackKw,
28 LocalsKw,
29 EndKw,
30 CompiledKw,
31 FromKw,
32 InnerClassKw,
33 NestMembersKw,
34 BootstrapMethodKw,
35
36 Public,
37 Private,
38 Protected,
39 Static,
40 Super,
41 Final,
42 Abstract,
43 Synchronized,
44 Native,
45 Synthetic,
46 Deprecated,
47 Varargs,
48
49 ALoad0,
50 ALoad1,
51 ALoad2,
52 ALoad3,
53 ILoad0,
54 ILoad1,
55 ILoad2,
56 ILoad3,
57 Ldc,
58 LdcW,
59 Ldc2W,
60 InvokeSpecial,
61 InvokeVirtual,
62 InvokeStatic,
63 InvokeInterface,
64 InvokeDynamic,
65 GetStatic,
66 PutStatic,
67 GetField,
68 PutField,
69 Return,
70 IReturn,
71 AReturn,
72 LReturn,
73 FReturn,
74 DReturn,
75 Nop,
76 Dup,
77 Pop,
78 New,
79
80 LeftBrace,
81 RightBrace,
82 LeftParen,
83 RightParen,
84 LeftBracket,
85 RightBracket,
86 Colon,
87 Semicolon,
88 Dot,
89 Comma,
90 Slash,
91
92 StringLiteral,
93 Number,
94 TypeDescriptor,
95 IdentifierToken,
96 Whitespace,
97 Newline,
98 Comment,
99 Eof,
100 Error,
101}
102
103impl oak_core::SyntaxKind for JasmSyntaxKind {
104 fn is_trivia(&self) -> bool {
105 matches!(self, Self::Whitespace | Self::Newline | Self::Comment)
106 }
107
108 fn is_comment(&self) -> bool {
109 matches!(self, Self::Comment)
110 }
111
112 fn is_whitespace(&self) -> bool {
113 matches!(self, Self::Whitespace | Self::Newline)
114 }
115
116 fn is_token_type(&self) -> bool {
117 !matches!(
118 self,
119 Self::Root
120 | Self::Class
121 | Self::Method
122 | Self::Field
123 | Self::Instruction
124 | Self::IdentifierNode
125 | Self::StringNode
126 | Self::NumberNode
127 | Self::ErrorNode
128 )
129 }
130
131 fn is_element_type(&self) -> bool {
132 matches!(
133 self,
134 Self::Root
135 | Self::Class
136 | Self::Method
137 | Self::Field
138 | Self::Instruction
139 | Self::IdentifierNode
140 | Self::StringNode
141 | Self::NumberNode
142 | Self::ErrorNode
143 )
144 }
145}