diff options
Diffstat (limited to 'crates/ra_syntax/src')
-rw-r--r-- | crates/ra_syntax/src/ast.rs | 2 | ||||
-rw-r--r-- | crates/ra_syntax/src/ast/generated/nodes.rs | 3054 | ||||
-rw-r--r-- | crates/ra_syntax/src/ast/generated/tokens.rs | 3059 |
3 files changed, 3060 insertions, 3055 deletions
diff --git a/crates/ra_syntax/src/ast.rs b/crates/ra_syntax/src/ast.rs index 9da44e251..a42eec91a 100644 --- a/crates/ra_syntax/src/ast.rs +++ b/crates/ra_syntax/src/ast.rs | |||
@@ -21,7 +21,7 @@ pub use self::{ | |||
21 | AttrKind, FieldKind, PathSegmentKind, SelfParamKind, SlicePatComponents, StructKind, | 21 | AttrKind, FieldKind, PathSegmentKind, SelfParamKind, SlicePatComponents, StructKind, |
22 | TypeBoundKind, VisibilityKind, | 22 | TypeBoundKind, VisibilityKind, |
23 | }, | 23 | }, |
24 | generated::nodes::*, | 24 | generated::{nodes::*, tokens::*}, |
25 | tokens::*, | 25 | tokens::*, |
26 | traits::*, | 26 | traits::*, |
27 | }; | 27 | }; |
diff --git a/crates/ra_syntax/src/ast/generated/nodes.rs b/crates/ra_syntax/src/ast/generated/nodes.rs index bd92e9c87..7d74c9fc9 100644 --- a/crates/ra_syntax/src/ast/generated/nodes.rs +++ b/crates/ra_syntax/src/ast/generated/nodes.rs | |||
@@ -1,3064 +1,12 @@ | |||
1 | //! Generated file, do not edit by hand, see `xtask/src/codegen` | 1 | //! Generated file, do not edit by hand, see `xtask/src/codegen` |
2 | 2 | ||
3 | #[allow(unused_imports)] | 3 | use super::tokens::*; |
4 | use crate::{ | 4 | use crate::{ |
5 | ast::{self, support, AstChildren, AstNode, AstToken}, | 5 | ast::{self, support, AstChildren, AstNode, AstToken}, |
6 | NodeOrToken, SyntaxElement, | ||
7 | SyntaxKind::{self, *}, | 6 | SyntaxKind::{self, *}, |
8 | SyntaxNode, SyntaxToken, | 7 | SyntaxNode, SyntaxToken, |
9 | }; | 8 | }; |
10 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | 9 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] |
11 | pub struct Semi { | ||
12 | pub(crate) syntax: SyntaxToken, | ||
13 | } | ||
14 | impl std::fmt::Display for Semi { | ||
15 | fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { | ||
16 | std::fmt::Display::fmt(&self.syntax, f) | ||
17 | } | ||
18 | } | ||
19 | impl AstToken for Semi { | ||
20 | fn can_cast(kind: SyntaxKind) -> bool { | ||
21 | match kind { | ||
22 | SEMI => true, | ||
23 | _ => false, | ||
24 | } | ||
25 | } | ||
26 | fn cast(syntax: SyntaxToken) -> Option<Self> { | ||
27 | if Self::can_cast(syntax.kind()) { | ||
28 | Some(Self { syntax }) | ||
29 | } else { | ||
30 | None | ||
31 | } | ||
32 | } | ||
33 | fn syntax(&self) -> &SyntaxToken { | ||
34 | &self.syntax | ||
35 | } | ||
36 | } | ||
37 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
38 | pub struct Comma { | ||
39 | pub(crate) syntax: SyntaxToken, | ||
40 | } | ||
41 | impl std::fmt::Display for Comma { | ||
42 | fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { | ||
43 | std::fmt::Display::fmt(&self.syntax, f) | ||
44 | } | ||
45 | } | ||
46 | impl AstToken for Comma { | ||
47 | fn can_cast(kind: SyntaxKind) -> bool { | ||
48 | match kind { | ||
49 | COMMA => true, | ||
50 | _ => false, | ||
51 | } | ||
52 | } | ||
53 | fn cast(syntax: SyntaxToken) -> Option<Self> { | ||
54 | if Self::can_cast(syntax.kind()) { | ||
55 | Some(Self { syntax }) | ||
56 | } else { | ||
57 | None | ||
58 | } | ||
59 | } | ||
60 | fn syntax(&self) -> &SyntaxToken { | ||
61 | &self.syntax | ||
62 | } | ||
63 | } | ||
64 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
65 | pub struct LParen { | ||
66 | pub(crate) syntax: SyntaxToken, | ||
67 | } | ||
68 | impl std::fmt::Display for LParen { | ||
69 | fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { | ||
70 | std::fmt::Display::fmt(&self.syntax, f) | ||
71 | } | ||
72 | } | ||
73 | impl AstToken for LParen { | ||
74 | fn can_cast(kind: SyntaxKind) -> bool { | ||
75 | match kind { | ||
76 | L_PAREN => true, | ||
77 | _ => false, | ||
78 | } | ||
79 | } | ||
80 | fn cast(syntax: SyntaxToken) -> Option<Self> { | ||
81 | if Self::can_cast(syntax.kind()) { | ||
82 | Some(Self { syntax }) | ||
83 | } else { | ||
84 | None | ||
85 | } | ||
86 | } | ||
87 | fn syntax(&self) -> &SyntaxToken { | ||
88 | &self.syntax | ||
89 | } | ||
90 | } | ||
91 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
92 | pub struct RParen { | ||
93 | pub(crate) syntax: SyntaxToken, | ||
94 | } | ||
95 | impl std::fmt::Display for RParen { | ||
96 | fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { | ||
97 | std::fmt::Display::fmt(&self.syntax, f) | ||
98 | } | ||
99 | } | ||
100 | impl AstToken for RParen { | ||
101 | fn can_cast(kind: SyntaxKind) -> bool { | ||
102 | match kind { | ||
103 | R_PAREN => true, | ||
104 | _ => false, | ||
105 | } | ||
106 | } | ||
107 | fn cast(syntax: SyntaxToken) -> Option<Self> { | ||
108 | if Self::can_cast(syntax.kind()) { | ||
109 | Some(Self { syntax }) | ||
110 | } else { | ||
111 | None | ||
112 | } | ||
113 | } | ||
114 | fn syntax(&self) -> &SyntaxToken { | ||
115 | &self.syntax | ||
116 | } | ||
117 | } | ||
118 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
119 | pub struct LCurly { | ||
120 | pub(crate) syntax: SyntaxToken, | ||
121 | } | ||
122 | impl std::fmt::Display for LCurly { | ||
123 | fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { | ||
124 | std::fmt::Display::fmt(&self.syntax, f) | ||
125 | } | ||
126 | } | ||
127 | impl AstToken for LCurly { | ||
128 | fn can_cast(kind: SyntaxKind) -> bool { | ||
129 | match kind { | ||
130 | L_CURLY => true, | ||
131 | _ => false, | ||
132 | } | ||
133 | } | ||
134 | fn cast(syntax: SyntaxToken) -> Option<Self> { | ||
135 | if Self::can_cast(syntax.kind()) { | ||
136 | Some(Self { syntax }) | ||
137 | } else { | ||
138 | None | ||
139 | } | ||
140 | } | ||
141 | fn syntax(&self) -> &SyntaxToken { | ||
142 | &self.syntax | ||
143 | } | ||
144 | } | ||
145 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
146 | pub struct RCurly { | ||
147 | pub(crate) syntax: SyntaxToken, | ||
148 | } | ||
149 | impl std::fmt::Display for RCurly { | ||
150 | fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { | ||
151 | std::fmt::Display::fmt(&self.syntax, f) | ||
152 | } | ||
153 | } | ||
154 | impl AstToken for RCurly { | ||
155 | fn can_cast(kind: SyntaxKind) -> bool { | ||
156 | match kind { | ||
157 | R_CURLY => true, | ||
158 | _ => false, | ||
159 | } | ||
160 | } | ||
161 | fn cast(syntax: SyntaxToken) -> Option<Self> { | ||
162 | if Self::can_cast(syntax.kind()) { | ||
163 | Some(Self { syntax }) | ||
164 | } else { | ||
165 | None | ||
166 | } | ||
167 | } | ||
168 | fn syntax(&self) -> &SyntaxToken { | ||
169 | &self.syntax | ||
170 | } | ||
171 | } | ||
172 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
173 | pub struct LBrack { | ||
174 | pub(crate) syntax: SyntaxToken, | ||
175 | } | ||
176 | impl std::fmt::Display for LBrack { | ||
177 | fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { | ||
178 | std::fmt::Display::fmt(&self.syntax, f) | ||
179 | } | ||
180 | } | ||
181 | impl AstToken for LBrack { | ||
182 | fn can_cast(kind: SyntaxKind) -> bool { | ||
183 | match kind { | ||
184 | L_BRACK => true, | ||
185 | _ => false, | ||
186 | } | ||
187 | } | ||
188 | fn cast(syntax: SyntaxToken) -> Option<Self> { | ||
189 | if Self::can_cast(syntax.kind()) { | ||
190 | Some(Self { syntax }) | ||
191 | } else { | ||
192 | None | ||
193 | } | ||
194 | } | ||
195 | fn syntax(&self) -> &SyntaxToken { | ||
196 | &self.syntax | ||
197 | } | ||
198 | } | ||
199 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
200 | pub struct RBrack { | ||
201 | pub(crate) syntax: SyntaxToken, | ||
202 | } | ||
203 | impl std::fmt::Display for RBrack { | ||
204 | fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { | ||
205 | std::fmt::Display::fmt(&self.syntax, f) | ||
206 | } | ||
207 | } | ||
208 | impl AstToken for RBrack { | ||
209 | fn can_cast(kind: SyntaxKind) -> bool { | ||
210 | match kind { | ||
211 | R_BRACK => true, | ||
212 | _ => false, | ||
213 | } | ||
214 | } | ||
215 | fn cast(syntax: SyntaxToken) -> Option<Self> { | ||
216 | if Self::can_cast(syntax.kind()) { | ||
217 | Some(Self { syntax }) | ||
218 | } else { | ||
219 | None | ||
220 | } | ||
221 | } | ||
222 | fn syntax(&self) -> &SyntaxToken { | ||
223 | &self.syntax | ||
224 | } | ||
225 | } | ||
226 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
227 | pub struct LAngle { | ||
228 | pub(crate) syntax: SyntaxToken, | ||
229 | } | ||
230 | impl std::fmt::Display for LAngle { | ||
231 | fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { | ||
232 | std::fmt::Display::fmt(&self.syntax, f) | ||
233 | } | ||
234 | } | ||
235 | impl AstToken for LAngle { | ||
236 | fn can_cast(kind: SyntaxKind) -> bool { | ||
237 | match kind { | ||
238 | L_ANGLE => true, | ||
239 | _ => false, | ||
240 | } | ||
241 | } | ||
242 | fn cast(syntax: SyntaxToken) -> Option<Self> { | ||
243 | if Self::can_cast(syntax.kind()) { | ||
244 | Some(Self { syntax }) | ||
245 | } else { | ||
246 | None | ||
247 | } | ||
248 | } | ||
249 | fn syntax(&self) -> &SyntaxToken { | ||
250 | &self.syntax | ||
251 | } | ||
252 | } | ||
253 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
254 | pub struct RAngle { | ||
255 | pub(crate) syntax: SyntaxToken, | ||
256 | } | ||
257 | impl std::fmt::Display for RAngle { | ||
258 | fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { | ||
259 | std::fmt::Display::fmt(&self.syntax, f) | ||
260 | } | ||
261 | } | ||
262 | impl AstToken for RAngle { | ||
263 | fn can_cast(kind: SyntaxKind) -> bool { | ||
264 | match kind { | ||
265 | R_ANGLE => true, | ||
266 | _ => false, | ||
267 | } | ||
268 | } | ||
269 | fn cast(syntax: SyntaxToken) -> Option<Self> { | ||
270 | if Self::can_cast(syntax.kind()) { | ||
271 | Some(Self { syntax }) | ||
272 | } else { | ||
273 | None | ||
274 | } | ||
275 | } | ||
276 | fn syntax(&self) -> &SyntaxToken { | ||
277 | &self.syntax | ||
278 | } | ||
279 | } | ||
280 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
281 | pub struct At { | ||
282 | pub(crate) syntax: SyntaxToken, | ||
283 | } | ||
284 | impl std::fmt::Display for At { | ||
285 | fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { | ||
286 | std::fmt::Display::fmt(&self.syntax, f) | ||
287 | } | ||
288 | } | ||
289 | impl AstToken for At { | ||
290 | fn can_cast(kind: SyntaxKind) -> bool { | ||
291 | match kind { | ||
292 | AT => true, | ||
293 | _ => false, | ||
294 | } | ||
295 | } | ||
296 | fn cast(syntax: SyntaxToken) -> Option<Self> { | ||
297 | if Self::can_cast(syntax.kind()) { | ||
298 | Some(Self { syntax }) | ||
299 | } else { | ||
300 | None | ||
301 | } | ||
302 | } | ||
303 | fn syntax(&self) -> &SyntaxToken { | ||
304 | &self.syntax | ||
305 | } | ||
306 | } | ||
307 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
308 | pub struct Pound { | ||
309 | pub(crate) syntax: SyntaxToken, | ||
310 | } | ||
311 | impl std::fmt::Display for Pound { | ||
312 | fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { | ||
313 | std::fmt::Display::fmt(&self.syntax, f) | ||
314 | } | ||
315 | } | ||
316 | impl AstToken for Pound { | ||
317 | fn can_cast(kind: SyntaxKind) -> bool { | ||
318 | match kind { | ||
319 | POUND => true, | ||
320 | _ => false, | ||
321 | } | ||
322 | } | ||
323 | fn cast(syntax: SyntaxToken) -> Option<Self> { | ||
324 | if Self::can_cast(syntax.kind()) { | ||
325 | Some(Self { syntax }) | ||
326 | } else { | ||
327 | None | ||
328 | } | ||
329 | } | ||
330 | fn syntax(&self) -> &SyntaxToken { | ||
331 | &self.syntax | ||
332 | } | ||
333 | } | ||
334 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
335 | pub struct Tilde { | ||
336 | pub(crate) syntax: SyntaxToken, | ||
337 | } | ||
338 | impl std::fmt::Display for Tilde { | ||
339 | fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { | ||
340 | std::fmt::Display::fmt(&self.syntax, f) | ||
341 | } | ||
342 | } | ||
343 | impl AstToken for Tilde { | ||
344 | fn can_cast(kind: SyntaxKind) -> bool { | ||
345 | match kind { | ||
346 | TILDE => true, | ||
347 | _ => false, | ||
348 | } | ||
349 | } | ||
350 | fn cast(syntax: SyntaxToken) -> Option<Self> { | ||
351 | if Self::can_cast(syntax.kind()) { | ||
352 | Some(Self { syntax }) | ||
353 | } else { | ||
354 | None | ||
355 | } | ||
356 | } | ||
357 | fn syntax(&self) -> &SyntaxToken { | ||
358 | &self.syntax | ||
359 | } | ||
360 | } | ||
361 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
362 | pub struct Question { | ||
363 | pub(crate) syntax: SyntaxToken, | ||
364 | } | ||
365 | impl std::fmt::Display for Question { | ||
366 | fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { | ||
367 | std::fmt::Display::fmt(&self.syntax, f) | ||
368 | } | ||
369 | } | ||
370 | impl AstToken for Question { | ||
371 | fn can_cast(kind: SyntaxKind) -> bool { | ||
372 | match kind { | ||
373 | QUESTION => true, | ||
374 | _ => false, | ||
375 | } | ||
376 | } | ||
377 | fn cast(syntax: SyntaxToken) -> Option<Self> { | ||
378 | if Self::can_cast(syntax.kind()) { | ||
379 | Some(Self { syntax }) | ||
380 | } else { | ||
381 | None | ||
382 | } | ||
383 | } | ||
384 | fn syntax(&self) -> &SyntaxToken { | ||
385 | &self.syntax | ||
386 | } | ||
387 | } | ||
388 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
389 | pub struct Dollar { | ||
390 | pub(crate) syntax: SyntaxToken, | ||
391 | } | ||
392 | impl std::fmt::Display for Dollar { | ||
393 | fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { | ||
394 | std::fmt::Display::fmt(&self.syntax, f) | ||
395 | } | ||
396 | } | ||
397 | impl AstToken for Dollar { | ||
398 | fn can_cast(kind: SyntaxKind) -> bool { | ||
399 | match kind { | ||
400 | DOLLAR => true, | ||
401 | _ => false, | ||
402 | } | ||
403 | } | ||
404 | fn cast(syntax: SyntaxToken) -> Option<Self> { | ||
405 | if Self::can_cast(syntax.kind()) { | ||
406 | Some(Self { syntax }) | ||
407 | } else { | ||
408 | None | ||
409 | } | ||
410 | } | ||
411 | fn syntax(&self) -> &SyntaxToken { | ||
412 | &self.syntax | ||
413 | } | ||
414 | } | ||
415 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
416 | pub struct Amp { | ||
417 | pub(crate) syntax: SyntaxToken, | ||
418 | } | ||
419 | impl std::fmt::Display for Amp { | ||
420 | fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { | ||
421 | std::fmt::Display::fmt(&self.syntax, f) | ||
422 | } | ||
423 | } | ||
424 | impl AstToken for Amp { | ||
425 | fn can_cast(kind: SyntaxKind) -> bool { | ||
426 | match kind { | ||
427 | AMP => true, | ||
428 | _ => false, | ||
429 | } | ||
430 | } | ||
431 | fn cast(syntax: SyntaxToken) -> Option<Self> { | ||
432 | if Self::can_cast(syntax.kind()) { | ||
433 | Some(Self { syntax }) | ||
434 | } else { | ||
435 | None | ||
436 | } | ||
437 | } | ||
438 | fn syntax(&self) -> &SyntaxToken { | ||
439 | &self.syntax | ||
440 | } | ||
441 | } | ||
442 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
443 | pub struct Pipe { | ||
444 | pub(crate) syntax: SyntaxToken, | ||
445 | } | ||
446 | impl std::fmt::Display for Pipe { | ||
447 | fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { | ||
448 | std::fmt::Display::fmt(&self.syntax, f) | ||
449 | } | ||
450 | } | ||
451 | impl AstToken for Pipe { | ||
452 | fn can_cast(kind: SyntaxKind) -> bool { | ||
453 | match kind { | ||
454 | PIPE => true, | ||
455 | _ => false, | ||
456 | } | ||
457 | } | ||
458 | fn cast(syntax: SyntaxToken) -> Option<Self> { | ||
459 | if Self::can_cast(syntax.kind()) { | ||
460 | Some(Self { syntax }) | ||
461 | } else { | ||
462 | None | ||
463 | } | ||
464 | } | ||
465 | fn syntax(&self) -> &SyntaxToken { | ||
466 | &self.syntax | ||
467 | } | ||
468 | } | ||
469 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
470 | pub struct Plus { | ||
471 | pub(crate) syntax: SyntaxToken, | ||
472 | } | ||
473 | impl std::fmt::Display for Plus { | ||
474 | fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { | ||
475 | std::fmt::Display::fmt(&self.syntax, f) | ||
476 | } | ||
477 | } | ||
478 | impl AstToken for Plus { | ||
479 | fn can_cast(kind: SyntaxKind) -> bool { | ||
480 | match kind { | ||
481 | PLUS => true, | ||
482 | _ => false, | ||
483 | } | ||
484 | } | ||
485 | fn cast(syntax: SyntaxToken) -> Option<Self> { | ||
486 | if Self::can_cast(syntax.kind()) { | ||
487 | Some(Self { syntax }) | ||
488 | } else { | ||
489 | None | ||
490 | } | ||
491 | } | ||
492 | fn syntax(&self) -> &SyntaxToken { | ||
493 | &self.syntax | ||
494 | } | ||
495 | } | ||
496 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
497 | pub struct Star { | ||
498 | pub(crate) syntax: SyntaxToken, | ||
499 | } | ||
500 | impl std::fmt::Display for Star { | ||
501 | fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { | ||
502 | std::fmt::Display::fmt(&self.syntax, f) | ||
503 | } | ||
504 | } | ||
505 | impl AstToken for Star { | ||
506 | fn can_cast(kind: SyntaxKind) -> bool { | ||
507 | match kind { | ||
508 | STAR => true, | ||
509 | _ => false, | ||
510 | } | ||
511 | } | ||
512 | fn cast(syntax: SyntaxToken) -> Option<Self> { | ||
513 | if Self::can_cast(syntax.kind()) { | ||
514 | Some(Self { syntax }) | ||
515 | } else { | ||
516 | None | ||
517 | } | ||
518 | } | ||
519 | fn syntax(&self) -> &SyntaxToken { | ||
520 | &self.syntax | ||
521 | } | ||
522 | } | ||
523 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
524 | pub struct Slash { | ||
525 | pub(crate) syntax: SyntaxToken, | ||
526 | } | ||
527 | impl std::fmt::Display for Slash { | ||
528 | fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { | ||
529 | std::fmt::Display::fmt(&self.syntax, f) | ||
530 | } | ||
531 | } | ||
532 | impl AstToken for Slash { | ||
533 | fn can_cast(kind: SyntaxKind) -> bool { | ||
534 | match kind { | ||
535 | SLASH => true, | ||
536 | _ => false, | ||
537 | } | ||
538 | } | ||
539 | fn cast(syntax: SyntaxToken) -> Option<Self> { | ||
540 | if Self::can_cast(syntax.kind()) { | ||
541 | Some(Self { syntax }) | ||
542 | } else { | ||
543 | None | ||
544 | } | ||
545 | } | ||
546 | fn syntax(&self) -> &SyntaxToken { | ||
547 | &self.syntax | ||
548 | } | ||
549 | } | ||
550 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
551 | pub struct Caret { | ||
552 | pub(crate) syntax: SyntaxToken, | ||
553 | } | ||
554 | impl std::fmt::Display for Caret { | ||
555 | fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { | ||
556 | std::fmt::Display::fmt(&self.syntax, f) | ||
557 | } | ||
558 | } | ||
559 | impl AstToken for Caret { | ||
560 | fn can_cast(kind: SyntaxKind) -> bool { | ||
561 | match kind { | ||
562 | CARET => true, | ||
563 | _ => false, | ||
564 | } | ||
565 | } | ||
566 | fn cast(syntax: SyntaxToken) -> Option<Self> { | ||
567 | if Self::can_cast(syntax.kind()) { | ||
568 | Some(Self { syntax }) | ||
569 | } else { | ||
570 | None | ||
571 | } | ||
572 | } | ||
573 | fn syntax(&self) -> &SyntaxToken { | ||
574 | &self.syntax | ||
575 | } | ||
576 | } | ||
577 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
578 | pub struct Percent { | ||
579 | pub(crate) syntax: SyntaxToken, | ||
580 | } | ||
581 | impl std::fmt::Display for Percent { | ||
582 | fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { | ||
583 | std::fmt::Display::fmt(&self.syntax, f) | ||
584 | } | ||
585 | } | ||
586 | impl AstToken for Percent { | ||
587 | fn can_cast(kind: SyntaxKind) -> bool { | ||
588 | match kind { | ||
589 | PERCENT => true, | ||
590 | _ => false, | ||
591 | } | ||
592 | } | ||
593 | fn cast(syntax: SyntaxToken) -> Option<Self> { | ||
594 | if Self::can_cast(syntax.kind()) { | ||
595 | Some(Self { syntax }) | ||
596 | } else { | ||
597 | None | ||
598 | } | ||
599 | } | ||
600 | fn syntax(&self) -> &SyntaxToken { | ||
601 | &self.syntax | ||
602 | } | ||
603 | } | ||
604 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
605 | pub struct Underscore { | ||
606 | pub(crate) syntax: SyntaxToken, | ||
607 | } | ||
608 | impl std::fmt::Display for Underscore { | ||
609 | fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { | ||
610 | std::fmt::Display::fmt(&self.syntax, f) | ||
611 | } | ||
612 | } | ||
613 | impl AstToken for Underscore { | ||
614 | fn can_cast(kind: SyntaxKind) -> bool { | ||
615 | match kind { | ||
616 | UNDERSCORE => true, | ||
617 | _ => false, | ||
618 | } | ||
619 | } | ||
620 | fn cast(syntax: SyntaxToken) -> Option<Self> { | ||
621 | if Self::can_cast(syntax.kind()) { | ||
622 | Some(Self { syntax }) | ||
623 | } else { | ||
624 | None | ||
625 | } | ||
626 | } | ||
627 | fn syntax(&self) -> &SyntaxToken { | ||
628 | &self.syntax | ||
629 | } | ||
630 | } | ||
631 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
632 | pub struct Dot { | ||
633 | pub(crate) syntax: SyntaxToken, | ||
634 | } | ||
635 | impl std::fmt::Display for Dot { | ||
636 | fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { | ||
637 | std::fmt::Display::fmt(&self.syntax, f) | ||
638 | } | ||
639 | } | ||
640 | impl AstToken for Dot { | ||
641 | fn can_cast(kind: SyntaxKind) -> bool { | ||
642 | match kind { | ||
643 | DOT => true, | ||
644 | _ => false, | ||
645 | } | ||
646 | } | ||
647 | fn cast(syntax: SyntaxToken) -> Option<Self> { | ||
648 | if Self::can_cast(syntax.kind()) { | ||
649 | Some(Self { syntax }) | ||
650 | } else { | ||
651 | None | ||
652 | } | ||
653 | } | ||
654 | fn syntax(&self) -> &SyntaxToken { | ||
655 | &self.syntax | ||
656 | } | ||
657 | } | ||
658 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
659 | pub struct Dotdot { | ||
660 | pub(crate) syntax: SyntaxToken, | ||
661 | } | ||
662 | impl std::fmt::Display for Dotdot { | ||
663 | fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { | ||
664 | std::fmt::Display::fmt(&self.syntax, f) | ||
665 | } | ||
666 | } | ||
667 | impl AstToken for Dotdot { | ||
668 | fn can_cast(kind: SyntaxKind) -> bool { | ||
669 | match kind { | ||
670 | DOTDOT => true, | ||
671 | _ => false, | ||
672 | } | ||
673 | } | ||
674 | fn cast(syntax: SyntaxToken) -> Option<Self> { | ||
675 | if Self::can_cast(syntax.kind()) { | ||
676 | Some(Self { syntax }) | ||
677 | } else { | ||
678 | None | ||
679 | } | ||
680 | } | ||
681 | fn syntax(&self) -> &SyntaxToken { | ||
682 | &self.syntax | ||
683 | } | ||
684 | } | ||
685 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
686 | pub struct Dotdotdot { | ||
687 | pub(crate) syntax: SyntaxToken, | ||
688 | } | ||
689 | impl std::fmt::Display for Dotdotdot { | ||
690 | fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { | ||
691 | std::fmt::Display::fmt(&self.syntax, f) | ||
692 | } | ||
693 | } | ||
694 | impl AstToken for Dotdotdot { | ||
695 | fn can_cast(kind: SyntaxKind) -> bool { | ||
696 | match kind { | ||
697 | DOTDOTDOT => true, | ||
698 | _ => false, | ||
699 | } | ||
700 | } | ||
701 | fn cast(syntax: SyntaxToken) -> Option<Self> { | ||
702 | if Self::can_cast(syntax.kind()) { | ||
703 | Some(Self { syntax }) | ||
704 | } else { | ||
705 | None | ||
706 | } | ||
707 | } | ||
708 | fn syntax(&self) -> &SyntaxToken { | ||
709 | &self.syntax | ||
710 | } | ||
711 | } | ||
712 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
713 | pub struct Dotdoteq { | ||
714 | pub(crate) syntax: SyntaxToken, | ||
715 | } | ||
716 | impl std::fmt::Display for Dotdoteq { | ||
717 | fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { | ||
718 | std::fmt::Display::fmt(&self.syntax, f) | ||
719 | } | ||
720 | } | ||
721 | impl AstToken for Dotdoteq { | ||
722 | fn can_cast(kind: SyntaxKind) -> bool { | ||
723 | match kind { | ||
724 | DOTDOTEQ => true, | ||
725 | _ => false, | ||
726 | } | ||
727 | } | ||
728 | fn cast(syntax: SyntaxToken) -> Option<Self> { | ||
729 | if Self::can_cast(syntax.kind()) { | ||
730 | Some(Self { syntax }) | ||
731 | } else { | ||
732 | None | ||
733 | } | ||
734 | } | ||
735 | fn syntax(&self) -> &SyntaxToken { | ||
736 | &self.syntax | ||
737 | } | ||
738 | } | ||
739 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
740 | pub struct Colon { | ||
741 | pub(crate) syntax: SyntaxToken, | ||
742 | } | ||
743 | impl std::fmt::Display for Colon { | ||
744 | fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { | ||
745 | std::fmt::Display::fmt(&self.syntax, f) | ||
746 | } | ||
747 | } | ||
748 | impl AstToken for Colon { | ||
749 | fn can_cast(kind: SyntaxKind) -> bool { | ||
750 | match kind { | ||
751 | COLON => true, | ||
752 | _ => false, | ||
753 | } | ||
754 | } | ||
755 | fn cast(syntax: SyntaxToken) -> Option<Self> { | ||
756 | if Self::can_cast(syntax.kind()) { | ||
757 | Some(Self { syntax }) | ||
758 | } else { | ||
759 | None | ||
760 | } | ||
761 | } | ||
762 | fn syntax(&self) -> &SyntaxToken { | ||
763 | &self.syntax | ||
764 | } | ||
765 | } | ||
766 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
767 | pub struct Coloncolon { | ||
768 | pub(crate) syntax: SyntaxToken, | ||
769 | } | ||
770 | impl std::fmt::Display for Coloncolon { | ||
771 | fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { | ||
772 | std::fmt::Display::fmt(&self.syntax, f) | ||
773 | } | ||
774 | } | ||
775 | impl AstToken for Coloncolon { | ||
776 | fn can_cast(kind: SyntaxKind) -> bool { | ||
777 | match kind { | ||
778 | COLONCOLON => true, | ||
779 | _ => false, | ||
780 | } | ||
781 | } | ||
782 | fn cast(syntax: SyntaxToken) -> Option<Self> { | ||
783 | if Self::can_cast(syntax.kind()) { | ||
784 | Some(Self { syntax }) | ||
785 | } else { | ||
786 | None | ||
787 | } | ||
788 | } | ||
789 | fn syntax(&self) -> &SyntaxToken { | ||
790 | &self.syntax | ||
791 | } | ||
792 | } | ||
793 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
794 | pub struct Eq { | ||
795 | pub(crate) syntax: SyntaxToken, | ||
796 | } | ||
797 | impl std::fmt::Display for Eq { | ||
798 | fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { | ||
799 | std::fmt::Display::fmt(&self.syntax, f) | ||
800 | } | ||
801 | } | ||
802 | impl AstToken for Eq { | ||
803 | fn can_cast(kind: SyntaxKind) -> bool { | ||
804 | match kind { | ||
805 | EQ => true, | ||
806 | _ => false, | ||
807 | } | ||
808 | } | ||
809 | fn cast(syntax: SyntaxToken) -> Option<Self> { | ||
810 | if Self::can_cast(syntax.kind()) { | ||
811 | Some(Self { syntax }) | ||
812 | } else { | ||
813 | None | ||
814 | } | ||
815 | } | ||
816 | fn syntax(&self) -> &SyntaxToken { | ||
817 | &self.syntax | ||
818 | } | ||
819 | } | ||
820 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
821 | pub struct Eqeq { | ||
822 | pub(crate) syntax: SyntaxToken, | ||
823 | } | ||
824 | impl std::fmt::Display for Eqeq { | ||
825 | fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { | ||
826 | std::fmt::Display::fmt(&self.syntax, f) | ||
827 | } | ||
828 | } | ||
829 | impl AstToken for Eqeq { | ||
830 | fn can_cast(kind: SyntaxKind) -> bool { | ||
831 | match kind { | ||
832 | EQEQ => true, | ||
833 | _ => false, | ||
834 | } | ||
835 | } | ||
836 | fn cast(syntax: SyntaxToken) -> Option<Self> { | ||
837 | if Self::can_cast(syntax.kind()) { | ||
838 | Some(Self { syntax }) | ||
839 | } else { | ||
840 | None | ||
841 | } | ||
842 | } | ||
843 | fn syntax(&self) -> &SyntaxToken { | ||
844 | &self.syntax | ||
845 | } | ||
846 | } | ||
847 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
848 | pub struct FatArrow { | ||
849 | pub(crate) syntax: SyntaxToken, | ||
850 | } | ||
851 | impl std::fmt::Display for FatArrow { | ||
852 | fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { | ||
853 | std::fmt::Display::fmt(&self.syntax, f) | ||
854 | } | ||
855 | } | ||
856 | impl AstToken for FatArrow { | ||
857 | fn can_cast(kind: SyntaxKind) -> bool { | ||
858 | match kind { | ||
859 | FAT_ARROW => true, | ||
860 | _ => false, | ||
861 | } | ||
862 | } | ||
863 | fn cast(syntax: SyntaxToken) -> Option<Self> { | ||
864 | if Self::can_cast(syntax.kind()) { | ||
865 | Some(Self { syntax }) | ||
866 | } else { | ||
867 | None | ||
868 | } | ||
869 | } | ||
870 | fn syntax(&self) -> &SyntaxToken { | ||
871 | &self.syntax | ||
872 | } | ||
873 | } | ||
874 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
875 | pub struct Excl { | ||
876 | pub(crate) syntax: SyntaxToken, | ||
877 | } | ||
878 | impl std::fmt::Display for Excl { | ||
879 | fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { | ||
880 | std::fmt::Display::fmt(&self.syntax, f) | ||
881 | } | ||
882 | } | ||
883 | impl AstToken for Excl { | ||
884 | fn can_cast(kind: SyntaxKind) -> bool { | ||
885 | match kind { | ||
886 | EXCL => true, | ||
887 | _ => false, | ||
888 | } | ||
889 | } | ||
890 | fn cast(syntax: SyntaxToken) -> Option<Self> { | ||
891 | if Self::can_cast(syntax.kind()) { | ||
892 | Some(Self { syntax }) | ||
893 | } else { | ||
894 | None | ||
895 | } | ||
896 | } | ||
897 | fn syntax(&self) -> &SyntaxToken { | ||
898 | &self.syntax | ||
899 | } | ||
900 | } | ||
901 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
902 | pub struct Neq { | ||
903 | pub(crate) syntax: SyntaxToken, | ||
904 | } | ||
905 | impl std::fmt::Display for Neq { | ||
906 | fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { | ||
907 | std::fmt::Display::fmt(&self.syntax, f) | ||
908 | } | ||
909 | } | ||
910 | impl AstToken for Neq { | ||
911 | fn can_cast(kind: SyntaxKind) -> bool { | ||
912 | match kind { | ||
913 | NEQ => true, | ||
914 | _ => false, | ||
915 | } | ||
916 | } | ||
917 | fn cast(syntax: SyntaxToken) -> Option<Self> { | ||
918 | if Self::can_cast(syntax.kind()) { | ||
919 | Some(Self { syntax }) | ||
920 | } else { | ||
921 | None | ||
922 | } | ||
923 | } | ||
924 | fn syntax(&self) -> &SyntaxToken { | ||
925 | &self.syntax | ||
926 | } | ||
927 | } | ||
928 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
929 | pub struct Minus { | ||
930 | pub(crate) syntax: SyntaxToken, | ||
931 | } | ||
932 | impl std::fmt::Display for Minus { | ||
933 | fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { | ||
934 | std::fmt::Display::fmt(&self.syntax, f) | ||
935 | } | ||
936 | } | ||
937 | impl AstToken for Minus { | ||
938 | fn can_cast(kind: SyntaxKind) -> bool { | ||
939 | match kind { | ||
940 | MINUS => true, | ||
941 | _ => false, | ||
942 | } | ||
943 | } | ||
944 | fn cast(syntax: SyntaxToken) -> Option<Self> { | ||
945 | if Self::can_cast(syntax.kind()) { | ||
946 | Some(Self { syntax }) | ||
947 | } else { | ||
948 | None | ||
949 | } | ||
950 | } | ||
951 | fn syntax(&self) -> &SyntaxToken { | ||
952 | &self.syntax | ||
953 | } | ||
954 | } | ||
955 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
956 | pub struct ThinArrow { | ||
957 | pub(crate) syntax: SyntaxToken, | ||
958 | } | ||
959 | impl std::fmt::Display for ThinArrow { | ||
960 | fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { | ||
961 | std::fmt::Display::fmt(&self.syntax, f) | ||
962 | } | ||
963 | } | ||
964 | impl AstToken for ThinArrow { | ||
965 | fn can_cast(kind: SyntaxKind) -> bool { | ||
966 | match kind { | ||
967 | THIN_ARROW => true, | ||
968 | _ => false, | ||
969 | } | ||
970 | } | ||
971 | fn cast(syntax: SyntaxToken) -> Option<Self> { | ||
972 | if Self::can_cast(syntax.kind()) { | ||
973 | Some(Self { syntax }) | ||
974 | } else { | ||
975 | None | ||
976 | } | ||
977 | } | ||
978 | fn syntax(&self) -> &SyntaxToken { | ||
979 | &self.syntax | ||
980 | } | ||
981 | } | ||
982 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
983 | pub struct Lteq { | ||
984 | pub(crate) syntax: SyntaxToken, | ||
985 | } | ||
986 | impl std::fmt::Display for Lteq { | ||
987 | fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { | ||
988 | std::fmt::Display::fmt(&self.syntax, f) | ||
989 | } | ||
990 | } | ||
991 | impl AstToken for Lteq { | ||
992 | fn can_cast(kind: SyntaxKind) -> bool { | ||
993 | match kind { | ||
994 | LTEQ => true, | ||
995 | _ => false, | ||
996 | } | ||
997 | } | ||
998 | fn cast(syntax: SyntaxToken) -> Option<Self> { | ||
999 | if Self::can_cast(syntax.kind()) { | ||
1000 | Some(Self { syntax }) | ||
1001 | } else { | ||
1002 | None | ||
1003 | } | ||
1004 | } | ||
1005 | fn syntax(&self) -> &SyntaxToken { | ||
1006 | &self.syntax | ||
1007 | } | ||
1008 | } | ||
1009 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
1010 | pub struct Gteq { | ||
1011 | pub(crate) syntax: SyntaxToken, | ||
1012 | } | ||
1013 | impl std::fmt::Display for Gteq { | ||
1014 | fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { | ||
1015 | std::fmt::Display::fmt(&self.syntax, f) | ||
1016 | } | ||
1017 | } | ||
1018 | impl AstToken for Gteq { | ||
1019 | fn can_cast(kind: SyntaxKind) -> bool { | ||
1020 | match kind { | ||
1021 | GTEQ => true, | ||
1022 | _ => false, | ||
1023 | } | ||
1024 | } | ||
1025 | fn cast(syntax: SyntaxToken) -> Option<Self> { | ||
1026 | if Self::can_cast(syntax.kind()) { | ||
1027 | Some(Self { syntax }) | ||
1028 | } else { | ||
1029 | None | ||
1030 | } | ||
1031 | } | ||
1032 | fn syntax(&self) -> &SyntaxToken { | ||
1033 | &self.syntax | ||
1034 | } | ||
1035 | } | ||
1036 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
1037 | pub struct Pluseq { | ||
1038 | pub(crate) syntax: SyntaxToken, | ||
1039 | } | ||
1040 | impl std::fmt::Display for Pluseq { | ||
1041 | fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { | ||
1042 | std::fmt::Display::fmt(&self.syntax, f) | ||
1043 | } | ||
1044 | } | ||
1045 | impl AstToken for Pluseq { | ||
1046 | fn can_cast(kind: SyntaxKind) -> bool { | ||
1047 | match kind { | ||
1048 | PLUSEQ => true, | ||
1049 | _ => false, | ||
1050 | } | ||
1051 | } | ||
1052 | fn cast(syntax: SyntaxToken) -> Option<Self> { | ||
1053 | if Self::can_cast(syntax.kind()) { | ||
1054 | Some(Self { syntax }) | ||
1055 | } else { | ||
1056 | None | ||
1057 | } | ||
1058 | } | ||
1059 | fn syntax(&self) -> &SyntaxToken { | ||
1060 | &self.syntax | ||
1061 | } | ||
1062 | } | ||
1063 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
1064 | pub struct Minuseq { | ||
1065 | pub(crate) syntax: SyntaxToken, | ||
1066 | } | ||
1067 | impl std::fmt::Display for Minuseq { | ||
1068 | fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { | ||
1069 | std::fmt::Display::fmt(&self.syntax, f) | ||
1070 | } | ||
1071 | } | ||
1072 | impl AstToken for Minuseq { | ||
1073 | fn can_cast(kind: SyntaxKind) -> bool { | ||
1074 | match kind { | ||
1075 | MINUSEQ => true, | ||
1076 | _ => false, | ||
1077 | } | ||
1078 | } | ||
1079 | fn cast(syntax: SyntaxToken) -> Option<Self> { | ||
1080 | if Self::can_cast(syntax.kind()) { | ||
1081 | Some(Self { syntax }) | ||
1082 | } else { | ||
1083 | None | ||
1084 | } | ||
1085 | } | ||
1086 | fn syntax(&self) -> &SyntaxToken { | ||
1087 | &self.syntax | ||
1088 | } | ||
1089 | } | ||
1090 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
1091 | pub struct Pipeeq { | ||
1092 | pub(crate) syntax: SyntaxToken, | ||
1093 | } | ||
1094 | impl std::fmt::Display for Pipeeq { | ||
1095 | fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { | ||
1096 | std::fmt::Display::fmt(&self.syntax, f) | ||
1097 | } | ||
1098 | } | ||
1099 | impl AstToken for Pipeeq { | ||
1100 | fn can_cast(kind: SyntaxKind) -> bool { | ||
1101 | match kind { | ||
1102 | PIPEEQ => true, | ||
1103 | _ => false, | ||
1104 | } | ||
1105 | } | ||
1106 | fn cast(syntax: SyntaxToken) -> Option<Self> { | ||
1107 | if Self::can_cast(syntax.kind()) { | ||
1108 | Some(Self { syntax }) | ||
1109 | } else { | ||
1110 | None | ||
1111 | } | ||
1112 | } | ||
1113 | fn syntax(&self) -> &SyntaxToken { | ||
1114 | &self.syntax | ||
1115 | } | ||
1116 | } | ||
1117 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
1118 | pub struct Ampeq { | ||
1119 | pub(crate) syntax: SyntaxToken, | ||
1120 | } | ||
1121 | impl std::fmt::Display for Ampeq { | ||
1122 | fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { | ||
1123 | std::fmt::Display::fmt(&self.syntax, f) | ||
1124 | } | ||
1125 | } | ||
1126 | impl AstToken for Ampeq { | ||
1127 | fn can_cast(kind: SyntaxKind) -> bool { | ||
1128 | match kind { | ||
1129 | AMPEQ => true, | ||
1130 | _ => false, | ||
1131 | } | ||
1132 | } | ||
1133 | fn cast(syntax: SyntaxToken) -> Option<Self> { | ||
1134 | if Self::can_cast(syntax.kind()) { | ||
1135 | Some(Self { syntax }) | ||
1136 | } else { | ||
1137 | None | ||
1138 | } | ||
1139 | } | ||
1140 | fn syntax(&self) -> &SyntaxToken { | ||
1141 | &self.syntax | ||
1142 | } | ||
1143 | } | ||
1144 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
1145 | pub struct Careteq { | ||
1146 | pub(crate) syntax: SyntaxToken, | ||
1147 | } | ||
1148 | impl std::fmt::Display for Careteq { | ||
1149 | fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { | ||
1150 | std::fmt::Display::fmt(&self.syntax, f) | ||
1151 | } | ||
1152 | } | ||
1153 | impl AstToken for Careteq { | ||
1154 | fn can_cast(kind: SyntaxKind) -> bool { | ||
1155 | match kind { | ||
1156 | CARETEQ => true, | ||
1157 | _ => false, | ||
1158 | } | ||
1159 | } | ||
1160 | fn cast(syntax: SyntaxToken) -> Option<Self> { | ||
1161 | if Self::can_cast(syntax.kind()) { | ||
1162 | Some(Self { syntax }) | ||
1163 | } else { | ||
1164 | None | ||
1165 | } | ||
1166 | } | ||
1167 | fn syntax(&self) -> &SyntaxToken { | ||
1168 | &self.syntax | ||
1169 | } | ||
1170 | } | ||
1171 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
1172 | pub struct Slasheq { | ||
1173 | pub(crate) syntax: SyntaxToken, | ||
1174 | } | ||
1175 | impl std::fmt::Display for Slasheq { | ||
1176 | fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { | ||
1177 | std::fmt::Display::fmt(&self.syntax, f) | ||
1178 | } | ||
1179 | } | ||
1180 | impl AstToken for Slasheq { | ||
1181 | fn can_cast(kind: SyntaxKind) -> bool { | ||
1182 | match kind { | ||
1183 | SLASHEQ => true, | ||
1184 | _ => false, | ||
1185 | } | ||
1186 | } | ||
1187 | fn cast(syntax: SyntaxToken) -> Option<Self> { | ||
1188 | if Self::can_cast(syntax.kind()) { | ||
1189 | Some(Self { syntax }) | ||
1190 | } else { | ||
1191 | None | ||
1192 | } | ||
1193 | } | ||
1194 | fn syntax(&self) -> &SyntaxToken { | ||
1195 | &self.syntax | ||
1196 | } | ||
1197 | } | ||
1198 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
1199 | pub struct Stareq { | ||
1200 | pub(crate) syntax: SyntaxToken, | ||
1201 | } | ||
1202 | impl std::fmt::Display for Stareq { | ||
1203 | fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { | ||
1204 | std::fmt::Display::fmt(&self.syntax, f) | ||
1205 | } | ||
1206 | } | ||
1207 | impl AstToken for Stareq { | ||
1208 | fn can_cast(kind: SyntaxKind) -> bool { | ||
1209 | match kind { | ||
1210 | STAREQ => true, | ||
1211 | _ => false, | ||
1212 | } | ||
1213 | } | ||
1214 | fn cast(syntax: SyntaxToken) -> Option<Self> { | ||
1215 | if Self::can_cast(syntax.kind()) { | ||
1216 | Some(Self { syntax }) | ||
1217 | } else { | ||
1218 | None | ||
1219 | } | ||
1220 | } | ||
1221 | fn syntax(&self) -> &SyntaxToken { | ||
1222 | &self.syntax | ||
1223 | } | ||
1224 | } | ||
1225 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
1226 | pub struct Percenteq { | ||
1227 | pub(crate) syntax: SyntaxToken, | ||
1228 | } | ||
1229 | impl std::fmt::Display for Percenteq { | ||
1230 | fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { | ||
1231 | std::fmt::Display::fmt(&self.syntax, f) | ||
1232 | } | ||
1233 | } | ||
1234 | impl AstToken for Percenteq { | ||
1235 | fn can_cast(kind: SyntaxKind) -> bool { | ||
1236 | match kind { | ||
1237 | PERCENTEQ => true, | ||
1238 | _ => false, | ||
1239 | } | ||
1240 | } | ||
1241 | fn cast(syntax: SyntaxToken) -> Option<Self> { | ||
1242 | if Self::can_cast(syntax.kind()) { | ||
1243 | Some(Self { syntax }) | ||
1244 | } else { | ||
1245 | None | ||
1246 | } | ||
1247 | } | ||
1248 | fn syntax(&self) -> &SyntaxToken { | ||
1249 | &self.syntax | ||
1250 | } | ||
1251 | } | ||
1252 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
1253 | pub struct Ampamp { | ||
1254 | pub(crate) syntax: SyntaxToken, | ||
1255 | } | ||
1256 | impl std::fmt::Display for Ampamp { | ||
1257 | fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { | ||
1258 | std::fmt::Display::fmt(&self.syntax, f) | ||
1259 | } | ||
1260 | } | ||
1261 | impl AstToken for Ampamp { | ||
1262 | fn can_cast(kind: SyntaxKind) -> bool { | ||
1263 | match kind { | ||
1264 | AMPAMP => true, | ||
1265 | _ => false, | ||
1266 | } | ||
1267 | } | ||
1268 | fn cast(syntax: SyntaxToken) -> Option<Self> { | ||
1269 | if Self::can_cast(syntax.kind()) { | ||
1270 | Some(Self { syntax }) | ||
1271 | } else { | ||
1272 | None | ||
1273 | } | ||
1274 | } | ||
1275 | fn syntax(&self) -> &SyntaxToken { | ||
1276 | &self.syntax | ||
1277 | } | ||
1278 | } | ||
1279 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
1280 | pub struct Pipepipe { | ||
1281 | pub(crate) syntax: SyntaxToken, | ||
1282 | } | ||
1283 | impl std::fmt::Display for Pipepipe { | ||
1284 | fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { | ||
1285 | std::fmt::Display::fmt(&self.syntax, f) | ||
1286 | } | ||
1287 | } | ||
1288 | impl AstToken for Pipepipe { | ||
1289 | fn can_cast(kind: SyntaxKind) -> bool { | ||
1290 | match kind { | ||
1291 | PIPEPIPE => true, | ||
1292 | _ => false, | ||
1293 | } | ||
1294 | } | ||
1295 | fn cast(syntax: SyntaxToken) -> Option<Self> { | ||
1296 | if Self::can_cast(syntax.kind()) { | ||
1297 | Some(Self { syntax }) | ||
1298 | } else { | ||
1299 | None | ||
1300 | } | ||
1301 | } | ||
1302 | fn syntax(&self) -> &SyntaxToken { | ||
1303 | &self.syntax | ||
1304 | } | ||
1305 | } | ||
1306 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
1307 | pub struct Shl { | ||
1308 | pub(crate) syntax: SyntaxToken, | ||
1309 | } | ||
1310 | impl std::fmt::Display for Shl { | ||
1311 | fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { | ||
1312 | std::fmt::Display::fmt(&self.syntax, f) | ||
1313 | } | ||
1314 | } | ||
1315 | impl AstToken for Shl { | ||
1316 | fn can_cast(kind: SyntaxKind) -> bool { | ||
1317 | match kind { | ||
1318 | SHL => true, | ||
1319 | _ => false, | ||
1320 | } | ||
1321 | } | ||
1322 | fn cast(syntax: SyntaxToken) -> Option<Self> { | ||
1323 | if Self::can_cast(syntax.kind()) { | ||
1324 | Some(Self { syntax }) | ||
1325 | } else { | ||
1326 | None | ||
1327 | } | ||
1328 | } | ||
1329 | fn syntax(&self) -> &SyntaxToken { | ||
1330 | &self.syntax | ||
1331 | } | ||
1332 | } | ||
1333 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
1334 | pub struct Shr { | ||
1335 | pub(crate) syntax: SyntaxToken, | ||
1336 | } | ||
1337 | impl std::fmt::Display for Shr { | ||
1338 | fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { | ||
1339 | std::fmt::Display::fmt(&self.syntax, f) | ||
1340 | } | ||
1341 | } | ||
1342 | impl AstToken for Shr { | ||
1343 | fn can_cast(kind: SyntaxKind) -> bool { | ||
1344 | match kind { | ||
1345 | SHR => true, | ||
1346 | _ => false, | ||
1347 | } | ||
1348 | } | ||
1349 | fn cast(syntax: SyntaxToken) -> Option<Self> { | ||
1350 | if Self::can_cast(syntax.kind()) { | ||
1351 | Some(Self { syntax }) | ||
1352 | } else { | ||
1353 | None | ||
1354 | } | ||
1355 | } | ||
1356 | fn syntax(&self) -> &SyntaxToken { | ||
1357 | &self.syntax | ||
1358 | } | ||
1359 | } | ||
1360 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
1361 | pub struct Shleq { | ||
1362 | pub(crate) syntax: SyntaxToken, | ||
1363 | } | ||
1364 | impl std::fmt::Display for Shleq { | ||
1365 | fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { | ||
1366 | std::fmt::Display::fmt(&self.syntax, f) | ||
1367 | } | ||
1368 | } | ||
1369 | impl AstToken for Shleq { | ||
1370 | fn can_cast(kind: SyntaxKind) -> bool { | ||
1371 | match kind { | ||
1372 | SHLEQ => true, | ||
1373 | _ => false, | ||
1374 | } | ||
1375 | } | ||
1376 | fn cast(syntax: SyntaxToken) -> Option<Self> { | ||
1377 | if Self::can_cast(syntax.kind()) { | ||
1378 | Some(Self { syntax }) | ||
1379 | } else { | ||
1380 | None | ||
1381 | } | ||
1382 | } | ||
1383 | fn syntax(&self) -> &SyntaxToken { | ||
1384 | &self.syntax | ||
1385 | } | ||
1386 | } | ||
1387 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
1388 | pub struct Shreq { | ||
1389 | pub(crate) syntax: SyntaxToken, | ||
1390 | } | ||
1391 | impl std::fmt::Display for Shreq { | ||
1392 | fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { | ||
1393 | std::fmt::Display::fmt(&self.syntax, f) | ||
1394 | } | ||
1395 | } | ||
1396 | impl AstToken for Shreq { | ||
1397 | fn can_cast(kind: SyntaxKind) -> bool { | ||
1398 | match kind { | ||
1399 | SHREQ => true, | ||
1400 | _ => false, | ||
1401 | } | ||
1402 | } | ||
1403 | fn cast(syntax: SyntaxToken) -> Option<Self> { | ||
1404 | if Self::can_cast(syntax.kind()) { | ||
1405 | Some(Self { syntax }) | ||
1406 | } else { | ||
1407 | None | ||
1408 | } | ||
1409 | } | ||
1410 | fn syntax(&self) -> &SyntaxToken { | ||
1411 | &self.syntax | ||
1412 | } | ||
1413 | } | ||
1414 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
1415 | pub struct AsKw { | ||
1416 | pub(crate) syntax: SyntaxToken, | ||
1417 | } | ||
1418 | impl std::fmt::Display for AsKw { | ||
1419 | fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { | ||
1420 | std::fmt::Display::fmt(&self.syntax, f) | ||
1421 | } | ||
1422 | } | ||
1423 | impl AstToken for AsKw { | ||
1424 | fn can_cast(kind: SyntaxKind) -> bool { | ||
1425 | match kind { | ||
1426 | AS_KW => true, | ||
1427 | _ => false, | ||
1428 | } | ||
1429 | } | ||
1430 | fn cast(syntax: SyntaxToken) -> Option<Self> { | ||
1431 | if Self::can_cast(syntax.kind()) { | ||
1432 | Some(Self { syntax }) | ||
1433 | } else { | ||
1434 | None | ||
1435 | } | ||
1436 | } | ||
1437 | fn syntax(&self) -> &SyntaxToken { | ||
1438 | &self.syntax | ||
1439 | } | ||
1440 | } | ||
1441 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
1442 | pub struct AsyncKw { | ||
1443 | pub(crate) syntax: SyntaxToken, | ||
1444 | } | ||
1445 | impl std::fmt::Display for AsyncKw { | ||
1446 | fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { | ||
1447 | std::fmt::Display::fmt(&self.syntax, f) | ||
1448 | } | ||
1449 | } | ||
1450 | impl AstToken for AsyncKw { | ||
1451 | fn can_cast(kind: SyntaxKind) -> bool { | ||
1452 | match kind { | ||
1453 | ASYNC_KW => true, | ||
1454 | _ => false, | ||
1455 | } | ||
1456 | } | ||
1457 | fn cast(syntax: SyntaxToken) -> Option<Self> { | ||
1458 | if Self::can_cast(syntax.kind()) { | ||
1459 | Some(Self { syntax }) | ||
1460 | } else { | ||
1461 | None | ||
1462 | } | ||
1463 | } | ||
1464 | fn syntax(&self) -> &SyntaxToken { | ||
1465 | &self.syntax | ||
1466 | } | ||
1467 | } | ||
1468 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
1469 | pub struct AwaitKw { | ||
1470 | pub(crate) syntax: SyntaxToken, | ||
1471 | } | ||
1472 | impl std::fmt::Display for AwaitKw { | ||
1473 | fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { | ||
1474 | std::fmt::Display::fmt(&self.syntax, f) | ||
1475 | } | ||
1476 | } | ||
1477 | impl AstToken for AwaitKw { | ||
1478 | fn can_cast(kind: SyntaxKind) -> bool { | ||
1479 | match kind { | ||
1480 | AWAIT_KW => true, | ||
1481 | _ => false, | ||
1482 | } | ||
1483 | } | ||
1484 | fn cast(syntax: SyntaxToken) -> Option<Self> { | ||
1485 | if Self::can_cast(syntax.kind()) { | ||
1486 | Some(Self { syntax }) | ||
1487 | } else { | ||
1488 | None | ||
1489 | } | ||
1490 | } | ||
1491 | fn syntax(&self) -> &SyntaxToken { | ||
1492 | &self.syntax | ||
1493 | } | ||
1494 | } | ||
1495 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
1496 | pub struct BoxKw { | ||
1497 | pub(crate) syntax: SyntaxToken, | ||
1498 | } | ||
1499 | impl std::fmt::Display for BoxKw { | ||
1500 | fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { | ||
1501 | std::fmt::Display::fmt(&self.syntax, f) | ||
1502 | } | ||
1503 | } | ||
1504 | impl AstToken for BoxKw { | ||
1505 | fn can_cast(kind: SyntaxKind) -> bool { | ||
1506 | match kind { | ||
1507 | BOX_KW => true, | ||
1508 | _ => false, | ||
1509 | } | ||
1510 | } | ||
1511 | fn cast(syntax: SyntaxToken) -> Option<Self> { | ||
1512 | if Self::can_cast(syntax.kind()) { | ||
1513 | Some(Self { syntax }) | ||
1514 | } else { | ||
1515 | None | ||
1516 | } | ||
1517 | } | ||
1518 | fn syntax(&self) -> &SyntaxToken { | ||
1519 | &self.syntax | ||
1520 | } | ||
1521 | } | ||
1522 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
1523 | pub struct BreakKw { | ||
1524 | pub(crate) syntax: SyntaxToken, | ||
1525 | } | ||
1526 | impl std::fmt::Display for BreakKw { | ||
1527 | fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { | ||
1528 | std::fmt::Display::fmt(&self.syntax, f) | ||
1529 | } | ||
1530 | } | ||
1531 | impl AstToken for BreakKw { | ||
1532 | fn can_cast(kind: SyntaxKind) -> bool { | ||
1533 | match kind { | ||
1534 | BREAK_KW => true, | ||
1535 | _ => false, | ||
1536 | } | ||
1537 | } | ||
1538 | fn cast(syntax: SyntaxToken) -> Option<Self> { | ||
1539 | if Self::can_cast(syntax.kind()) { | ||
1540 | Some(Self { syntax }) | ||
1541 | } else { | ||
1542 | None | ||
1543 | } | ||
1544 | } | ||
1545 | fn syntax(&self) -> &SyntaxToken { | ||
1546 | &self.syntax | ||
1547 | } | ||
1548 | } | ||
1549 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
1550 | pub struct ConstKw { | ||
1551 | pub(crate) syntax: SyntaxToken, | ||
1552 | } | ||
1553 | impl std::fmt::Display for ConstKw { | ||
1554 | fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { | ||
1555 | std::fmt::Display::fmt(&self.syntax, f) | ||
1556 | } | ||
1557 | } | ||
1558 | impl AstToken for ConstKw { | ||
1559 | fn can_cast(kind: SyntaxKind) -> bool { | ||
1560 | match kind { | ||
1561 | CONST_KW => true, | ||
1562 | _ => false, | ||
1563 | } | ||
1564 | } | ||
1565 | fn cast(syntax: SyntaxToken) -> Option<Self> { | ||
1566 | if Self::can_cast(syntax.kind()) { | ||
1567 | Some(Self { syntax }) | ||
1568 | } else { | ||
1569 | None | ||
1570 | } | ||
1571 | } | ||
1572 | fn syntax(&self) -> &SyntaxToken { | ||
1573 | &self.syntax | ||
1574 | } | ||
1575 | } | ||
1576 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
1577 | pub struct ContinueKw { | ||
1578 | pub(crate) syntax: SyntaxToken, | ||
1579 | } | ||
1580 | impl std::fmt::Display for ContinueKw { | ||
1581 | fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { | ||
1582 | std::fmt::Display::fmt(&self.syntax, f) | ||
1583 | } | ||
1584 | } | ||
1585 | impl AstToken for ContinueKw { | ||
1586 | fn can_cast(kind: SyntaxKind) -> bool { | ||
1587 | match kind { | ||
1588 | CONTINUE_KW => true, | ||
1589 | _ => false, | ||
1590 | } | ||
1591 | } | ||
1592 | fn cast(syntax: SyntaxToken) -> Option<Self> { | ||
1593 | if Self::can_cast(syntax.kind()) { | ||
1594 | Some(Self { syntax }) | ||
1595 | } else { | ||
1596 | None | ||
1597 | } | ||
1598 | } | ||
1599 | fn syntax(&self) -> &SyntaxToken { | ||
1600 | &self.syntax | ||
1601 | } | ||
1602 | } | ||
1603 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
1604 | pub struct CrateKw { | ||
1605 | pub(crate) syntax: SyntaxToken, | ||
1606 | } | ||
1607 | impl std::fmt::Display for CrateKw { | ||
1608 | fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { | ||
1609 | std::fmt::Display::fmt(&self.syntax, f) | ||
1610 | } | ||
1611 | } | ||
1612 | impl AstToken for CrateKw { | ||
1613 | fn can_cast(kind: SyntaxKind) -> bool { | ||
1614 | match kind { | ||
1615 | CRATE_KW => true, | ||
1616 | _ => false, | ||
1617 | } | ||
1618 | } | ||
1619 | fn cast(syntax: SyntaxToken) -> Option<Self> { | ||
1620 | if Self::can_cast(syntax.kind()) { | ||
1621 | Some(Self { syntax }) | ||
1622 | } else { | ||
1623 | None | ||
1624 | } | ||
1625 | } | ||
1626 | fn syntax(&self) -> &SyntaxToken { | ||
1627 | &self.syntax | ||
1628 | } | ||
1629 | } | ||
1630 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
1631 | pub struct DynKw { | ||
1632 | pub(crate) syntax: SyntaxToken, | ||
1633 | } | ||
1634 | impl std::fmt::Display for DynKw { | ||
1635 | fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { | ||
1636 | std::fmt::Display::fmt(&self.syntax, f) | ||
1637 | } | ||
1638 | } | ||
1639 | impl AstToken for DynKw { | ||
1640 | fn can_cast(kind: SyntaxKind) -> bool { | ||
1641 | match kind { | ||
1642 | DYN_KW => true, | ||
1643 | _ => false, | ||
1644 | } | ||
1645 | } | ||
1646 | fn cast(syntax: SyntaxToken) -> Option<Self> { | ||
1647 | if Self::can_cast(syntax.kind()) { | ||
1648 | Some(Self { syntax }) | ||
1649 | } else { | ||
1650 | None | ||
1651 | } | ||
1652 | } | ||
1653 | fn syntax(&self) -> &SyntaxToken { | ||
1654 | &self.syntax | ||
1655 | } | ||
1656 | } | ||
1657 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
1658 | pub struct ElseKw { | ||
1659 | pub(crate) syntax: SyntaxToken, | ||
1660 | } | ||
1661 | impl std::fmt::Display for ElseKw { | ||
1662 | fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { | ||
1663 | std::fmt::Display::fmt(&self.syntax, f) | ||
1664 | } | ||
1665 | } | ||
1666 | impl AstToken for ElseKw { | ||
1667 | fn can_cast(kind: SyntaxKind) -> bool { | ||
1668 | match kind { | ||
1669 | ELSE_KW => true, | ||
1670 | _ => false, | ||
1671 | } | ||
1672 | } | ||
1673 | fn cast(syntax: SyntaxToken) -> Option<Self> { | ||
1674 | if Self::can_cast(syntax.kind()) { | ||
1675 | Some(Self { syntax }) | ||
1676 | } else { | ||
1677 | None | ||
1678 | } | ||
1679 | } | ||
1680 | fn syntax(&self) -> &SyntaxToken { | ||
1681 | &self.syntax | ||
1682 | } | ||
1683 | } | ||
1684 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
1685 | pub struct EnumKw { | ||
1686 | pub(crate) syntax: SyntaxToken, | ||
1687 | } | ||
1688 | impl std::fmt::Display for EnumKw { | ||
1689 | fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { | ||
1690 | std::fmt::Display::fmt(&self.syntax, f) | ||
1691 | } | ||
1692 | } | ||
1693 | impl AstToken for EnumKw { | ||
1694 | fn can_cast(kind: SyntaxKind) -> bool { | ||
1695 | match kind { | ||
1696 | ENUM_KW => true, | ||
1697 | _ => false, | ||
1698 | } | ||
1699 | } | ||
1700 | fn cast(syntax: SyntaxToken) -> Option<Self> { | ||
1701 | if Self::can_cast(syntax.kind()) { | ||
1702 | Some(Self { syntax }) | ||
1703 | } else { | ||
1704 | None | ||
1705 | } | ||
1706 | } | ||
1707 | fn syntax(&self) -> &SyntaxToken { | ||
1708 | &self.syntax | ||
1709 | } | ||
1710 | } | ||
1711 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
1712 | pub struct ExternKw { | ||
1713 | pub(crate) syntax: SyntaxToken, | ||
1714 | } | ||
1715 | impl std::fmt::Display for ExternKw { | ||
1716 | fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { | ||
1717 | std::fmt::Display::fmt(&self.syntax, f) | ||
1718 | } | ||
1719 | } | ||
1720 | impl AstToken for ExternKw { | ||
1721 | fn can_cast(kind: SyntaxKind) -> bool { | ||
1722 | match kind { | ||
1723 | EXTERN_KW => true, | ||
1724 | _ => false, | ||
1725 | } | ||
1726 | } | ||
1727 | fn cast(syntax: SyntaxToken) -> Option<Self> { | ||
1728 | if Self::can_cast(syntax.kind()) { | ||
1729 | Some(Self { syntax }) | ||
1730 | } else { | ||
1731 | None | ||
1732 | } | ||
1733 | } | ||
1734 | fn syntax(&self) -> &SyntaxToken { | ||
1735 | &self.syntax | ||
1736 | } | ||
1737 | } | ||
1738 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
1739 | pub struct FalseKw { | ||
1740 | pub(crate) syntax: SyntaxToken, | ||
1741 | } | ||
1742 | impl std::fmt::Display for FalseKw { | ||
1743 | fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { | ||
1744 | std::fmt::Display::fmt(&self.syntax, f) | ||
1745 | } | ||
1746 | } | ||
1747 | impl AstToken for FalseKw { | ||
1748 | fn can_cast(kind: SyntaxKind) -> bool { | ||
1749 | match kind { | ||
1750 | FALSE_KW => true, | ||
1751 | _ => false, | ||
1752 | } | ||
1753 | } | ||
1754 | fn cast(syntax: SyntaxToken) -> Option<Self> { | ||
1755 | if Self::can_cast(syntax.kind()) { | ||
1756 | Some(Self { syntax }) | ||
1757 | } else { | ||
1758 | None | ||
1759 | } | ||
1760 | } | ||
1761 | fn syntax(&self) -> &SyntaxToken { | ||
1762 | &self.syntax | ||
1763 | } | ||
1764 | } | ||
1765 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
1766 | pub struct FnKw { | ||
1767 | pub(crate) syntax: SyntaxToken, | ||
1768 | } | ||
1769 | impl std::fmt::Display for FnKw { | ||
1770 | fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { | ||
1771 | std::fmt::Display::fmt(&self.syntax, f) | ||
1772 | } | ||
1773 | } | ||
1774 | impl AstToken for FnKw { | ||
1775 | fn can_cast(kind: SyntaxKind) -> bool { | ||
1776 | match kind { | ||
1777 | FN_KW => true, | ||
1778 | _ => false, | ||
1779 | } | ||
1780 | } | ||
1781 | fn cast(syntax: SyntaxToken) -> Option<Self> { | ||
1782 | if Self::can_cast(syntax.kind()) { | ||
1783 | Some(Self { syntax }) | ||
1784 | } else { | ||
1785 | None | ||
1786 | } | ||
1787 | } | ||
1788 | fn syntax(&self) -> &SyntaxToken { | ||
1789 | &self.syntax | ||
1790 | } | ||
1791 | } | ||
1792 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
1793 | pub struct ForKw { | ||
1794 | pub(crate) syntax: SyntaxToken, | ||
1795 | } | ||
1796 | impl std::fmt::Display for ForKw { | ||
1797 | fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { | ||
1798 | std::fmt::Display::fmt(&self.syntax, f) | ||
1799 | } | ||
1800 | } | ||
1801 | impl AstToken for ForKw { | ||
1802 | fn can_cast(kind: SyntaxKind) -> bool { | ||
1803 | match kind { | ||
1804 | FOR_KW => true, | ||
1805 | _ => false, | ||
1806 | } | ||
1807 | } | ||
1808 | fn cast(syntax: SyntaxToken) -> Option<Self> { | ||
1809 | if Self::can_cast(syntax.kind()) { | ||
1810 | Some(Self { syntax }) | ||
1811 | } else { | ||
1812 | None | ||
1813 | } | ||
1814 | } | ||
1815 | fn syntax(&self) -> &SyntaxToken { | ||
1816 | &self.syntax | ||
1817 | } | ||
1818 | } | ||
1819 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
1820 | pub struct IfKw { | ||
1821 | pub(crate) syntax: SyntaxToken, | ||
1822 | } | ||
1823 | impl std::fmt::Display for IfKw { | ||
1824 | fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { | ||
1825 | std::fmt::Display::fmt(&self.syntax, f) | ||
1826 | } | ||
1827 | } | ||
1828 | impl AstToken for IfKw { | ||
1829 | fn can_cast(kind: SyntaxKind) -> bool { | ||
1830 | match kind { | ||
1831 | IF_KW => true, | ||
1832 | _ => false, | ||
1833 | } | ||
1834 | } | ||
1835 | fn cast(syntax: SyntaxToken) -> Option<Self> { | ||
1836 | if Self::can_cast(syntax.kind()) { | ||
1837 | Some(Self { syntax }) | ||
1838 | } else { | ||
1839 | None | ||
1840 | } | ||
1841 | } | ||
1842 | fn syntax(&self) -> &SyntaxToken { | ||
1843 | &self.syntax | ||
1844 | } | ||
1845 | } | ||
1846 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
1847 | pub struct ImplKw { | ||
1848 | pub(crate) syntax: SyntaxToken, | ||
1849 | } | ||
1850 | impl std::fmt::Display for ImplKw { | ||
1851 | fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { | ||
1852 | std::fmt::Display::fmt(&self.syntax, f) | ||
1853 | } | ||
1854 | } | ||
1855 | impl AstToken for ImplKw { | ||
1856 | fn can_cast(kind: SyntaxKind) -> bool { | ||
1857 | match kind { | ||
1858 | IMPL_KW => true, | ||
1859 | _ => false, | ||
1860 | } | ||
1861 | } | ||
1862 | fn cast(syntax: SyntaxToken) -> Option<Self> { | ||
1863 | if Self::can_cast(syntax.kind()) { | ||
1864 | Some(Self { syntax }) | ||
1865 | } else { | ||
1866 | None | ||
1867 | } | ||
1868 | } | ||
1869 | fn syntax(&self) -> &SyntaxToken { | ||
1870 | &self.syntax | ||
1871 | } | ||
1872 | } | ||
1873 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
1874 | pub struct InKw { | ||
1875 | pub(crate) syntax: SyntaxToken, | ||
1876 | } | ||
1877 | impl std::fmt::Display for InKw { | ||
1878 | fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { | ||
1879 | std::fmt::Display::fmt(&self.syntax, f) | ||
1880 | } | ||
1881 | } | ||
1882 | impl AstToken for InKw { | ||
1883 | fn can_cast(kind: SyntaxKind) -> bool { | ||
1884 | match kind { | ||
1885 | IN_KW => true, | ||
1886 | _ => false, | ||
1887 | } | ||
1888 | } | ||
1889 | fn cast(syntax: SyntaxToken) -> Option<Self> { | ||
1890 | if Self::can_cast(syntax.kind()) { | ||
1891 | Some(Self { syntax }) | ||
1892 | } else { | ||
1893 | None | ||
1894 | } | ||
1895 | } | ||
1896 | fn syntax(&self) -> &SyntaxToken { | ||
1897 | &self.syntax | ||
1898 | } | ||
1899 | } | ||
1900 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
1901 | pub struct LetKw { | ||
1902 | pub(crate) syntax: SyntaxToken, | ||
1903 | } | ||
1904 | impl std::fmt::Display for LetKw { | ||
1905 | fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { | ||
1906 | std::fmt::Display::fmt(&self.syntax, f) | ||
1907 | } | ||
1908 | } | ||
1909 | impl AstToken for LetKw { | ||
1910 | fn can_cast(kind: SyntaxKind) -> bool { | ||
1911 | match kind { | ||
1912 | LET_KW => true, | ||
1913 | _ => false, | ||
1914 | } | ||
1915 | } | ||
1916 | fn cast(syntax: SyntaxToken) -> Option<Self> { | ||
1917 | if Self::can_cast(syntax.kind()) { | ||
1918 | Some(Self { syntax }) | ||
1919 | } else { | ||
1920 | None | ||
1921 | } | ||
1922 | } | ||
1923 | fn syntax(&self) -> &SyntaxToken { | ||
1924 | &self.syntax | ||
1925 | } | ||
1926 | } | ||
1927 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
1928 | pub struct LoopKw { | ||
1929 | pub(crate) syntax: SyntaxToken, | ||
1930 | } | ||
1931 | impl std::fmt::Display for LoopKw { | ||
1932 | fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { | ||
1933 | std::fmt::Display::fmt(&self.syntax, f) | ||
1934 | } | ||
1935 | } | ||
1936 | impl AstToken for LoopKw { | ||
1937 | fn can_cast(kind: SyntaxKind) -> bool { | ||
1938 | match kind { | ||
1939 | LOOP_KW => true, | ||
1940 | _ => false, | ||
1941 | } | ||
1942 | } | ||
1943 | fn cast(syntax: SyntaxToken) -> Option<Self> { | ||
1944 | if Self::can_cast(syntax.kind()) { | ||
1945 | Some(Self { syntax }) | ||
1946 | } else { | ||
1947 | None | ||
1948 | } | ||
1949 | } | ||
1950 | fn syntax(&self) -> &SyntaxToken { | ||
1951 | &self.syntax | ||
1952 | } | ||
1953 | } | ||
1954 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
1955 | pub struct MacroKw { | ||
1956 | pub(crate) syntax: SyntaxToken, | ||
1957 | } | ||
1958 | impl std::fmt::Display for MacroKw { | ||
1959 | fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { | ||
1960 | std::fmt::Display::fmt(&self.syntax, f) | ||
1961 | } | ||
1962 | } | ||
1963 | impl AstToken for MacroKw { | ||
1964 | fn can_cast(kind: SyntaxKind) -> bool { | ||
1965 | match kind { | ||
1966 | MACRO_KW => true, | ||
1967 | _ => false, | ||
1968 | } | ||
1969 | } | ||
1970 | fn cast(syntax: SyntaxToken) -> Option<Self> { | ||
1971 | if Self::can_cast(syntax.kind()) { | ||
1972 | Some(Self { syntax }) | ||
1973 | } else { | ||
1974 | None | ||
1975 | } | ||
1976 | } | ||
1977 | fn syntax(&self) -> &SyntaxToken { | ||
1978 | &self.syntax | ||
1979 | } | ||
1980 | } | ||
1981 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
1982 | pub struct MatchKw { | ||
1983 | pub(crate) syntax: SyntaxToken, | ||
1984 | } | ||
1985 | impl std::fmt::Display for MatchKw { | ||
1986 | fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { | ||
1987 | std::fmt::Display::fmt(&self.syntax, f) | ||
1988 | } | ||
1989 | } | ||
1990 | impl AstToken for MatchKw { | ||
1991 | fn can_cast(kind: SyntaxKind) -> bool { | ||
1992 | match kind { | ||
1993 | MATCH_KW => true, | ||
1994 | _ => false, | ||
1995 | } | ||
1996 | } | ||
1997 | fn cast(syntax: SyntaxToken) -> Option<Self> { | ||
1998 | if Self::can_cast(syntax.kind()) { | ||
1999 | Some(Self { syntax }) | ||
2000 | } else { | ||
2001 | None | ||
2002 | } | ||
2003 | } | ||
2004 | fn syntax(&self) -> &SyntaxToken { | ||
2005 | &self.syntax | ||
2006 | } | ||
2007 | } | ||
2008 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
2009 | pub struct ModKw { | ||
2010 | pub(crate) syntax: SyntaxToken, | ||
2011 | } | ||
2012 | impl std::fmt::Display for ModKw { | ||
2013 | fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { | ||
2014 | std::fmt::Display::fmt(&self.syntax, f) | ||
2015 | } | ||
2016 | } | ||
2017 | impl AstToken for ModKw { | ||
2018 | fn can_cast(kind: SyntaxKind) -> bool { | ||
2019 | match kind { | ||
2020 | MOD_KW => true, | ||
2021 | _ => false, | ||
2022 | } | ||
2023 | } | ||
2024 | fn cast(syntax: SyntaxToken) -> Option<Self> { | ||
2025 | if Self::can_cast(syntax.kind()) { | ||
2026 | Some(Self { syntax }) | ||
2027 | } else { | ||
2028 | None | ||
2029 | } | ||
2030 | } | ||
2031 | fn syntax(&self) -> &SyntaxToken { | ||
2032 | &self.syntax | ||
2033 | } | ||
2034 | } | ||
2035 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
2036 | pub struct MoveKw { | ||
2037 | pub(crate) syntax: SyntaxToken, | ||
2038 | } | ||
2039 | impl std::fmt::Display for MoveKw { | ||
2040 | fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { | ||
2041 | std::fmt::Display::fmt(&self.syntax, f) | ||
2042 | } | ||
2043 | } | ||
2044 | impl AstToken for MoveKw { | ||
2045 | fn can_cast(kind: SyntaxKind) -> bool { | ||
2046 | match kind { | ||
2047 | MOVE_KW => true, | ||
2048 | _ => false, | ||
2049 | } | ||
2050 | } | ||
2051 | fn cast(syntax: SyntaxToken) -> Option<Self> { | ||
2052 | if Self::can_cast(syntax.kind()) { | ||
2053 | Some(Self { syntax }) | ||
2054 | } else { | ||
2055 | None | ||
2056 | } | ||
2057 | } | ||
2058 | fn syntax(&self) -> &SyntaxToken { | ||
2059 | &self.syntax | ||
2060 | } | ||
2061 | } | ||
2062 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
2063 | pub struct MutKw { | ||
2064 | pub(crate) syntax: SyntaxToken, | ||
2065 | } | ||
2066 | impl std::fmt::Display for MutKw { | ||
2067 | fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { | ||
2068 | std::fmt::Display::fmt(&self.syntax, f) | ||
2069 | } | ||
2070 | } | ||
2071 | impl AstToken for MutKw { | ||
2072 | fn can_cast(kind: SyntaxKind) -> bool { | ||
2073 | match kind { | ||
2074 | MUT_KW => true, | ||
2075 | _ => false, | ||
2076 | } | ||
2077 | } | ||
2078 | fn cast(syntax: SyntaxToken) -> Option<Self> { | ||
2079 | if Self::can_cast(syntax.kind()) { | ||
2080 | Some(Self { syntax }) | ||
2081 | } else { | ||
2082 | None | ||
2083 | } | ||
2084 | } | ||
2085 | fn syntax(&self) -> &SyntaxToken { | ||
2086 | &self.syntax | ||
2087 | } | ||
2088 | } | ||
2089 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
2090 | pub struct PubKw { | ||
2091 | pub(crate) syntax: SyntaxToken, | ||
2092 | } | ||
2093 | impl std::fmt::Display for PubKw { | ||
2094 | fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { | ||
2095 | std::fmt::Display::fmt(&self.syntax, f) | ||
2096 | } | ||
2097 | } | ||
2098 | impl AstToken for PubKw { | ||
2099 | fn can_cast(kind: SyntaxKind) -> bool { | ||
2100 | match kind { | ||
2101 | PUB_KW => true, | ||
2102 | _ => false, | ||
2103 | } | ||
2104 | } | ||
2105 | fn cast(syntax: SyntaxToken) -> Option<Self> { | ||
2106 | if Self::can_cast(syntax.kind()) { | ||
2107 | Some(Self { syntax }) | ||
2108 | } else { | ||
2109 | None | ||
2110 | } | ||
2111 | } | ||
2112 | fn syntax(&self) -> &SyntaxToken { | ||
2113 | &self.syntax | ||
2114 | } | ||
2115 | } | ||
2116 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
2117 | pub struct RefKw { | ||
2118 | pub(crate) syntax: SyntaxToken, | ||
2119 | } | ||
2120 | impl std::fmt::Display for RefKw { | ||
2121 | fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { | ||
2122 | std::fmt::Display::fmt(&self.syntax, f) | ||
2123 | } | ||
2124 | } | ||
2125 | impl AstToken for RefKw { | ||
2126 | fn can_cast(kind: SyntaxKind) -> bool { | ||
2127 | match kind { | ||
2128 | REF_KW => true, | ||
2129 | _ => false, | ||
2130 | } | ||
2131 | } | ||
2132 | fn cast(syntax: SyntaxToken) -> Option<Self> { | ||
2133 | if Self::can_cast(syntax.kind()) { | ||
2134 | Some(Self { syntax }) | ||
2135 | } else { | ||
2136 | None | ||
2137 | } | ||
2138 | } | ||
2139 | fn syntax(&self) -> &SyntaxToken { | ||
2140 | &self.syntax | ||
2141 | } | ||
2142 | } | ||
2143 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
2144 | pub struct ReturnKw { | ||
2145 | pub(crate) syntax: SyntaxToken, | ||
2146 | } | ||
2147 | impl std::fmt::Display for ReturnKw { | ||
2148 | fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { | ||
2149 | std::fmt::Display::fmt(&self.syntax, f) | ||
2150 | } | ||
2151 | } | ||
2152 | impl AstToken for ReturnKw { | ||
2153 | fn can_cast(kind: SyntaxKind) -> bool { | ||
2154 | match kind { | ||
2155 | RETURN_KW => true, | ||
2156 | _ => false, | ||
2157 | } | ||
2158 | } | ||
2159 | fn cast(syntax: SyntaxToken) -> Option<Self> { | ||
2160 | if Self::can_cast(syntax.kind()) { | ||
2161 | Some(Self { syntax }) | ||
2162 | } else { | ||
2163 | None | ||
2164 | } | ||
2165 | } | ||
2166 | fn syntax(&self) -> &SyntaxToken { | ||
2167 | &self.syntax | ||
2168 | } | ||
2169 | } | ||
2170 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
2171 | pub struct SelfKw { | ||
2172 | pub(crate) syntax: SyntaxToken, | ||
2173 | } | ||
2174 | impl std::fmt::Display for SelfKw { | ||
2175 | fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { | ||
2176 | std::fmt::Display::fmt(&self.syntax, f) | ||
2177 | } | ||
2178 | } | ||
2179 | impl AstToken for SelfKw { | ||
2180 | fn can_cast(kind: SyntaxKind) -> bool { | ||
2181 | match kind { | ||
2182 | SELF_KW => true, | ||
2183 | _ => false, | ||
2184 | } | ||
2185 | } | ||
2186 | fn cast(syntax: SyntaxToken) -> Option<Self> { | ||
2187 | if Self::can_cast(syntax.kind()) { | ||
2188 | Some(Self { syntax }) | ||
2189 | } else { | ||
2190 | None | ||
2191 | } | ||
2192 | } | ||
2193 | fn syntax(&self) -> &SyntaxToken { | ||
2194 | &self.syntax | ||
2195 | } | ||
2196 | } | ||
2197 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
2198 | pub struct StaticKw { | ||
2199 | pub(crate) syntax: SyntaxToken, | ||
2200 | } | ||
2201 | impl std::fmt::Display for StaticKw { | ||
2202 | fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { | ||
2203 | std::fmt::Display::fmt(&self.syntax, f) | ||
2204 | } | ||
2205 | } | ||
2206 | impl AstToken for StaticKw { | ||
2207 | fn can_cast(kind: SyntaxKind) -> bool { | ||
2208 | match kind { | ||
2209 | STATIC_KW => true, | ||
2210 | _ => false, | ||
2211 | } | ||
2212 | } | ||
2213 | fn cast(syntax: SyntaxToken) -> Option<Self> { | ||
2214 | if Self::can_cast(syntax.kind()) { | ||
2215 | Some(Self { syntax }) | ||
2216 | } else { | ||
2217 | None | ||
2218 | } | ||
2219 | } | ||
2220 | fn syntax(&self) -> &SyntaxToken { | ||
2221 | &self.syntax | ||
2222 | } | ||
2223 | } | ||
2224 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
2225 | pub struct StructKw { | ||
2226 | pub(crate) syntax: SyntaxToken, | ||
2227 | } | ||
2228 | impl std::fmt::Display for StructKw { | ||
2229 | fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { | ||
2230 | std::fmt::Display::fmt(&self.syntax, f) | ||
2231 | } | ||
2232 | } | ||
2233 | impl AstToken for StructKw { | ||
2234 | fn can_cast(kind: SyntaxKind) -> bool { | ||
2235 | match kind { | ||
2236 | STRUCT_KW => true, | ||
2237 | _ => false, | ||
2238 | } | ||
2239 | } | ||
2240 | fn cast(syntax: SyntaxToken) -> Option<Self> { | ||
2241 | if Self::can_cast(syntax.kind()) { | ||
2242 | Some(Self { syntax }) | ||
2243 | } else { | ||
2244 | None | ||
2245 | } | ||
2246 | } | ||
2247 | fn syntax(&self) -> &SyntaxToken { | ||
2248 | &self.syntax | ||
2249 | } | ||
2250 | } | ||
2251 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
2252 | pub struct SuperKw { | ||
2253 | pub(crate) syntax: SyntaxToken, | ||
2254 | } | ||
2255 | impl std::fmt::Display for SuperKw { | ||
2256 | fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { | ||
2257 | std::fmt::Display::fmt(&self.syntax, f) | ||
2258 | } | ||
2259 | } | ||
2260 | impl AstToken for SuperKw { | ||
2261 | fn can_cast(kind: SyntaxKind) -> bool { | ||
2262 | match kind { | ||
2263 | SUPER_KW => true, | ||
2264 | _ => false, | ||
2265 | } | ||
2266 | } | ||
2267 | fn cast(syntax: SyntaxToken) -> Option<Self> { | ||
2268 | if Self::can_cast(syntax.kind()) { | ||
2269 | Some(Self { syntax }) | ||
2270 | } else { | ||
2271 | None | ||
2272 | } | ||
2273 | } | ||
2274 | fn syntax(&self) -> &SyntaxToken { | ||
2275 | &self.syntax | ||
2276 | } | ||
2277 | } | ||
2278 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
2279 | pub struct TraitKw { | ||
2280 | pub(crate) syntax: SyntaxToken, | ||
2281 | } | ||
2282 | impl std::fmt::Display for TraitKw { | ||
2283 | fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { | ||
2284 | std::fmt::Display::fmt(&self.syntax, f) | ||
2285 | } | ||
2286 | } | ||
2287 | impl AstToken for TraitKw { | ||
2288 | fn can_cast(kind: SyntaxKind) -> bool { | ||
2289 | match kind { | ||
2290 | TRAIT_KW => true, | ||
2291 | _ => false, | ||
2292 | } | ||
2293 | } | ||
2294 | fn cast(syntax: SyntaxToken) -> Option<Self> { | ||
2295 | if Self::can_cast(syntax.kind()) { | ||
2296 | Some(Self { syntax }) | ||
2297 | } else { | ||
2298 | None | ||
2299 | } | ||
2300 | } | ||
2301 | fn syntax(&self) -> &SyntaxToken { | ||
2302 | &self.syntax | ||
2303 | } | ||
2304 | } | ||
2305 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
2306 | pub struct TrueKw { | ||
2307 | pub(crate) syntax: SyntaxToken, | ||
2308 | } | ||
2309 | impl std::fmt::Display for TrueKw { | ||
2310 | fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { | ||
2311 | std::fmt::Display::fmt(&self.syntax, f) | ||
2312 | } | ||
2313 | } | ||
2314 | impl AstToken for TrueKw { | ||
2315 | fn can_cast(kind: SyntaxKind) -> bool { | ||
2316 | match kind { | ||
2317 | TRUE_KW => true, | ||
2318 | _ => false, | ||
2319 | } | ||
2320 | } | ||
2321 | fn cast(syntax: SyntaxToken) -> Option<Self> { | ||
2322 | if Self::can_cast(syntax.kind()) { | ||
2323 | Some(Self { syntax }) | ||
2324 | } else { | ||
2325 | None | ||
2326 | } | ||
2327 | } | ||
2328 | fn syntax(&self) -> &SyntaxToken { | ||
2329 | &self.syntax | ||
2330 | } | ||
2331 | } | ||
2332 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
2333 | pub struct TryKw { | ||
2334 | pub(crate) syntax: SyntaxToken, | ||
2335 | } | ||
2336 | impl std::fmt::Display for TryKw { | ||
2337 | fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { | ||
2338 | std::fmt::Display::fmt(&self.syntax, f) | ||
2339 | } | ||
2340 | } | ||
2341 | impl AstToken for TryKw { | ||
2342 | fn can_cast(kind: SyntaxKind) -> bool { | ||
2343 | match kind { | ||
2344 | TRY_KW => true, | ||
2345 | _ => false, | ||
2346 | } | ||
2347 | } | ||
2348 | fn cast(syntax: SyntaxToken) -> Option<Self> { | ||
2349 | if Self::can_cast(syntax.kind()) { | ||
2350 | Some(Self { syntax }) | ||
2351 | } else { | ||
2352 | None | ||
2353 | } | ||
2354 | } | ||
2355 | fn syntax(&self) -> &SyntaxToken { | ||
2356 | &self.syntax | ||
2357 | } | ||
2358 | } | ||
2359 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
2360 | pub struct TypeKw { | ||
2361 | pub(crate) syntax: SyntaxToken, | ||
2362 | } | ||
2363 | impl std::fmt::Display for TypeKw { | ||
2364 | fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { | ||
2365 | std::fmt::Display::fmt(&self.syntax, f) | ||
2366 | } | ||
2367 | } | ||
2368 | impl AstToken for TypeKw { | ||
2369 | fn can_cast(kind: SyntaxKind) -> bool { | ||
2370 | match kind { | ||
2371 | TYPE_KW => true, | ||
2372 | _ => false, | ||
2373 | } | ||
2374 | } | ||
2375 | fn cast(syntax: SyntaxToken) -> Option<Self> { | ||
2376 | if Self::can_cast(syntax.kind()) { | ||
2377 | Some(Self { syntax }) | ||
2378 | } else { | ||
2379 | None | ||
2380 | } | ||
2381 | } | ||
2382 | fn syntax(&self) -> &SyntaxToken { | ||
2383 | &self.syntax | ||
2384 | } | ||
2385 | } | ||
2386 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
2387 | pub struct UnsafeKw { | ||
2388 | pub(crate) syntax: SyntaxToken, | ||
2389 | } | ||
2390 | impl std::fmt::Display for UnsafeKw { | ||
2391 | fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { | ||
2392 | std::fmt::Display::fmt(&self.syntax, f) | ||
2393 | } | ||
2394 | } | ||
2395 | impl AstToken for UnsafeKw { | ||
2396 | fn can_cast(kind: SyntaxKind) -> bool { | ||
2397 | match kind { | ||
2398 | UNSAFE_KW => true, | ||
2399 | _ => false, | ||
2400 | } | ||
2401 | } | ||
2402 | fn cast(syntax: SyntaxToken) -> Option<Self> { | ||
2403 | if Self::can_cast(syntax.kind()) { | ||
2404 | Some(Self { syntax }) | ||
2405 | } else { | ||
2406 | None | ||
2407 | } | ||
2408 | } | ||
2409 | fn syntax(&self) -> &SyntaxToken { | ||
2410 | &self.syntax | ||
2411 | } | ||
2412 | } | ||
2413 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
2414 | pub struct UseKw { | ||
2415 | pub(crate) syntax: SyntaxToken, | ||
2416 | } | ||
2417 | impl std::fmt::Display for UseKw { | ||
2418 | fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { | ||
2419 | std::fmt::Display::fmt(&self.syntax, f) | ||
2420 | } | ||
2421 | } | ||
2422 | impl AstToken for UseKw { | ||
2423 | fn can_cast(kind: SyntaxKind) -> bool { | ||
2424 | match kind { | ||
2425 | USE_KW => true, | ||
2426 | _ => false, | ||
2427 | } | ||
2428 | } | ||
2429 | fn cast(syntax: SyntaxToken) -> Option<Self> { | ||
2430 | if Self::can_cast(syntax.kind()) { | ||
2431 | Some(Self { syntax }) | ||
2432 | } else { | ||
2433 | None | ||
2434 | } | ||
2435 | } | ||
2436 | fn syntax(&self) -> &SyntaxToken { | ||
2437 | &self.syntax | ||
2438 | } | ||
2439 | } | ||
2440 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
2441 | pub struct WhereKw { | ||
2442 | pub(crate) syntax: SyntaxToken, | ||
2443 | } | ||
2444 | impl std::fmt::Display for WhereKw { | ||
2445 | fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { | ||
2446 | std::fmt::Display::fmt(&self.syntax, f) | ||
2447 | } | ||
2448 | } | ||
2449 | impl AstToken for WhereKw { | ||
2450 | fn can_cast(kind: SyntaxKind) -> bool { | ||
2451 | match kind { | ||
2452 | WHERE_KW => true, | ||
2453 | _ => false, | ||
2454 | } | ||
2455 | } | ||
2456 | fn cast(syntax: SyntaxToken) -> Option<Self> { | ||
2457 | if Self::can_cast(syntax.kind()) { | ||
2458 | Some(Self { syntax }) | ||
2459 | } else { | ||
2460 | None | ||
2461 | } | ||
2462 | } | ||
2463 | fn syntax(&self) -> &SyntaxToken { | ||
2464 | &self.syntax | ||
2465 | } | ||
2466 | } | ||
2467 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
2468 | pub struct WhileKw { | ||
2469 | pub(crate) syntax: SyntaxToken, | ||
2470 | } | ||
2471 | impl std::fmt::Display for WhileKw { | ||
2472 | fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { | ||
2473 | std::fmt::Display::fmt(&self.syntax, f) | ||
2474 | } | ||
2475 | } | ||
2476 | impl AstToken for WhileKw { | ||
2477 | fn can_cast(kind: SyntaxKind) -> bool { | ||
2478 | match kind { | ||
2479 | WHILE_KW => true, | ||
2480 | _ => false, | ||
2481 | } | ||
2482 | } | ||
2483 | fn cast(syntax: SyntaxToken) -> Option<Self> { | ||
2484 | if Self::can_cast(syntax.kind()) { | ||
2485 | Some(Self { syntax }) | ||
2486 | } else { | ||
2487 | None | ||
2488 | } | ||
2489 | } | ||
2490 | fn syntax(&self) -> &SyntaxToken { | ||
2491 | &self.syntax | ||
2492 | } | ||
2493 | } | ||
2494 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
2495 | pub struct AutoKw { | ||
2496 | pub(crate) syntax: SyntaxToken, | ||
2497 | } | ||
2498 | impl std::fmt::Display for AutoKw { | ||
2499 | fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { | ||
2500 | std::fmt::Display::fmt(&self.syntax, f) | ||
2501 | } | ||
2502 | } | ||
2503 | impl AstToken for AutoKw { | ||
2504 | fn can_cast(kind: SyntaxKind) -> bool { | ||
2505 | match kind { | ||
2506 | AUTO_KW => true, | ||
2507 | _ => false, | ||
2508 | } | ||
2509 | } | ||
2510 | fn cast(syntax: SyntaxToken) -> Option<Self> { | ||
2511 | if Self::can_cast(syntax.kind()) { | ||
2512 | Some(Self { syntax }) | ||
2513 | } else { | ||
2514 | None | ||
2515 | } | ||
2516 | } | ||
2517 | fn syntax(&self) -> &SyntaxToken { | ||
2518 | &self.syntax | ||
2519 | } | ||
2520 | } | ||
2521 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
2522 | pub struct DefaultKw { | ||
2523 | pub(crate) syntax: SyntaxToken, | ||
2524 | } | ||
2525 | impl std::fmt::Display for DefaultKw { | ||
2526 | fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { | ||
2527 | std::fmt::Display::fmt(&self.syntax, f) | ||
2528 | } | ||
2529 | } | ||
2530 | impl AstToken for DefaultKw { | ||
2531 | fn can_cast(kind: SyntaxKind) -> bool { | ||
2532 | match kind { | ||
2533 | DEFAULT_KW => true, | ||
2534 | _ => false, | ||
2535 | } | ||
2536 | } | ||
2537 | fn cast(syntax: SyntaxToken) -> Option<Self> { | ||
2538 | if Self::can_cast(syntax.kind()) { | ||
2539 | Some(Self { syntax }) | ||
2540 | } else { | ||
2541 | None | ||
2542 | } | ||
2543 | } | ||
2544 | fn syntax(&self) -> &SyntaxToken { | ||
2545 | &self.syntax | ||
2546 | } | ||
2547 | } | ||
2548 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
2549 | pub struct ExistentialKw { | ||
2550 | pub(crate) syntax: SyntaxToken, | ||
2551 | } | ||
2552 | impl std::fmt::Display for ExistentialKw { | ||
2553 | fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { | ||
2554 | std::fmt::Display::fmt(&self.syntax, f) | ||
2555 | } | ||
2556 | } | ||
2557 | impl AstToken for ExistentialKw { | ||
2558 | fn can_cast(kind: SyntaxKind) -> bool { | ||
2559 | match kind { | ||
2560 | EXISTENTIAL_KW => true, | ||
2561 | _ => false, | ||
2562 | } | ||
2563 | } | ||
2564 | fn cast(syntax: SyntaxToken) -> Option<Self> { | ||
2565 | if Self::can_cast(syntax.kind()) { | ||
2566 | Some(Self { syntax }) | ||
2567 | } else { | ||
2568 | None | ||
2569 | } | ||
2570 | } | ||
2571 | fn syntax(&self) -> &SyntaxToken { | ||
2572 | &self.syntax | ||
2573 | } | ||
2574 | } | ||
2575 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
2576 | pub struct UnionKw { | ||
2577 | pub(crate) syntax: SyntaxToken, | ||
2578 | } | ||
2579 | impl std::fmt::Display for UnionKw { | ||
2580 | fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { | ||
2581 | std::fmt::Display::fmt(&self.syntax, f) | ||
2582 | } | ||
2583 | } | ||
2584 | impl AstToken for UnionKw { | ||
2585 | fn can_cast(kind: SyntaxKind) -> bool { | ||
2586 | match kind { | ||
2587 | UNION_KW => true, | ||
2588 | _ => false, | ||
2589 | } | ||
2590 | } | ||
2591 | fn cast(syntax: SyntaxToken) -> Option<Self> { | ||
2592 | if Self::can_cast(syntax.kind()) { | ||
2593 | Some(Self { syntax }) | ||
2594 | } else { | ||
2595 | None | ||
2596 | } | ||
2597 | } | ||
2598 | fn syntax(&self) -> &SyntaxToken { | ||
2599 | &self.syntax | ||
2600 | } | ||
2601 | } | ||
2602 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
2603 | pub struct RawKw { | ||
2604 | pub(crate) syntax: SyntaxToken, | ||
2605 | } | ||
2606 | impl std::fmt::Display for RawKw { | ||
2607 | fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { | ||
2608 | std::fmt::Display::fmt(&self.syntax, f) | ||
2609 | } | ||
2610 | } | ||
2611 | impl AstToken for RawKw { | ||
2612 | fn can_cast(kind: SyntaxKind) -> bool { | ||
2613 | match kind { | ||
2614 | RAW_KW => true, | ||
2615 | _ => false, | ||
2616 | } | ||
2617 | } | ||
2618 | fn cast(syntax: SyntaxToken) -> Option<Self> { | ||
2619 | if Self::can_cast(syntax.kind()) { | ||
2620 | Some(Self { syntax }) | ||
2621 | } else { | ||
2622 | None | ||
2623 | } | ||
2624 | } | ||
2625 | fn syntax(&self) -> &SyntaxToken { | ||
2626 | &self.syntax | ||
2627 | } | ||
2628 | } | ||
2629 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
2630 | pub struct IntNumber { | ||
2631 | pub(crate) syntax: SyntaxToken, | ||
2632 | } | ||
2633 | impl std::fmt::Display for IntNumber { | ||
2634 | fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { | ||
2635 | std::fmt::Display::fmt(&self.syntax, f) | ||
2636 | } | ||
2637 | } | ||
2638 | impl AstToken for IntNumber { | ||
2639 | fn can_cast(kind: SyntaxKind) -> bool { | ||
2640 | match kind { | ||
2641 | INT_NUMBER => true, | ||
2642 | _ => false, | ||
2643 | } | ||
2644 | } | ||
2645 | fn cast(syntax: SyntaxToken) -> Option<Self> { | ||
2646 | if Self::can_cast(syntax.kind()) { | ||
2647 | Some(Self { syntax }) | ||
2648 | } else { | ||
2649 | None | ||
2650 | } | ||
2651 | } | ||
2652 | fn syntax(&self) -> &SyntaxToken { | ||
2653 | &self.syntax | ||
2654 | } | ||
2655 | } | ||
2656 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
2657 | pub struct FloatNumber { | ||
2658 | pub(crate) syntax: SyntaxToken, | ||
2659 | } | ||
2660 | impl std::fmt::Display for FloatNumber { | ||
2661 | fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { | ||
2662 | std::fmt::Display::fmt(&self.syntax, f) | ||
2663 | } | ||
2664 | } | ||
2665 | impl AstToken for FloatNumber { | ||
2666 | fn can_cast(kind: SyntaxKind) -> bool { | ||
2667 | match kind { | ||
2668 | FLOAT_NUMBER => true, | ||
2669 | _ => false, | ||
2670 | } | ||
2671 | } | ||
2672 | fn cast(syntax: SyntaxToken) -> Option<Self> { | ||
2673 | if Self::can_cast(syntax.kind()) { | ||
2674 | Some(Self { syntax }) | ||
2675 | } else { | ||
2676 | None | ||
2677 | } | ||
2678 | } | ||
2679 | fn syntax(&self) -> &SyntaxToken { | ||
2680 | &self.syntax | ||
2681 | } | ||
2682 | } | ||
2683 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
2684 | pub struct Char { | ||
2685 | pub(crate) syntax: SyntaxToken, | ||
2686 | } | ||
2687 | impl std::fmt::Display for Char { | ||
2688 | fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { | ||
2689 | std::fmt::Display::fmt(&self.syntax, f) | ||
2690 | } | ||
2691 | } | ||
2692 | impl AstToken for Char { | ||
2693 | fn can_cast(kind: SyntaxKind) -> bool { | ||
2694 | match kind { | ||
2695 | CHAR => true, | ||
2696 | _ => false, | ||
2697 | } | ||
2698 | } | ||
2699 | fn cast(syntax: SyntaxToken) -> Option<Self> { | ||
2700 | if Self::can_cast(syntax.kind()) { | ||
2701 | Some(Self { syntax }) | ||
2702 | } else { | ||
2703 | None | ||
2704 | } | ||
2705 | } | ||
2706 | fn syntax(&self) -> &SyntaxToken { | ||
2707 | &self.syntax | ||
2708 | } | ||
2709 | } | ||
2710 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
2711 | pub struct Byte { | ||
2712 | pub(crate) syntax: SyntaxToken, | ||
2713 | } | ||
2714 | impl std::fmt::Display for Byte { | ||
2715 | fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { | ||
2716 | std::fmt::Display::fmt(&self.syntax, f) | ||
2717 | } | ||
2718 | } | ||
2719 | impl AstToken for Byte { | ||
2720 | fn can_cast(kind: SyntaxKind) -> bool { | ||
2721 | match kind { | ||
2722 | BYTE => true, | ||
2723 | _ => false, | ||
2724 | } | ||
2725 | } | ||
2726 | fn cast(syntax: SyntaxToken) -> Option<Self> { | ||
2727 | if Self::can_cast(syntax.kind()) { | ||
2728 | Some(Self { syntax }) | ||
2729 | } else { | ||
2730 | None | ||
2731 | } | ||
2732 | } | ||
2733 | fn syntax(&self) -> &SyntaxToken { | ||
2734 | &self.syntax | ||
2735 | } | ||
2736 | } | ||
2737 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
2738 | pub struct String { | ||
2739 | pub(crate) syntax: SyntaxToken, | ||
2740 | } | ||
2741 | impl std::fmt::Display for String { | ||
2742 | fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { | ||
2743 | std::fmt::Display::fmt(&self.syntax, f) | ||
2744 | } | ||
2745 | } | ||
2746 | impl AstToken for String { | ||
2747 | fn can_cast(kind: SyntaxKind) -> bool { | ||
2748 | match kind { | ||
2749 | STRING => true, | ||
2750 | _ => false, | ||
2751 | } | ||
2752 | } | ||
2753 | fn cast(syntax: SyntaxToken) -> Option<Self> { | ||
2754 | if Self::can_cast(syntax.kind()) { | ||
2755 | Some(Self { syntax }) | ||
2756 | } else { | ||
2757 | None | ||
2758 | } | ||
2759 | } | ||
2760 | fn syntax(&self) -> &SyntaxToken { | ||
2761 | &self.syntax | ||
2762 | } | ||
2763 | } | ||
2764 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
2765 | pub struct RawString { | ||
2766 | pub(crate) syntax: SyntaxToken, | ||
2767 | } | ||
2768 | impl std::fmt::Display for RawString { | ||
2769 | fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { | ||
2770 | std::fmt::Display::fmt(&self.syntax, f) | ||
2771 | } | ||
2772 | } | ||
2773 | impl AstToken for RawString { | ||
2774 | fn can_cast(kind: SyntaxKind) -> bool { | ||
2775 | match kind { | ||
2776 | RAW_STRING => true, | ||
2777 | _ => false, | ||
2778 | } | ||
2779 | } | ||
2780 | fn cast(syntax: SyntaxToken) -> Option<Self> { | ||
2781 | if Self::can_cast(syntax.kind()) { | ||
2782 | Some(Self { syntax }) | ||
2783 | } else { | ||
2784 | None | ||
2785 | } | ||
2786 | } | ||
2787 | fn syntax(&self) -> &SyntaxToken { | ||
2788 | &self.syntax | ||
2789 | } | ||
2790 | } | ||
2791 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
2792 | pub struct ByteString { | ||
2793 | pub(crate) syntax: SyntaxToken, | ||
2794 | } | ||
2795 | impl std::fmt::Display for ByteString { | ||
2796 | fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { | ||
2797 | std::fmt::Display::fmt(&self.syntax, f) | ||
2798 | } | ||
2799 | } | ||
2800 | impl AstToken for ByteString { | ||
2801 | fn can_cast(kind: SyntaxKind) -> bool { | ||
2802 | match kind { | ||
2803 | BYTE_STRING => true, | ||
2804 | _ => false, | ||
2805 | } | ||
2806 | } | ||
2807 | fn cast(syntax: SyntaxToken) -> Option<Self> { | ||
2808 | if Self::can_cast(syntax.kind()) { | ||
2809 | Some(Self { syntax }) | ||
2810 | } else { | ||
2811 | None | ||
2812 | } | ||
2813 | } | ||
2814 | fn syntax(&self) -> &SyntaxToken { | ||
2815 | &self.syntax | ||
2816 | } | ||
2817 | } | ||
2818 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
2819 | pub struct RawByteString { | ||
2820 | pub(crate) syntax: SyntaxToken, | ||
2821 | } | ||
2822 | impl std::fmt::Display for RawByteString { | ||
2823 | fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { | ||
2824 | std::fmt::Display::fmt(&self.syntax, f) | ||
2825 | } | ||
2826 | } | ||
2827 | impl AstToken for RawByteString { | ||
2828 | fn can_cast(kind: SyntaxKind) -> bool { | ||
2829 | match kind { | ||
2830 | RAW_BYTE_STRING => true, | ||
2831 | _ => false, | ||
2832 | } | ||
2833 | } | ||
2834 | fn cast(syntax: SyntaxToken) -> Option<Self> { | ||
2835 | if Self::can_cast(syntax.kind()) { | ||
2836 | Some(Self { syntax }) | ||
2837 | } else { | ||
2838 | None | ||
2839 | } | ||
2840 | } | ||
2841 | fn syntax(&self) -> &SyntaxToken { | ||
2842 | &self.syntax | ||
2843 | } | ||
2844 | } | ||
2845 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
2846 | pub struct Error { | ||
2847 | pub(crate) syntax: SyntaxToken, | ||
2848 | } | ||
2849 | impl std::fmt::Display for Error { | ||
2850 | fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { | ||
2851 | std::fmt::Display::fmt(&self.syntax, f) | ||
2852 | } | ||
2853 | } | ||
2854 | impl AstToken for Error { | ||
2855 | fn can_cast(kind: SyntaxKind) -> bool { | ||
2856 | match kind { | ||
2857 | ERROR => true, | ||
2858 | _ => false, | ||
2859 | } | ||
2860 | } | ||
2861 | fn cast(syntax: SyntaxToken) -> Option<Self> { | ||
2862 | if Self::can_cast(syntax.kind()) { | ||
2863 | Some(Self { syntax }) | ||
2864 | } else { | ||
2865 | None | ||
2866 | } | ||
2867 | } | ||
2868 | fn syntax(&self) -> &SyntaxToken { | ||
2869 | &self.syntax | ||
2870 | } | ||
2871 | } | ||
2872 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
2873 | pub struct Ident { | ||
2874 | pub(crate) syntax: SyntaxToken, | ||
2875 | } | ||
2876 | impl std::fmt::Display for Ident { | ||
2877 | fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { | ||
2878 | std::fmt::Display::fmt(&self.syntax, f) | ||
2879 | } | ||
2880 | } | ||
2881 | impl AstToken for Ident { | ||
2882 | fn can_cast(kind: SyntaxKind) -> bool { | ||
2883 | match kind { | ||
2884 | IDENT => true, | ||
2885 | _ => false, | ||
2886 | } | ||
2887 | } | ||
2888 | fn cast(syntax: SyntaxToken) -> Option<Self> { | ||
2889 | if Self::can_cast(syntax.kind()) { | ||
2890 | Some(Self { syntax }) | ||
2891 | } else { | ||
2892 | None | ||
2893 | } | ||
2894 | } | ||
2895 | fn syntax(&self) -> &SyntaxToken { | ||
2896 | &self.syntax | ||
2897 | } | ||
2898 | } | ||
2899 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
2900 | pub struct Whitespace { | ||
2901 | pub(crate) syntax: SyntaxToken, | ||
2902 | } | ||
2903 | impl std::fmt::Display for Whitespace { | ||
2904 | fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { | ||
2905 | std::fmt::Display::fmt(&self.syntax, f) | ||
2906 | } | ||
2907 | } | ||
2908 | impl AstToken for Whitespace { | ||
2909 | fn can_cast(kind: SyntaxKind) -> bool { | ||
2910 | match kind { | ||
2911 | WHITESPACE => true, | ||
2912 | _ => false, | ||
2913 | } | ||
2914 | } | ||
2915 | fn cast(syntax: SyntaxToken) -> Option<Self> { | ||
2916 | if Self::can_cast(syntax.kind()) { | ||
2917 | Some(Self { syntax }) | ||
2918 | } else { | ||
2919 | None | ||
2920 | } | ||
2921 | } | ||
2922 | fn syntax(&self) -> &SyntaxToken { | ||
2923 | &self.syntax | ||
2924 | } | ||
2925 | } | ||
2926 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
2927 | pub struct Lifetime { | ||
2928 | pub(crate) syntax: SyntaxToken, | ||
2929 | } | ||
2930 | impl std::fmt::Display for Lifetime { | ||
2931 | fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { | ||
2932 | std::fmt::Display::fmt(&self.syntax, f) | ||
2933 | } | ||
2934 | } | ||
2935 | impl AstToken for Lifetime { | ||
2936 | fn can_cast(kind: SyntaxKind) -> bool { | ||
2937 | match kind { | ||
2938 | LIFETIME => true, | ||
2939 | _ => false, | ||
2940 | } | ||
2941 | } | ||
2942 | fn cast(syntax: SyntaxToken) -> Option<Self> { | ||
2943 | if Self::can_cast(syntax.kind()) { | ||
2944 | Some(Self { syntax }) | ||
2945 | } else { | ||
2946 | None | ||
2947 | } | ||
2948 | } | ||
2949 | fn syntax(&self) -> &SyntaxToken { | ||
2950 | &self.syntax | ||
2951 | } | ||
2952 | } | ||
2953 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
2954 | pub struct Comment { | ||
2955 | pub(crate) syntax: SyntaxToken, | ||
2956 | } | ||
2957 | impl std::fmt::Display for Comment { | ||
2958 | fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { | ||
2959 | std::fmt::Display::fmt(&self.syntax, f) | ||
2960 | } | ||
2961 | } | ||
2962 | impl AstToken for Comment { | ||
2963 | fn can_cast(kind: SyntaxKind) -> bool { | ||
2964 | match kind { | ||
2965 | COMMENT => true, | ||
2966 | _ => false, | ||
2967 | } | ||
2968 | } | ||
2969 | fn cast(syntax: SyntaxToken) -> Option<Self> { | ||
2970 | if Self::can_cast(syntax.kind()) { | ||
2971 | Some(Self { syntax }) | ||
2972 | } else { | ||
2973 | None | ||
2974 | } | ||
2975 | } | ||
2976 | fn syntax(&self) -> &SyntaxToken { | ||
2977 | &self.syntax | ||
2978 | } | ||
2979 | } | ||
2980 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
2981 | pub struct Shebang { | ||
2982 | pub(crate) syntax: SyntaxToken, | ||
2983 | } | ||
2984 | impl std::fmt::Display for Shebang { | ||
2985 | fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { | ||
2986 | std::fmt::Display::fmt(&self.syntax, f) | ||
2987 | } | ||
2988 | } | ||
2989 | impl AstToken for Shebang { | ||
2990 | fn can_cast(kind: SyntaxKind) -> bool { | ||
2991 | match kind { | ||
2992 | SHEBANG => true, | ||
2993 | _ => false, | ||
2994 | } | ||
2995 | } | ||
2996 | fn cast(syntax: SyntaxToken) -> Option<Self> { | ||
2997 | if Self::can_cast(syntax.kind()) { | ||
2998 | Some(Self { syntax }) | ||
2999 | } else { | ||
3000 | None | ||
3001 | } | ||
3002 | } | ||
3003 | fn syntax(&self) -> &SyntaxToken { | ||
3004 | &self.syntax | ||
3005 | } | ||
3006 | } | ||
3007 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
3008 | pub struct LDollar { | ||
3009 | pub(crate) syntax: SyntaxToken, | ||
3010 | } | ||
3011 | impl std::fmt::Display for LDollar { | ||
3012 | fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { | ||
3013 | std::fmt::Display::fmt(&self.syntax, f) | ||
3014 | } | ||
3015 | } | ||
3016 | impl AstToken for LDollar { | ||
3017 | fn can_cast(kind: SyntaxKind) -> bool { | ||
3018 | match kind { | ||
3019 | L_DOLLAR => true, | ||
3020 | _ => false, | ||
3021 | } | ||
3022 | } | ||
3023 | fn cast(syntax: SyntaxToken) -> Option<Self> { | ||
3024 | if Self::can_cast(syntax.kind()) { | ||
3025 | Some(Self { syntax }) | ||
3026 | } else { | ||
3027 | None | ||
3028 | } | ||
3029 | } | ||
3030 | fn syntax(&self) -> &SyntaxToken { | ||
3031 | &self.syntax | ||
3032 | } | ||
3033 | } | ||
3034 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
3035 | pub struct RDollar { | ||
3036 | pub(crate) syntax: SyntaxToken, | ||
3037 | } | ||
3038 | impl std::fmt::Display for RDollar { | ||
3039 | fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { | ||
3040 | std::fmt::Display::fmt(&self.syntax, f) | ||
3041 | } | ||
3042 | } | ||
3043 | impl AstToken for RDollar { | ||
3044 | fn can_cast(kind: SyntaxKind) -> bool { | ||
3045 | match kind { | ||
3046 | R_DOLLAR => true, | ||
3047 | _ => false, | ||
3048 | } | ||
3049 | } | ||
3050 | fn cast(syntax: SyntaxToken) -> Option<Self> { | ||
3051 | if Self::can_cast(syntax.kind()) { | ||
3052 | Some(Self { syntax }) | ||
3053 | } else { | ||
3054 | None | ||
3055 | } | ||
3056 | } | ||
3057 | fn syntax(&self) -> &SyntaxToken { | ||
3058 | &self.syntax | ||
3059 | } | ||
3060 | } | ||
3061 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
3062 | pub struct SourceFile { | 10 | pub struct SourceFile { |
3063 | pub(crate) syntax: SyntaxNode, | 11 | pub(crate) syntax: SyntaxNode, |
3064 | } | 12 | } |
diff --git a/crates/ra_syntax/src/ast/generated/tokens.rs b/crates/ra_syntax/src/ast/generated/tokens.rs index 4494af1be..27b2d2977 100644 --- a/crates/ra_syntax/src/ast/generated/tokens.rs +++ b/crates/ra_syntax/src/ast/generated/tokens.rs | |||
@@ -1 +1,3058 @@ | |||
1 | //! Generated file, do not edit by hand, see `xtask/src/codegen` \ No newline at end of file | 1 | //! Generated file, do not edit by hand, see `xtask/src/codegen` |
2 | |||
3 | use crate::{ | ||
4 | ast::AstToken, | ||
5 | SyntaxKind::{self, *}, | ||
6 | SyntaxToken, | ||
7 | }; | ||
8 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
9 | pub struct Semi { | ||
10 | pub(crate) syntax: SyntaxToken, | ||
11 | } | ||
12 | impl std::fmt::Display for Semi { | ||
13 | fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { | ||
14 | std::fmt::Display::fmt(&self.syntax, f) | ||
15 | } | ||
16 | } | ||
17 | impl AstToken for Semi { | ||
18 | fn can_cast(kind: SyntaxKind) -> bool { | ||
19 | match kind { | ||
20 | SEMI => true, | ||
21 | _ => false, | ||
22 | } | ||
23 | } | ||
24 | fn cast(syntax: SyntaxToken) -> Option<Self> { | ||
25 | if Self::can_cast(syntax.kind()) { | ||
26 | Some(Self { syntax }) | ||
27 | } else { | ||
28 | None | ||
29 | } | ||
30 | } | ||
31 | fn syntax(&self) -> &SyntaxToken { | ||
32 | &self.syntax | ||
33 | } | ||
34 | } | ||
35 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
36 | pub struct Comma { | ||
37 | pub(crate) syntax: SyntaxToken, | ||
38 | } | ||
39 | impl std::fmt::Display for Comma { | ||
40 | fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { | ||
41 | std::fmt::Display::fmt(&self.syntax, f) | ||
42 | } | ||
43 | } | ||
44 | impl AstToken for Comma { | ||
45 | fn can_cast(kind: SyntaxKind) -> bool { | ||
46 | match kind { | ||
47 | COMMA => true, | ||
48 | _ => false, | ||
49 | } | ||
50 | } | ||
51 | fn cast(syntax: SyntaxToken) -> Option<Self> { | ||
52 | if Self::can_cast(syntax.kind()) { | ||
53 | Some(Self { syntax }) | ||
54 | } else { | ||
55 | None | ||
56 | } | ||
57 | } | ||
58 | fn syntax(&self) -> &SyntaxToken { | ||
59 | &self.syntax | ||
60 | } | ||
61 | } | ||
62 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
63 | pub struct LParen { | ||
64 | pub(crate) syntax: SyntaxToken, | ||
65 | } | ||
66 | impl std::fmt::Display for LParen { | ||
67 | fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { | ||
68 | std::fmt::Display::fmt(&self.syntax, f) | ||
69 | } | ||
70 | } | ||
71 | impl AstToken for LParen { | ||
72 | fn can_cast(kind: SyntaxKind) -> bool { | ||
73 | match kind { | ||
74 | L_PAREN => true, | ||
75 | _ => false, | ||
76 | } | ||
77 | } | ||
78 | fn cast(syntax: SyntaxToken) -> Option<Self> { | ||
79 | if Self::can_cast(syntax.kind()) { | ||
80 | Some(Self { syntax }) | ||
81 | } else { | ||
82 | None | ||
83 | } | ||
84 | } | ||
85 | fn syntax(&self) -> &SyntaxToken { | ||
86 | &self.syntax | ||
87 | } | ||
88 | } | ||
89 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
90 | pub struct RParen { | ||
91 | pub(crate) syntax: SyntaxToken, | ||
92 | } | ||
93 | impl std::fmt::Display for RParen { | ||
94 | fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { | ||
95 | std::fmt::Display::fmt(&self.syntax, f) | ||
96 | } | ||
97 | } | ||
98 | impl AstToken for RParen { | ||
99 | fn can_cast(kind: SyntaxKind) -> bool { | ||
100 | match kind { | ||
101 | R_PAREN => true, | ||
102 | _ => false, | ||
103 | } | ||
104 | } | ||
105 | fn cast(syntax: SyntaxToken) -> Option<Self> { | ||
106 | if Self::can_cast(syntax.kind()) { | ||
107 | Some(Self { syntax }) | ||
108 | } else { | ||
109 | None | ||
110 | } | ||
111 | } | ||
112 | fn syntax(&self) -> &SyntaxToken { | ||
113 | &self.syntax | ||
114 | } | ||
115 | } | ||
116 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
117 | pub struct LCurly { | ||
118 | pub(crate) syntax: SyntaxToken, | ||
119 | } | ||
120 | impl std::fmt::Display for LCurly { | ||
121 | fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { | ||
122 | std::fmt::Display::fmt(&self.syntax, f) | ||
123 | } | ||
124 | } | ||
125 | impl AstToken for LCurly { | ||
126 | fn can_cast(kind: SyntaxKind) -> bool { | ||
127 | match kind { | ||
128 | L_CURLY => true, | ||
129 | _ => false, | ||
130 | } | ||
131 | } | ||
132 | fn cast(syntax: SyntaxToken) -> Option<Self> { | ||
133 | if Self::can_cast(syntax.kind()) { | ||
134 | Some(Self { syntax }) | ||
135 | } else { | ||
136 | None | ||
137 | } | ||
138 | } | ||
139 | fn syntax(&self) -> &SyntaxToken { | ||
140 | &self.syntax | ||
141 | } | ||
142 | } | ||
143 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
144 | pub struct RCurly { | ||
145 | pub(crate) syntax: SyntaxToken, | ||
146 | } | ||
147 | impl std::fmt::Display for RCurly { | ||
148 | fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { | ||
149 | std::fmt::Display::fmt(&self.syntax, f) | ||
150 | } | ||
151 | } | ||
152 | impl AstToken for RCurly { | ||
153 | fn can_cast(kind: SyntaxKind) -> bool { | ||
154 | match kind { | ||
155 | R_CURLY => true, | ||
156 | _ => false, | ||
157 | } | ||
158 | } | ||
159 | fn cast(syntax: SyntaxToken) -> Option<Self> { | ||
160 | if Self::can_cast(syntax.kind()) { | ||
161 | Some(Self { syntax }) | ||
162 | } else { | ||
163 | None | ||
164 | } | ||
165 | } | ||
166 | fn syntax(&self) -> &SyntaxToken { | ||
167 | &self.syntax | ||
168 | } | ||
169 | } | ||
170 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
171 | pub struct LBrack { | ||
172 | pub(crate) syntax: SyntaxToken, | ||
173 | } | ||
174 | impl std::fmt::Display for LBrack { | ||
175 | fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { | ||
176 | std::fmt::Display::fmt(&self.syntax, f) | ||
177 | } | ||
178 | } | ||
179 | impl AstToken for LBrack { | ||
180 | fn can_cast(kind: SyntaxKind) -> bool { | ||
181 | match kind { | ||
182 | L_BRACK => true, | ||
183 | _ => false, | ||
184 | } | ||
185 | } | ||
186 | fn cast(syntax: SyntaxToken) -> Option<Self> { | ||
187 | if Self::can_cast(syntax.kind()) { | ||
188 | Some(Self { syntax }) | ||
189 | } else { | ||
190 | None | ||
191 | } | ||
192 | } | ||
193 | fn syntax(&self) -> &SyntaxToken { | ||
194 | &self.syntax | ||
195 | } | ||
196 | } | ||
197 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
198 | pub struct RBrack { | ||
199 | pub(crate) syntax: SyntaxToken, | ||
200 | } | ||
201 | impl std::fmt::Display for RBrack { | ||
202 | fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { | ||
203 | std::fmt::Display::fmt(&self.syntax, f) | ||
204 | } | ||
205 | } | ||
206 | impl AstToken for RBrack { | ||
207 | fn can_cast(kind: SyntaxKind) -> bool { | ||
208 | match kind { | ||
209 | R_BRACK => true, | ||
210 | _ => false, | ||
211 | } | ||
212 | } | ||
213 | fn cast(syntax: SyntaxToken) -> Option<Self> { | ||
214 | if Self::can_cast(syntax.kind()) { | ||
215 | Some(Self { syntax }) | ||
216 | } else { | ||
217 | None | ||
218 | } | ||
219 | } | ||
220 | fn syntax(&self) -> &SyntaxToken { | ||
221 | &self.syntax | ||
222 | } | ||
223 | } | ||
224 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
225 | pub struct LAngle { | ||
226 | pub(crate) syntax: SyntaxToken, | ||
227 | } | ||
228 | impl std::fmt::Display for LAngle { | ||
229 | fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { | ||
230 | std::fmt::Display::fmt(&self.syntax, f) | ||
231 | } | ||
232 | } | ||
233 | impl AstToken for LAngle { | ||
234 | fn can_cast(kind: SyntaxKind) -> bool { | ||
235 | match kind { | ||
236 | L_ANGLE => true, | ||
237 | _ => false, | ||
238 | } | ||
239 | } | ||
240 | fn cast(syntax: SyntaxToken) -> Option<Self> { | ||
241 | if Self::can_cast(syntax.kind()) { | ||
242 | Some(Self { syntax }) | ||
243 | } else { | ||
244 | None | ||
245 | } | ||
246 | } | ||
247 | fn syntax(&self) -> &SyntaxToken { | ||
248 | &self.syntax | ||
249 | } | ||
250 | } | ||
251 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
252 | pub struct RAngle { | ||
253 | pub(crate) syntax: SyntaxToken, | ||
254 | } | ||
255 | impl std::fmt::Display for RAngle { | ||
256 | fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { | ||
257 | std::fmt::Display::fmt(&self.syntax, f) | ||
258 | } | ||
259 | } | ||
260 | impl AstToken for RAngle { | ||
261 | fn can_cast(kind: SyntaxKind) -> bool { | ||
262 | match kind { | ||
263 | R_ANGLE => true, | ||
264 | _ => false, | ||
265 | } | ||
266 | } | ||
267 | fn cast(syntax: SyntaxToken) -> Option<Self> { | ||
268 | if Self::can_cast(syntax.kind()) { | ||
269 | Some(Self { syntax }) | ||
270 | } else { | ||
271 | None | ||
272 | } | ||
273 | } | ||
274 | fn syntax(&self) -> &SyntaxToken { | ||
275 | &self.syntax | ||
276 | } | ||
277 | } | ||
278 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
279 | pub struct At { | ||
280 | pub(crate) syntax: SyntaxToken, | ||
281 | } | ||
282 | impl std::fmt::Display for At { | ||
283 | fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { | ||
284 | std::fmt::Display::fmt(&self.syntax, f) | ||
285 | } | ||
286 | } | ||
287 | impl AstToken for At { | ||
288 | fn can_cast(kind: SyntaxKind) -> bool { | ||
289 | match kind { | ||
290 | AT => true, | ||
291 | _ => false, | ||
292 | } | ||
293 | } | ||
294 | fn cast(syntax: SyntaxToken) -> Option<Self> { | ||
295 | if Self::can_cast(syntax.kind()) { | ||
296 | Some(Self { syntax }) | ||
297 | } else { | ||
298 | None | ||
299 | } | ||
300 | } | ||
301 | fn syntax(&self) -> &SyntaxToken { | ||
302 | &self.syntax | ||
303 | } | ||
304 | } | ||
305 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
306 | pub struct Pound { | ||
307 | pub(crate) syntax: SyntaxToken, | ||
308 | } | ||
309 | impl std::fmt::Display for Pound { | ||
310 | fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { | ||
311 | std::fmt::Display::fmt(&self.syntax, f) | ||
312 | } | ||
313 | } | ||
314 | impl AstToken for Pound { | ||
315 | fn can_cast(kind: SyntaxKind) -> bool { | ||
316 | match kind { | ||
317 | POUND => true, | ||
318 | _ => false, | ||
319 | } | ||
320 | } | ||
321 | fn cast(syntax: SyntaxToken) -> Option<Self> { | ||
322 | if Self::can_cast(syntax.kind()) { | ||
323 | Some(Self { syntax }) | ||
324 | } else { | ||
325 | None | ||
326 | } | ||
327 | } | ||
328 | fn syntax(&self) -> &SyntaxToken { | ||
329 | &self.syntax | ||
330 | } | ||
331 | } | ||
332 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
333 | pub struct Tilde { | ||
334 | pub(crate) syntax: SyntaxToken, | ||
335 | } | ||
336 | impl std::fmt::Display for Tilde { | ||
337 | fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { | ||
338 | std::fmt::Display::fmt(&self.syntax, f) | ||
339 | } | ||
340 | } | ||
341 | impl AstToken for Tilde { | ||
342 | fn can_cast(kind: SyntaxKind) -> bool { | ||
343 | match kind { | ||
344 | TILDE => true, | ||
345 | _ => false, | ||
346 | } | ||
347 | } | ||
348 | fn cast(syntax: SyntaxToken) -> Option<Self> { | ||
349 | if Self::can_cast(syntax.kind()) { | ||
350 | Some(Self { syntax }) | ||
351 | } else { | ||
352 | None | ||
353 | } | ||
354 | } | ||
355 | fn syntax(&self) -> &SyntaxToken { | ||
356 | &self.syntax | ||
357 | } | ||
358 | } | ||
359 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
360 | pub struct Question { | ||
361 | pub(crate) syntax: SyntaxToken, | ||
362 | } | ||
363 | impl std::fmt::Display for Question { | ||
364 | fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { | ||
365 | std::fmt::Display::fmt(&self.syntax, f) | ||
366 | } | ||
367 | } | ||
368 | impl AstToken for Question { | ||
369 | fn can_cast(kind: SyntaxKind) -> bool { | ||
370 | match kind { | ||
371 | QUESTION => true, | ||
372 | _ => false, | ||
373 | } | ||
374 | } | ||
375 | fn cast(syntax: SyntaxToken) -> Option<Self> { | ||
376 | if Self::can_cast(syntax.kind()) { | ||
377 | Some(Self { syntax }) | ||
378 | } else { | ||
379 | None | ||
380 | } | ||
381 | } | ||
382 | fn syntax(&self) -> &SyntaxToken { | ||
383 | &self.syntax | ||
384 | } | ||
385 | } | ||
386 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
387 | pub struct Dollar { | ||
388 | pub(crate) syntax: SyntaxToken, | ||
389 | } | ||
390 | impl std::fmt::Display for Dollar { | ||
391 | fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { | ||
392 | std::fmt::Display::fmt(&self.syntax, f) | ||
393 | } | ||
394 | } | ||
395 | impl AstToken for Dollar { | ||
396 | fn can_cast(kind: SyntaxKind) -> bool { | ||
397 | match kind { | ||
398 | DOLLAR => true, | ||
399 | _ => false, | ||
400 | } | ||
401 | } | ||
402 | fn cast(syntax: SyntaxToken) -> Option<Self> { | ||
403 | if Self::can_cast(syntax.kind()) { | ||
404 | Some(Self { syntax }) | ||
405 | } else { | ||
406 | None | ||
407 | } | ||
408 | } | ||
409 | fn syntax(&self) -> &SyntaxToken { | ||
410 | &self.syntax | ||
411 | } | ||
412 | } | ||
413 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
414 | pub struct Amp { | ||
415 | pub(crate) syntax: SyntaxToken, | ||
416 | } | ||
417 | impl std::fmt::Display for Amp { | ||
418 | fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { | ||
419 | std::fmt::Display::fmt(&self.syntax, f) | ||
420 | } | ||
421 | } | ||
422 | impl AstToken for Amp { | ||
423 | fn can_cast(kind: SyntaxKind) -> bool { | ||
424 | match kind { | ||
425 | AMP => true, | ||
426 | _ => false, | ||
427 | } | ||
428 | } | ||
429 | fn cast(syntax: SyntaxToken) -> Option<Self> { | ||
430 | if Self::can_cast(syntax.kind()) { | ||
431 | Some(Self { syntax }) | ||
432 | } else { | ||
433 | None | ||
434 | } | ||
435 | } | ||
436 | fn syntax(&self) -> &SyntaxToken { | ||
437 | &self.syntax | ||
438 | } | ||
439 | } | ||
440 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
441 | pub struct Pipe { | ||
442 | pub(crate) syntax: SyntaxToken, | ||
443 | } | ||
444 | impl std::fmt::Display for Pipe { | ||
445 | fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { | ||
446 | std::fmt::Display::fmt(&self.syntax, f) | ||
447 | } | ||
448 | } | ||
449 | impl AstToken for Pipe { | ||
450 | fn can_cast(kind: SyntaxKind) -> bool { | ||
451 | match kind { | ||
452 | PIPE => true, | ||
453 | _ => false, | ||
454 | } | ||
455 | } | ||
456 | fn cast(syntax: SyntaxToken) -> Option<Self> { | ||
457 | if Self::can_cast(syntax.kind()) { | ||
458 | Some(Self { syntax }) | ||
459 | } else { | ||
460 | None | ||
461 | } | ||
462 | } | ||
463 | fn syntax(&self) -> &SyntaxToken { | ||
464 | &self.syntax | ||
465 | } | ||
466 | } | ||
467 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
468 | pub struct Plus { | ||
469 | pub(crate) syntax: SyntaxToken, | ||
470 | } | ||
471 | impl std::fmt::Display for Plus { | ||
472 | fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { | ||
473 | std::fmt::Display::fmt(&self.syntax, f) | ||
474 | } | ||
475 | } | ||
476 | impl AstToken for Plus { | ||
477 | fn can_cast(kind: SyntaxKind) -> bool { | ||
478 | match kind { | ||
479 | PLUS => true, | ||
480 | _ => false, | ||
481 | } | ||
482 | } | ||
483 | fn cast(syntax: SyntaxToken) -> Option<Self> { | ||
484 | if Self::can_cast(syntax.kind()) { | ||
485 | Some(Self { syntax }) | ||
486 | } else { | ||
487 | None | ||
488 | } | ||
489 | } | ||
490 | fn syntax(&self) -> &SyntaxToken { | ||
491 | &self.syntax | ||
492 | } | ||
493 | } | ||
494 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
495 | pub struct Star { | ||
496 | pub(crate) syntax: SyntaxToken, | ||
497 | } | ||
498 | impl std::fmt::Display for Star { | ||
499 | fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { | ||
500 | std::fmt::Display::fmt(&self.syntax, f) | ||
501 | } | ||
502 | } | ||
503 | impl AstToken for Star { | ||
504 | fn can_cast(kind: SyntaxKind) -> bool { | ||
505 | match kind { | ||
506 | STAR => true, | ||
507 | _ => false, | ||
508 | } | ||
509 | } | ||
510 | fn cast(syntax: SyntaxToken) -> Option<Self> { | ||
511 | if Self::can_cast(syntax.kind()) { | ||
512 | Some(Self { syntax }) | ||
513 | } else { | ||
514 | None | ||
515 | } | ||
516 | } | ||
517 | fn syntax(&self) -> &SyntaxToken { | ||
518 | &self.syntax | ||
519 | } | ||
520 | } | ||
521 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
522 | pub struct Slash { | ||
523 | pub(crate) syntax: SyntaxToken, | ||
524 | } | ||
525 | impl std::fmt::Display for Slash { | ||
526 | fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { | ||
527 | std::fmt::Display::fmt(&self.syntax, f) | ||
528 | } | ||
529 | } | ||
530 | impl AstToken for Slash { | ||
531 | fn can_cast(kind: SyntaxKind) -> bool { | ||
532 | match kind { | ||
533 | SLASH => true, | ||
534 | _ => false, | ||
535 | } | ||
536 | } | ||
537 | fn cast(syntax: SyntaxToken) -> Option<Self> { | ||
538 | if Self::can_cast(syntax.kind()) { | ||
539 | Some(Self { syntax }) | ||
540 | } else { | ||
541 | None | ||
542 | } | ||
543 | } | ||
544 | fn syntax(&self) -> &SyntaxToken { | ||
545 | &self.syntax | ||
546 | } | ||
547 | } | ||
548 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
549 | pub struct Caret { | ||
550 | pub(crate) syntax: SyntaxToken, | ||
551 | } | ||
552 | impl std::fmt::Display for Caret { | ||
553 | fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { | ||
554 | std::fmt::Display::fmt(&self.syntax, f) | ||
555 | } | ||
556 | } | ||
557 | impl AstToken for Caret { | ||
558 | fn can_cast(kind: SyntaxKind) -> bool { | ||
559 | match kind { | ||
560 | CARET => true, | ||
561 | _ => false, | ||
562 | } | ||
563 | } | ||
564 | fn cast(syntax: SyntaxToken) -> Option<Self> { | ||
565 | if Self::can_cast(syntax.kind()) { | ||
566 | Some(Self { syntax }) | ||
567 | } else { | ||
568 | None | ||
569 | } | ||
570 | } | ||
571 | fn syntax(&self) -> &SyntaxToken { | ||
572 | &self.syntax | ||
573 | } | ||
574 | } | ||
575 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
576 | pub struct Percent { | ||
577 | pub(crate) syntax: SyntaxToken, | ||
578 | } | ||
579 | impl std::fmt::Display for Percent { | ||
580 | fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { | ||
581 | std::fmt::Display::fmt(&self.syntax, f) | ||
582 | } | ||
583 | } | ||
584 | impl AstToken for Percent { | ||
585 | fn can_cast(kind: SyntaxKind) -> bool { | ||
586 | match kind { | ||
587 | PERCENT => true, | ||
588 | _ => false, | ||
589 | } | ||
590 | } | ||
591 | fn cast(syntax: SyntaxToken) -> Option<Self> { | ||
592 | if Self::can_cast(syntax.kind()) { | ||
593 | Some(Self { syntax }) | ||
594 | } else { | ||
595 | None | ||
596 | } | ||
597 | } | ||
598 | fn syntax(&self) -> &SyntaxToken { | ||
599 | &self.syntax | ||
600 | } | ||
601 | } | ||
602 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
603 | pub struct Underscore { | ||
604 | pub(crate) syntax: SyntaxToken, | ||
605 | } | ||
606 | impl std::fmt::Display for Underscore { | ||
607 | fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { | ||
608 | std::fmt::Display::fmt(&self.syntax, f) | ||
609 | } | ||
610 | } | ||
611 | impl AstToken for Underscore { | ||
612 | fn can_cast(kind: SyntaxKind) -> bool { | ||
613 | match kind { | ||
614 | UNDERSCORE => true, | ||
615 | _ => false, | ||
616 | } | ||
617 | } | ||
618 | fn cast(syntax: SyntaxToken) -> Option<Self> { | ||
619 | if Self::can_cast(syntax.kind()) { | ||
620 | Some(Self { syntax }) | ||
621 | } else { | ||
622 | None | ||
623 | } | ||
624 | } | ||
625 | fn syntax(&self) -> &SyntaxToken { | ||
626 | &self.syntax | ||
627 | } | ||
628 | } | ||
629 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
630 | pub struct Dot { | ||
631 | pub(crate) syntax: SyntaxToken, | ||
632 | } | ||
633 | impl std::fmt::Display for Dot { | ||
634 | fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { | ||
635 | std::fmt::Display::fmt(&self.syntax, f) | ||
636 | } | ||
637 | } | ||
638 | impl AstToken for Dot { | ||
639 | fn can_cast(kind: SyntaxKind) -> bool { | ||
640 | match kind { | ||
641 | DOT => true, | ||
642 | _ => false, | ||
643 | } | ||
644 | } | ||
645 | fn cast(syntax: SyntaxToken) -> Option<Self> { | ||
646 | if Self::can_cast(syntax.kind()) { | ||
647 | Some(Self { syntax }) | ||
648 | } else { | ||
649 | None | ||
650 | } | ||
651 | } | ||
652 | fn syntax(&self) -> &SyntaxToken { | ||
653 | &self.syntax | ||
654 | } | ||
655 | } | ||
656 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
657 | pub struct Dotdot { | ||
658 | pub(crate) syntax: SyntaxToken, | ||
659 | } | ||
660 | impl std::fmt::Display for Dotdot { | ||
661 | fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { | ||
662 | std::fmt::Display::fmt(&self.syntax, f) | ||
663 | } | ||
664 | } | ||
665 | impl AstToken for Dotdot { | ||
666 | fn can_cast(kind: SyntaxKind) -> bool { | ||
667 | match kind { | ||
668 | DOTDOT => true, | ||
669 | _ => false, | ||
670 | } | ||
671 | } | ||
672 | fn cast(syntax: SyntaxToken) -> Option<Self> { | ||
673 | if Self::can_cast(syntax.kind()) { | ||
674 | Some(Self { syntax }) | ||
675 | } else { | ||
676 | None | ||
677 | } | ||
678 | } | ||
679 | fn syntax(&self) -> &SyntaxToken { | ||
680 | &self.syntax | ||
681 | } | ||
682 | } | ||
683 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
684 | pub struct Dotdotdot { | ||
685 | pub(crate) syntax: SyntaxToken, | ||
686 | } | ||
687 | impl std::fmt::Display for Dotdotdot { | ||
688 | fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { | ||
689 | std::fmt::Display::fmt(&self.syntax, f) | ||
690 | } | ||
691 | } | ||
692 | impl AstToken for Dotdotdot { | ||
693 | fn can_cast(kind: SyntaxKind) -> bool { | ||
694 | match kind { | ||
695 | DOTDOTDOT => true, | ||
696 | _ => false, | ||
697 | } | ||
698 | } | ||
699 | fn cast(syntax: SyntaxToken) -> Option<Self> { | ||
700 | if Self::can_cast(syntax.kind()) { | ||
701 | Some(Self { syntax }) | ||
702 | } else { | ||
703 | None | ||
704 | } | ||
705 | } | ||
706 | fn syntax(&self) -> &SyntaxToken { | ||
707 | &self.syntax | ||
708 | } | ||
709 | } | ||
710 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
711 | pub struct Dotdoteq { | ||
712 | pub(crate) syntax: SyntaxToken, | ||
713 | } | ||
714 | impl std::fmt::Display for Dotdoteq { | ||
715 | fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { | ||
716 | std::fmt::Display::fmt(&self.syntax, f) | ||
717 | } | ||
718 | } | ||
719 | impl AstToken for Dotdoteq { | ||
720 | fn can_cast(kind: SyntaxKind) -> bool { | ||
721 | match kind { | ||
722 | DOTDOTEQ => true, | ||
723 | _ => false, | ||
724 | } | ||
725 | } | ||
726 | fn cast(syntax: SyntaxToken) -> Option<Self> { | ||
727 | if Self::can_cast(syntax.kind()) { | ||
728 | Some(Self { syntax }) | ||
729 | } else { | ||
730 | None | ||
731 | } | ||
732 | } | ||
733 | fn syntax(&self) -> &SyntaxToken { | ||
734 | &self.syntax | ||
735 | } | ||
736 | } | ||
737 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
738 | pub struct Colon { | ||
739 | pub(crate) syntax: SyntaxToken, | ||
740 | } | ||
741 | impl std::fmt::Display for Colon { | ||
742 | fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { | ||
743 | std::fmt::Display::fmt(&self.syntax, f) | ||
744 | } | ||
745 | } | ||
746 | impl AstToken for Colon { | ||
747 | fn can_cast(kind: SyntaxKind) -> bool { | ||
748 | match kind { | ||
749 | COLON => true, | ||
750 | _ => false, | ||
751 | } | ||
752 | } | ||
753 | fn cast(syntax: SyntaxToken) -> Option<Self> { | ||
754 | if Self::can_cast(syntax.kind()) { | ||
755 | Some(Self { syntax }) | ||
756 | } else { | ||
757 | None | ||
758 | } | ||
759 | } | ||
760 | fn syntax(&self) -> &SyntaxToken { | ||
761 | &self.syntax | ||
762 | } | ||
763 | } | ||
764 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
765 | pub struct Coloncolon { | ||
766 | pub(crate) syntax: SyntaxToken, | ||
767 | } | ||
768 | impl std::fmt::Display for Coloncolon { | ||
769 | fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { | ||
770 | std::fmt::Display::fmt(&self.syntax, f) | ||
771 | } | ||
772 | } | ||
773 | impl AstToken for Coloncolon { | ||
774 | fn can_cast(kind: SyntaxKind) -> bool { | ||
775 | match kind { | ||
776 | COLONCOLON => true, | ||
777 | _ => false, | ||
778 | } | ||
779 | } | ||
780 | fn cast(syntax: SyntaxToken) -> Option<Self> { | ||
781 | if Self::can_cast(syntax.kind()) { | ||
782 | Some(Self { syntax }) | ||
783 | } else { | ||
784 | None | ||
785 | } | ||
786 | } | ||
787 | fn syntax(&self) -> &SyntaxToken { | ||
788 | &self.syntax | ||
789 | } | ||
790 | } | ||
791 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
792 | pub struct Eq { | ||
793 | pub(crate) syntax: SyntaxToken, | ||
794 | } | ||
795 | impl std::fmt::Display for Eq { | ||
796 | fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { | ||
797 | std::fmt::Display::fmt(&self.syntax, f) | ||
798 | } | ||
799 | } | ||
800 | impl AstToken for Eq { | ||
801 | fn can_cast(kind: SyntaxKind) -> bool { | ||
802 | match kind { | ||
803 | EQ => true, | ||
804 | _ => false, | ||
805 | } | ||
806 | } | ||
807 | fn cast(syntax: SyntaxToken) -> Option<Self> { | ||
808 | if Self::can_cast(syntax.kind()) { | ||
809 | Some(Self { syntax }) | ||
810 | } else { | ||
811 | None | ||
812 | } | ||
813 | } | ||
814 | fn syntax(&self) -> &SyntaxToken { | ||
815 | &self.syntax | ||
816 | } | ||
817 | } | ||
818 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
819 | pub struct Eqeq { | ||
820 | pub(crate) syntax: SyntaxToken, | ||
821 | } | ||
822 | impl std::fmt::Display for Eqeq { | ||
823 | fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { | ||
824 | std::fmt::Display::fmt(&self.syntax, f) | ||
825 | } | ||
826 | } | ||
827 | impl AstToken for Eqeq { | ||
828 | fn can_cast(kind: SyntaxKind) -> bool { | ||
829 | match kind { | ||
830 | EQEQ => true, | ||
831 | _ => false, | ||
832 | } | ||
833 | } | ||
834 | fn cast(syntax: SyntaxToken) -> Option<Self> { | ||
835 | if Self::can_cast(syntax.kind()) { | ||
836 | Some(Self { syntax }) | ||
837 | } else { | ||
838 | None | ||
839 | } | ||
840 | } | ||
841 | fn syntax(&self) -> &SyntaxToken { | ||
842 | &self.syntax | ||
843 | } | ||
844 | } | ||
845 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
846 | pub struct FatArrow { | ||
847 | pub(crate) syntax: SyntaxToken, | ||
848 | } | ||
849 | impl std::fmt::Display for FatArrow { | ||
850 | fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { | ||
851 | std::fmt::Display::fmt(&self.syntax, f) | ||
852 | } | ||
853 | } | ||
854 | impl AstToken for FatArrow { | ||
855 | fn can_cast(kind: SyntaxKind) -> bool { | ||
856 | match kind { | ||
857 | FAT_ARROW => true, | ||
858 | _ => false, | ||
859 | } | ||
860 | } | ||
861 | fn cast(syntax: SyntaxToken) -> Option<Self> { | ||
862 | if Self::can_cast(syntax.kind()) { | ||
863 | Some(Self { syntax }) | ||
864 | } else { | ||
865 | None | ||
866 | } | ||
867 | } | ||
868 | fn syntax(&self) -> &SyntaxToken { | ||
869 | &self.syntax | ||
870 | } | ||
871 | } | ||
872 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
873 | pub struct Excl { | ||
874 | pub(crate) syntax: SyntaxToken, | ||
875 | } | ||
876 | impl std::fmt::Display for Excl { | ||
877 | fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { | ||
878 | std::fmt::Display::fmt(&self.syntax, f) | ||
879 | } | ||
880 | } | ||
881 | impl AstToken for Excl { | ||
882 | fn can_cast(kind: SyntaxKind) -> bool { | ||
883 | match kind { | ||
884 | EXCL => true, | ||
885 | _ => false, | ||
886 | } | ||
887 | } | ||
888 | fn cast(syntax: SyntaxToken) -> Option<Self> { | ||
889 | if Self::can_cast(syntax.kind()) { | ||
890 | Some(Self { syntax }) | ||
891 | } else { | ||
892 | None | ||
893 | } | ||
894 | } | ||
895 | fn syntax(&self) -> &SyntaxToken { | ||
896 | &self.syntax | ||
897 | } | ||
898 | } | ||
899 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
900 | pub struct Neq { | ||
901 | pub(crate) syntax: SyntaxToken, | ||
902 | } | ||
903 | impl std::fmt::Display for Neq { | ||
904 | fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { | ||
905 | std::fmt::Display::fmt(&self.syntax, f) | ||
906 | } | ||
907 | } | ||
908 | impl AstToken for Neq { | ||
909 | fn can_cast(kind: SyntaxKind) -> bool { | ||
910 | match kind { | ||
911 | NEQ => true, | ||
912 | _ => false, | ||
913 | } | ||
914 | } | ||
915 | fn cast(syntax: SyntaxToken) -> Option<Self> { | ||
916 | if Self::can_cast(syntax.kind()) { | ||
917 | Some(Self { syntax }) | ||
918 | } else { | ||
919 | None | ||
920 | } | ||
921 | } | ||
922 | fn syntax(&self) -> &SyntaxToken { | ||
923 | &self.syntax | ||
924 | } | ||
925 | } | ||
926 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
927 | pub struct Minus { | ||
928 | pub(crate) syntax: SyntaxToken, | ||
929 | } | ||
930 | impl std::fmt::Display for Minus { | ||
931 | fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { | ||
932 | std::fmt::Display::fmt(&self.syntax, f) | ||
933 | } | ||
934 | } | ||
935 | impl AstToken for Minus { | ||
936 | fn can_cast(kind: SyntaxKind) -> bool { | ||
937 | match kind { | ||
938 | MINUS => true, | ||
939 | _ => false, | ||
940 | } | ||
941 | } | ||
942 | fn cast(syntax: SyntaxToken) -> Option<Self> { | ||
943 | if Self::can_cast(syntax.kind()) { | ||
944 | Some(Self { syntax }) | ||
945 | } else { | ||
946 | None | ||
947 | } | ||
948 | } | ||
949 | fn syntax(&self) -> &SyntaxToken { | ||
950 | &self.syntax | ||
951 | } | ||
952 | } | ||
953 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
954 | pub struct ThinArrow { | ||
955 | pub(crate) syntax: SyntaxToken, | ||
956 | } | ||
957 | impl std::fmt::Display for ThinArrow { | ||
958 | fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { | ||
959 | std::fmt::Display::fmt(&self.syntax, f) | ||
960 | } | ||
961 | } | ||
962 | impl AstToken for ThinArrow { | ||
963 | fn can_cast(kind: SyntaxKind) -> bool { | ||
964 | match kind { | ||
965 | THIN_ARROW => true, | ||
966 | _ => false, | ||
967 | } | ||
968 | } | ||
969 | fn cast(syntax: SyntaxToken) -> Option<Self> { | ||
970 | if Self::can_cast(syntax.kind()) { | ||
971 | Some(Self { syntax }) | ||
972 | } else { | ||
973 | None | ||
974 | } | ||
975 | } | ||
976 | fn syntax(&self) -> &SyntaxToken { | ||
977 | &self.syntax | ||
978 | } | ||
979 | } | ||
980 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
981 | pub struct Lteq { | ||
982 | pub(crate) syntax: SyntaxToken, | ||
983 | } | ||
984 | impl std::fmt::Display for Lteq { | ||
985 | fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { | ||
986 | std::fmt::Display::fmt(&self.syntax, f) | ||
987 | } | ||
988 | } | ||
989 | impl AstToken for Lteq { | ||
990 | fn can_cast(kind: SyntaxKind) -> bool { | ||
991 | match kind { | ||
992 | LTEQ => true, | ||
993 | _ => false, | ||
994 | } | ||
995 | } | ||
996 | fn cast(syntax: SyntaxToken) -> Option<Self> { | ||
997 | if Self::can_cast(syntax.kind()) { | ||
998 | Some(Self { syntax }) | ||
999 | } else { | ||
1000 | None | ||
1001 | } | ||
1002 | } | ||
1003 | fn syntax(&self) -> &SyntaxToken { | ||
1004 | &self.syntax | ||
1005 | } | ||
1006 | } | ||
1007 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
1008 | pub struct Gteq { | ||
1009 | pub(crate) syntax: SyntaxToken, | ||
1010 | } | ||
1011 | impl std::fmt::Display for Gteq { | ||
1012 | fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { | ||
1013 | std::fmt::Display::fmt(&self.syntax, f) | ||
1014 | } | ||
1015 | } | ||
1016 | impl AstToken for Gteq { | ||
1017 | fn can_cast(kind: SyntaxKind) -> bool { | ||
1018 | match kind { | ||
1019 | GTEQ => true, | ||
1020 | _ => false, | ||
1021 | } | ||
1022 | } | ||
1023 | fn cast(syntax: SyntaxToken) -> Option<Self> { | ||
1024 | if Self::can_cast(syntax.kind()) { | ||
1025 | Some(Self { syntax }) | ||
1026 | } else { | ||
1027 | None | ||
1028 | } | ||
1029 | } | ||
1030 | fn syntax(&self) -> &SyntaxToken { | ||
1031 | &self.syntax | ||
1032 | } | ||
1033 | } | ||
1034 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
1035 | pub struct Pluseq { | ||
1036 | pub(crate) syntax: SyntaxToken, | ||
1037 | } | ||
1038 | impl std::fmt::Display for Pluseq { | ||
1039 | fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { | ||
1040 | std::fmt::Display::fmt(&self.syntax, f) | ||
1041 | } | ||
1042 | } | ||
1043 | impl AstToken for Pluseq { | ||
1044 | fn can_cast(kind: SyntaxKind) -> bool { | ||
1045 | match kind { | ||
1046 | PLUSEQ => true, | ||
1047 | _ => false, | ||
1048 | } | ||
1049 | } | ||
1050 | fn cast(syntax: SyntaxToken) -> Option<Self> { | ||
1051 | if Self::can_cast(syntax.kind()) { | ||
1052 | Some(Self { syntax }) | ||
1053 | } else { | ||
1054 | None | ||
1055 | } | ||
1056 | } | ||
1057 | fn syntax(&self) -> &SyntaxToken { | ||
1058 | &self.syntax | ||
1059 | } | ||
1060 | } | ||
1061 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
1062 | pub struct Minuseq { | ||
1063 | pub(crate) syntax: SyntaxToken, | ||
1064 | } | ||
1065 | impl std::fmt::Display for Minuseq { | ||
1066 | fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { | ||
1067 | std::fmt::Display::fmt(&self.syntax, f) | ||
1068 | } | ||
1069 | } | ||
1070 | impl AstToken for Minuseq { | ||
1071 | fn can_cast(kind: SyntaxKind) -> bool { | ||
1072 | match kind { | ||
1073 | MINUSEQ => true, | ||
1074 | _ => false, | ||
1075 | } | ||
1076 | } | ||
1077 | fn cast(syntax: SyntaxToken) -> Option<Self> { | ||
1078 | if Self::can_cast(syntax.kind()) { | ||
1079 | Some(Self { syntax }) | ||
1080 | } else { | ||
1081 | None | ||
1082 | } | ||
1083 | } | ||
1084 | fn syntax(&self) -> &SyntaxToken { | ||
1085 | &self.syntax | ||
1086 | } | ||
1087 | } | ||
1088 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
1089 | pub struct Pipeeq { | ||
1090 | pub(crate) syntax: SyntaxToken, | ||
1091 | } | ||
1092 | impl std::fmt::Display for Pipeeq { | ||
1093 | fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { | ||
1094 | std::fmt::Display::fmt(&self.syntax, f) | ||
1095 | } | ||
1096 | } | ||
1097 | impl AstToken for Pipeeq { | ||
1098 | fn can_cast(kind: SyntaxKind) -> bool { | ||
1099 | match kind { | ||
1100 | PIPEEQ => true, | ||
1101 | _ => false, | ||
1102 | } | ||
1103 | } | ||
1104 | fn cast(syntax: SyntaxToken) -> Option<Self> { | ||
1105 | if Self::can_cast(syntax.kind()) { | ||
1106 | Some(Self { syntax }) | ||
1107 | } else { | ||
1108 | None | ||
1109 | } | ||
1110 | } | ||
1111 | fn syntax(&self) -> &SyntaxToken { | ||
1112 | &self.syntax | ||
1113 | } | ||
1114 | } | ||
1115 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
1116 | pub struct Ampeq { | ||
1117 | pub(crate) syntax: SyntaxToken, | ||
1118 | } | ||
1119 | impl std::fmt::Display for Ampeq { | ||
1120 | fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { | ||
1121 | std::fmt::Display::fmt(&self.syntax, f) | ||
1122 | } | ||
1123 | } | ||
1124 | impl AstToken for Ampeq { | ||
1125 | fn can_cast(kind: SyntaxKind) -> bool { | ||
1126 | match kind { | ||
1127 | AMPEQ => true, | ||
1128 | _ => false, | ||
1129 | } | ||
1130 | } | ||
1131 | fn cast(syntax: SyntaxToken) -> Option<Self> { | ||
1132 | if Self::can_cast(syntax.kind()) { | ||
1133 | Some(Self { syntax }) | ||
1134 | } else { | ||
1135 | None | ||
1136 | } | ||
1137 | } | ||
1138 | fn syntax(&self) -> &SyntaxToken { | ||
1139 | &self.syntax | ||
1140 | } | ||
1141 | } | ||
1142 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
1143 | pub struct Careteq { | ||
1144 | pub(crate) syntax: SyntaxToken, | ||
1145 | } | ||
1146 | impl std::fmt::Display for Careteq { | ||
1147 | fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { | ||
1148 | std::fmt::Display::fmt(&self.syntax, f) | ||
1149 | } | ||
1150 | } | ||
1151 | impl AstToken for Careteq { | ||
1152 | fn can_cast(kind: SyntaxKind) -> bool { | ||
1153 | match kind { | ||
1154 | CARETEQ => true, | ||
1155 | _ => false, | ||
1156 | } | ||
1157 | } | ||
1158 | fn cast(syntax: SyntaxToken) -> Option<Self> { | ||
1159 | if Self::can_cast(syntax.kind()) { | ||
1160 | Some(Self { syntax }) | ||
1161 | } else { | ||
1162 | None | ||
1163 | } | ||
1164 | } | ||
1165 | fn syntax(&self) -> &SyntaxToken { | ||
1166 | &self.syntax | ||
1167 | } | ||
1168 | } | ||
1169 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
1170 | pub struct Slasheq { | ||
1171 | pub(crate) syntax: SyntaxToken, | ||
1172 | } | ||
1173 | impl std::fmt::Display for Slasheq { | ||
1174 | fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { | ||
1175 | std::fmt::Display::fmt(&self.syntax, f) | ||
1176 | } | ||
1177 | } | ||
1178 | impl AstToken for Slasheq { | ||
1179 | fn can_cast(kind: SyntaxKind) -> bool { | ||
1180 | match kind { | ||
1181 | SLASHEQ => true, | ||
1182 | _ => false, | ||
1183 | } | ||
1184 | } | ||
1185 | fn cast(syntax: SyntaxToken) -> Option<Self> { | ||
1186 | if Self::can_cast(syntax.kind()) { | ||
1187 | Some(Self { syntax }) | ||
1188 | } else { | ||
1189 | None | ||
1190 | } | ||
1191 | } | ||
1192 | fn syntax(&self) -> &SyntaxToken { | ||
1193 | &self.syntax | ||
1194 | } | ||
1195 | } | ||
1196 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
1197 | pub struct Stareq { | ||
1198 | pub(crate) syntax: SyntaxToken, | ||
1199 | } | ||
1200 | impl std::fmt::Display for Stareq { | ||
1201 | fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { | ||
1202 | std::fmt::Display::fmt(&self.syntax, f) | ||
1203 | } | ||
1204 | } | ||
1205 | impl AstToken for Stareq { | ||
1206 | fn can_cast(kind: SyntaxKind) -> bool { | ||
1207 | match kind { | ||
1208 | STAREQ => true, | ||
1209 | _ => false, | ||
1210 | } | ||
1211 | } | ||
1212 | fn cast(syntax: SyntaxToken) -> Option<Self> { | ||
1213 | if Self::can_cast(syntax.kind()) { | ||
1214 | Some(Self { syntax }) | ||
1215 | } else { | ||
1216 | None | ||
1217 | } | ||
1218 | } | ||
1219 | fn syntax(&self) -> &SyntaxToken { | ||
1220 | &self.syntax | ||
1221 | } | ||
1222 | } | ||
1223 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
1224 | pub struct Percenteq { | ||
1225 | pub(crate) syntax: SyntaxToken, | ||
1226 | } | ||
1227 | impl std::fmt::Display for Percenteq { | ||
1228 | fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { | ||
1229 | std::fmt::Display::fmt(&self.syntax, f) | ||
1230 | } | ||
1231 | } | ||
1232 | impl AstToken for Percenteq { | ||
1233 | fn can_cast(kind: SyntaxKind) -> bool { | ||
1234 | match kind { | ||
1235 | PERCENTEQ => true, | ||
1236 | _ => false, | ||
1237 | } | ||
1238 | } | ||
1239 | fn cast(syntax: SyntaxToken) -> Option<Self> { | ||
1240 | if Self::can_cast(syntax.kind()) { | ||
1241 | Some(Self { syntax }) | ||
1242 | } else { | ||
1243 | None | ||
1244 | } | ||
1245 | } | ||
1246 | fn syntax(&self) -> &SyntaxToken { | ||
1247 | &self.syntax | ||
1248 | } | ||
1249 | } | ||
1250 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
1251 | pub struct Ampamp { | ||
1252 | pub(crate) syntax: SyntaxToken, | ||
1253 | } | ||
1254 | impl std::fmt::Display for Ampamp { | ||
1255 | fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { | ||
1256 | std::fmt::Display::fmt(&self.syntax, f) | ||
1257 | } | ||
1258 | } | ||
1259 | impl AstToken for Ampamp { | ||
1260 | fn can_cast(kind: SyntaxKind) -> bool { | ||
1261 | match kind { | ||
1262 | AMPAMP => true, | ||
1263 | _ => false, | ||
1264 | } | ||
1265 | } | ||
1266 | fn cast(syntax: SyntaxToken) -> Option<Self> { | ||
1267 | if Self::can_cast(syntax.kind()) { | ||
1268 | Some(Self { syntax }) | ||
1269 | } else { | ||
1270 | None | ||
1271 | } | ||
1272 | } | ||
1273 | fn syntax(&self) -> &SyntaxToken { | ||
1274 | &self.syntax | ||
1275 | } | ||
1276 | } | ||
1277 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
1278 | pub struct Pipepipe { | ||
1279 | pub(crate) syntax: SyntaxToken, | ||
1280 | } | ||
1281 | impl std::fmt::Display for Pipepipe { | ||
1282 | fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { | ||
1283 | std::fmt::Display::fmt(&self.syntax, f) | ||
1284 | } | ||
1285 | } | ||
1286 | impl AstToken for Pipepipe { | ||
1287 | fn can_cast(kind: SyntaxKind) -> bool { | ||
1288 | match kind { | ||
1289 | PIPEPIPE => true, | ||
1290 | _ => false, | ||
1291 | } | ||
1292 | } | ||
1293 | fn cast(syntax: SyntaxToken) -> Option<Self> { | ||
1294 | if Self::can_cast(syntax.kind()) { | ||
1295 | Some(Self { syntax }) | ||
1296 | } else { | ||
1297 | None | ||
1298 | } | ||
1299 | } | ||
1300 | fn syntax(&self) -> &SyntaxToken { | ||
1301 | &self.syntax | ||
1302 | } | ||
1303 | } | ||
1304 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
1305 | pub struct Shl { | ||
1306 | pub(crate) syntax: SyntaxToken, | ||
1307 | } | ||
1308 | impl std::fmt::Display for Shl { | ||
1309 | fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { | ||
1310 | std::fmt::Display::fmt(&self.syntax, f) | ||
1311 | } | ||
1312 | } | ||
1313 | impl AstToken for Shl { | ||
1314 | fn can_cast(kind: SyntaxKind) -> bool { | ||
1315 | match kind { | ||
1316 | SHL => true, | ||
1317 | _ => false, | ||
1318 | } | ||
1319 | } | ||
1320 | fn cast(syntax: SyntaxToken) -> Option<Self> { | ||
1321 | if Self::can_cast(syntax.kind()) { | ||
1322 | Some(Self { syntax }) | ||
1323 | } else { | ||
1324 | None | ||
1325 | } | ||
1326 | } | ||
1327 | fn syntax(&self) -> &SyntaxToken { | ||
1328 | &self.syntax | ||
1329 | } | ||
1330 | } | ||
1331 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
1332 | pub struct Shr { | ||
1333 | pub(crate) syntax: SyntaxToken, | ||
1334 | } | ||
1335 | impl std::fmt::Display for Shr { | ||
1336 | fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { | ||
1337 | std::fmt::Display::fmt(&self.syntax, f) | ||
1338 | } | ||
1339 | } | ||
1340 | impl AstToken for Shr { | ||
1341 | fn can_cast(kind: SyntaxKind) -> bool { | ||
1342 | match kind { | ||
1343 | SHR => true, | ||
1344 | _ => false, | ||
1345 | } | ||
1346 | } | ||
1347 | fn cast(syntax: SyntaxToken) -> Option<Self> { | ||
1348 | if Self::can_cast(syntax.kind()) { | ||
1349 | Some(Self { syntax }) | ||
1350 | } else { | ||
1351 | None | ||
1352 | } | ||
1353 | } | ||
1354 | fn syntax(&self) -> &SyntaxToken { | ||
1355 | &self.syntax | ||
1356 | } | ||
1357 | } | ||
1358 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
1359 | pub struct Shleq { | ||
1360 | pub(crate) syntax: SyntaxToken, | ||
1361 | } | ||
1362 | impl std::fmt::Display for Shleq { | ||
1363 | fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { | ||
1364 | std::fmt::Display::fmt(&self.syntax, f) | ||
1365 | } | ||
1366 | } | ||
1367 | impl AstToken for Shleq { | ||
1368 | fn can_cast(kind: SyntaxKind) -> bool { | ||
1369 | match kind { | ||
1370 | SHLEQ => true, | ||
1371 | _ => false, | ||
1372 | } | ||
1373 | } | ||
1374 | fn cast(syntax: SyntaxToken) -> Option<Self> { | ||
1375 | if Self::can_cast(syntax.kind()) { | ||
1376 | Some(Self { syntax }) | ||
1377 | } else { | ||
1378 | None | ||
1379 | } | ||
1380 | } | ||
1381 | fn syntax(&self) -> &SyntaxToken { | ||
1382 | &self.syntax | ||
1383 | } | ||
1384 | } | ||
1385 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
1386 | pub struct Shreq { | ||
1387 | pub(crate) syntax: SyntaxToken, | ||
1388 | } | ||
1389 | impl std::fmt::Display for Shreq { | ||
1390 | fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { | ||
1391 | std::fmt::Display::fmt(&self.syntax, f) | ||
1392 | } | ||
1393 | } | ||
1394 | impl AstToken for Shreq { | ||
1395 | fn can_cast(kind: SyntaxKind) -> bool { | ||
1396 | match kind { | ||
1397 | SHREQ => true, | ||
1398 | _ => false, | ||
1399 | } | ||
1400 | } | ||
1401 | fn cast(syntax: SyntaxToken) -> Option<Self> { | ||
1402 | if Self::can_cast(syntax.kind()) { | ||
1403 | Some(Self { syntax }) | ||
1404 | } else { | ||
1405 | None | ||
1406 | } | ||
1407 | } | ||
1408 | fn syntax(&self) -> &SyntaxToken { | ||
1409 | &self.syntax | ||
1410 | } | ||
1411 | } | ||
1412 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
1413 | pub struct AsKw { | ||
1414 | pub(crate) syntax: SyntaxToken, | ||
1415 | } | ||
1416 | impl std::fmt::Display for AsKw { | ||
1417 | fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { | ||
1418 | std::fmt::Display::fmt(&self.syntax, f) | ||
1419 | } | ||
1420 | } | ||
1421 | impl AstToken for AsKw { | ||
1422 | fn can_cast(kind: SyntaxKind) -> bool { | ||
1423 | match kind { | ||
1424 | AS_KW => true, | ||
1425 | _ => false, | ||
1426 | } | ||
1427 | } | ||
1428 | fn cast(syntax: SyntaxToken) -> Option<Self> { | ||
1429 | if Self::can_cast(syntax.kind()) { | ||
1430 | Some(Self { syntax }) | ||
1431 | } else { | ||
1432 | None | ||
1433 | } | ||
1434 | } | ||
1435 | fn syntax(&self) -> &SyntaxToken { | ||
1436 | &self.syntax | ||
1437 | } | ||
1438 | } | ||
1439 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
1440 | pub struct AsyncKw { | ||
1441 | pub(crate) syntax: SyntaxToken, | ||
1442 | } | ||
1443 | impl std::fmt::Display for AsyncKw { | ||
1444 | fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { | ||
1445 | std::fmt::Display::fmt(&self.syntax, f) | ||
1446 | } | ||
1447 | } | ||
1448 | impl AstToken for AsyncKw { | ||
1449 | fn can_cast(kind: SyntaxKind) -> bool { | ||
1450 | match kind { | ||
1451 | ASYNC_KW => true, | ||
1452 | _ => false, | ||
1453 | } | ||
1454 | } | ||
1455 | fn cast(syntax: SyntaxToken) -> Option<Self> { | ||
1456 | if Self::can_cast(syntax.kind()) { | ||
1457 | Some(Self { syntax }) | ||
1458 | } else { | ||
1459 | None | ||
1460 | } | ||
1461 | } | ||
1462 | fn syntax(&self) -> &SyntaxToken { | ||
1463 | &self.syntax | ||
1464 | } | ||
1465 | } | ||
1466 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
1467 | pub struct AwaitKw { | ||
1468 | pub(crate) syntax: SyntaxToken, | ||
1469 | } | ||
1470 | impl std::fmt::Display for AwaitKw { | ||
1471 | fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { | ||
1472 | std::fmt::Display::fmt(&self.syntax, f) | ||
1473 | } | ||
1474 | } | ||
1475 | impl AstToken for AwaitKw { | ||
1476 | fn can_cast(kind: SyntaxKind) -> bool { | ||
1477 | match kind { | ||
1478 | AWAIT_KW => true, | ||
1479 | _ => false, | ||
1480 | } | ||
1481 | } | ||
1482 | fn cast(syntax: SyntaxToken) -> Option<Self> { | ||
1483 | if Self::can_cast(syntax.kind()) { | ||
1484 | Some(Self { syntax }) | ||
1485 | } else { | ||
1486 | None | ||
1487 | } | ||
1488 | } | ||
1489 | fn syntax(&self) -> &SyntaxToken { | ||
1490 | &self.syntax | ||
1491 | } | ||
1492 | } | ||
1493 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
1494 | pub struct BoxKw { | ||
1495 | pub(crate) syntax: SyntaxToken, | ||
1496 | } | ||
1497 | impl std::fmt::Display for BoxKw { | ||
1498 | fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { | ||
1499 | std::fmt::Display::fmt(&self.syntax, f) | ||
1500 | } | ||
1501 | } | ||
1502 | impl AstToken for BoxKw { | ||
1503 | fn can_cast(kind: SyntaxKind) -> bool { | ||
1504 | match kind { | ||
1505 | BOX_KW => true, | ||
1506 | _ => false, | ||
1507 | } | ||
1508 | } | ||
1509 | fn cast(syntax: SyntaxToken) -> Option<Self> { | ||
1510 | if Self::can_cast(syntax.kind()) { | ||
1511 | Some(Self { syntax }) | ||
1512 | } else { | ||
1513 | None | ||
1514 | } | ||
1515 | } | ||
1516 | fn syntax(&self) -> &SyntaxToken { | ||
1517 | &self.syntax | ||
1518 | } | ||
1519 | } | ||
1520 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
1521 | pub struct BreakKw { | ||
1522 | pub(crate) syntax: SyntaxToken, | ||
1523 | } | ||
1524 | impl std::fmt::Display for BreakKw { | ||
1525 | fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { | ||
1526 | std::fmt::Display::fmt(&self.syntax, f) | ||
1527 | } | ||
1528 | } | ||
1529 | impl AstToken for BreakKw { | ||
1530 | fn can_cast(kind: SyntaxKind) -> bool { | ||
1531 | match kind { | ||
1532 | BREAK_KW => true, | ||
1533 | _ => false, | ||
1534 | } | ||
1535 | } | ||
1536 | fn cast(syntax: SyntaxToken) -> Option<Self> { | ||
1537 | if Self::can_cast(syntax.kind()) { | ||
1538 | Some(Self { syntax }) | ||
1539 | } else { | ||
1540 | None | ||
1541 | } | ||
1542 | } | ||
1543 | fn syntax(&self) -> &SyntaxToken { | ||
1544 | &self.syntax | ||
1545 | } | ||
1546 | } | ||
1547 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
1548 | pub struct ConstKw { | ||
1549 | pub(crate) syntax: SyntaxToken, | ||
1550 | } | ||
1551 | impl std::fmt::Display for ConstKw { | ||
1552 | fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { | ||
1553 | std::fmt::Display::fmt(&self.syntax, f) | ||
1554 | } | ||
1555 | } | ||
1556 | impl AstToken for ConstKw { | ||
1557 | fn can_cast(kind: SyntaxKind) -> bool { | ||
1558 | match kind { | ||
1559 | CONST_KW => true, | ||
1560 | _ => false, | ||
1561 | } | ||
1562 | } | ||
1563 | fn cast(syntax: SyntaxToken) -> Option<Self> { | ||
1564 | if Self::can_cast(syntax.kind()) { | ||
1565 | Some(Self { syntax }) | ||
1566 | } else { | ||
1567 | None | ||
1568 | } | ||
1569 | } | ||
1570 | fn syntax(&self) -> &SyntaxToken { | ||
1571 | &self.syntax | ||
1572 | } | ||
1573 | } | ||
1574 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
1575 | pub struct ContinueKw { | ||
1576 | pub(crate) syntax: SyntaxToken, | ||
1577 | } | ||
1578 | impl std::fmt::Display for ContinueKw { | ||
1579 | fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { | ||
1580 | std::fmt::Display::fmt(&self.syntax, f) | ||
1581 | } | ||
1582 | } | ||
1583 | impl AstToken for ContinueKw { | ||
1584 | fn can_cast(kind: SyntaxKind) -> bool { | ||
1585 | match kind { | ||
1586 | CONTINUE_KW => true, | ||
1587 | _ => false, | ||
1588 | } | ||
1589 | } | ||
1590 | fn cast(syntax: SyntaxToken) -> Option<Self> { | ||
1591 | if Self::can_cast(syntax.kind()) { | ||
1592 | Some(Self { syntax }) | ||
1593 | } else { | ||
1594 | None | ||
1595 | } | ||
1596 | } | ||
1597 | fn syntax(&self) -> &SyntaxToken { | ||
1598 | &self.syntax | ||
1599 | } | ||
1600 | } | ||
1601 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
1602 | pub struct CrateKw { | ||
1603 | pub(crate) syntax: SyntaxToken, | ||
1604 | } | ||
1605 | impl std::fmt::Display for CrateKw { | ||
1606 | fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { | ||
1607 | std::fmt::Display::fmt(&self.syntax, f) | ||
1608 | } | ||
1609 | } | ||
1610 | impl AstToken for CrateKw { | ||
1611 | fn can_cast(kind: SyntaxKind) -> bool { | ||
1612 | match kind { | ||
1613 | CRATE_KW => true, | ||
1614 | _ => false, | ||
1615 | } | ||
1616 | } | ||
1617 | fn cast(syntax: SyntaxToken) -> Option<Self> { | ||
1618 | if Self::can_cast(syntax.kind()) { | ||
1619 | Some(Self { syntax }) | ||
1620 | } else { | ||
1621 | None | ||
1622 | } | ||
1623 | } | ||
1624 | fn syntax(&self) -> &SyntaxToken { | ||
1625 | &self.syntax | ||
1626 | } | ||
1627 | } | ||
1628 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
1629 | pub struct DynKw { | ||
1630 | pub(crate) syntax: SyntaxToken, | ||
1631 | } | ||
1632 | impl std::fmt::Display for DynKw { | ||
1633 | fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { | ||
1634 | std::fmt::Display::fmt(&self.syntax, f) | ||
1635 | } | ||
1636 | } | ||
1637 | impl AstToken for DynKw { | ||
1638 | fn can_cast(kind: SyntaxKind) -> bool { | ||
1639 | match kind { | ||
1640 | DYN_KW => true, | ||
1641 | _ => false, | ||
1642 | } | ||
1643 | } | ||
1644 | fn cast(syntax: SyntaxToken) -> Option<Self> { | ||
1645 | if Self::can_cast(syntax.kind()) { | ||
1646 | Some(Self { syntax }) | ||
1647 | } else { | ||
1648 | None | ||
1649 | } | ||
1650 | } | ||
1651 | fn syntax(&self) -> &SyntaxToken { | ||
1652 | &self.syntax | ||
1653 | } | ||
1654 | } | ||
1655 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
1656 | pub struct ElseKw { | ||
1657 | pub(crate) syntax: SyntaxToken, | ||
1658 | } | ||
1659 | impl std::fmt::Display for ElseKw { | ||
1660 | fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { | ||
1661 | std::fmt::Display::fmt(&self.syntax, f) | ||
1662 | } | ||
1663 | } | ||
1664 | impl AstToken for ElseKw { | ||
1665 | fn can_cast(kind: SyntaxKind) -> bool { | ||
1666 | match kind { | ||
1667 | ELSE_KW => true, | ||
1668 | _ => false, | ||
1669 | } | ||
1670 | } | ||
1671 | fn cast(syntax: SyntaxToken) -> Option<Self> { | ||
1672 | if Self::can_cast(syntax.kind()) { | ||
1673 | Some(Self { syntax }) | ||
1674 | } else { | ||
1675 | None | ||
1676 | } | ||
1677 | } | ||
1678 | fn syntax(&self) -> &SyntaxToken { | ||
1679 | &self.syntax | ||
1680 | } | ||
1681 | } | ||
1682 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
1683 | pub struct EnumKw { | ||
1684 | pub(crate) syntax: SyntaxToken, | ||
1685 | } | ||
1686 | impl std::fmt::Display for EnumKw { | ||
1687 | fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { | ||
1688 | std::fmt::Display::fmt(&self.syntax, f) | ||
1689 | } | ||
1690 | } | ||
1691 | impl AstToken for EnumKw { | ||
1692 | fn can_cast(kind: SyntaxKind) -> bool { | ||
1693 | match kind { | ||
1694 | ENUM_KW => true, | ||
1695 | _ => false, | ||
1696 | } | ||
1697 | } | ||
1698 | fn cast(syntax: SyntaxToken) -> Option<Self> { | ||
1699 | if Self::can_cast(syntax.kind()) { | ||
1700 | Some(Self { syntax }) | ||
1701 | } else { | ||
1702 | None | ||
1703 | } | ||
1704 | } | ||
1705 | fn syntax(&self) -> &SyntaxToken { | ||
1706 | &self.syntax | ||
1707 | } | ||
1708 | } | ||
1709 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
1710 | pub struct ExternKw { | ||
1711 | pub(crate) syntax: SyntaxToken, | ||
1712 | } | ||
1713 | impl std::fmt::Display for ExternKw { | ||
1714 | fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { | ||
1715 | std::fmt::Display::fmt(&self.syntax, f) | ||
1716 | } | ||
1717 | } | ||
1718 | impl AstToken for ExternKw { | ||
1719 | fn can_cast(kind: SyntaxKind) -> bool { | ||
1720 | match kind { | ||
1721 | EXTERN_KW => true, | ||
1722 | _ => false, | ||
1723 | } | ||
1724 | } | ||
1725 | fn cast(syntax: SyntaxToken) -> Option<Self> { | ||
1726 | if Self::can_cast(syntax.kind()) { | ||
1727 | Some(Self { syntax }) | ||
1728 | } else { | ||
1729 | None | ||
1730 | } | ||
1731 | } | ||
1732 | fn syntax(&self) -> &SyntaxToken { | ||
1733 | &self.syntax | ||
1734 | } | ||
1735 | } | ||
1736 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
1737 | pub struct FalseKw { | ||
1738 | pub(crate) syntax: SyntaxToken, | ||
1739 | } | ||
1740 | impl std::fmt::Display for FalseKw { | ||
1741 | fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { | ||
1742 | std::fmt::Display::fmt(&self.syntax, f) | ||
1743 | } | ||
1744 | } | ||
1745 | impl AstToken for FalseKw { | ||
1746 | fn can_cast(kind: SyntaxKind) -> bool { | ||
1747 | match kind { | ||
1748 | FALSE_KW => true, | ||
1749 | _ => false, | ||
1750 | } | ||
1751 | } | ||
1752 | fn cast(syntax: SyntaxToken) -> Option<Self> { | ||
1753 | if Self::can_cast(syntax.kind()) { | ||
1754 | Some(Self { syntax }) | ||
1755 | } else { | ||
1756 | None | ||
1757 | } | ||
1758 | } | ||
1759 | fn syntax(&self) -> &SyntaxToken { | ||
1760 | &self.syntax | ||
1761 | } | ||
1762 | } | ||
1763 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
1764 | pub struct FnKw { | ||
1765 | pub(crate) syntax: SyntaxToken, | ||
1766 | } | ||
1767 | impl std::fmt::Display for FnKw { | ||
1768 | fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { | ||
1769 | std::fmt::Display::fmt(&self.syntax, f) | ||
1770 | } | ||
1771 | } | ||
1772 | impl AstToken for FnKw { | ||
1773 | fn can_cast(kind: SyntaxKind) -> bool { | ||
1774 | match kind { | ||
1775 | FN_KW => true, | ||
1776 | _ => false, | ||
1777 | } | ||
1778 | } | ||
1779 | fn cast(syntax: SyntaxToken) -> Option<Self> { | ||
1780 | if Self::can_cast(syntax.kind()) { | ||
1781 | Some(Self { syntax }) | ||
1782 | } else { | ||
1783 | None | ||
1784 | } | ||
1785 | } | ||
1786 | fn syntax(&self) -> &SyntaxToken { | ||
1787 | &self.syntax | ||
1788 | } | ||
1789 | } | ||
1790 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
1791 | pub struct ForKw { | ||
1792 | pub(crate) syntax: SyntaxToken, | ||
1793 | } | ||
1794 | impl std::fmt::Display for ForKw { | ||
1795 | fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { | ||
1796 | std::fmt::Display::fmt(&self.syntax, f) | ||
1797 | } | ||
1798 | } | ||
1799 | impl AstToken for ForKw { | ||
1800 | fn can_cast(kind: SyntaxKind) -> bool { | ||
1801 | match kind { | ||
1802 | FOR_KW => true, | ||
1803 | _ => false, | ||
1804 | } | ||
1805 | } | ||
1806 | fn cast(syntax: SyntaxToken) -> Option<Self> { | ||
1807 | if Self::can_cast(syntax.kind()) { | ||
1808 | Some(Self { syntax }) | ||
1809 | } else { | ||
1810 | None | ||
1811 | } | ||
1812 | } | ||
1813 | fn syntax(&self) -> &SyntaxToken { | ||
1814 | &self.syntax | ||
1815 | } | ||
1816 | } | ||
1817 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
1818 | pub struct IfKw { | ||
1819 | pub(crate) syntax: SyntaxToken, | ||
1820 | } | ||
1821 | impl std::fmt::Display for IfKw { | ||
1822 | fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { | ||
1823 | std::fmt::Display::fmt(&self.syntax, f) | ||
1824 | } | ||
1825 | } | ||
1826 | impl AstToken for IfKw { | ||
1827 | fn can_cast(kind: SyntaxKind) -> bool { | ||
1828 | match kind { | ||
1829 | IF_KW => true, | ||
1830 | _ => false, | ||
1831 | } | ||
1832 | } | ||
1833 | fn cast(syntax: SyntaxToken) -> Option<Self> { | ||
1834 | if Self::can_cast(syntax.kind()) { | ||
1835 | Some(Self { syntax }) | ||
1836 | } else { | ||
1837 | None | ||
1838 | } | ||
1839 | } | ||
1840 | fn syntax(&self) -> &SyntaxToken { | ||
1841 | &self.syntax | ||
1842 | } | ||
1843 | } | ||
1844 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
1845 | pub struct ImplKw { | ||
1846 | pub(crate) syntax: SyntaxToken, | ||
1847 | } | ||
1848 | impl std::fmt::Display for ImplKw { | ||
1849 | fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { | ||
1850 | std::fmt::Display::fmt(&self.syntax, f) | ||
1851 | } | ||
1852 | } | ||
1853 | impl AstToken for ImplKw { | ||
1854 | fn can_cast(kind: SyntaxKind) -> bool { | ||
1855 | match kind { | ||
1856 | IMPL_KW => true, | ||
1857 | _ => false, | ||
1858 | } | ||
1859 | } | ||
1860 | fn cast(syntax: SyntaxToken) -> Option<Self> { | ||
1861 | if Self::can_cast(syntax.kind()) { | ||
1862 | Some(Self { syntax }) | ||
1863 | } else { | ||
1864 | None | ||
1865 | } | ||
1866 | } | ||
1867 | fn syntax(&self) -> &SyntaxToken { | ||
1868 | &self.syntax | ||
1869 | } | ||
1870 | } | ||
1871 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
1872 | pub struct InKw { | ||
1873 | pub(crate) syntax: SyntaxToken, | ||
1874 | } | ||
1875 | impl std::fmt::Display for InKw { | ||
1876 | fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { | ||
1877 | std::fmt::Display::fmt(&self.syntax, f) | ||
1878 | } | ||
1879 | } | ||
1880 | impl AstToken for InKw { | ||
1881 | fn can_cast(kind: SyntaxKind) -> bool { | ||
1882 | match kind { | ||
1883 | IN_KW => true, | ||
1884 | _ => false, | ||
1885 | } | ||
1886 | } | ||
1887 | fn cast(syntax: SyntaxToken) -> Option<Self> { | ||
1888 | if Self::can_cast(syntax.kind()) { | ||
1889 | Some(Self { syntax }) | ||
1890 | } else { | ||
1891 | None | ||
1892 | } | ||
1893 | } | ||
1894 | fn syntax(&self) -> &SyntaxToken { | ||
1895 | &self.syntax | ||
1896 | } | ||
1897 | } | ||
1898 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
1899 | pub struct LetKw { | ||
1900 | pub(crate) syntax: SyntaxToken, | ||
1901 | } | ||
1902 | impl std::fmt::Display for LetKw { | ||
1903 | fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { | ||
1904 | std::fmt::Display::fmt(&self.syntax, f) | ||
1905 | } | ||
1906 | } | ||
1907 | impl AstToken for LetKw { | ||
1908 | fn can_cast(kind: SyntaxKind) -> bool { | ||
1909 | match kind { | ||
1910 | LET_KW => true, | ||
1911 | _ => false, | ||
1912 | } | ||
1913 | } | ||
1914 | fn cast(syntax: SyntaxToken) -> Option<Self> { | ||
1915 | if Self::can_cast(syntax.kind()) { | ||
1916 | Some(Self { syntax }) | ||
1917 | } else { | ||
1918 | None | ||
1919 | } | ||
1920 | } | ||
1921 | fn syntax(&self) -> &SyntaxToken { | ||
1922 | &self.syntax | ||
1923 | } | ||
1924 | } | ||
1925 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
1926 | pub struct LoopKw { | ||
1927 | pub(crate) syntax: SyntaxToken, | ||
1928 | } | ||
1929 | impl std::fmt::Display for LoopKw { | ||
1930 | fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { | ||
1931 | std::fmt::Display::fmt(&self.syntax, f) | ||
1932 | } | ||
1933 | } | ||
1934 | impl AstToken for LoopKw { | ||
1935 | fn can_cast(kind: SyntaxKind) -> bool { | ||
1936 | match kind { | ||
1937 | LOOP_KW => true, | ||
1938 | _ => false, | ||
1939 | } | ||
1940 | } | ||
1941 | fn cast(syntax: SyntaxToken) -> Option<Self> { | ||
1942 | if Self::can_cast(syntax.kind()) { | ||
1943 | Some(Self { syntax }) | ||
1944 | } else { | ||
1945 | None | ||
1946 | } | ||
1947 | } | ||
1948 | fn syntax(&self) -> &SyntaxToken { | ||
1949 | &self.syntax | ||
1950 | } | ||
1951 | } | ||
1952 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
1953 | pub struct MacroKw { | ||
1954 | pub(crate) syntax: SyntaxToken, | ||
1955 | } | ||
1956 | impl std::fmt::Display for MacroKw { | ||
1957 | fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { | ||
1958 | std::fmt::Display::fmt(&self.syntax, f) | ||
1959 | } | ||
1960 | } | ||
1961 | impl AstToken for MacroKw { | ||
1962 | fn can_cast(kind: SyntaxKind) -> bool { | ||
1963 | match kind { | ||
1964 | MACRO_KW => true, | ||
1965 | _ => false, | ||
1966 | } | ||
1967 | } | ||
1968 | fn cast(syntax: SyntaxToken) -> Option<Self> { | ||
1969 | if Self::can_cast(syntax.kind()) { | ||
1970 | Some(Self { syntax }) | ||
1971 | } else { | ||
1972 | None | ||
1973 | } | ||
1974 | } | ||
1975 | fn syntax(&self) -> &SyntaxToken { | ||
1976 | &self.syntax | ||
1977 | } | ||
1978 | } | ||
1979 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
1980 | pub struct MatchKw { | ||
1981 | pub(crate) syntax: SyntaxToken, | ||
1982 | } | ||
1983 | impl std::fmt::Display for MatchKw { | ||
1984 | fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { | ||
1985 | std::fmt::Display::fmt(&self.syntax, f) | ||
1986 | } | ||
1987 | } | ||
1988 | impl AstToken for MatchKw { | ||
1989 | fn can_cast(kind: SyntaxKind) -> bool { | ||
1990 | match kind { | ||
1991 | MATCH_KW => true, | ||
1992 | _ => false, | ||
1993 | } | ||
1994 | } | ||
1995 | fn cast(syntax: SyntaxToken) -> Option<Self> { | ||
1996 | if Self::can_cast(syntax.kind()) { | ||
1997 | Some(Self { syntax }) | ||
1998 | } else { | ||
1999 | None | ||
2000 | } | ||
2001 | } | ||
2002 | fn syntax(&self) -> &SyntaxToken { | ||
2003 | &self.syntax | ||
2004 | } | ||
2005 | } | ||
2006 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
2007 | pub struct ModKw { | ||
2008 | pub(crate) syntax: SyntaxToken, | ||
2009 | } | ||
2010 | impl std::fmt::Display for ModKw { | ||
2011 | fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { | ||
2012 | std::fmt::Display::fmt(&self.syntax, f) | ||
2013 | } | ||
2014 | } | ||
2015 | impl AstToken for ModKw { | ||
2016 | fn can_cast(kind: SyntaxKind) -> bool { | ||
2017 | match kind { | ||
2018 | MOD_KW => true, | ||
2019 | _ => false, | ||
2020 | } | ||
2021 | } | ||
2022 | fn cast(syntax: SyntaxToken) -> Option<Self> { | ||
2023 | if Self::can_cast(syntax.kind()) { | ||
2024 | Some(Self { syntax }) | ||
2025 | } else { | ||
2026 | None | ||
2027 | } | ||
2028 | } | ||
2029 | fn syntax(&self) -> &SyntaxToken { | ||
2030 | &self.syntax | ||
2031 | } | ||
2032 | } | ||
2033 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
2034 | pub struct MoveKw { | ||
2035 | pub(crate) syntax: SyntaxToken, | ||
2036 | } | ||
2037 | impl std::fmt::Display for MoveKw { | ||
2038 | fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { | ||
2039 | std::fmt::Display::fmt(&self.syntax, f) | ||
2040 | } | ||
2041 | } | ||
2042 | impl AstToken for MoveKw { | ||
2043 | fn can_cast(kind: SyntaxKind) -> bool { | ||
2044 | match kind { | ||
2045 | MOVE_KW => true, | ||
2046 | _ => false, | ||
2047 | } | ||
2048 | } | ||
2049 | fn cast(syntax: SyntaxToken) -> Option<Self> { | ||
2050 | if Self::can_cast(syntax.kind()) { | ||
2051 | Some(Self { syntax }) | ||
2052 | } else { | ||
2053 | None | ||
2054 | } | ||
2055 | } | ||
2056 | fn syntax(&self) -> &SyntaxToken { | ||
2057 | &self.syntax | ||
2058 | } | ||
2059 | } | ||
2060 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
2061 | pub struct MutKw { | ||
2062 | pub(crate) syntax: SyntaxToken, | ||
2063 | } | ||
2064 | impl std::fmt::Display for MutKw { | ||
2065 | fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { | ||
2066 | std::fmt::Display::fmt(&self.syntax, f) | ||
2067 | } | ||
2068 | } | ||
2069 | impl AstToken for MutKw { | ||
2070 | fn can_cast(kind: SyntaxKind) -> bool { | ||
2071 | match kind { | ||
2072 | MUT_KW => true, | ||
2073 | _ => false, | ||
2074 | } | ||
2075 | } | ||
2076 | fn cast(syntax: SyntaxToken) -> Option<Self> { | ||
2077 | if Self::can_cast(syntax.kind()) { | ||
2078 | Some(Self { syntax }) | ||
2079 | } else { | ||
2080 | None | ||
2081 | } | ||
2082 | } | ||
2083 | fn syntax(&self) -> &SyntaxToken { | ||
2084 | &self.syntax | ||
2085 | } | ||
2086 | } | ||
2087 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
2088 | pub struct PubKw { | ||
2089 | pub(crate) syntax: SyntaxToken, | ||
2090 | } | ||
2091 | impl std::fmt::Display for PubKw { | ||
2092 | fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { | ||
2093 | std::fmt::Display::fmt(&self.syntax, f) | ||
2094 | } | ||
2095 | } | ||
2096 | impl AstToken for PubKw { | ||
2097 | fn can_cast(kind: SyntaxKind) -> bool { | ||
2098 | match kind { | ||
2099 | PUB_KW => true, | ||
2100 | _ => false, | ||
2101 | } | ||
2102 | } | ||
2103 | fn cast(syntax: SyntaxToken) -> Option<Self> { | ||
2104 | if Self::can_cast(syntax.kind()) { | ||
2105 | Some(Self { syntax }) | ||
2106 | } else { | ||
2107 | None | ||
2108 | } | ||
2109 | } | ||
2110 | fn syntax(&self) -> &SyntaxToken { | ||
2111 | &self.syntax | ||
2112 | } | ||
2113 | } | ||
2114 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
2115 | pub struct RefKw { | ||
2116 | pub(crate) syntax: SyntaxToken, | ||
2117 | } | ||
2118 | impl std::fmt::Display for RefKw { | ||
2119 | fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { | ||
2120 | std::fmt::Display::fmt(&self.syntax, f) | ||
2121 | } | ||
2122 | } | ||
2123 | impl AstToken for RefKw { | ||
2124 | fn can_cast(kind: SyntaxKind) -> bool { | ||
2125 | match kind { | ||
2126 | REF_KW => true, | ||
2127 | _ => false, | ||
2128 | } | ||
2129 | } | ||
2130 | fn cast(syntax: SyntaxToken) -> Option<Self> { | ||
2131 | if Self::can_cast(syntax.kind()) { | ||
2132 | Some(Self { syntax }) | ||
2133 | } else { | ||
2134 | None | ||
2135 | } | ||
2136 | } | ||
2137 | fn syntax(&self) -> &SyntaxToken { | ||
2138 | &self.syntax | ||
2139 | } | ||
2140 | } | ||
2141 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
2142 | pub struct ReturnKw { | ||
2143 | pub(crate) syntax: SyntaxToken, | ||
2144 | } | ||
2145 | impl std::fmt::Display for ReturnKw { | ||
2146 | fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { | ||
2147 | std::fmt::Display::fmt(&self.syntax, f) | ||
2148 | } | ||
2149 | } | ||
2150 | impl AstToken for ReturnKw { | ||
2151 | fn can_cast(kind: SyntaxKind) -> bool { | ||
2152 | match kind { | ||
2153 | RETURN_KW => true, | ||
2154 | _ => false, | ||
2155 | } | ||
2156 | } | ||
2157 | fn cast(syntax: SyntaxToken) -> Option<Self> { | ||
2158 | if Self::can_cast(syntax.kind()) { | ||
2159 | Some(Self { syntax }) | ||
2160 | } else { | ||
2161 | None | ||
2162 | } | ||
2163 | } | ||
2164 | fn syntax(&self) -> &SyntaxToken { | ||
2165 | &self.syntax | ||
2166 | } | ||
2167 | } | ||
2168 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
2169 | pub struct SelfKw { | ||
2170 | pub(crate) syntax: SyntaxToken, | ||
2171 | } | ||
2172 | impl std::fmt::Display for SelfKw { | ||
2173 | fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { | ||
2174 | std::fmt::Display::fmt(&self.syntax, f) | ||
2175 | } | ||
2176 | } | ||
2177 | impl AstToken for SelfKw { | ||
2178 | fn can_cast(kind: SyntaxKind) -> bool { | ||
2179 | match kind { | ||
2180 | SELF_KW => true, | ||
2181 | _ => false, | ||
2182 | } | ||
2183 | } | ||
2184 | fn cast(syntax: SyntaxToken) -> Option<Self> { | ||
2185 | if Self::can_cast(syntax.kind()) { | ||
2186 | Some(Self { syntax }) | ||
2187 | } else { | ||
2188 | None | ||
2189 | } | ||
2190 | } | ||
2191 | fn syntax(&self) -> &SyntaxToken { | ||
2192 | &self.syntax | ||
2193 | } | ||
2194 | } | ||
2195 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
2196 | pub struct StaticKw { | ||
2197 | pub(crate) syntax: SyntaxToken, | ||
2198 | } | ||
2199 | impl std::fmt::Display for StaticKw { | ||
2200 | fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { | ||
2201 | std::fmt::Display::fmt(&self.syntax, f) | ||
2202 | } | ||
2203 | } | ||
2204 | impl AstToken for StaticKw { | ||
2205 | fn can_cast(kind: SyntaxKind) -> bool { | ||
2206 | match kind { | ||
2207 | STATIC_KW => true, | ||
2208 | _ => false, | ||
2209 | } | ||
2210 | } | ||
2211 | fn cast(syntax: SyntaxToken) -> Option<Self> { | ||
2212 | if Self::can_cast(syntax.kind()) { | ||
2213 | Some(Self { syntax }) | ||
2214 | } else { | ||
2215 | None | ||
2216 | } | ||
2217 | } | ||
2218 | fn syntax(&self) -> &SyntaxToken { | ||
2219 | &self.syntax | ||
2220 | } | ||
2221 | } | ||
2222 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
2223 | pub struct StructKw { | ||
2224 | pub(crate) syntax: SyntaxToken, | ||
2225 | } | ||
2226 | impl std::fmt::Display for StructKw { | ||
2227 | fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { | ||
2228 | std::fmt::Display::fmt(&self.syntax, f) | ||
2229 | } | ||
2230 | } | ||
2231 | impl AstToken for StructKw { | ||
2232 | fn can_cast(kind: SyntaxKind) -> bool { | ||
2233 | match kind { | ||
2234 | STRUCT_KW => true, | ||
2235 | _ => false, | ||
2236 | } | ||
2237 | } | ||
2238 | fn cast(syntax: SyntaxToken) -> Option<Self> { | ||
2239 | if Self::can_cast(syntax.kind()) { | ||
2240 | Some(Self { syntax }) | ||
2241 | } else { | ||
2242 | None | ||
2243 | } | ||
2244 | } | ||
2245 | fn syntax(&self) -> &SyntaxToken { | ||
2246 | &self.syntax | ||
2247 | } | ||
2248 | } | ||
2249 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
2250 | pub struct SuperKw { | ||
2251 | pub(crate) syntax: SyntaxToken, | ||
2252 | } | ||
2253 | impl std::fmt::Display for SuperKw { | ||
2254 | fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { | ||
2255 | std::fmt::Display::fmt(&self.syntax, f) | ||
2256 | } | ||
2257 | } | ||
2258 | impl AstToken for SuperKw { | ||
2259 | fn can_cast(kind: SyntaxKind) -> bool { | ||
2260 | match kind { | ||
2261 | SUPER_KW => true, | ||
2262 | _ => false, | ||
2263 | } | ||
2264 | } | ||
2265 | fn cast(syntax: SyntaxToken) -> Option<Self> { | ||
2266 | if Self::can_cast(syntax.kind()) { | ||
2267 | Some(Self { syntax }) | ||
2268 | } else { | ||
2269 | None | ||
2270 | } | ||
2271 | } | ||
2272 | fn syntax(&self) -> &SyntaxToken { | ||
2273 | &self.syntax | ||
2274 | } | ||
2275 | } | ||
2276 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
2277 | pub struct TraitKw { | ||
2278 | pub(crate) syntax: SyntaxToken, | ||
2279 | } | ||
2280 | impl std::fmt::Display for TraitKw { | ||
2281 | fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { | ||
2282 | std::fmt::Display::fmt(&self.syntax, f) | ||
2283 | } | ||
2284 | } | ||
2285 | impl AstToken for TraitKw { | ||
2286 | fn can_cast(kind: SyntaxKind) -> bool { | ||
2287 | match kind { | ||
2288 | TRAIT_KW => true, | ||
2289 | _ => false, | ||
2290 | } | ||
2291 | } | ||
2292 | fn cast(syntax: SyntaxToken) -> Option<Self> { | ||
2293 | if Self::can_cast(syntax.kind()) { | ||
2294 | Some(Self { syntax }) | ||
2295 | } else { | ||
2296 | None | ||
2297 | } | ||
2298 | } | ||
2299 | fn syntax(&self) -> &SyntaxToken { | ||
2300 | &self.syntax | ||
2301 | } | ||
2302 | } | ||
2303 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
2304 | pub struct TrueKw { | ||
2305 | pub(crate) syntax: SyntaxToken, | ||
2306 | } | ||
2307 | impl std::fmt::Display for TrueKw { | ||
2308 | fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { | ||
2309 | std::fmt::Display::fmt(&self.syntax, f) | ||
2310 | } | ||
2311 | } | ||
2312 | impl AstToken for TrueKw { | ||
2313 | fn can_cast(kind: SyntaxKind) -> bool { | ||
2314 | match kind { | ||
2315 | TRUE_KW => true, | ||
2316 | _ => false, | ||
2317 | } | ||
2318 | } | ||
2319 | fn cast(syntax: SyntaxToken) -> Option<Self> { | ||
2320 | if Self::can_cast(syntax.kind()) { | ||
2321 | Some(Self { syntax }) | ||
2322 | } else { | ||
2323 | None | ||
2324 | } | ||
2325 | } | ||
2326 | fn syntax(&self) -> &SyntaxToken { | ||
2327 | &self.syntax | ||
2328 | } | ||
2329 | } | ||
2330 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
2331 | pub struct TryKw { | ||
2332 | pub(crate) syntax: SyntaxToken, | ||
2333 | } | ||
2334 | impl std::fmt::Display for TryKw { | ||
2335 | fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { | ||
2336 | std::fmt::Display::fmt(&self.syntax, f) | ||
2337 | } | ||
2338 | } | ||
2339 | impl AstToken for TryKw { | ||
2340 | fn can_cast(kind: SyntaxKind) -> bool { | ||
2341 | match kind { | ||
2342 | TRY_KW => true, | ||
2343 | _ => false, | ||
2344 | } | ||
2345 | } | ||
2346 | fn cast(syntax: SyntaxToken) -> Option<Self> { | ||
2347 | if Self::can_cast(syntax.kind()) { | ||
2348 | Some(Self { syntax }) | ||
2349 | } else { | ||
2350 | None | ||
2351 | } | ||
2352 | } | ||
2353 | fn syntax(&self) -> &SyntaxToken { | ||
2354 | &self.syntax | ||
2355 | } | ||
2356 | } | ||
2357 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
2358 | pub struct TypeKw { | ||
2359 | pub(crate) syntax: SyntaxToken, | ||
2360 | } | ||
2361 | impl std::fmt::Display for TypeKw { | ||
2362 | fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { | ||
2363 | std::fmt::Display::fmt(&self.syntax, f) | ||
2364 | } | ||
2365 | } | ||
2366 | impl AstToken for TypeKw { | ||
2367 | fn can_cast(kind: SyntaxKind) -> bool { | ||
2368 | match kind { | ||
2369 | TYPE_KW => true, | ||
2370 | _ => false, | ||
2371 | } | ||
2372 | } | ||
2373 | fn cast(syntax: SyntaxToken) -> Option<Self> { | ||
2374 | if Self::can_cast(syntax.kind()) { | ||
2375 | Some(Self { syntax }) | ||
2376 | } else { | ||
2377 | None | ||
2378 | } | ||
2379 | } | ||
2380 | fn syntax(&self) -> &SyntaxToken { | ||
2381 | &self.syntax | ||
2382 | } | ||
2383 | } | ||
2384 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
2385 | pub struct UnsafeKw { | ||
2386 | pub(crate) syntax: SyntaxToken, | ||
2387 | } | ||
2388 | impl std::fmt::Display for UnsafeKw { | ||
2389 | fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { | ||
2390 | std::fmt::Display::fmt(&self.syntax, f) | ||
2391 | } | ||
2392 | } | ||
2393 | impl AstToken for UnsafeKw { | ||
2394 | fn can_cast(kind: SyntaxKind) -> bool { | ||
2395 | match kind { | ||
2396 | UNSAFE_KW => true, | ||
2397 | _ => false, | ||
2398 | } | ||
2399 | } | ||
2400 | fn cast(syntax: SyntaxToken) -> Option<Self> { | ||
2401 | if Self::can_cast(syntax.kind()) { | ||
2402 | Some(Self { syntax }) | ||
2403 | } else { | ||
2404 | None | ||
2405 | } | ||
2406 | } | ||
2407 | fn syntax(&self) -> &SyntaxToken { | ||
2408 | &self.syntax | ||
2409 | } | ||
2410 | } | ||
2411 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
2412 | pub struct UseKw { | ||
2413 | pub(crate) syntax: SyntaxToken, | ||
2414 | } | ||
2415 | impl std::fmt::Display for UseKw { | ||
2416 | fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { | ||
2417 | std::fmt::Display::fmt(&self.syntax, f) | ||
2418 | } | ||
2419 | } | ||
2420 | impl AstToken for UseKw { | ||
2421 | fn can_cast(kind: SyntaxKind) -> bool { | ||
2422 | match kind { | ||
2423 | USE_KW => true, | ||
2424 | _ => false, | ||
2425 | } | ||
2426 | } | ||
2427 | fn cast(syntax: SyntaxToken) -> Option<Self> { | ||
2428 | if Self::can_cast(syntax.kind()) { | ||
2429 | Some(Self { syntax }) | ||
2430 | } else { | ||
2431 | None | ||
2432 | } | ||
2433 | } | ||
2434 | fn syntax(&self) -> &SyntaxToken { | ||
2435 | &self.syntax | ||
2436 | } | ||
2437 | } | ||
2438 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
2439 | pub struct WhereKw { | ||
2440 | pub(crate) syntax: SyntaxToken, | ||
2441 | } | ||
2442 | impl std::fmt::Display for WhereKw { | ||
2443 | fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { | ||
2444 | std::fmt::Display::fmt(&self.syntax, f) | ||
2445 | } | ||
2446 | } | ||
2447 | impl AstToken for WhereKw { | ||
2448 | fn can_cast(kind: SyntaxKind) -> bool { | ||
2449 | match kind { | ||
2450 | WHERE_KW => true, | ||
2451 | _ => false, | ||
2452 | } | ||
2453 | } | ||
2454 | fn cast(syntax: SyntaxToken) -> Option<Self> { | ||
2455 | if Self::can_cast(syntax.kind()) { | ||
2456 | Some(Self { syntax }) | ||
2457 | } else { | ||
2458 | None | ||
2459 | } | ||
2460 | } | ||
2461 | fn syntax(&self) -> &SyntaxToken { | ||
2462 | &self.syntax | ||
2463 | } | ||
2464 | } | ||
2465 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
2466 | pub struct WhileKw { | ||
2467 | pub(crate) syntax: SyntaxToken, | ||
2468 | } | ||
2469 | impl std::fmt::Display for WhileKw { | ||
2470 | fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { | ||
2471 | std::fmt::Display::fmt(&self.syntax, f) | ||
2472 | } | ||
2473 | } | ||
2474 | impl AstToken for WhileKw { | ||
2475 | fn can_cast(kind: SyntaxKind) -> bool { | ||
2476 | match kind { | ||
2477 | WHILE_KW => true, | ||
2478 | _ => false, | ||
2479 | } | ||
2480 | } | ||
2481 | fn cast(syntax: SyntaxToken) -> Option<Self> { | ||
2482 | if Self::can_cast(syntax.kind()) { | ||
2483 | Some(Self { syntax }) | ||
2484 | } else { | ||
2485 | None | ||
2486 | } | ||
2487 | } | ||
2488 | fn syntax(&self) -> &SyntaxToken { | ||
2489 | &self.syntax | ||
2490 | } | ||
2491 | } | ||
2492 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
2493 | pub struct AutoKw { | ||
2494 | pub(crate) syntax: SyntaxToken, | ||
2495 | } | ||
2496 | impl std::fmt::Display for AutoKw { | ||
2497 | fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { | ||
2498 | std::fmt::Display::fmt(&self.syntax, f) | ||
2499 | } | ||
2500 | } | ||
2501 | impl AstToken for AutoKw { | ||
2502 | fn can_cast(kind: SyntaxKind) -> bool { | ||
2503 | match kind { | ||
2504 | AUTO_KW => true, | ||
2505 | _ => false, | ||
2506 | } | ||
2507 | } | ||
2508 | fn cast(syntax: SyntaxToken) -> Option<Self> { | ||
2509 | if Self::can_cast(syntax.kind()) { | ||
2510 | Some(Self { syntax }) | ||
2511 | } else { | ||
2512 | None | ||
2513 | } | ||
2514 | } | ||
2515 | fn syntax(&self) -> &SyntaxToken { | ||
2516 | &self.syntax | ||
2517 | } | ||
2518 | } | ||
2519 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
2520 | pub struct DefaultKw { | ||
2521 | pub(crate) syntax: SyntaxToken, | ||
2522 | } | ||
2523 | impl std::fmt::Display for DefaultKw { | ||
2524 | fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { | ||
2525 | std::fmt::Display::fmt(&self.syntax, f) | ||
2526 | } | ||
2527 | } | ||
2528 | impl AstToken for DefaultKw { | ||
2529 | fn can_cast(kind: SyntaxKind) -> bool { | ||
2530 | match kind { | ||
2531 | DEFAULT_KW => true, | ||
2532 | _ => false, | ||
2533 | } | ||
2534 | } | ||
2535 | fn cast(syntax: SyntaxToken) -> Option<Self> { | ||
2536 | if Self::can_cast(syntax.kind()) { | ||
2537 | Some(Self { syntax }) | ||
2538 | } else { | ||
2539 | None | ||
2540 | } | ||
2541 | } | ||
2542 | fn syntax(&self) -> &SyntaxToken { | ||
2543 | &self.syntax | ||
2544 | } | ||
2545 | } | ||
2546 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
2547 | pub struct ExistentialKw { | ||
2548 | pub(crate) syntax: SyntaxToken, | ||
2549 | } | ||
2550 | impl std::fmt::Display for ExistentialKw { | ||
2551 | fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { | ||
2552 | std::fmt::Display::fmt(&self.syntax, f) | ||
2553 | } | ||
2554 | } | ||
2555 | impl AstToken for ExistentialKw { | ||
2556 | fn can_cast(kind: SyntaxKind) -> bool { | ||
2557 | match kind { | ||
2558 | EXISTENTIAL_KW => true, | ||
2559 | _ => false, | ||
2560 | } | ||
2561 | } | ||
2562 | fn cast(syntax: SyntaxToken) -> Option<Self> { | ||
2563 | if Self::can_cast(syntax.kind()) { | ||
2564 | Some(Self { syntax }) | ||
2565 | } else { | ||
2566 | None | ||
2567 | } | ||
2568 | } | ||
2569 | fn syntax(&self) -> &SyntaxToken { | ||
2570 | &self.syntax | ||
2571 | } | ||
2572 | } | ||
2573 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
2574 | pub struct UnionKw { | ||
2575 | pub(crate) syntax: SyntaxToken, | ||
2576 | } | ||
2577 | impl std::fmt::Display for UnionKw { | ||
2578 | fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { | ||
2579 | std::fmt::Display::fmt(&self.syntax, f) | ||
2580 | } | ||
2581 | } | ||
2582 | impl AstToken for UnionKw { | ||
2583 | fn can_cast(kind: SyntaxKind) -> bool { | ||
2584 | match kind { | ||
2585 | UNION_KW => true, | ||
2586 | _ => false, | ||
2587 | } | ||
2588 | } | ||
2589 | fn cast(syntax: SyntaxToken) -> Option<Self> { | ||
2590 | if Self::can_cast(syntax.kind()) { | ||
2591 | Some(Self { syntax }) | ||
2592 | } else { | ||
2593 | None | ||
2594 | } | ||
2595 | } | ||
2596 | fn syntax(&self) -> &SyntaxToken { | ||
2597 | &self.syntax | ||
2598 | } | ||
2599 | } | ||
2600 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
2601 | pub struct RawKw { | ||
2602 | pub(crate) syntax: SyntaxToken, | ||
2603 | } | ||
2604 | impl std::fmt::Display for RawKw { | ||
2605 | fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { | ||
2606 | std::fmt::Display::fmt(&self.syntax, f) | ||
2607 | } | ||
2608 | } | ||
2609 | impl AstToken for RawKw { | ||
2610 | fn can_cast(kind: SyntaxKind) -> bool { | ||
2611 | match kind { | ||
2612 | RAW_KW => true, | ||
2613 | _ => false, | ||
2614 | } | ||
2615 | } | ||
2616 | fn cast(syntax: SyntaxToken) -> Option<Self> { | ||
2617 | if Self::can_cast(syntax.kind()) { | ||
2618 | Some(Self { syntax }) | ||
2619 | } else { | ||
2620 | None | ||
2621 | } | ||
2622 | } | ||
2623 | fn syntax(&self) -> &SyntaxToken { | ||
2624 | &self.syntax | ||
2625 | } | ||
2626 | } | ||
2627 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
2628 | pub struct IntNumber { | ||
2629 | pub(crate) syntax: SyntaxToken, | ||
2630 | } | ||
2631 | impl std::fmt::Display for IntNumber { | ||
2632 | fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { | ||
2633 | std::fmt::Display::fmt(&self.syntax, f) | ||
2634 | } | ||
2635 | } | ||
2636 | impl AstToken for IntNumber { | ||
2637 | fn can_cast(kind: SyntaxKind) -> bool { | ||
2638 | match kind { | ||
2639 | INT_NUMBER => true, | ||
2640 | _ => false, | ||
2641 | } | ||
2642 | } | ||
2643 | fn cast(syntax: SyntaxToken) -> Option<Self> { | ||
2644 | if Self::can_cast(syntax.kind()) { | ||
2645 | Some(Self { syntax }) | ||
2646 | } else { | ||
2647 | None | ||
2648 | } | ||
2649 | } | ||
2650 | fn syntax(&self) -> &SyntaxToken { | ||
2651 | &self.syntax | ||
2652 | } | ||
2653 | } | ||
2654 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
2655 | pub struct FloatNumber { | ||
2656 | pub(crate) syntax: SyntaxToken, | ||
2657 | } | ||
2658 | impl std::fmt::Display for FloatNumber { | ||
2659 | fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { | ||
2660 | std::fmt::Display::fmt(&self.syntax, f) | ||
2661 | } | ||
2662 | } | ||
2663 | impl AstToken for FloatNumber { | ||
2664 | fn can_cast(kind: SyntaxKind) -> bool { | ||
2665 | match kind { | ||
2666 | FLOAT_NUMBER => true, | ||
2667 | _ => false, | ||
2668 | } | ||
2669 | } | ||
2670 | fn cast(syntax: SyntaxToken) -> Option<Self> { | ||
2671 | if Self::can_cast(syntax.kind()) { | ||
2672 | Some(Self { syntax }) | ||
2673 | } else { | ||
2674 | None | ||
2675 | } | ||
2676 | } | ||
2677 | fn syntax(&self) -> &SyntaxToken { | ||
2678 | &self.syntax | ||
2679 | } | ||
2680 | } | ||
2681 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
2682 | pub struct Char { | ||
2683 | pub(crate) syntax: SyntaxToken, | ||
2684 | } | ||
2685 | impl std::fmt::Display for Char { | ||
2686 | fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { | ||
2687 | std::fmt::Display::fmt(&self.syntax, f) | ||
2688 | } | ||
2689 | } | ||
2690 | impl AstToken for Char { | ||
2691 | fn can_cast(kind: SyntaxKind) -> bool { | ||
2692 | match kind { | ||
2693 | CHAR => true, | ||
2694 | _ => false, | ||
2695 | } | ||
2696 | } | ||
2697 | fn cast(syntax: SyntaxToken) -> Option<Self> { | ||
2698 | if Self::can_cast(syntax.kind()) { | ||
2699 | Some(Self { syntax }) | ||
2700 | } else { | ||
2701 | None | ||
2702 | } | ||
2703 | } | ||
2704 | fn syntax(&self) -> &SyntaxToken { | ||
2705 | &self.syntax | ||
2706 | } | ||
2707 | } | ||
2708 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
2709 | pub struct Byte { | ||
2710 | pub(crate) syntax: SyntaxToken, | ||
2711 | } | ||
2712 | impl std::fmt::Display for Byte { | ||
2713 | fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { | ||
2714 | std::fmt::Display::fmt(&self.syntax, f) | ||
2715 | } | ||
2716 | } | ||
2717 | impl AstToken for Byte { | ||
2718 | fn can_cast(kind: SyntaxKind) -> bool { | ||
2719 | match kind { | ||
2720 | BYTE => true, | ||
2721 | _ => false, | ||
2722 | } | ||
2723 | } | ||
2724 | fn cast(syntax: SyntaxToken) -> Option<Self> { | ||
2725 | if Self::can_cast(syntax.kind()) { | ||
2726 | Some(Self { syntax }) | ||
2727 | } else { | ||
2728 | None | ||
2729 | } | ||
2730 | } | ||
2731 | fn syntax(&self) -> &SyntaxToken { | ||
2732 | &self.syntax | ||
2733 | } | ||
2734 | } | ||
2735 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
2736 | pub struct String { | ||
2737 | pub(crate) syntax: SyntaxToken, | ||
2738 | } | ||
2739 | impl std::fmt::Display for String { | ||
2740 | fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { | ||
2741 | std::fmt::Display::fmt(&self.syntax, f) | ||
2742 | } | ||
2743 | } | ||
2744 | impl AstToken for String { | ||
2745 | fn can_cast(kind: SyntaxKind) -> bool { | ||
2746 | match kind { | ||
2747 | STRING => true, | ||
2748 | _ => false, | ||
2749 | } | ||
2750 | } | ||
2751 | fn cast(syntax: SyntaxToken) -> Option<Self> { | ||
2752 | if Self::can_cast(syntax.kind()) { | ||
2753 | Some(Self { syntax }) | ||
2754 | } else { | ||
2755 | None | ||
2756 | } | ||
2757 | } | ||
2758 | fn syntax(&self) -> &SyntaxToken { | ||
2759 | &self.syntax | ||
2760 | } | ||
2761 | } | ||
2762 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
2763 | pub struct RawString { | ||
2764 | pub(crate) syntax: SyntaxToken, | ||
2765 | } | ||
2766 | impl std::fmt::Display for RawString { | ||
2767 | fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { | ||
2768 | std::fmt::Display::fmt(&self.syntax, f) | ||
2769 | } | ||
2770 | } | ||
2771 | impl AstToken for RawString { | ||
2772 | fn can_cast(kind: SyntaxKind) -> bool { | ||
2773 | match kind { | ||
2774 | RAW_STRING => true, | ||
2775 | _ => false, | ||
2776 | } | ||
2777 | } | ||
2778 | fn cast(syntax: SyntaxToken) -> Option<Self> { | ||
2779 | if Self::can_cast(syntax.kind()) { | ||
2780 | Some(Self { syntax }) | ||
2781 | } else { | ||
2782 | None | ||
2783 | } | ||
2784 | } | ||
2785 | fn syntax(&self) -> &SyntaxToken { | ||
2786 | &self.syntax | ||
2787 | } | ||
2788 | } | ||
2789 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
2790 | pub struct ByteString { | ||
2791 | pub(crate) syntax: SyntaxToken, | ||
2792 | } | ||
2793 | impl std::fmt::Display for ByteString { | ||
2794 | fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { | ||
2795 | std::fmt::Display::fmt(&self.syntax, f) | ||
2796 | } | ||
2797 | } | ||
2798 | impl AstToken for ByteString { | ||
2799 | fn can_cast(kind: SyntaxKind) -> bool { | ||
2800 | match kind { | ||
2801 | BYTE_STRING => true, | ||
2802 | _ => false, | ||
2803 | } | ||
2804 | } | ||
2805 | fn cast(syntax: SyntaxToken) -> Option<Self> { | ||
2806 | if Self::can_cast(syntax.kind()) { | ||
2807 | Some(Self { syntax }) | ||
2808 | } else { | ||
2809 | None | ||
2810 | } | ||
2811 | } | ||
2812 | fn syntax(&self) -> &SyntaxToken { | ||
2813 | &self.syntax | ||
2814 | } | ||
2815 | } | ||
2816 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
2817 | pub struct RawByteString { | ||
2818 | pub(crate) syntax: SyntaxToken, | ||
2819 | } | ||
2820 | impl std::fmt::Display for RawByteString { | ||
2821 | fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { | ||
2822 | std::fmt::Display::fmt(&self.syntax, f) | ||
2823 | } | ||
2824 | } | ||
2825 | impl AstToken for RawByteString { | ||
2826 | fn can_cast(kind: SyntaxKind) -> bool { | ||
2827 | match kind { | ||
2828 | RAW_BYTE_STRING => true, | ||
2829 | _ => false, | ||
2830 | } | ||
2831 | } | ||
2832 | fn cast(syntax: SyntaxToken) -> Option<Self> { | ||
2833 | if Self::can_cast(syntax.kind()) { | ||
2834 | Some(Self { syntax }) | ||
2835 | } else { | ||
2836 | None | ||
2837 | } | ||
2838 | } | ||
2839 | fn syntax(&self) -> &SyntaxToken { | ||
2840 | &self.syntax | ||
2841 | } | ||
2842 | } | ||
2843 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
2844 | pub struct Error { | ||
2845 | pub(crate) syntax: SyntaxToken, | ||
2846 | } | ||
2847 | impl std::fmt::Display for Error { | ||
2848 | fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { | ||
2849 | std::fmt::Display::fmt(&self.syntax, f) | ||
2850 | } | ||
2851 | } | ||
2852 | impl AstToken for Error { | ||
2853 | fn can_cast(kind: SyntaxKind) -> bool { | ||
2854 | match kind { | ||
2855 | ERROR => true, | ||
2856 | _ => false, | ||
2857 | } | ||
2858 | } | ||
2859 | fn cast(syntax: SyntaxToken) -> Option<Self> { | ||
2860 | if Self::can_cast(syntax.kind()) { | ||
2861 | Some(Self { syntax }) | ||
2862 | } else { | ||
2863 | None | ||
2864 | } | ||
2865 | } | ||
2866 | fn syntax(&self) -> &SyntaxToken { | ||
2867 | &self.syntax | ||
2868 | } | ||
2869 | } | ||
2870 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
2871 | pub struct Ident { | ||
2872 | pub(crate) syntax: SyntaxToken, | ||
2873 | } | ||
2874 | impl std::fmt::Display for Ident { | ||
2875 | fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { | ||
2876 | std::fmt::Display::fmt(&self.syntax, f) | ||
2877 | } | ||
2878 | } | ||
2879 | impl AstToken for Ident { | ||
2880 | fn can_cast(kind: SyntaxKind) -> bool { | ||
2881 | match kind { | ||
2882 | IDENT => true, | ||
2883 | _ => false, | ||
2884 | } | ||
2885 | } | ||
2886 | fn cast(syntax: SyntaxToken) -> Option<Self> { | ||
2887 | if Self::can_cast(syntax.kind()) { | ||
2888 | Some(Self { syntax }) | ||
2889 | } else { | ||
2890 | None | ||
2891 | } | ||
2892 | } | ||
2893 | fn syntax(&self) -> &SyntaxToken { | ||
2894 | &self.syntax | ||
2895 | } | ||
2896 | } | ||
2897 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
2898 | pub struct Whitespace { | ||
2899 | pub(crate) syntax: SyntaxToken, | ||
2900 | } | ||
2901 | impl std::fmt::Display for Whitespace { | ||
2902 | fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { | ||
2903 | std::fmt::Display::fmt(&self.syntax, f) | ||
2904 | } | ||
2905 | } | ||
2906 | impl AstToken for Whitespace { | ||
2907 | fn can_cast(kind: SyntaxKind) -> bool { | ||
2908 | match kind { | ||
2909 | WHITESPACE => true, | ||
2910 | _ => false, | ||
2911 | } | ||
2912 | } | ||
2913 | fn cast(syntax: SyntaxToken) -> Option<Self> { | ||
2914 | if Self::can_cast(syntax.kind()) { | ||
2915 | Some(Self { syntax }) | ||
2916 | } else { | ||
2917 | None | ||
2918 | } | ||
2919 | } | ||
2920 | fn syntax(&self) -> &SyntaxToken { | ||
2921 | &self.syntax | ||
2922 | } | ||
2923 | } | ||
2924 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
2925 | pub struct Lifetime { | ||
2926 | pub(crate) syntax: SyntaxToken, | ||
2927 | } | ||
2928 | impl std::fmt::Display for Lifetime { | ||
2929 | fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { | ||
2930 | std::fmt::Display::fmt(&self.syntax, f) | ||
2931 | } | ||
2932 | } | ||
2933 | impl AstToken for Lifetime { | ||
2934 | fn can_cast(kind: SyntaxKind) -> bool { | ||
2935 | match kind { | ||
2936 | LIFETIME => true, | ||
2937 | _ => false, | ||
2938 | } | ||
2939 | } | ||
2940 | fn cast(syntax: SyntaxToken) -> Option<Self> { | ||
2941 | if Self::can_cast(syntax.kind()) { | ||
2942 | Some(Self { syntax }) | ||
2943 | } else { | ||
2944 | None | ||
2945 | } | ||
2946 | } | ||
2947 | fn syntax(&self) -> &SyntaxToken { | ||
2948 | &self.syntax | ||
2949 | } | ||
2950 | } | ||
2951 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
2952 | pub struct Comment { | ||
2953 | pub(crate) syntax: SyntaxToken, | ||
2954 | } | ||
2955 | impl std::fmt::Display for Comment { | ||
2956 | fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { | ||
2957 | std::fmt::Display::fmt(&self.syntax, f) | ||
2958 | } | ||
2959 | } | ||
2960 | impl AstToken for Comment { | ||
2961 | fn can_cast(kind: SyntaxKind) -> bool { | ||
2962 | match kind { | ||
2963 | COMMENT => true, | ||
2964 | _ => false, | ||
2965 | } | ||
2966 | } | ||
2967 | fn cast(syntax: SyntaxToken) -> Option<Self> { | ||
2968 | if Self::can_cast(syntax.kind()) { | ||
2969 | Some(Self { syntax }) | ||
2970 | } else { | ||
2971 | None | ||
2972 | } | ||
2973 | } | ||
2974 | fn syntax(&self) -> &SyntaxToken { | ||
2975 | &self.syntax | ||
2976 | } | ||
2977 | } | ||
2978 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
2979 | pub struct Shebang { | ||
2980 | pub(crate) syntax: SyntaxToken, | ||
2981 | } | ||
2982 | impl std::fmt::Display for Shebang { | ||
2983 | fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { | ||
2984 | std::fmt::Display::fmt(&self.syntax, f) | ||
2985 | } | ||
2986 | } | ||
2987 | impl AstToken for Shebang { | ||
2988 | fn can_cast(kind: SyntaxKind) -> bool { | ||
2989 | match kind { | ||
2990 | SHEBANG => true, | ||
2991 | _ => false, | ||
2992 | } | ||
2993 | } | ||
2994 | fn cast(syntax: SyntaxToken) -> Option<Self> { | ||
2995 | if Self::can_cast(syntax.kind()) { | ||
2996 | Some(Self { syntax }) | ||
2997 | } else { | ||
2998 | None | ||
2999 | } | ||
3000 | } | ||
3001 | fn syntax(&self) -> &SyntaxToken { | ||
3002 | &self.syntax | ||
3003 | } | ||
3004 | } | ||
3005 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
3006 | pub struct LDollar { | ||
3007 | pub(crate) syntax: SyntaxToken, | ||
3008 | } | ||
3009 | impl std::fmt::Display for LDollar { | ||
3010 | fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { | ||
3011 | std::fmt::Display::fmt(&self.syntax, f) | ||
3012 | } | ||
3013 | } | ||
3014 | impl AstToken for LDollar { | ||
3015 | fn can_cast(kind: SyntaxKind) -> bool { | ||
3016 | match kind { | ||
3017 | L_DOLLAR => true, | ||
3018 | _ => false, | ||
3019 | } | ||
3020 | } | ||
3021 | fn cast(syntax: SyntaxToken) -> Option<Self> { | ||
3022 | if Self::can_cast(syntax.kind()) { | ||
3023 | Some(Self { syntax }) | ||
3024 | } else { | ||
3025 | None | ||
3026 | } | ||
3027 | } | ||
3028 | fn syntax(&self) -> &SyntaxToken { | ||
3029 | &self.syntax | ||
3030 | } | ||
3031 | } | ||
3032 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
3033 | pub struct RDollar { | ||
3034 | pub(crate) syntax: SyntaxToken, | ||
3035 | } | ||
3036 | impl std::fmt::Display for RDollar { | ||
3037 | fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { | ||
3038 | std::fmt::Display::fmt(&self.syntax, f) | ||
3039 | } | ||
3040 | } | ||
3041 | impl AstToken for RDollar { | ||
3042 | fn can_cast(kind: SyntaxKind) -> bool { | ||
3043 | match kind { | ||
3044 | R_DOLLAR => true, | ||
3045 | _ => false, | ||
3046 | } | ||
3047 | } | ||
3048 | fn cast(syntax: SyntaxToken) -> Option<Self> { | ||
3049 | if Self::can_cast(syntax.kind()) { | ||
3050 | Some(Self { syntax }) | ||
3051 | } else { | ||
3052 | None | ||
3053 | } | ||
3054 | } | ||
3055 | fn syntax(&self) -> &SyntaxToken { | ||
3056 | &self.syntax | ||
3057 | } | ||
3058 | } | ||