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