diff options
Diffstat (limited to 'src/syntax_kinds')
-rw-r--r-- | src/syntax_kinds/generated.rs | 508 | ||||
-rw-r--r-- | src/syntax_kinds/generated.rs.tera | 73 | ||||
-rw-r--r-- | src/syntax_kinds/mod.rs | 26 |
3 files changed, 0 insertions, 607 deletions
diff --git a/src/syntax_kinds/generated.rs b/src/syntax_kinds/generated.rs deleted file mode 100644 index de2807ba6..000000000 --- a/src/syntax_kinds/generated.rs +++ /dev/null | |||
@@ -1,508 +0,0 @@ | |||
1 | #![allow(bad_style, missing_docs, unreachable_pub)] | ||
2 | #![cfg_attr(rustfmt, rustfmt_skip)] | ||
3 | use super::SyntaxInfo; | ||
4 | |||
5 | /// The kind of syntax node, e.g. `IDENT`, `USE_KW`, or `STRUCT_DEF`. | ||
6 | #[derive(Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash)] | ||
7 | pub enum SyntaxKind { | ||
8 | // Technical SyntaxKinds: they appear temporally during parsing, | ||
9 | // but never end up in the final tree | ||
10 | #[doc(hidden)] | ||
11 | TOMBSTONE, | ||
12 | #[doc(hidden)] | ||
13 | EOF, | ||
14 | SEMI, | ||
15 | COMMA, | ||
16 | L_PAREN, | ||
17 | R_PAREN, | ||
18 | L_CURLY, | ||
19 | R_CURLY, | ||
20 | L_BRACK, | ||
21 | R_BRACK, | ||
22 | L_ANGLE, | ||
23 | R_ANGLE, | ||
24 | AT, | ||
25 | POUND, | ||
26 | TILDE, | ||
27 | QUESTION, | ||
28 | DOLLAR, | ||
29 | AMP, | ||
30 | PIPE, | ||
31 | PLUS, | ||
32 | STAR, | ||
33 | SLASH, | ||
34 | CARET, | ||
35 | PERCENT, | ||
36 | DOT, | ||
37 | DOTDOT, | ||
38 | DOTDOTDOT, | ||
39 | DOTDOTEQ, | ||
40 | COLON, | ||
41 | COLONCOLON, | ||
42 | EQ, | ||
43 | EQEQ, | ||
44 | FAT_ARROW, | ||
45 | EXCL, | ||
46 | NEQ, | ||
47 | MINUS, | ||
48 | THIN_ARROW, | ||
49 | LTEQ, | ||
50 | GTEQ, | ||
51 | PLUSEQ, | ||
52 | MINUSEQ, | ||
53 | AMPAMP, | ||
54 | PIPEPIPE, | ||
55 | SHL, | ||
56 | SHR, | ||
57 | SHLEQ, | ||
58 | SHREQ, | ||
59 | USE_KW, | ||
60 | FN_KW, | ||
61 | STRUCT_KW, | ||
62 | ENUM_KW, | ||
63 | TRAIT_KW, | ||
64 | IMPL_KW, | ||
65 | TRUE_KW, | ||
66 | FALSE_KW, | ||
67 | AS_KW, | ||
68 | EXTERN_KW, | ||
69 | CRATE_KW, | ||
70 | MOD_KW, | ||
71 | PUB_KW, | ||
72 | SELF_KW, | ||
73 | SUPER_KW, | ||
74 | IN_KW, | ||
75 | WHERE_KW, | ||
76 | FOR_KW, | ||
77 | LOOP_KW, | ||
78 | WHILE_KW, | ||
79 | IF_KW, | ||
80 | ELSE_KW, | ||
81 | MATCH_KW, | ||
82 | CONST_KW, | ||
83 | STATIC_KW, | ||
84 | MUT_KW, | ||
85 | UNSAFE_KW, | ||
86 | TYPE_KW, | ||
87 | REF_KW, | ||
88 | LET_KW, | ||
89 | MOVE_KW, | ||
90 | RETURN_KW, | ||
91 | AUTO_KW, | ||
92 | DEFAULT_KW, | ||
93 | UNION_KW, | ||
94 | ERROR, | ||
95 | IDENT, | ||
96 | UNDERSCORE, | ||
97 | WHITESPACE, | ||
98 | INT_NUMBER, | ||
99 | FLOAT_NUMBER, | ||
100 | LIFETIME, | ||
101 | CHAR, | ||
102 | BYTE, | ||
103 | STRING, | ||
104 | RAW_STRING, | ||
105 | BYTE_STRING, | ||
106 | RAW_BYTE_STRING, | ||
107 | COMMENT, | ||
108 | DOC_COMMENT, | ||
109 | SHEBANG, | ||
110 | FILE, | ||
111 | STRUCT_ITEM, | ||
112 | ENUM_ITEM, | ||
113 | FUNCTION, | ||
114 | EXTERN_CRATE_ITEM, | ||
115 | MOD_ITEM, | ||
116 | USE_ITEM, | ||
117 | STATIC_ITEM, | ||
118 | CONST_ITEM, | ||
119 | TRAIT_ITEM, | ||
120 | IMPL_ITEM, | ||
121 | TYPE_ITEM, | ||
122 | MACRO_CALL, | ||
123 | TOKEN_TREE, | ||
124 | PAREN_TYPE, | ||
125 | TUPLE_TYPE, | ||
126 | NEVER_TYPE, | ||
127 | PATH_TYPE, | ||
128 | POINTER_TYPE, | ||
129 | ARRAY_TYPE, | ||
130 | SLICE_TYPE, | ||
131 | REFERENCE_TYPE, | ||
132 | PLACEHOLDER_TYPE, | ||
133 | FN_POINTER_TYPE, | ||
134 | FOR_TYPE, | ||
135 | IMPL_TRAIT_TYPE, | ||
136 | REF_PAT, | ||
137 | BIND_PAT, | ||
138 | PLACEHOLDER_PAT, | ||
139 | PATH_PAT, | ||
140 | STRUCT_PAT, | ||
141 | TUPLE_STRUCT_PAT, | ||
142 | TUPLE_PAT, | ||
143 | SLICE_PAT, | ||
144 | RANGE_PAT, | ||
145 | TUPLE_EXPR, | ||
146 | ARRAY_EXPR, | ||
147 | PAREN_EXPR, | ||
148 | PATH_EXPR, | ||
149 | LAMBDA_EXPR, | ||
150 | IF_EXPR, | ||
151 | WHILE_EXPR, | ||
152 | LOOP_EXPR, | ||
153 | FOR_EXPR, | ||
154 | BLOCK_EXPR, | ||
155 | RETURN_EXPR, | ||
156 | MATCH_EXPR, | ||
157 | MATCH_ARM, | ||
158 | MATCH_GUARD, | ||
159 | STRUCT_LIT, | ||
160 | STRUCT_LIT_FIELD, | ||
161 | CALL_EXPR, | ||
162 | INDEX_EXPR, | ||
163 | METHOD_CALL_EXPR, | ||
164 | FIELD_EXPR, | ||
165 | TRY_EXPR, | ||
166 | CAST_EXPR, | ||
167 | REF_EXPR, | ||
168 | PREFIX_EXPR, | ||
169 | RANGE_EXPR, | ||
170 | BIN_EXPR, | ||
171 | EXTERN_BLOCK_EXPR, | ||
172 | ENUM_VARIANT, | ||
173 | NAMED_FIELD, | ||
174 | POS_FIELD, | ||
175 | ATTR, | ||
176 | META_ITEM, | ||
177 | USE_TREE, | ||
178 | PATH, | ||
179 | PATH_SEGMENT, | ||
180 | LITERAL, | ||
181 | ALIAS, | ||
182 | VISIBILITY, | ||
183 | WHERE_CLAUSE, | ||
184 | WHERE_PRED, | ||
185 | ABI, | ||
186 | NAME, | ||
187 | NAME_REF, | ||
188 | LET_STMT, | ||
189 | EXPR_STMT, | ||
190 | TYPE_PARAM_LIST, | ||
191 | LIFETIME_PARAM, | ||
192 | TYPE_PARAM, | ||
193 | TYPE_ARG_LIST, | ||
194 | LIFETIME_ARG, | ||
195 | TYPE_ARG, | ||
196 | ASSOC_TYPE_ARG, | ||
197 | PARAM_LIST, | ||
198 | PARAM, | ||
199 | SELF_PARAM, | ||
200 | ARG_LIST, | ||
201 | } | ||
202 | use self::SyntaxKind::*; | ||
203 | |||
204 | impl SyntaxKind { | ||
205 | pub fn is_keyword(self) -> bool { | ||
206 | match self { | ||
207 | | USE_KW | ||
208 | | FN_KW | ||
209 | | STRUCT_KW | ||
210 | | ENUM_KW | ||
211 | | TRAIT_KW | ||
212 | | IMPL_KW | ||
213 | | TRUE_KW | ||
214 | | FALSE_KW | ||
215 | | AS_KW | ||
216 | | EXTERN_KW | ||
217 | | CRATE_KW | ||
218 | | MOD_KW | ||
219 | | PUB_KW | ||
220 | | SELF_KW | ||
221 | | SUPER_KW | ||
222 | | IN_KW | ||
223 | | WHERE_KW | ||
224 | | FOR_KW | ||
225 | | LOOP_KW | ||
226 | | WHILE_KW | ||
227 | | IF_KW | ||
228 | | ELSE_KW | ||
229 | | MATCH_KW | ||
230 | | CONST_KW | ||
231 | | STATIC_KW | ||
232 | | MUT_KW | ||
233 | | UNSAFE_KW | ||
234 | | TYPE_KW | ||
235 | | REF_KW | ||
236 | | LET_KW | ||
237 | | MOVE_KW | ||
238 | | RETURN_KW | ||
239 | | AUTO_KW | ||
240 | | DEFAULT_KW | ||
241 | | UNION_KW | ||
242 | => true, | ||
243 | _ => false | ||
244 | } | ||
245 | } | ||
246 | |||
247 | pub(crate) fn info(self) -> &'static SyntaxInfo { | ||
248 | match self { | ||
249 | SEMI => &SyntaxInfo { name: "SEMI" }, | ||
250 | COMMA => &SyntaxInfo { name: "COMMA" }, | ||
251 | L_PAREN => &SyntaxInfo { name: "L_PAREN" }, | ||
252 | R_PAREN => &SyntaxInfo { name: "R_PAREN" }, | ||
253 | L_CURLY => &SyntaxInfo { name: "L_CURLY" }, | ||
254 | R_CURLY => &SyntaxInfo { name: "R_CURLY" }, | ||
255 | L_BRACK => &SyntaxInfo { name: "L_BRACK" }, | ||
256 | R_BRACK => &SyntaxInfo { name: "R_BRACK" }, | ||
257 | L_ANGLE => &SyntaxInfo { name: "L_ANGLE" }, | ||
258 | R_ANGLE => &SyntaxInfo { name: "R_ANGLE" }, | ||
259 | AT => &SyntaxInfo { name: "AT" }, | ||
260 | POUND => &SyntaxInfo { name: "POUND" }, | ||
261 | TILDE => &SyntaxInfo { name: "TILDE" }, | ||
262 | QUESTION => &SyntaxInfo { name: "QUESTION" }, | ||
263 | DOLLAR => &SyntaxInfo { name: "DOLLAR" }, | ||
264 | AMP => &SyntaxInfo { name: "AMP" }, | ||
265 | PIPE => &SyntaxInfo { name: "PIPE" }, | ||
266 | PLUS => &SyntaxInfo { name: "PLUS" }, | ||
267 | STAR => &SyntaxInfo { name: "STAR" }, | ||
268 | SLASH => &SyntaxInfo { name: "SLASH" }, | ||
269 | CARET => &SyntaxInfo { name: "CARET" }, | ||
270 | PERCENT => &SyntaxInfo { name: "PERCENT" }, | ||
271 | DOT => &SyntaxInfo { name: "DOT" }, | ||
272 | DOTDOT => &SyntaxInfo { name: "DOTDOT" }, | ||
273 | DOTDOTDOT => &SyntaxInfo { name: "DOTDOTDOT" }, | ||
274 | DOTDOTEQ => &SyntaxInfo { name: "DOTDOTEQ" }, | ||
275 | COLON => &SyntaxInfo { name: "COLON" }, | ||
276 | COLONCOLON => &SyntaxInfo { name: "COLONCOLON" }, | ||
277 | EQ => &SyntaxInfo { name: "EQ" }, | ||
278 | EQEQ => &SyntaxInfo { name: "EQEQ" }, | ||
279 | FAT_ARROW => &SyntaxInfo { name: "FAT_ARROW" }, | ||
280 | EXCL => &SyntaxInfo { name: "EXCL" }, | ||
281 | NEQ => &SyntaxInfo { name: "NEQ" }, | ||
282 | MINUS => &SyntaxInfo { name: "MINUS" }, | ||
283 | THIN_ARROW => &SyntaxInfo { name: "THIN_ARROW" }, | ||
284 | LTEQ => &SyntaxInfo { name: "LTEQ" }, | ||
285 | GTEQ => &SyntaxInfo { name: "GTEQ" }, | ||
286 | PLUSEQ => &SyntaxInfo { name: "PLUSEQ" }, | ||
287 | MINUSEQ => &SyntaxInfo { name: "MINUSEQ" }, | ||
288 | AMPAMP => &SyntaxInfo { name: "AMPAMP" }, | ||
289 | PIPEPIPE => &SyntaxInfo { name: "PIPEPIPE" }, | ||
290 | SHL => &SyntaxInfo { name: "SHL" }, | ||
291 | SHR => &SyntaxInfo { name: "SHR" }, | ||
292 | SHLEQ => &SyntaxInfo { name: "SHLEQ" }, | ||
293 | SHREQ => &SyntaxInfo { name: "SHREQ" }, | ||
294 | USE_KW => &SyntaxInfo { name: "USE_KW" }, | ||
295 | FN_KW => &SyntaxInfo { name: "FN_KW" }, | ||
296 | STRUCT_KW => &SyntaxInfo { name: "STRUCT_KW" }, | ||
297 | ENUM_KW => &SyntaxInfo { name: "ENUM_KW" }, | ||
298 | TRAIT_KW => &SyntaxInfo { name: "TRAIT_KW" }, | ||
299 | IMPL_KW => &SyntaxInfo { name: "IMPL_KW" }, | ||
300 | TRUE_KW => &SyntaxInfo { name: "TRUE_KW" }, | ||
301 | FALSE_KW => &SyntaxInfo { name: "FALSE_KW" }, | ||
302 | AS_KW => &SyntaxInfo { name: "AS_KW" }, | ||
303 | EXTERN_KW => &SyntaxInfo { name: "EXTERN_KW" }, | ||
304 | CRATE_KW => &SyntaxInfo { name: "CRATE_KW" }, | ||
305 | MOD_KW => &SyntaxInfo { name: "MOD_KW" }, | ||
306 | PUB_KW => &SyntaxInfo { name: "PUB_KW" }, | ||
307 | SELF_KW => &SyntaxInfo { name: "SELF_KW" }, | ||
308 | SUPER_KW => &SyntaxInfo { name: "SUPER_KW" }, | ||
309 | IN_KW => &SyntaxInfo { name: "IN_KW" }, | ||
310 | WHERE_KW => &SyntaxInfo { name: "WHERE_KW" }, | ||
311 | FOR_KW => &SyntaxInfo { name: "FOR_KW" }, | ||
312 | LOOP_KW => &SyntaxInfo { name: "LOOP_KW" }, | ||
313 | WHILE_KW => &SyntaxInfo { name: "WHILE_KW" }, | ||
314 | IF_KW => &SyntaxInfo { name: "IF_KW" }, | ||
315 | ELSE_KW => &SyntaxInfo { name: "ELSE_KW" }, | ||
316 | MATCH_KW => &SyntaxInfo { name: "MATCH_KW" }, | ||
317 | CONST_KW => &SyntaxInfo { name: "CONST_KW" }, | ||
318 | STATIC_KW => &SyntaxInfo { name: "STATIC_KW" }, | ||
319 | MUT_KW => &SyntaxInfo { name: "MUT_KW" }, | ||
320 | UNSAFE_KW => &SyntaxInfo { name: "UNSAFE_KW" }, | ||
321 | TYPE_KW => &SyntaxInfo { name: "TYPE_KW" }, | ||
322 | REF_KW => &SyntaxInfo { name: "REF_KW" }, | ||
323 | LET_KW => &SyntaxInfo { name: "LET_KW" }, | ||
324 | MOVE_KW => &SyntaxInfo { name: "MOVE_KW" }, | ||
325 | RETURN_KW => &SyntaxInfo { name: "RETURN_KW" }, | ||
326 | AUTO_KW => &SyntaxInfo { name: "AUTO_KW" }, | ||
327 | DEFAULT_KW => &SyntaxInfo { name: "DEFAULT_KW" }, | ||
328 | UNION_KW => &SyntaxInfo { name: "UNION_KW" }, | ||
329 | ERROR => &SyntaxInfo { name: "ERROR" }, | ||
330 | IDENT => &SyntaxInfo { name: "IDENT" }, | ||
331 | UNDERSCORE => &SyntaxInfo { name: "UNDERSCORE" }, | ||
332 | WHITESPACE => &SyntaxInfo { name: "WHITESPACE" }, | ||
333 | INT_NUMBER => &SyntaxInfo { name: "INT_NUMBER" }, | ||
334 | FLOAT_NUMBER => &SyntaxInfo { name: "FLOAT_NUMBER" }, | ||
335 | LIFETIME => &SyntaxInfo { name: "LIFETIME" }, | ||
336 | CHAR => &SyntaxInfo { name: "CHAR" }, | ||
337 | BYTE => &SyntaxInfo { name: "BYTE" }, | ||
338 | STRING => &SyntaxInfo { name: "STRING" }, | ||
339 | RAW_STRING => &SyntaxInfo { name: "RAW_STRING" }, | ||
340 | BYTE_STRING => &SyntaxInfo { name: "BYTE_STRING" }, | ||
341 | RAW_BYTE_STRING => &SyntaxInfo { name: "RAW_BYTE_STRING" }, | ||
342 | COMMENT => &SyntaxInfo { name: "COMMENT" }, | ||
343 | DOC_COMMENT => &SyntaxInfo { name: "DOC_COMMENT" }, | ||
344 | SHEBANG => &SyntaxInfo { name: "SHEBANG" }, | ||
345 | FILE => &SyntaxInfo { name: "FILE" }, | ||
346 | STRUCT_ITEM => &SyntaxInfo { name: "STRUCT_ITEM" }, | ||
347 | ENUM_ITEM => &SyntaxInfo { name: "ENUM_ITEM" }, | ||
348 | FUNCTION => &SyntaxInfo { name: "FUNCTION" }, | ||
349 | EXTERN_CRATE_ITEM => &SyntaxInfo { name: "EXTERN_CRATE_ITEM" }, | ||
350 | MOD_ITEM => &SyntaxInfo { name: "MOD_ITEM" }, | ||
351 | USE_ITEM => &SyntaxInfo { name: "USE_ITEM" }, | ||
352 | STATIC_ITEM => &SyntaxInfo { name: "STATIC_ITEM" }, | ||
353 | CONST_ITEM => &SyntaxInfo { name: "CONST_ITEM" }, | ||
354 | TRAIT_ITEM => &SyntaxInfo { name: "TRAIT_ITEM" }, | ||
355 | IMPL_ITEM => &SyntaxInfo { name: "IMPL_ITEM" }, | ||
356 | TYPE_ITEM => &SyntaxInfo { name: "TYPE_ITEM" }, | ||
357 | MACRO_CALL => &SyntaxInfo { name: "MACRO_CALL" }, | ||
358 | TOKEN_TREE => &SyntaxInfo { name: "TOKEN_TREE" }, | ||
359 | PAREN_TYPE => &SyntaxInfo { name: "PAREN_TYPE" }, | ||
360 | TUPLE_TYPE => &SyntaxInfo { name: "TUPLE_TYPE" }, | ||
361 | NEVER_TYPE => &SyntaxInfo { name: "NEVER_TYPE" }, | ||
362 | PATH_TYPE => &SyntaxInfo { name: "PATH_TYPE" }, | ||
363 | POINTER_TYPE => &SyntaxInfo { name: "POINTER_TYPE" }, | ||
364 | ARRAY_TYPE => &SyntaxInfo { name: "ARRAY_TYPE" }, | ||
365 | SLICE_TYPE => &SyntaxInfo { name: "SLICE_TYPE" }, | ||
366 | REFERENCE_TYPE => &SyntaxInfo { name: "REFERENCE_TYPE" }, | ||
367 | PLACEHOLDER_TYPE => &SyntaxInfo { name: "PLACEHOLDER_TYPE" }, | ||
368 | FN_POINTER_TYPE => &SyntaxInfo { name: "FN_POINTER_TYPE" }, | ||
369 | FOR_TYPE => &SyntaxInfo { name: "FOR_TYPE" }, | ||
370 | IMPL_TRAIT_TYPE => &SyntaxInfo { name: "IMPL_TRAIT_TYPE" }, | ||
371 | REF_PAT => &SyntaxInfo { name: "REF_PAT" }, | ||
372 | BIND_PAT => &SyntaxInfo { name: "BIND_PAT" }, | ||
373 | PLACEHOLDER_PAT => &SyntaxInfo { name: "PLACEHOLDER_PAT" }, | ||
374 | PATH_PAT => &SyntaxInfo { name: "PATH_PAT" }, | ||
375 | STRUCT_PAT => &SyntaxInfo { name: "STRUCT_PAT" }, | ||
376 | TUPLE_STRUCT_PAT => &SyntaxInfo { name: "TUPLE_STRUCT_PAT" }, | ||
377 | TUPLE_PAT => &SyntaxInfo { name: "TUPLE_PAT" }, | ||
378 | SLICE_PAT => &SyntaxInfo { name: "SLICE_PAT" }, | ||
379 | RANGE_PAT => &SyntaxInfo { name: "RANGE_PAT" }, | ||
380 | TUPLE_EXPR => &SyntaxInfo { name: "TUPLE_EXPR" }, | ||
381 | ARRAY_EXPR => &SyntaxInfo { name: "ARRAY_EXPR" }, | ||
382 | PAREN_EXPR => &SyntaxInfo { name: "PAREN_EXPR" }, | ||
383 | PATH_EXPR => &SyntaxInfo { name: "PATH_EXPR" }, | ||
384 | LAMBDA_EXPR => &SyntaxInfo { name: "LAMBDA_EXPR" }, | ||
385 | IF_EXPR => &SyntaxInfo { name: "IF_EXPR" }, | ||
386 | WHILE_EXPR => &SyntaxInfo { name: "WHILE_EXPR" }, | ||
387 | LOOP_EXPR => &SyntaxInfo { name: "LOOP_EXPR" }, | ||
388 | FOR_EXPR => &SyntaxInfo { name: "FOR_EXPR" }, | ||
389 | BLOCK_EXPR => &SyntaxInfo { name: "BLOCK_EXPR" }, | ||
390 | RETURN_EXPR => &SyntaxInfo { name: "RETURN_EXPR" }, | ||
391 | MATCH_EXPR => &SyntaxInfo { name: "MATCH_EXPR" }, | ||
392 | MATCH_ARM => &SyntaxInfo { name: "MATCH_ARM" }, | ||
393 | MATCH_GUARD => &SyntaxInfo { name: "MATCH_GUARD" }, | ||
394 | STRUCT_LIT => &SyntaxInfo { name: "STRUCT_LIT" }, | ||
395 | STRUCT_LIT_FIELD => &SyntaxInfo { name: "STRUCT_LIT_FIELD" }, | ||
396 | CALL_EXPR => &SyntaxInfo { name: "CALL_EXPR" }, | ||
397 | INDEX_EXPR => &SyntaxInfo { name: "INDEX_EXPR" }, | ||
398 | METHOD_CALL_EXPR => &SyntaxInfo { name: "METHOD_CALL_EXPR" }, | ||
399 | FIELD_EXPR => &SyntaxInfo { name: "FIELD_EXPR" }, | ||
400 | TRY_EXPR => &SyntaxInfo { name: "TRY_EXPR" }, | ||
401 | CAST_EXPR => &SyntaxInfo { name: "CAST_EXPR" }, | ||
402 | REF_EXPR => &SyntaxInfo { name: "REF_EXPR" }, | ||
403 | PREFIX_EXPR => &SyntaxInfo { name: "PREFIX_EXPR" }, | ||
404 | RANGE_EXPR => &SyntaxInfo { name: "RANGE_EXPR" }, | ||
405 | BIN_EXPR => &SyntaxInfo { name: "BIN_EXPR" }, | ||
406 | EXTERN_BLOCK_EXPR => &SyntaxInfo { name: "EXTERN_BLOCK_EXPR" }, | ||
407 | ENUM_VARIANT => &SyntaxInfo { name: "ENUM_VARIANT" }, | ||
408 | NAMED_FIELD => &SyntaxInfo { name: "NAMED_FIELD" }, | ||
409 | POS_FIELD => &SyntaxInfo { name: "POS_FIELD" }, | ||
410 | ATTR => &SyntaxInfo { name: "ATTR" }, | ||
411 | META_ITEM => &SyntaxInfo { name: "META_ITEM" }, | ||
412 | USE_TREE => &SyntaxInfo { name: "USE_TREE" }, | ||
413 | PATH => &SyntaxInfo { name: "PATH" }, | ||
414 | PATH_SEGMENT => &SyntaxInfo { name: "PATH_SEGMENT" }, | ||
415 | LITERAL => &SyntaxInfo { name: "LITERAL" }, | ||
416 | ALIAS => &SyntaxInfo { name: "ALIAS" }, | ||
417 | VISIBILITY => &SyntaxInfo { name: "VISIBILITY" }, | ||
418 | WHERE_CLAUSE => &SyntaxInfo { name: "WHERE_CLAUSE" }, | ||
419 | WHERE_PRED => &SyntaxInfo { name: "WHERE_PRED" }, | ||
420 | ABI => &SyntaxInfo { name: "ABI" }, | ||
421 | NAME => &SyntaxInfo { name: "NAME" }, | ||
422 | NAME_REF => &SyntaxInfo { name: "NAME_REF" }, | ||
423 | LET_STMT => &SyntaxInfo { name: "LET_STMT" }, | ||
424 | EXPR_STMT => &SyntaxInfo { name: "EXPR_STMT" }, | ||
425 | TYPE_PARAM_LIST => &SyntaxInfo { name: "TYPE_PARAM_LIST" }, | ||
426 | LIFETIME_PARAM => &SyntaxInfo { name: "LIFETIME_PARAM" }, | ||
427 | TYPE_PARAM => &SyntaxInfo { name: "TYPE_PARAM" }, | ||
428 | TYPE_ARG_LIST => &SyntaxInfo { name: "TYPE_ARG_LIST" }, | ||
429 | LIFETIME_ARG => &SyntaxInfo { name: "LIFETIME_ARG" }, | ||
430 | TYPE_ARG => &SyntaxInfo { name: "TYPE_ARG" }, | ||
431 | ASSOC_TYPE_ARG => &SyntaxInfo { name: "ASSOC_TYPE_ARG" }, | ||
432 | PARAM_LIST => &SyntaxInfo { name: "PARAM_LIST" }, | ||
433 | PARAM => &SyntaxInfo { name: "PARAM" }, | ||
434 | SELF_PARAM => &SyntaxInfo { name: "SELF_PARAM" }, | ||
435 | ARG_LIST => &SyntaxInfo { name: "ARG_LIST" }, | ||
436 | TOMBSTONE => &SyntaxInfo { name: "TOMBSTONE" }, | ||
437 | EOF => &SyntaxInfo { name: "EOF" }, | ||
438 | } | ||
439 | } | ||
440 | pub(crate) fn from_keyword(ident: &str) -> Option<SyntaxKind> { | ||
441 | let kw = match ident { | ||
442 | "use" => USE_KW, | ||
443 | "fn" => FN_KW, | ||
444 | "struct" => STRUCT_KW, | ||
445 | "enum" => ENUM_KW, | ||
446 | "trait" => TRAIT_KW, | ||
447 | "impl" => IMPL_KW, | ||
448 | "true" => TRUE_KW, | ||
449 | "false" => FALSE_KW, | ||
450 | "as" => AS_KW, | ||
451 | "extern" => EXTERN_KW, | ||
452 | "crate" => CRATE_KW, | ||
453 | "mod" => MOD_KW, | ||
454 | "pub" => PUB_KW, | ||
455 | "self" => SELF_KW, | ||
456 | "super" => SUPER_KW, | ||
457 | "in" => IN_KW, | ||
458 | "where" => WHERE_KW, | ||
459 | "for" => FOR_KW, | ||
460 | "loop" => LOOP_KW, | ||
461 | "while" => WHILE_KW, | ||
462 | "if" => IF_KW, | ||
463 | "else" => ELSE_KW, | ||
464 | "match" => MATCH_KW, | ||
465 | "const" => CONST_KW, | ||
466 | "static" => STATIC_KW, | ||
467 | "mut" => MUT_KW, | ||
468 | "unsafe" => UNSAFE_KW, | ||
469 | "type" => TYPE_KW, | ||
470 | "ref" => REF_KW, | ||
471 | "let" => LET_KW, | ||
472 | "move" => MOVE_KW, | ||
473 | "return" => RETURN_KW, | ||
474 | _ => return None, | ||
475 | }; | ||
476 | Some(kw) | ||
477 | } | ||
478 | |||
479 | pub(crate) fn from_char(c: char) -> Option<SyntaxKind> { | ||
480 | let tok = match c { | ||
481 | ';' => SEMI, | ||
482 | ',' => COMMA, | ||
483 | '(' => L_PAREN, | ||
484 | ')' => R_PAREN, | ||
485 | '{' => L_CURLY, | ||
486 | '}' => R_CURLY, | ||
487 | '[' => L_BRACK, | ||
488 | ']' => R_BRACK, | ||
489 | '<' => L_ANGLE, | ||
490 | '>' => R_ANGLE, | ||
491 | '@' => AT, | ||
492 | '#' => POUND, | ||
493 | '~' => TILDE, | ||
494 | '?' => QUESTION, | ||
495 | '$' => DOLLAR, | ||
496 | '&' => AMP, | ||
497 | '|' => PIPE, | ||
498 | '+' => PLUS, | ||
499 | '*' => STAR, | ||
500 | '/' => SLASH, | ||
501 | '^' => CARET, | ||
502 | '%' => PERCENT, | ||
503 | _ => return None, | ||
504 | }; | ||
505 | Some(tok) | ||
506 | } | ||
507 | } | ||
508 | |||
diff --git a/src/syntax_kinds/generated.rs.tera b/src/syntax_kinds/generated.rs.tera deleted file mode 100644 index 90618721a..000000000 --- a/src/syntax_kinds/generated.rs.tera +++ /dev/null | |||
@@ -1,73 +0,0 @@ | |||
1 | #![allow(bad_style, missing_docs, unreachable_pub)] | ||
2 | #![cfg_attr(rustfmt, rustfmt_skip)] | ||
3 | use super::SyntaxInfo; | ||
4 | |||
5 | /// The kind of syntax node, e.g. `IDENT`, `USE_KW`, or `STRUCT_DEF`. | ||
6 | #[derive(Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash)] | ||
7 | pub enum SyntaxKind { | ||
8 | // Technical SyntaxKinds: they appear temporally during parsing, | ||
9 | // but never end up in the final tree | ||
10 | #[doc(hidden)] | ||
11 | TOMBSTONE, | ||
12 | #[doc(hidden)] | ||
13 | EOF, | ||
14 | |||
15 | {%- for t in concat(a=single_byte_tokens, b=multi_byte_tokens) %} | ||
16 | {{t.1}}, | ||
17 | {%- endfor -%} | ||
18 | {% for kw in concat(a=keywords, b=contextual_keywords) %} | ||
19 | {{kw | upper}}_KW, | ||
20 | {%- endfor -%} | ||
21 | {% for t in concat(a=tokens, b=nodes) %} | ||
22 | {{t}}, | ||
23 | {%- endfor %} | ||
24 | } | ||
25 | use self::SyntaxKind::*; | ||
26 | |||
27 | impl SyntaxKind { | ||
28 | pub fn is_keyword(self) -> bool { | ||
29 | match self { | ||
30 | {%- for kw in concat(a=keywords, b=contextual_keywords) %} | ||
31 | | {{kw | upper}}_KW | ||
32 | {%- endfor %} | ||
33 | => true, | ||
34 | _ => false | ||
35 | } | ||
36 | } | ||
37 | |||
38 | pub(crate) fn info(self) -> &'static SyntaxInfo { | ||
39 | match self { | ||
40 | {%- for t in concat(a=single_byte_tokens, b=multi_byte_tokens) %} | ||
41 | {{t.1}} => &SyntaxInfo { name: "{{t.1}}" }, | ||
42 | {%- endfor -%} | ||
43 | {% for kw in concat(a=keywords, b=contextual_keywords) %} | ||
44 | {{kw | upper}}_KW => &SyntaxInfo { name: "{{kw | upper}}_KW" }, | ||
45 | {%- endfor -%} | ||
46 | {% for t in concat(a=tokens, b=nodes) %} | ||
47 | {{t}} => &SyntaxInfo { name: "{{t}}" }, | ||
48 | {%- endfor %} | ||
49 | TOMBSTONE => &SyntaxInfo { name: "TOMBSTONE" }, | ||
50 | EOF => &SyntaxInfo { name: "EOF" }, | ||
51 | } | ||
52 | } | ||
53 | pub(crate) fn from_keyword(ident: &str) -> Option<SyntaxKind> { | ||
54 | let kw = match ident { | ||
55 | {%- for kw in keywords %} | ||
56 | "{{kw}}" => {{kw | upper}}_KW, | ||
57 | {%- endfor %} | ||
58 | _ => return None, | ||
59 | }; | ||
60 | Some(kw) | ||
61 | } | ||
62 | |||
63 | pub(crate) fn from_char(c: char) -> Option<SyntaxKind> { | ||
64 | let tok = match c { | ||
65 | {%- for t in single_byte_tokens %} | ||
66 | '{{t.0}}' => {{t.1}}, | ||
67 | {%- endfor %} | ||
68 | _ => return None, | ||
69 | }; | ||
70 | Some(tok) | ||
71 | } | ||
72 | } | ||
73 | |||
diff --git a/src/syntax_kinds/mod.rs b/src/syntax_kinds/mod.rs deleted file mode 100644 index ed4fa5d4d..000000000 --- a/src/syntax_kinds/mod.rs +++ /dev/null | |||
@@ -1,26 +0,0 @@ | |||
1 | mod generated; | ||
2 | |||
3 | use std::fmt; | ||
4 | use SyntaxKind::*; | ||
5 | |||
6 | pub use self::generated::SyntaxKind; | ||
7 | |||
8 | impl fmt::Debug for SyntaxKind { | ||
9 | fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { | ||
10 | let name = self.info().name; | ||
11 | f.write_str(name) | ||
12 | } | ||
13 | } | ||
14 | |||
15 | pub(crate) struct SyntaxInfo { | ||
16 | pub name: &'static str, | ||
17 | } | ||
18 | |||
19 | impl SyntaxKind { | ||
20 | pub(crate) fn is_trivia(self) -> bool { | ||
21 | match self { | ||
22 | WHITESPACE | COMMENT | DOC_COMMENT => true, | ||
23 | _ => false, | ||
24 | } | ||
25 | } | ||
26 | } | ||