1#[derive(Copy, Clone, Debug, PartialEq, Eq, Hash)]
2pub enum SoliditySyntaxKind {
3 Whitespace,
5 Newline,
6
7 LineComment,
9 BlockComment,
10
11 Contract,
13 Interface,
14 Library,
15 Function,
16 Modifier,
17 Event,
18 Struct,
19 Enum,
20 Mapping,
21 Array,
22
23 Public,
25 Private,
26 Internal,
27 External,
28
29 Pure,
31 View,
32 Payable,
33 Constant,
34
35 Bool,
37 String,
38 Bytes,
39 Address,
40 Uint,
41 Int,
42 Fixed,
43 Ufixed,
44
45 If,
47 Else,
48 For,
49 While,
50 Do,
51 Break,
52 Continue,
53 Return,
54 Try,
55 Catch,
56
57 Import,
59 Pragma,
60 Using,
61 Is,
62 Override,
63 Virtual,
64 Abstract,
65
66 NumberLiteral,
68 StringLiteral,
69 BooleanLiteral,
70 AddressLiteral,
71 HexLiteral,
72
73 Identifier,
75
76 Plus,
78 Minus,
79 Star,
80 Slash,
81 Percent,
82 Power,
83 Equal,
84 NotEqual,
85 Less,
86 Greater,
87 LessEqual,
88 GreaterEqual,
89 And,
90 Or,
91 Not,
92 BitAnd,
93 BitOr,
94 BitXor,
95 BitNot,
96 LeftShift,
97 RightShift,
98 Assign,
99 PlusAssign,
100 MinusAssign,
101 StarAssign,
102 SlashAssign,
103 PercentAssign,
104
105 LeftParen,
107 RightParen,
108 LeftBrace,
109 RightBrace,
110 LeftBracket,
111 RightBracket,
112 Semicolon,
113 Comma,
114 Dot,
115 Arrow,
116
117 SourceFile,
119
120 Error,
122 Eof,
123}
124
125impl oak_core::TokenType for SoliditySyntaxKind {
126 type Role = oak_core::UniversalTokenRole;
127 const END_OF_STREAM: Self = Self::Eof;
128
129 fn role(&self) -> Self::Role {
130 match self {
131 Self::Whitespace | Self::Newline => oak_core::UniversalTokenRole::Whitespace,
132 Self::LineComment | Self::BlockComment => oak_core::UniversalTokenRole::Comment,
133 Self::Contract
134 | Self::Interface
135 | Self::Library
136 | Self::Function
137 | Self::Modifier
138 | Self::Event
139 | Self::Struct
140 | Self::Enum
141 | Self::Mapping
142 | Self::Public
143 | Self::Private
144 | Self::Internal
145 | Self::External
146 | Self::Pure
147 | Self::View
148 | Self::Payable
149 | Self::Constant
150 | Self::Bool
151 | Self::String
152 | Self::Bytes
153 | Self::Address
154 | Self::Uint
155 | Self::Int
156 | Self::Fixed
157 | Self::Ufixed
158 | Self::If
159 | Self::Else
160 | Self::For
161 | Self::While
162 | Self::Do
163 | Self::Break
164 | Self::Continue
165 | Self::Return
166 | Self::Try
167 | Self::Catch
168 | Self::Import
169 | Self::Pragma
170 | Self::Using
171 | Self::Is
172 | Self::Override
173 | Self::Virtual
174 | Self::Abstract => oak_core::UniversalTokenRole::Keyword,
175 Self::NumberLiteral | Self::StringLiteral | Self::BooleanLiteral | Self::AddressLiteral | Self::HexLiteral => oak_core::UniversalTokenRole::Literal,
176 Self::Identifier => oak_core::UniversalTokenRole::Name,
177 Self::Plus
178 | Self::Minus
179 | Self::Star
180 | Self::Slash
181 | Self::Percent
182 | Self::Power
183 | Self::Equal
184 | Self::NotEqual
185 | Self::Less
186 | Self::Greater
187 | Self::LessEqual
188 | Self::GreaterEqual
189 | Self::And
190 | Self::Or
191 | Self::Not
192 | Self::BitAnd
193 | Self::BitOr
194 | Self::BitXor
195 | Self::BitNot
196 | Self::LeftShift
197 | Self::RightShift
198 | Self::Assign
199 | Self::PlusAssign
200 | Self::MinusAssign
201 | Self::StarAssign
202 | Self::SlashAssign
203 | Self::PercentAssign => oak_core::UniversalTokenRole::Operator,
204 Self::LeftParen | Self::RightParen | Self::LeftBrace | Self::RightBrace | Self::LeftBracket | Self::RightBracket | Self::Semicolon | Self::Comma | Self::Dot | Self::Arrow => oak_core::UniversalTokenRole::Punctuation,
205 Self::Error => oak_core::UniversalTokenRole::Error,
206 Self::Eof => oak_core::UniversalTokenRole::Eof,
207 _ => oak_core::UniversalTokenRole::None,
208 }
209 }
210
211 fn is_ignored(&self) -> bool {
212 matches!(self, Self::Whitespace | Self::Newline | Self::LineComment | Self::BlockComment)
213 }
214
215 fn is_comment(&self) -> bool {
216 matches!(self, Self::LineComment | Self::BlockComment)
217 }
218
219 fn is_whitespace(&self) -> bool {
220 matches!(self, Self::Whitespace | Self::Newline)
221 }
222}
223
224impl SoliditySyntaxKind {
225 pub fn is_token_type(&self) -> bool {
226 !matches!(self, Self::SourceFile)
227 }
228
229 pub fn is_element_type(&self) -> bool {
230 matches!(self, Self::SourceFile)
231 }
232}
233
234impl oak_core::ElementType for SoliditySyntaxKind {
235 type Role = oak_core::UniversalElementRole;
236
237 fn role(&self) -> Self::Role {
238 match self {
239 Self::SourceFile => oak_core::UniversalElementRole::Root,
240 _ => oak_core::UniversalElementRole::None,
241 }
242 }
243}