diff options
Diffstat (limited to 'crates/ra_parser/src/syntax_kind/generated.rs')
-rw-r--r-- | crates/ra_parser/src/syntax_kind/generated.rs | 642 |
1 files changed, 642 insertions, 0 deletions
diff --git a/crates/ra_parser/src/syntax_kind/generated.rs b/crates/ra_parser/src/syntax_kind/generated.rs new file mode 100644 index 000000000..1d8f988ae --- /dev/null +++ b/crates/ra_parser/src/syntax_kind/generated.rs | |||
@@ -0,0 +1,642 @@ | |||
1 | // This file is automatically generated based on the file `./generated.rs.tera` when `cargo gen-syntax` is run | ||
2 | // Do not edit manually | ||
3 | |||
4 | #![allow(bad_style, missing_docs, unreachable_pub)] | ||
5 | #![cfg_attr(rustfmt, rustfmt_skip)] | ||
6 | use super::SyntaxInfo; | ||
7 | |||
8 | /// The kind of syntax node, e.g. `IDENT`, `USE_KW`, or `STRUCT_DEF`. | ||
9 | #[derive(Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash)] | ||
10 | pub enum SyntaxKind { | ||
11 | // Technical SyntaxKinds: they appear temporally during parsing, | ||
12 | // but never end up in the final tree | ||
13 | #[doc(hidden)] | ||
14 | TOMBSTONE, | ||
15 | #[doc(hidden)] | ||
16 | EOF, | ||
17 | SEMI, | ||
18 | COMMA, | ||
19 | L_PAREN, | ||
20 | R_PAREN, | ||
21 | L_CURLY, | ||
22 | R_CURLY, | ||
23 | L_BRACK, | ||
24 | R_BRACK, | ||
25 | L_ANGLE, | ||
26 | R_ANGLE, | ||
27 | AT, | ||
28 | POUND, | ||
29 | TILDE, | ||
30 | QUESTION, | ||
31 | DOLLAR, | ||
32 | AMP, | ||
33 | PIPE, | ||
34 | PLUS, | ||
35 | STAR, | ||
36 | SLASH, | ||
37 | CARET, | ||
38 | PERCENT, | ||
39 | UNDERSCORE, | ||
40 | DOT, | ||
41 | DOTDOT, | ||
42 | DOTDOTDOT, | ||
43 | DOTDOTEQ, | ||
44 | COLON, | ||
45 | COLONCOLON, | ||
46 | EQ, | ||
47 | EQEQ, | ||
48 | FAT_ARROW, | ||
49 | EXCL, | ||
50 | NEQ, | ||
51 | MINUS, | ||
52 | THIN_ARROW, | ||
53 | LTEQ, | ||
54 | GTEQ, | ||
55 | PLUSEQ, | ||
56 | MINUSEQ, | ||
57 | PIPEEQ, | ||
58 | AMPEQ, | ||
59 | CARETEQ, | ||
60 | SLASHEQ, | ||
61 | STAREQ, | ||
62 | PERCENTEQ, | ||
63 | AMPAMP, | ||
64 | PIPEPIPE, | ||
65 | SHL, | ||
66 | SHR, | ||
67 | SHLEQ, | ||
68 | SHREQ, | ||
69 | USE_KW, | ||
70 | FN_KW, | ||
71 | STRUCT_KW, | ||
72 | ENUM_KW, | ||
73 | TRAIT_KW, | ||
74 | IMPL_KW, | ||
75 | DYN_KW, | ||
76 | TRUE_KW, | ||
77 | FALSE_KW, | ||
78 | AS_KW, | ||
79 | EXTERN_KW, | ||
80 | CRATE_KW, | ||
81 | MOD_KW, | ||
82 | PUB_KW, | ||
83 | SELF_KW, | ||
84 | SUPER_KW, | ||
85 | IN_KW, | ||
86 | WHERE_KW, | ||
87 | FOR_KW, | ||
88 | LOOP_KW, | ||
89 | WHILE_KW, | ||
90 | CONTINUE_KW, | ||
91 | BREAK_KW, | ||
92 | IF_KW, | ||
93 | ELSE_KW, | ||
94 | MATCH_KW, | ||
95 | CONST_KW, | ||
96 | STATIC_KW, | ||
97 | MUT_KW, | ||
98 | UNSAFE_KW, | ||
99 | TYPE_KW, | ||
100 | REF_KW, | ||
101 | LET_KW, | ||
102 | MOVE_KW, | ||
103 | RETURN_KW, | ||
104 | AUTO_KW, | ||
105 | DEFAULT_KW, | ||
106 | UNION_KW, | ||
107 | INT_NUMBER, | ||
108 | FLOAT_NUMBER, | ||
109 | CHAR, | ||
110 | BYTE, | ||
111 | STRING, | ||
112 | RAW_STRING, | ||
113 | BYTE_STRING, | ||
114 | RAW_BYTE_STRING, | ||
115 | ERROR, | ||
116 | IDENT, | ||
117 | WHITESPACE, | ||
118 | LIFETIME, | ||
119 | COMMENT, | ||
120 | SHEBANG, | ||
121 | SOURCE_FILE, | ||
122 | STRUCT_DEF, | ||
123 | ENUM_DEF, | ||
124 | FN_DEF, | ||
125 | RET_TYPE, | ||
126 | EXTERN_CRATE_ITEM, | ||
127 | MODULE, | ||
128 | USE_ITEM, | ||
129 | STATIC_DEF, | ||
130 | CONST_DEF, | ||
131 | TRAIT_DEF, | ||
132 | IMPL_BLOCK, | ||
133 | TYPE_DEF, | ||
134 | MACRO_CALL, | ||
135 | TOKEN_TREE, | ||
136 | PAREN_TYPE, | ||
137 | TUPLE_TYPE, | ||
138 | NEVER_TYPE, | ||
139 | PATH_TYPE, | ||
140 | POINTER_TYPE, | ||
141 | ARRAY_TYPE, | ||
142 | SLICE_TYPE, | ||
143 | REFERENCE_TYPE, | ||
144 | PLACEHOLDER_TYPE, | ||
145 | FN_POINTER_TYPE, | ||
146 | FOR_TYPE, | ||
147 | IMPL_TRAIT_TYPE, | ||
148 | DYN_TRAIT_TYPE, | ||
149 | REF_PAT, | ||
150 | BIND_PAT, | ||
151 | PLACEHOLDER_PAT, | ||
152 | PATH_PAT, | ||
153 | STRUCT_PAT, | ||
154 | FIELD_PAT_LIST, | ||
155 | FIELD_PAT, | ||
156 | TUPLE_STRUCT_PAT, | ||
157 | TUPLE_PAT, | ||
158 | SLICE_PAT, | ||
159 | RANGE_PAT, | ||
160 | LITERAL_PAT, | ||
161 | TUPLE_EXPR, | ||
162 | ARRAY_EXPR, | ||
163 | PAREN_EXPR, | ||
164 | PATH_EXPR, | ||
165 | LAMBDA_EXPR, | ||
166 | IF_EXPR, | ||
167 | WHILE_EXPR, | ||
168 | CONDITION, | ||
169 | LOOP_EXPR, | ||
170 | FOR_EXPR, | ||
171 | CONTINUE_EXPR, | ||
172 | BREAK_EXPR, | ||
173 | LABEL, | ||
174 | BLOCK_EXPR, | ||
175 | RETURN_EXPR, | ||
176 | MATCH_EXPR, | ||
177 | MATCH_ARM_LIST, | ||
178 | MATCH_ARM, | ||
179 | MATCH_GUARD, | ||
180 | STRUCT_LIT, | ||
181 | NAMED_FIELD_LIST, | ||
182 | NAMED_FIELD, | ||
183 | CALL_EXPR, | ||
184 | INDEX_EXPR, | ||
185 | METHOD_CALL_EXPR, | ||
186 | FIELD_EXPR, | ||
187 | TRY_EXPR, | ||
188 | CAST_EXPR, | ||
189 | REF_EXPR, | ||
190 | PREFIX_EXPR, | ||
191 | RANGE_EXPR, | ||
192 | BIN_EXPR, | ||
193 | BLOCK, | ||
194 | EXTERN_BLOCK, | ||
195 | EXTERN_ITEM_LIST, | ||
196 | ENUM_VARIANT, | ||
197 | NAMED_FIELD_DEF_LIST, | ||
198 | NAMED_FIELD_DEF, | ||
199 | POS_FIELD_DEF_LIST, | ||
200 | POS_FIELD_DEF, | ||
201 | ENUM_VARIANT_LIST, | ||
202 | ITEM_LIST, | ||
203 | ATTR, | ||
204 | META_ITEM, | ||
205 | USE_TREE, | ||
206 | USE_TREE_LIST, | ||
207 | PATH, | ||
208 | PATH_SEGMENT, | ||
209 | LITERAL, | ||
210 | ALIAS, | ||
211 | VISIBILITY, | ||
212 | WHERE_CLAUSE, | ||
213 | WHERE_PRED, | ||
214 | ABI, | ||
215 | NAME, | ||
216 | NAME_REF, | ||
217 | LET_STMT, | ||
218 | EXPR_STMT, | ||
219 | TYPE_PARAM_LIST, | ||
220 | LIFETIME_PARAM, | ||
221 | TYPE_PARAM, | ||
222 | TYPE_ARG_LIST, | ||
223 | LIFETIME_ARG, | ||
224 | TYPE_ARG, | ||
225 | ASSOC_TYPE_ARG, | ||
226 | PARAM_LIST, | ||
227 | PARAM, | ||
228 | SELF_PARAM, | ||
229 | ARG_LIST, | ||
230 | } | ||
231 | use self::SyntaxKind::*; | ||
232 | |||
233 | impl SyntaxKind { | ||
234 | pub fn is_keyword(self) -> bool { | ||
235 | match self { | ||
236 | | USE_KW | ||
237 | | FN_KW | ||
238 | | STRUCT_KW | ||
239 | | ENUM_KW | ||
240 | | TRAIT_KW | ||
241 | | IMPL_KW | ||
242 | | DYN_KW | ||
243 | | TRUE_KW | ||
244 | | FALSE_KW | ||
245 | | AS_KW | ||
246 | | EXTERN_KW | ||
247 | | CRATE_KW | ||
248 | | MOD_KW | ||
249 | | PUB_KW | ||
250 | | SELF_KW | ||
251 | | SUPER_KW | ||
252 | | IN_KW | ||
253 | | WHERE_KW | ||
254 | | FOR_KW | ||
255 | | LOOP_KW | ||
256 | | WHILE_KW | ||
257 | | CONTINUE_KW | ||
258 | | BREAK_KW | ||
259 | | IF_KW | ||
260 | | ELSE_KW | ||
261 | | MATCH_KW | ||
262 | | CONST_KW | ||
263 | | STATIC_KW | ||
264 | | MUT_KW | ||
265 | | UNSAFE_KW | ||
266 | | TYPE_KW | ||
267 | | REF_KW | ||
268 | | LET_KW | ||
269 | | MOVE_KW | ||
270 | | RETURN_KW | ||
271 | | AUTO_KW | ||
272 | | DEFAULT_KW | ||
273 | | UNION_KW | ||
274 | => true, | ||
275 | _ => false | ||
276 | } | ||
277 | } | ||
278 | |||
279 | pub fn is_punct(self) -> bool { | ||
280 | match self { | ||
281 | | SEMI | ||
282 | | COMMA | ||
283 | | L_PAREN | ||
284 | | R_PAREN | ||
285 | | L_CURLY | ||
286 | | R_CURLY | ||
287 | | L_BRACK | ||
288 | | R_BRACK | ||
289 | | L_ANGLE | ||
290 | | R_ANGLE | ||
291 | | AT | ||
292 | | POUND | ||
293 | | TILDE | ||
294 | | QUESTION | ||
295 | | DOLLAR | ||
296 | | AMP | ||
297 | | PIPE | ||
298 | | PLUS | ||
299 | | STAR | ||
300 | | SLASH | ||
301 | | CARET | ||
302 | | PERCENT | ||
303 | | UNDERSCORE | ||
304 | | DOT | ||
305 | | DOTDOT | ||
306 | | DOTDOTDOT | ||
307 | | DOTDOTEQ | ||
308 | | COLON | ||
309 | | COLONCOLON | ||
310 | | EQ | ||
311 | | EQEQ | ||
312 | | FAT_ARROW | ||
313 | | EXCL | ||
314 | | NEQ | ||
315 | | MINUS | ||
316 | | THIN_ARROW | ||
317 | | LTEQ | ||
318 | | GTEQ | ||
319 | | PLUSEQ | ||
320 | | MINUSEQ | ||
321 | | PIPEEQ | ||
322 | | AMPEQ | ||
323 | | CARETEQ | ||
324 | | SLASHEQ | ||
325 | | STAREQ | ||
326 | | PERCENTEQ | ||
327 | | AMPAMP | ||
328 | | PIPEPIPE | ||
329 | | SHL | ||
330 | | SHR | ||
331 | | SHLEQ | ||
332 | | SHREQ | ||
333 | => true, | ||
334 | _ => false | ||
335 | } | ||
336 | } | ||
337 | pub fn is_literal(self) -> bool { | ||
338 | match self { | ||
339 | | INT_NUMBER | ||
340 | | FLOAT_NUMBER | ||
341 | | CHAR | ||
342 | | BYTE | ||
343 | | STRING | ||
344 | | RAW_STRING | ||
345 | | BYTE_STRING | ||
346 | | RAW_BYTE_STRING | ||
347 | => true, | ||
348 | _ => false | ||
349 | } | ||
350 | } | ||
351 | |||
352 | pub(crate) fn info(self) -> &'static SyntaxInfo { | ||
353 | match self { | ||
354 | SEMI => &SyntaxInfo { name: "SEMI" }, | ||
355 | COMMA => &SyntaxInfo { name: "COMMA" }, | ||
356 | L_PAREN => &SyntaxInfo { name: "L_PAREN" }, | ||
357 | R_PAREN => &SyntaxInfo { name: "R_PAREN" }, | ||
358 | L_CURLY => &SyntaxInfo { name: "L_CURLY" }, | ||
359 | R_CURLY => &SyntaxInfo { name: "R_CURLY" }, | ||
360 | L_BRACK => &SyntaxInfo { name: "L_BRACK" }, | ||
361 | R_BRACK => &SyntaxInfo { name: "R_BRACK" }, | ||
362 | L_ANGLE => &SyntaxInfo { name: "L_ANGLE" }, | ||
363 | R_ANGLE => &SyntaxInfo { name: "R_ANGLE" }, | ||
364 | AT => &SyntaxInfo { name: "AT" }, | ||
365 | POUND => &SyntaxInfo { name: "POUND" }, | ||
366 | TILDE => &SyntaxInfo { name: "TILDE" }, | ||
367 | QUESTION => &SyntaxInfo { name: "QUESTION" }, | ||
368 | DOLLAR => &SyntaxInfo { name: "DOLLAR" }, | ||
369 | AMP => &SyntaxInfo { name: "AMP" }, | ||
370 | PIPE => &SyntaxInfo { name: "PIPE" }, | ||
371 | PLUS => &SyntaxInfo { name: "PLUS" }, | ||
372 | STAR => &SyntaxInfo { name: "STAR" }, | ||
373 | SLASH => &SyntaxInfo { name: "SLASH" }, | ||
374 | CARET => &SyntaxInfo { name: "CARET" }, | ||
375 | PERCENT => &SyntaxInfo { name: "PERCENT" }, | ||
376 | UNDERSCORE => &SyntaxInfo { name: "UNDERSCORE" }, | ||
377 | DOT => &SyntaxInfo { name: "DOT" }, | ||
378 | DOTDOT => &SyntaxInfo { name: "DOTDOT" }, | ||
379 | DOTDOTDOT => &SyntaxInfo { name: "DOTDOTDOT" }, | ||
380 | DOTDOTEQ => &SyntaxInfo { name: "DOTDOTEQ" }, | ||
381 | COLON => &SyntaxInfo { name: "COLON" }, | ||
382 | COLONCOLON => &SyntaxInfo { name: "COLONCOLON" }, | ||
383 | EQ => &SyntaxInfo { name: "EQ" }, | ||
384 | EQEQ => &SyntaxInfo { name: "EQEQ" }, | ||
385 | FAT_ARROW => &SyntaxInfo { name: "FAT_ARROW" }, | ||
386 | EXCL => &SyntaxInfo { name: "EXCL" }, | ||
387 | NEQ => &SyntaxInfo { name: "NEQ" }, | ||
388 | MINUS => &SyntaxInfo { name: "MINUS" }, | ||
389 | THIN_ARROW => &SyntaxInfo { name: "THIN_ARROW" }, | ||
390 | LTEQ => &SyntaxInfo { name: "LTEQ" }, | ||
391 | GTEQ => &SyntaxInfo { name: "GTEQ" }, | ||
392 | PLUSEQ => &SyntaxInfo { name: "PLUSEQ" }, | ||
393 | MINUSEQ => &SyntaxInfo { name: "MINUSEQ" }, | ||
394 | PIPEEQ => &SyntaxInfo { name: "PIPEEQ" }, | ||
395 | AMPEQ => &SyntaxInfo { name: "AMPEQ" }, | ||
396 | CARETEQ => &SyntaxInfo { name: "CARETEQ" }, | ||
397 | SLASHEQ => &SyntaxInfo { name: "SLASHEQ" }, | ||
398 | STAREQ => &SyntaxInfo { name: "STAREQ" }, | ||
399 | PERCENTEQ => &SyntaxInfo { name: "PERCENTEQ" }, | ||
400 | AMPAMP => &SyntaxInfo { name: "AMPAMP" }, | ||
401 | PIPEPIPE => &SyntaxInfo { name: "PIPEPIPE" }, | ||
402 | SHL => &SyntaxInfo { name: "SHL" }, | ||
403 | SHR => &SyntaxInfo { name: "SHR" }, | ||
404 | SHLEQ => &SyntaxInfo { name: "SHLEQ" }, | ||
405 | SHREQ => &SyntaxInfo { name: "SHREQ" }, | ||
406 | USE_KW => &SyntaxInfo { name: "USE_KW" }, | ||
407 | FN_KW => &SyntaxInfo { name: "FN_KW" }, | ||
408 | STRUCT_KW => &SyntaxInfo { name: "STRUCT_KW" }, | ||
409 | ENUM_KW => &SyntaxInfo { name: "ENUM_KW" }, | ||
410 | TRAIT_KW => &SyntaxInfo { name: "TRAIT_KW" }, | ||
411 | IMPL_KW => &SyntaxInfo { name: "IMPL_KW" }, | ||
412 | DYN_KW => &SyntaxInfo { name: "DYN_KW" }, | ||
413 | TRUE_KW => &SyntaxInfo { name: "TRUE_KW" }, | ||
414 | FALSE_KW => &SyntaxInfo { name: "FALSE_KW" }, | ||
415 | AS_KW => &SyntaxInfo { name: "AS_KW" }, | ||
416 | EXTERN_KW => &SyntaxInfo { name: "EXTERN_KW" }, | ||
417 | CRATE_KW => &SyntaxInfo { name: "CRATE_KW" }, | ||
418 | MOD_KW => &SyntaxInfo { name: "MOD_KW" }, | ||
419 | PUB_KW => &SyntaxInfo { name: "PUB_KW" }, | ||
420 | SELF_KW => &SyntaxInfo { name: "SELF_KW" }, | ||
421 | SUPER_KW => &SyntaxInfo { name: "SUPER_KW" }, | ||
422 | IN_KW => &SyntaxInfo { name: "IN_KW" }, | ||
423 | WHERE_KW => &SyntaxInfo { name: "WHERE_KW" }, | ||
424 | FOR_KW => &SyntaxInfo { name: "FOR_KW" }, | ||
425 | LOOP_KW => &SyntaxInfo { name: "LOOP_KW" }, | ||
426 | WHILE_KW => &SyntaxInfo { name: "WHILE_KW" }, | ||
427 | CONTINUE_KW => &SyntaxInfo { name: "CONTINUE_KW" }, | ||
428 | BREAK_KW => &SyntaxInfo { name: "BREAK_KW" }, | ||
429 | IF_KW => &SyntaxInfo { name: "IF_KW" }, | ||
430 | ELSE_KW => &SyntaxInfo { name: "ELSE_KW" }, | ||
431 | MATCH_KW => &SyntaxInfo { name: "MATCH_KW" }, | ||
432 | CONST_KW => &SyntaxInfo { name: "CONST_KW" }, | ||
433 | STATIC_KW => &SyntaxInfo { name: "STATIC_KW" }, | ||
434 | MUT_KW => &SyntaxInfo { name: "MUT_KW" }, | ||
435 | UNSAFE_KW => &SyntaxInfo { name: "UNSAFE_KW" }, | ||
436 | TYPE_KW => &SyntaxInfo { name: "TYPE_KW" }, | ||
437 | REF_KW => &SyntaxInfo { name: "REF_KW" }, | ||
438 | LET_KW => &SyntaxInfo { name: "LET_KW" }, | ||
439 | MOVE_KW => &SyntaxInfo { name: "MOVE_KW" }, | ||
440 | RETURN_KW => &SyntaxInfo { name: "RETURN_KW" }, | ||
441 | AUTO_KW => &SyntaxInfo { name: "AUTO_KW" }, | ||
442 | DEFAULT_KW => &SyntaxInfo { name: "DEFAULT_KW" }, | ||
443 | UNION_KW => &SyntaxInfo { name: "UNION_KW" }, | ||
444 | INT_NUMBER => &SyntaxInfo { name: "INT_NUMBER" }, | ||
445 | FLOAT_NUMBER => &SyntaxInfo { name: "FLOAT_NUMBER" }, | ||
446 | CHAR => &SyntaxInfo { name: "CHAR" }, | ||
447 | BYTE => &SyntaxInfo { name: "BYTE" }, | ||
448 | STRING => &SyntaxInfo { name: "STRING" }, | ||
449 | RAW_STRING => &SyntaxInfo { name: "RAW_STRING" }, | ||
450 | BYTE_STRING => &SyntaxInfo { name: "BYTE_STRING" }, | ||
451 | RAW_BYTE_STRING => &SyntaxInfo { name: "RAW_BYTE_STRING" }, | ||
452 | ERROR => &SyntaxInfo { name: "ERROR" }, | ||
453 | IDENT => &SyntaxInfo { name: "IDENT" }, | ||
454 | WHITESPACE => &SyntaxInfo { name: "WHITESPACE" }, | ||
455 | LIFETIME => &SyntaxInfo { name: "LIFETIME" }, | ||
456 | COMMENT => &SyntaxInfo { name: "COMMENT" }, | ||
457 | SHEBANG => &SyntaxInfo { name: "SHEBANG" }, | ||
458 | SOURCE_FILE => &SyntaxInfo { name: "SOURCE_FILE" }, | ||
459 | STRUCT_DEF => &SyntaxInfo { name: "STRUCT_DEF" }, | ||
460 | ENUM_DEF => &SyntaxInfo { name: "ENUM_DEF" }, | ||
461 | FN_DEF => &SyntaxInfo { name: "FN_DEF" }, | ||
462 | RET_TYPE => &SyntaxInfo { name: "RET_TYPE" }, | ||
463 | EXTERN_CRATE_ITEM => &SyntaxInfo { name: "EXTERN_CRATE_ITEM" }, | ||
464 | MODULE => &SyntaxInfo { name: "MODULE" }, | ||
465 | USE_ITEM => &SyntaxInfo { name: "USE_ITEM" }, | ||
466 | STATIC_DEF => &SyntaxInfo { name: "STATIC_DEF" }, | ||
467 | CONST_DEF => &SyntaxInfo { name: "CONST_DEF" }, | ||
468 | TRAIT_DEF => &SyntaxInfo { name: "TRAIT_DEF" }, | ||
469 | IMPL_BLOCK => &SyntaxInfo { name: "IMPL_BLOCK" }, | ||
470 | TYPE_DEF => &SyntaxInfo { name: "TYPE_DEF" }, | ||
471 | MACRO_CALL => &SyntaxInfo { name: "MACRO_CALL" }, | ||
472 | TOKEN_TREE => &SyntaxInfo { name: "TOKEN_TREE" }, | ||
473 | PAREN_TYPE => &SyntaxInfo { name: "PAREN_TYPE" }, | ||
474 | TUPLE_TYPE => &SyntaxInfo { name: "TUPLE_TYPE" }, | ||
475 | NEVER_TYPE => &SyntaxInfo { name: "NEVER_TYPE" }, | ||
476 | PATH_TYPE => &SyntaxInfo { name: "PATH_TYPE" }, | ||
477 | POINTER_TYPE => &SyntaxInfo { name: "POINTER_TYPE" }, | ||
478 | ARRAY_TYPE => &SyntaxInfo { name: "ARRAY_TYPE" }, | ||
479 | SLICE_TYPE => &SyntaxInfo { name: "SLICE_TYPE" }, | ||
480 | REFERENCE_TYPE => &SyntaxInfo { name: "REFERENCE_TYPE" }, | ||
481 | PLACEHOLDER_TYPE => &SyntaxInfo { name: "PLACEHOLDER_TYPE" }, | ||
482 | FN_POINTER_TYPE => &SyntaxInfo { name: "FN_POINTER_TYPE" }, | ||
483 | FOR_TYPE => &SyntaxInfo { name: "FOR_TYPE" }, | ||
484 | IMPL_TRAIT_TYPE => &SyntaxInfo { name: "IMPL_TRAIT_TYPE" }, | ||
485 | DYN_TRAIT_TYPE => &SyntaxInfo { name: "DYN_TRAIT_TYPE" }, | ||
486 | REF_PAT => &SyntaxInfo { name: "REF_PAT" }, | ||
487 | BIND_PAT => &SyntaxInfo { name: "BIND_PAT" }, | ||
488 | PLACEHOLDER_PAT => &SyntaxInfo { name: "PLACEHOLDER_PAT" }, | ||
489 | PATH_PAT => &SyntaxInfo { name: "PATH_PAT" }, | ||
490 | STRUCT_PAT => &SyntaxInfo { name: "STRUCT_PAT" }, | ||
491 | FIELD_PAT_LIST => &SyntaxInfo { name: "FIELD_PAT_LIST" }, | ||
492 | FIELD_PAT => &SyntaxInfo { name: "FIELD_PAT" }, | ||
493 | TUPLE_STRUCT_PAT => &SyntaxInfo { name: "TUPLE_STRUCT_PAT" }, | ||
494 | TUPLE_PAT => &SyntaxInfo { name: "TUPLE_PAT" }, | ||
495 | SLICE_PAT => &SyntaxInfo { name: "SLICE_PAT" }, | ||
496 | RANGE_PAT => &SyntaxInfo { name: "RANGE_PAT" }, | ||
497 | LITERAL_PAT => &SyntaxInfo { name: "LITERAL_PAT" }, | ||
498 | TUPLE_EXPR => &SyntaxInfo { name: "TUPLE_EXPR" }, | ||
499 | ARRAY_EXPR => &SyntaxInfo { name: "ARRAY_EXPR" }, | ||
500 | PAREN_EXPR => &SyntaxInfo { name: "PAREN_EXPR" }, | ||
501 | PATH_EXPR => &SyntaxInfo { name: "PATH_EXPR" }, | ||
502 | LAMBDA_EXPR => &SyntaxInfo { name: "LAMBDA_EXPR" }, | ||
503 | IF_EXPR => &SyntaxInfo { name: "IF_EXPR" }, | ||
504 | WHILE_EXPR => &SyntaxInfo { name: "WHILE_EXPR" }, | ||
505 | CONDITION => &SyntaxInfo { name: "CONDITION" }, | ||
506 | LOOP_EXPR => &SyntaxInfo { name: "LOOP_EXPR" }, | ||
507 | FOR_EXPR => &SyntaxInfo { name: "FOR_EXPR" }, | ||
508 | CONTINUE_EXPR => &SyntaxInfo { name: "CONTINUE_EXPR" }, | ||
509 | BREAK_EXPR => &SyntaxInfo { name: "BREAK_EXPR" }, | ||
510 | LABEL => &SyntaxInfo { name: "LABEL" }, | ||
511 | BLOCK_EXPR => &SyntaxInfo { name: "BLOCK_EXPR" }, | ||
512 | RETURN_EXPR => &SyntaxInfo { name: "RETURN_EXPR" }, | ||
513 | MATCH_EXPR => &SyntaxInfo { name: "MATCH_EXPR" }, | ||
514 | MATCH_ARM_LIST => &SyntaxInfo { name: "MATCH_ARM_LIST" }, | ||
515 | MATCH_ARM => &SyntaxInfo { name: "MATCH_ARM" }, | ||
516 | MATCH_GUARD => &SyntaxInfo { name: "MATCH_GUARD" }, | ||
517 | STRUCT_LIT => &SyntaxInfo { name: "STRUCT_LIT" }, | ||
518 | NAMED_FIELD_LIST => &SyntaxInfo { name: "NAMED_FIELD_LIST" }, | ||
519 | NAMED_FIELD => &SyntaxInfo { name: "NAMED_FIELD" }, | ||
520 | CALL_EXPR => &SyntaxInfo { name: "CALL_EXPR" }, | ||
521 | INDEX_EXPR => &SyntaxInfo { name: "INDEX_EXPR" }, | ||
522 | METHOD_CALL_EXPR => &SyntaxInfo { name: "METHOD_CALL_EXPR" }, | ||
523 | FIELD_EXPR => &SyntaxInfo { name: "FIELD_EXPR" }, | ||
524 | TRY_EXPR => &SyntaxInfo { name: "TRY_EXPR" }, | ||
525 | CAST_EXPR => &SyntaxInfo { name: "CAST_EXPR" }, | ||
526 | REF_EXPR => &SyntaxInfo { name: "REF_EXPR" }, | ||
527 | PREFIX_EXPR => &SyntaxInfo { name: "PREFIX_EXPR" }, | ||
528 | RANGE_EXPR => &SyntaxInfo { name: "RANGE_EXPR" }, | ||
529 | BIN_EXPR => &SyntaxInfo { name: "BIN_EXPR" }, | ||
530 | BLOCK => &SyntaxInfo { name: "BLOCK" }, | ||
531 | EXTERN_BLOCK => &SyntaxInfo { name: "EXTERN_BLOCK" }, | ||
532 | EXTERN_ITEM_LIST => &SyntaxInfo { name: "EXTERN_ITEM_LIST" }, | ||
533 | ENUM_VARIANT => &SyntaxInfo { name: "ENUM_VARIANT" }, | ||
534 | NAMED_FIELD_DEF_LIST => &SyntaxInfo { name: "NAMED_FIELD_DEF_LIST" }, | ||
535 | NAMED_FIELD_DEF => &SyntaxInfo { name: "NAMED_FIELD_DEF" }, | ||
536 | POS_FIELD_DEF_LIST => &SyntaxInfo { name: "POS_FIELD_DEF_LIST" }, | ||
537 | POS_FIELD_DEF => &SyntaxInfo { name: "POS_FIELD_DEF" }, | ||
538 | ENUM_VARIANT_LIST => &SyntaxInfo { name: "ENUM_VARIANT_LIST" }, | ||
539 | ITEM_LIST => &SyntaxInfo { name: "ITEM_LIST" }, | ||
540 | ATTR => &SyntaxInfo { name: "ATTR" }, | ||
541 | META_ITEM => &SyntaxInfo { name: "META_ITEM" }, | ||
542 | USE_TREE => &SyntaxInfo { name: "USE_TREE" }, | ||
543 | USE_TREE_LIST => &SyntaxInfo { name: "USE_TREE_LIST" }, | ||
544 | PATH => &SyntaxInfo { name: "PATH" }, | ||
545 | PATH_SEGMENT => &SyntaxInfo { name: "PATH_SEGMENT" }, | ||
546 | LITERAL => &SyntaxInfo { name: "LITERAL" }, | ||
547 | ALIAS => &SyntaxInfo { name: "ALIAS" }, | ||
548 | VISIBILITY => &SyntaxInfo { name: "VISIBILITY" }, | ||
549 | WHERE_CLAUSE => &SyntaxInfo { name: "WHERE_CLAUSE" }, | ||
550 | WHERE_PRED => &SyntaxInfo { name: "WHERE_PRED" }, | ||
551 | ABI => &SyntaxInfo { name: "ABI" }, | ||
552 | NAME => &SyntaxInfo { name: "NAME" }, | ||
553 | NAME_REF => &SyntaxInfo { name: "NAME_REF" }, | ||
554 | LET_STMT => &SyntaxInfo { name: "LET_STMT" }, | ||
555 | EXPR_STMT => &SyntaxInfo { name: "EXPR_STMT" }, | ||
556 | TYPE_PARAM_LIST => &SyntaxInfo { name: "TYPE_PARAM_LIST" }, | ||
557 | LIFETIME_PARAM => &SyntaxInfo { name: "LIFETIME_PARAM" }, | ||
558 | TYPE_PARAM => &SyntaxInfo { name: "TYPE_PARAM" }, | ||
559 | TYPE_ARG_LIST => &SyntaxInfo { name: "TYPE_ARG_LIST" }, | ||
560 | LIFETIME_ARG => &SyntaxInfo { name: "LIFETIME_ARG" }, | ||
561 | TYPE_ARG => &SyntaxInfo { name: "TYPE_ARG" }, | ||
562 | ASSOC_TYPE_ARG => &SyntaxInfo { name: "ASSOC_TYPE_ARG" }, | ||
563 | PARAM_LIST => &SyntaxInfo { name: "PARAM_LIST" }, | ||
564 | PARAM => &SyntaxInfo { name: "PARAM" }, | ||
565 | SELF_PARAM => &SyntaxInfo { name: "SELF_PARAM" }, | ||
566 | ARG_LIST => &SyntaxInfo { name: "ARG_LIST" }, | ||
567 | TOMBSTONE => &SyntaxInfo { name: "TOMBSTONE" }, | ||
568 | EOF => &SyntaxInfo { name: "EOF" }, | ||
569 | } | ||
570 | } | ||
571 | pub fn from_keyword(ident: &str) -> Option<SyntaxKind> { | ||
572 | let kw = match ident { | ||
573 | "use" => USE_KW, | ||
574 | "fn" => FN_KW, | ||
575 | "struct" => STRUCT_KW, | ||
576 | "enum" => ENUM_KW, | ||
577 | "trait" => TRAIT_KW, | ||
578 | "impl" => IMPL_KW, | ||
579 | "dyn" => DYN_KW, | ||
580 | "true" => TRUE_KW, | ||
581 | "false" => FALSE_KW, | ||
582 | "as" => AS_KW, | ||
583 | "extern" => EXTERN_KW, | ||
584 | "crate" => CRATE_KW, | ||
585 | "mod" => MOD_KW, | ||
586 | "pub" => PUB_KW, | ||
587 | "self" => SELF_KW, | ||
588 | "super" => SUPER_KW, | ||
589 | "in" => IN_KW, | ||
590 | "where" => WHERE_KW, | ||
591 | "for" => FOR_KW, | ||
592 | "loop" => LOOP_KW, | ||
593 | "while" => WHILE_KW, | ||
594 | "continue" => CONTINUE_KW, | ||
595 | "break" => BREAK_KW, | ||
596 | "if" => IF_KW, | ||
597 | "else" => ELSE_KW, | ||
598 | "match" => MATCH_KW, | ||
599 | "const" => CONST_KW, | ||
600 | "static" => STATIC_KW, | ||
601 | "mut" => MUT_KW, | ||
602 | "unsafe" => UNSAFE_KW, | ||
603 | "type" => TYPE_KW, | ||
604 | "ref" => REF_KW, | ||
605 | "let" => LET_KW, | ||
606 | "move" => MOVE_KW, | ||
607 | "return" => RETURN_KW, | ||
608 | _ => return None, | ||
609 | }; | ||
610 | Some(kw) | ||
611 | } | ||
612 | |||
613 | pub fn from_char(c: char) -> Option<SyntaxKind> { | ||
614 | let tok = match c { | ||
615 | ';' => SEMI, | ||
616 | ',' => COMMA, | ||
617 | '(' => L_PAREN, | ||
618 | ')' => R_PAREN, | ||
619 | '{' => L_CURLY, | ||
620 | '}' => R_CURLY, | ||
621 | '[' => L_BRACK, | ||
622 | ']' => R_BRACK, | ||
623 | '<' => L_ANGLE, | ||
624 | '>' => R_ANGLE, | ||
625 | '@' => AT, | ||
626 | '#' => POUND, | ||
627 | '~' => TILDE, | ||
628 | '?' => QUESTION, | ||
629 | '$' => DOLLAR, | ||
630 | '&' => AMP, | ||
631 | '|' => PIPE, | ||
632 | '+' => PLUS, | ||
633 | '*' => STAR, | ||
634 | '/' => SLASH, | ||
635 | '^' => CARET, | ||
636 | '%' => PERCENT, | ||
637 | '_' => UNDERSCORE, | ||
638 | _ => return None, | ||
639 | }; | ||
640 | Some(tok) | ||
641 | } | ||
642 | } | ||