diff options
Diffstat (limited to 'crates/ra_syntax/src/ast/generated/tokens.rs')
-rw-r--r-- | crates/ra_syntax/src/ast/generated/tokens.rs | 1829 |
1 files changed, 12 insertions, 1817 deletions
diff --git a/crates/ra_syntax/src/ast/generated/tokens.rs b/crates/ra_syntax/src/ast/generated/tokens.rs index 7344b0e49..f91befaac 100644 --- a/crates/ra_syntax/src/ast/generated/tokens.rs +++ b/crates/ra_syntax/src/ast/generated/tokens.rs | |||
@@ -5,1246 +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 IntNumber { | ||
1050 | pub(crate) syntax: SyntaxToken, | ||
1051 | } | ||
1052 | impl std::fmt::Display for IntNumber { | ||
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 IntNumber { | ||
1058 | fn can_cast(kind: SyntaxKind) -> bool { kind == INT_NUMBER } | ||
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 FloatNumber { | ||
1070 | pub(crate) syntax: SyntaxToken, | ||
1071 | } | ||
1072 | impl std::fmt::Display for FloatNumber { | ||
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 FloatNumber { | ||
1078 | fn can_cast(kind: SyntaxKind) -> bool { kind == FLOAT_NUMBER } | ||
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 Char { | ||
1090 | pub(crate) syntax: SyntaxToken, | ||
1091 | } | ||
1092 | impl std::fmt::Display for Char { | ||
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 Char { | ||
1098 | fn can_cast(kind: SyntaxKind) -> bool { kind == CHAR } | ||
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 Byte { | ||
1110 | pub(crate) syntax: SyntaxToken, | ||
1111 | } | ||
1112 | impl std::fmt::Display for Byte { | ||
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 Byte { | ||
1118 | fn can_cast(kind: SyntaxKind) -> bool { kind == BYTE } | ||
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 String { | ||
1130 | pub(crate) syntax: SyntaxToken, | ||
1131 | } | ||
1132 | impl std::fmt::Display for String { | ||
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 String { | ||
1138 | fn can_cast(kind: SyntaxKind) -> bool { kind == STRING } | ||
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 RawString { | ||
1150 | pub(crate) syntax: SyntaxToken, | ||
1151 | } | ||
1152 | impl std::fmt::Display for RawString { | ||
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 RawString { | ||
1158 | fn can_cast(kind: SyntaxKind) -> bool { kind == RAW_STRING } | ||
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 ByteString { | ||
1170 | pub(crate) syntax: SyntaxToken, | ||
1171 | } | ||
1172 | impl std::fmt::Display for ByteString { | ||
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 ByteString { | ||
1178 | fn can_cast(kind: SyntaxKind) -> bool { kind == BYTE_STRING } | ||
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 RawByteString { | ||
1190 | pub(crate) syntax: SyntaxToken, | ||
1191 | } | ||
1192 | impl std::fmt::Display for RawByteString { | ||
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 RawByteString { | ||
1198 | fn can_cast(kind: SyntaxKind) -> bool { kind == RAW_BYTE_STRING } | ||
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 Error { | ||
1210 | pub(crate) syntax: SyntaxToken, | ||
1211 | } | ||
1212 | impl std::fmt::Display for Error { | ||
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 Error { | ||
1218 | fn can_cast(kind: SyntaxKind) -> bool { kind == ERROR } | ||
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 Ident { | ||
1230 | pub(crate) syntax: SyntaxToken, | ||
1231 | } | ||
1232 | impl std::fmt::Display for Ident { | ||
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 Ident { | ||
1238 | fn can_cast(kind: SyntaxKind) -> bool { kind == IDENT } | ||
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)] | 9 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] |
1249 | pub struct Whitespace { | 10 | pub struct Whitespace { |
1250 | pub(crate) syntax: SyntaxToken, | 11 | pub(crate) syntax: SyntaxToken, |
@@ -1265,26 +26,7 @@ impl AstToken for Whitespace { | |||
1265 | } | 26 | } |
1266 | fn syntax(&self) -> &SyntaxToken { &self.syntax } | 27 | fn syntax(&self) -> &SyntaxToken { &self.syntax } |
1267 | } | 28 | } |
1268 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | 29 | |
1269 | pub struct Lifetime { | ||
1270 | pub(crate) syntax: SyntaxToken, | ||
1271 | } | ||
1272 | impl std::fmt::Display for Lifetime { | ||
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 Lifetime { | ||
1278 | fn can_cast(kind: SyntaxKind) -> bool { kind == LIFETIME } | ||
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)] | 30 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] |
1289 | pub struct Comment { | 31 | pub struct Comment { |
1290 | pub(crate) syntax: SyntaxToken, | 32 | pub(crate) syntax: SyntaxToken, |
@@ -1305,37 +47,18 @@ impl AstToken for Comment { | |||
1305 | } | 47 | } |
1306 | fn syntax(&self) -> &SyntaxToken { &self.syntax } | 48 | fn syntax(&self) -> &SyntaxToken { &self.syntax } |
1307 | } | 49 | } |
50 | |||
1308 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | 51 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] |
1309 | pub struct Shebang { | 52 | pub struct String { |
1310 | pub(crate) syntax: SyntaxToken, | ||
1311 | } | ||
1312 | impl std::fmt::Display for Shebang { | ||
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 Shebang { | ||
1318 | fn can_cast(kind: SyntaxKind) -> bool { kind == SHEBANG } | ||
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 LDollar { | ||
1330 | pub(crate) syntax: SyntaxToken, | 53 | pub(crate) syntax: SyntaxToken, |
1331 | } | 54 | } |
1332 | impl std::fmt::Display for LDollar { | 55 | impl std::fmt::Display for String { |
1333 | fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { | 56 | fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { |
1334 | std::fmt::Display::fmt(&self.syntax, f) | 57 | std::fmt::Display::fmt(&self.syntax, f) |
1335 | } | 58 | } |
1336 | } | 59 | } |
1337 | impl AstToken for LDollar { | 60 | impl AstToken for String { |
1338 | fn can_cast(kind: SyntaxKind) -> bool { kind == L_DOLLAR } | 61 | fn can_cast(kind: SyntaxKind) -> bool { kind == STRING } |
1339 | fn cast(syntax: SyntaxToken) -> Option<Self> { | 62 | fn cast(syntax: SyntaxToken) -> Option<Self> { |
1340 | if Self::can_cast(syntax.kind()) { | 63 | if Self::can_cast(syntax.kind()) { |
1341 | Some(Self { syntax }) | 64 | Some(Self { syntax }) |
@@ -1345,17 +68,18 @@ impl AstToken for LDollar { | |||
1345 | } | 68 | } |
1346 | fn syntax(&self) -> &SyntaxToken { &self.syntax } | 69 | fn syntax(&self) -> &SyntaxToken { &self.syntax } |
1347 | } | 70 | } |
71 | |||
1348 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | 72 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] |
1349 | pub struct RDollar { | 73 | pub struct RawString { |
1350 | pub(crate) syntax: SyntaxToken, | 74 | pub(crate) syntax: SyntaxToken, |
1351 | } | 75 | } |
1352 | impl std::fmt::Display for RDollar { | 76 | impl std::fmt::Display for RawString { |
1353 | fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { | 77 | fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { |
1354 | std::fmt::Display::fmt(&self.syntax, f) | 78 | std::fmt::Display::fmt(&self.syntax, f) |
1355 | } | 79 | } |
1356 | } | 80 | } |
1357 | impl AstToken for RDollar { | 81 | impl AstToken for RawString { |
1358 | fn can_cast(kind: SyntaxKind) -> bool { kind == R_DOLLAR } | 82 | fn can_cast(kind: SyntaxKind) -> bool { kind == RAW_STRING } |
1359 | fn cast(syntax: SyntaxToken) -> Option<Self> { | 83 | fn cast(syntax: SyntaxToken) -> Option<Self> { |
1360 | if Self::can_cast(syntax.kind()) { | 84 | if Self::can_cast(syntax.kind()) { |
1361 | Some(Self { syntax }) | 85 | Some(Self { syntax }) |
@@ -1365,532 +89,3 @@ impl AstToken for RDollar { | |||
1365 | } | 89 | } |
1366 | fn syntax(&self) -> &SyntaxToken { &self.syntax } | 90 | fn syntax(&self) -> &SyntaxToken { &self.syntax } |
1367 | } | 91 | } |
1368 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
1369 | pub enum LeftDelimiter { | ||
1370 | LParen(LParen), | ||
1371 | LBrack(LBrack), | ||
1372 | LCurly(LCurly), | ||
1373 | } | ||
1374 | impl From<LParen> for LeftDelimiter { | ||
1375 | fn from(node: LParen) -> LeftDelimiter { LeftDelimiter::LParen(node) } | ||
1376 | } | ||
1377 | impl From<LBrack> for LeftDelimiter { | ||
1378 | fn from(node: LBrack) -> LeftDelimiter { LeftDelimiter::LBrack(node) } | ||
1379 | } | ||
1380 | impl From<LCurly> for LeftDelimiter { | ||
1381 | fn from(node: LCurly) -> LeftDelimiter { LeftDelimiter::LCurly(node) } | ||
1382 | } | ||
1383 | impl std::fmt::Display for LeftDelimiter { | ||
1384 | fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { | ||
1385 | std::fmt::Display::fmt(self.syntax(), f) | ||
1386 | } | ||
1387 | } | ||
1388 | impl AstToken for LeftDelimiter { | ||
1389 | fn can_cast(kind: SyntaxKind) -> bool { | ||
1390 | match kind { | ||
1391 | L_PAREN | L_BRACK | L_CURLY => true, | ||
1392 | _ => false, | ||
1393 | } | ||
1394 | } | ||
1395 | fn cast(syntax: SyntaxToken) -> Option<Self> { | ||
1396 | let res = match syntax.kind() { | ||
1397 | L_PAREN => LeftDelimiter::LParen(LParen { syntax }), | ||
1398 | L_BRACK => LeftDelimiter::LBrack(LBrack { syntax }), | ||
1399 | L_CURLY => LeftDelimiter::LCurly(LCurly { syntax }), | ||
1400 | _ => return None, | ||
1401 | }; | ||
1402 | Some(res) | ||
1403 | } | ||
1404 | fn syntax(&self) -> &SyntaxToken { | ||
1405 | match self { | ||
1406 | LeftDelimiter::LParen(it) => &it.syntax, | ||
1407 | LeftDelimiter::LBrack(it) => &it.syntax, | ||
1408 | LeftDelimiter::LCurly(it) => &it.syntax, | ||
1409 | } | ||
1410 | } | ||
1411 | } | ||
1412 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
1413 | pub enum RightDelimiter { | ||
1414 | RParen(RParen), | ||
1415 | RBrack(RBrack), | ||
1416 | RCurly(RCurly), | ||
1417 | } | ||
1418 | impl From<RParen> for RightDelimiter { | ||
1419 | fn from(node: RParen) -> RightDelimiter { RightDelimiter::RParen(node) } | ||
1420 | } | ||
1421 | impl From<RBrack> for RightDelimiter { | ||
1422 | fn from(node: RBrack) -> RightDelimiter { RightDelimiter::RBrack(node) } | ||
1423 | } | ||
1424 | impl From<RCurly> for RightDelimiter { | ||
1425 | fn from(node: RCurly) -> RightDelimiter { RightDelimiter::RCurly(node) } | ||
1426 | } | ||
1427 | impl std::fmt::Display for RightDelimiter { | ||
1428 | fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { | ||
1429 | std::fmt::Display::fmt(self.syntax(), f) | ||
1430 | } | ||
1431 | } | ||
1432 | impl AstToken for RightDelimiter { | ||
1433 | fn can_cast(kind: SyntaxKind) -> bool { | ||
1434 | match kind { | ||
1435 | R_PAREN | R_BRACK | R_CURLY => true, | ||
1436 | _ => false, | ||
1437 | } | ||
1438 | } | ||
1439 | fn cast(syntax: SyntaxToken) -> Option<Self> { | ||
1440 | let res = match syntax.kind() { | ||
1441 | R_PAREN => RightDelimiter::RParen(RParen { syntax }), | ||
1442 | R_BRACK => RightDelimiter::RBrack(RBrack { syntax }), | ||
1443 | R_CURLY => RightDelimiter::RCurly(RCurly { syntax }), | ||
1444 | _ => return None, | ||
1445 | }; | ||
1446 | Some(res) | ||
1447 | } | ||
1448 | fn syntax(&self) -> &SyntaxToken { | ||
1449 | match self { | ||
1450 | RightDelimiter::RParen(it) => &it.syntax, | ||
1451 | RightDelimiter::RBrack(it) => &it.syntax, | ||
1452 | RightDelimiter::RCurly(it) => &it.syntax, | ||
1453 | } | ||
1454 | } | ||
1455 | } | ||
1456 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
1457 | pub enum RangeSeparator { | ||
1458 | Dotdot(Dotdot), | ||
1459 | Dotdotdot(Dotdotdot), | ||
1460 | Dotdoteq(Dotdoteq), | ||
1461 | } | ||
1462 | impl From<Dotdot> for RangeSeparator { | ||
1463 | fn from(node: Dotdot) -> RangeSeparator { RangeSeparator::Dotdot(node) } | ||
1464 | } | ||
1465 | impl From<Dotdotdot> for RangeSeparator { | ||
1466 | fn from(node: Dotdotdot) -> RangeSeparator { RangeSeparator::Dotdotdot(node) } | ||
1467 | } | ||
1468 | impl From<Dotdoteq> for RangeSeparator { | ||
1469 | fn from(node: Dotdoteq) -> RangeSeparator { RangeSeparator::Dotdoteq(node) } | ||
1470 | } | ||
1471 | impl std::fmt::Display for RangeSeparator { | ||
1472 | fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { | ||
1473 | std::fmt::Display::fmt(self.syntax(), f) | ||
1474 | } | ||
1475 | } | ||
1476 | impl AstToken for RangeSeparator { | ||
1477 | fn can_cast(kind: SyntaxKind) -> bool { | ||
1478 | match kind { | ||
1479 | DOTDOT | DOTDOTDOT | DOTDOTEQ => true, | ||
1480 | _ => false, | ||
1481 | } | ||
1482 | } | ||
1483 | fn cast(syntax: SyntaxToken) -> Option<Self> { | ||
1484 | let res = match syntax.kind() { | ||
1485 | DOTDOT => RangeSeparator::Dotdot(Dotdot { syntax }), | ||
1486 | DOTDOTDOT => RangeSeparator::Dotdotdot(Dotdotdot { syntax }), | ||
1487 | DOTDOTEQ => RangeSeparator::Dotdoteq(Dotdoteq { syntax }), | ||
1488 | _ => return None, | ||
1489 | }; | ||
1490 | Some(res) | ||
1491 | } | ||
1492 | fn syntax(&self) -> &SyntaxToken { | ||
1493 | match self { | ||
1494 | RangeSeparator::Dotdot(it) => &it.syntax, | ||
1495 | RangeSeparator::Dotdotdot(it) => &it.syntax, | ||
1496 | RangeSeparator::Dotdoteq(it) => &it.syntax, | ||
1497 | } | ||
1498 | } | ||
1499 | } | ||
1500 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
1501 | pub enum BinOp { | ||
1502 | Pipepipe(Pipepipe), | ||
1503 | Ampamp(Ampamp), | ||
1504 | Eqeq(Eqeq), | ||
1505 | Neq(Neq), | ||
1506 | Lteq(Lteq), | ||
1507 | Gteq(Gteq), | ||
1508 | LAngle(LAngle), | ||
1509 | RAngle(RAngle), | ||
1510 | Plus(Plus), | ||
1511 | Star(Star), | ||
1512 | Minus(Minus), | ||
1513 | Slash(Slash), | ||
1514 | Percent(Percent), | ||
1515 | Shl(Shl), | ||
1516 | Shr(Shr), | ||
1517 | Caret(Caret), | ||
1518 | Pipe(Pipe), | ||
1519 | Amp(Amp), | ||
1520 | Eq(Eq), | ||
1521 | Pluseq(Pluseq), | ||
1522 | Slasheq(Slasheq), | ||
1523 | Stareq(Stareq), | ||
1524 | Percenteq(Percenteq), | ||
1525 | Shreq(Shreq), | ||
1526 | Shleq(Shleq), | ||
1527 | Minuseq(Minuseq), | ||
1528 | Pipeeq(Pipeeq), | ||
1529 | Ampeq(Ampeq), | ||
1530 | Careteq(Careteq), | ||
1531 | } | ||
1532 | impl From<Pipepipe> for BinOp { | ||
1533 | fn from(node: Pipepipe) -> BinOp { BinOp::Pipepipe(node) } | ||
1534 | } | ||
1535 | impl From<Ampamp> for BinOp { | ||
1536 | fn from(node: Ampamp) -> BinOp { BinOp::Ampamp(node) } | ||
1537 | } | ||
1538 | impl From<Eqeq> for BinOp { | ||
1539 | fn from(node: Eqeq) -> BinOp { BinOp::Eqeq(node) } | ||
1540 | } | ||
1541 | impl From<Neq> for BinOp { | ||
1542 | fn from(node: Neq) -> BinOp { BinOp::Neq(node) } | ||
1543 | } | ||
1544 | impl From<Lteq> for BinOp { | ||
1545 | fn from(node: Lteq) -> BinOp { BinOp::Lteq(node) } | ||
1546 | } | ||
1547 | impl From<Gteq> for BinOp { | ||
1548 | fn from(node: Gteq) -> BinOp { BinOp::Gteq(node) } | ||
1549 | } | ||
1550 | impl From<LAngle> for BinOp { | ||
1551 | fn from(node: LAngle) -> BinOp { BinOp::LAngle(node) } | ||
1552 | } | ||
1553 | impl From<RAngle> for BinOp { | ||
1554 | fn from(node: RAngle) -> BinOp { BinOp::RAngle(node) } | ||
1555 | } | ||
1556 | impl From<Plus> for BinOp { | ||
1557 | fn from(node: Plus) -> BinOp { BinOp::Plus(node) } | ||
1558 | } | ||
1559 | impl From<Star> for BinOp { | ||
1560 | fn from(node: Star) -> BinOp { BinOp::Star(node) } | ||
1561 | } | ||
1562 | impl From<Minus> for BinOp { | ||
1563 | fn from(node: Minus) -> BinOp { BinOp::Minus(node) } | ||
1564 | } | ||
1565 | impl From<Slash> for BinOp { | ||
1566 | fn from(node: Slash) -> BinOp { BinOp::Slash(node) } | ||
1567 | } | ||
1568 | impl From<Percent> for BinOp { | ||
1569 | fn from(node: Percent) -> BinOp { BinOp::Percent(node) } | ||
1570 | } | ||
1571 | impl From<Shl> for BinOp { | ||
1572 | fn from(node: Shl) -> BinOp { BinOp::Shl(node) } | ||
1573 | } | ||
1574 | impl From<Shr> for BinOp { | ||
1575 | fn from(node: Shr) -> BinOp { BinOp::Shr(node) } | ||
1576 | } | ||
1577 | impl From<Caret> for BinOp { | ||
1578 | fn from(node: Caret) -> BinOp { BinOp::Caret(node) } | ||
1579 | } | ||
1580 | impl From<Pipe> for BinOp { | ||
1581 | fn from(node: Pipe) -> BinOp { BinOp::Pipe(node) } | ||
1582 | } | ||
1583 | impl From<Amp> for BinOp { | ||
1584 | fn from(node: Amp) -> BinOp { BinOp::Amp(node) } | ||
1585 | } | ||
1586 | impl From<Eq> for BinOp { | ||
1587 | fn from(node: Eq) -> BinOp { BinOp::Eq(node) } | ||
1588 | } | ||
1589 | impl From<Pluseq> for BinOp { | ||
1590 | fn from(node: Pluseq) -> BinOp { BinOp::Pluseq(node) } | ||
1591 | } | ||
1592 | impl From<Slasheq> for BinOp { | ||
1593 | fn from(node: Slasheq) -> BinOp { BinOp::Slasheq(node) } | ||
1594 | } | ||
1595 | impl From<Stareq> for BinOp { | ||
1596 | fn from(node: Stareq) -> BinOp { BinOp::Stareq(node) } | ||
1597 | } | ||
1598 | impl From<Percenteq> for BinOp { | ||
1599 | fn from(node: Percenteq) -> BinOp { BinOp::Percenteq(node) } | ||
1600 | } | ||
1601 | impl From<Shreq> for BinOp { | ||
1602 | fn from(node: Shreq) -> BinOp { BinOp::Shreq(node) } | ||
1603 | } | ||
1604 | impl From<Shleq> for BinOp { | ||
1605 | fn from(node: Shleq) -> BinOp { BinOp::Shleq(node) } | ||
1606 | } | ||
1607 | impl From<Minuseq> for BinOp { | ||
1608 | fn from(node: Minuseq) -> BinOp { BinOp::Minuseq(node) } | ||
1609 | } | ||
1610 | impl From<Pipeeq> for BinOp { | ||
1611 | fn from(node: Pipeeq) -> BinOp { BinOp::Pipeeq(node) } | ||
1612 | } | ||
1613 | impl From<Ampeq> for BinOp { | ||
1614 | fn from(node: Ampeq) -> BinOp { BinOp::Ampeq(node) } | ||
1615 | } | ||
1616 | impl From<Careteq> for BinOp { | ||
1617 | fn from(node: Careteq) -> BinOp { BinOp::Careteq(node) } | ||
1618 | } | ||
1619 | impl std::fmt::Display for BinOp { | ||
1620 | fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { | ||
1621 | std::fmt::Display::fmt(self.syntax(), f) | ||
1622 | } | ||
1623 | } | ||
1624 | impl AstToken for BinOp { | ||
1625 | fn can_cast(kind: SyntaxKind) -> bool { | ||
1626 | match kind { | ||
1627 | PIPEPIPE | AMPAMP | EQEQ | NEQ | LTEQ | GTEQ | L_ANGLE | R_ANGLE | PLUS | STAR | ||
1628 | | MINUS | SLASH | PERCENT | SHL | SHR | CARET | PIPE | AMP | EQ | PLUSEQ | SLASHEQ | ||
1629 | | STAREQ | PERCENTEQ | SHREQ | SHLEQ | MINUSEQ | PIPEEQ | AMPEQ | CARETEQ => true, | ||
1630 | _ => false, | ||
1631 | } | ||
1632 | } | ||
1633 | fn cast(syntax: SyntaxToken) -> Option<Self> { | ||
1634 | let res = match syntax.kind() { | ||
1635 | PIPEPIPE => BinOp::Pipepipe(Pipepipe { syntax }), | ||
1636 | AMPAMP => BinOp::Ampamp(Ampamp { syntax }), | ||
1637 | EQEQ => BinOp::Eqeq(Eqeq { syntax }), | ||
1638 | NEQ => BinOp::Neq(Neq { syntax }), | ||
1639 | LTEQ => BinOp::Lteq(Lteq { syntax }), | ||
1640 | GTEQ => BinOp::Gteq(Gteq { syntax }), | ||
1641 | L_ANGLE => BinOp::LAngle(LAngle { syntax }), | ||
1642 | R_ANGLE => BinOp::RAngle(RAngle { syntax }), | ||
1643 | PLUS => BinOp::Plus(Plus { syntax }), | ||
1644 | STAR => BinOp::Star(Star { syntax }), | ||
1645 | MINUS => BinOp::Minus(Minus { syntax }), | ||
1646 | SLASH => BinOp::Slash(Slash { syntax }), | ||
1647 | PERCENT => BinOp::Percent(Percent { syntax }), | ||
1648 | SHL => BinOp::Shl(Shl { syntax }), | ||
1649 | SHR => BinOp::Shr(Shr { syntax }), | ||
1650 | CARET => BinOp::Caret(Caret { syntax }), | ||
1651 | PIPE => BinOp::Pipe(Pipe { syntax }), | ||
1652 | AMP => BinOp::Amp(Amp { syntax }), | ||
1653 | EQ => BinOp::Eq(Eq { syntax }), | ||
1654 | PLUSEQ => BinOp::Pluseq(Pluseq { syntax }), | ||
1655 | SLASHEQ => BinOp::Slasheq(Slasheq { syntax }), | ||
1656 | STAREQ => BinOp::Stareq(Stareq { syntax }), | ||
1657 | PERCENTEQ => BinOp::Percenteq(Percenteq { syntax }), | ||
1658 | SHREQ => BinOp::Shreq(Shreq { syntax }), | ||
1659 | SHLEQ => BinOp::Shleq(Shleq { syntax }), | ||
1660 | MINUSEQ => BinOp::Minuseq(Minuseq { syntax }), | ||
1661 | PIPEEQ => BinOp::Pipeeq(Pipeeq { syntax }), | ||
1662 | AMPEQ => BinOp::Ampeq(Ampeq { syntax }), | ||
1663 | CARETEQ => BinOp::Careteq(Careteq { syntax }), | ||
1664 | _ => return None, | ||
1665 | }; | ||
1666 | Some(res) | ||
1667 | } | ||
1668 | fn syntax(&self) -> &SyntaxToken { | ||
1669 | match self { | ||
1670 | BinOp::Pipepipe(it) => &it.syntax, | ||
1671 | BinOp::Ampamp(it) => &it.syntax, | ||
1672 | BinOp::Eqeq(it) => &it.syntax, | ||
1673 | BinOp::Neq(it) => &it.syntax, | ||
1674 | BinOp::Lteq(it) => &it.syntax, | ||
1675 | BinOp::Gteq(it) => &it.syntax, | ||
1676 | BinOp::LAngle(it) => &it.syntax, | ||
1677 | BinOp::RAngle(it) => &it.syntax, | ||
1678 | BinOp::Plus(it) => &it.syntax, | ||
1679 | BinOp::Star(it) => &it.syntax, | ||
1680 | BinOp::Minus(it) => &it.syntax, | ||
1681 | BinOp::Slash(it) => &it.syntax, | ||
1682 | BinOp::Percent(it) => &it.syntax, | ||
1683 | BinOp::Shl(it) => &it.syntax, | ||
1684 | BinOp::Shr(it) => &it.syntax, | ||
1685 | BinOp::Caret(it) => &it.syntax, | ||
1686 | BinOp::Pipe(it) => &it.syntax, | ||
1687 | BinOp::Amp(it) => &it.syntax, | ||
1688 | BinOp::Eq(it) => &it.syntax, | ||
1689 | BinOp::Pluseq(it) => &it.syntax, | ||
1690 | BinOp::Slasheq(it) => &it.syntax, | ||
1691 | BinOp::Stareq(it) => &it.syntax, | ||
1692 | BinOp::Percenteq(it) => &it.syntax, | ||
1693 | BinOp::Shreq(it) => &it.syntax, | ||
1694 | BinOp::Shleq(it) => &it.syntax, | ||
1695 | BinOp::Minuseq(it) => &it.syntax, | ||
1696 | BinOp::Pipeeq(it) => &it.syntax, | ||
1697 | BinOp::Ampeq(it) => &it.syntax, | ||
1698 | BinOp::Careteq(it) => &it.syntax, | ||
1699 | } | ||
1700 | } | ||
1701 | } | ||
1702 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
1703 | pub enum PrefixOp { | ||
1704 | Minus(Minus), | ||
1705 | Excl(Excl), | ||
1706 | Star(Star), | ||
1707 | } | ||
1708 | impl From<Minus> for PrefixOp { | ||
1709 | fn from(node: Minus) -> PrefixOp { PrefixOp::Minus(node) } | ||
1710 | } | ||
1711 | impl From<Excl> for PrefixOp { | ||
1712 | fn from(node: Excl) -> PrefixOp { PrefixOp::Excl(node) } | ||
1713 | } | ||
1714 | impl From<Star> for PrefixOp { | ||
1715 | fn from(node: Star) -> PrefixOp { PrefixOp::Star(node) } | ||
1716 | } | ||
1717 | impl std::fmt::Display for PrefixOp { | ||
1718 | fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { | ||
1719 | std::fmt::Display::fmt(self.syntax(), f) | ||
1720 | } | ||
1721 | } | ||
1722 | impl AstToken for PrefixOp { | ||
1723 | fn can_cast(kind: SyntaxKind) -> bool { | ||
1724 | match kind { | ||
1725 | MINUS | EXCL | STAR => true, | ||
1726 | _ => false, | ||
1727 | } | ||
1728 | } | ||
1729 | fn cast(syntax: SyntaxToken) -> Option<Self> { | ||
1730 | let res = match syntax.kind() { | ||
1731 | MINUS => PrefixOp::Minus(Minus { syntax }), | ||
1732 | EXCL => PrefixOp::Excl(Excl { syntax }), | ||
1733 | STAR => PrefixOp::Star(Star { syntax }), | ||
1734 | _ => return None, | ||
1735 | }; | ||
1736 | Some(res) | ||
1737 | } | ||
1738 | fn syntax(&self) -> &SyntaxToken { | ||
1739 | match self { | ||
1740 | PrefixOp::Minus(it) => &it.syntax, | ||
1741 | PrefixOp::Excl(it) => &it.syntax, | ||
1742 | PrefixOp::Star(it) => &it.syntax, | ||
1743 | } | ||
1744 | } | ||
1745 | } | ||
1746 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
1747 | pub enum RangeOp { | ||
1748 | Dotdot(Dotdot), | ||
1749 | Dotdoteq(Dotdoteq), | ||
1750 | } | ||
1751 | impl From<Dotdot> for RangeOp { | ||
1752 | fn from(node: Dotdot) -> RangeOp { RangeOp::Dotdot(node) } | ||
1753 | } | ||
1754 | impl From<Dotdoteq> for RangeOp { | ||
1755 | fn from(node: Dotdoteq) -> RangeOp { RangeOp::Dotdoteq(node) } | ||
1756 | } | ||
1757 | impl std::fmt::Display for RangeOp { | ||
1758 | fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { | ||
1759 | std::fmt::Display::fmt(self.syntax(), f) | ||
1760 | } | ||
1761 | } | ||
1762 | impl AstToken for RangeOp { | ||
1763 | fn can_cast(kind: SyntaxKind) -> bool { | ||
1764 | match kind { | ||
1765 | DOTDOT | DOTDOTEQ => true, | ||
1766 | _ => false, | ||
1767 | } | ||
1768 | } | ||
1769 | fn cast(syntax: SyntaxToken) -> Option<Self> { | ||
1770 | let res = match syntax.kind() { | ||
1771 | DOTDOT => RangeOp::Dotdot(Dotdot { syntax }), | ||
1772 | DOTDOTEQ => RangeOp::Dotdoteq(Dotdoteq { syntax }), | ||
1773 | _ => return None, | ||
1774 | }; | ||
1775 | Some(res) | ||
1776 | } | ||
1777 | fn syntax(&self) -> &SyntaxToken { | ||
1778 | match self { | ||
1779 | RangeOp::Dotdot(it) => &it.syntax, | ||
1780 | RangeOp::Dotdoteq(it) => &it.syntax, | ||
1781 | } | ||
1782 | } | ||
1783 | } | ||
1784 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
1785 | pub enum LiteralToken { | ||
1786 | IntNumber(IntNumber), | ||
1787 | FloatNumber(FloatNumber), | ||
1788 | String(String), | ||
1789 | RawString(RawString), | ||
1790 | ByteString(ByteString), | ||
1791 | RawByteString(RawByteString), | ||
1792 | Char(Char), | ||
1793 | Byte(Byte), | ||
1794 | } | ||
1795 | impl From<IntNumber> for LiteralToken { | ||
1796 | fn from(node: IntNumber) -> LiteralToken { LiteralToken::IntNumber(node) } | ||
1797 | } | ||
1798 | impl From<FloatNumber> for LiteralToken { | ||
1799 | fn from(node: FloatNumber) -> LiteralToken { LiteralToken::FloatNumber(node) } | ||
1800 | } | ||
1801 | impl From<String> for LiteralToken { | ||
1802 | fn from(node: String) -> LiteralToken { LiteralToken::String(node) } | ||
1803 | } | ||
1804 | impl From<RawString> for LiteralToken { | ||
1805 | fn from(node: RawString) -> LiteralToken { LiteralToken::RawString(node) } | ||
1806 | } | ||
1807 | impl From<ByteString> for LiteralToken { | ||
1808 | fn from(node: ByteString) -> LiteralToken { LiteralToken::ByteString(node) } | ||
1809 | } | ||
1810 | impl From<RawByteString> for LiteralToken { | ||
1811 | fn from(node: RawByteString) -> LiteralToken { LiteralToken::RawByteString(node) } | ||
1812 | } | ||
1813 | impl From<Char> for LiteralToken { | ||
1814 | fn from(node: Char) -> LiteralToken { LiteralToken::Char(node) } | ||
1815 | } | ||
1816 | impl From<Byte> for LiteralToken { | ||
1817 | fn from(node: Byte) -> LiteralToken { LiteralToken::Byte(node) } | ||
1818 | } | ||
1819 | impl std::fmt::Display for LiteralToken { | ||
1820 | fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { | ||
1821 | std::fmt::Display::fmt(self.syntax(), f) | ||
1822 | } | ||
1823 | } | ||
1824 | impl AstToken for LiteralToken { | ||
1825 | fn can_cast(kind: SyntaxKind) -> bool { | ||
1826 | match kind { | ||
1827 | INT_NUMBER | FLOAT_NUMBER | STRING | RAW_STRING | BYTE_STRING | RAW_BYTE_STRING | ||
1828 | | CHAR | BYTE => true, | ||
1829 | _ => false, | ||
1830 | } | ||
1831 | } | ||
1832 | fn cast(syntax: SyntaxToken) -> Option<Self> { | ||
1833 | let res = match syntax.kind() { | ||
1834 | INT_NUMBER => LiteralToken::IntNumber(IntNumber { syntax }), | ||
1835 | FLOAT_NUMBER => LiteralToken::FloatNumber(FloatNumber { syntax }), | ||
1836 | STRING => LiteralToken::String(String { syntax }), | ||
1837 | RAW_STRING => LiteralToken::RawString(RawString { syntax }), | ||
1838 | BYTE_STRING => LiteralToken::ByteString(ByteString { syntax }), | ||
1839 | RAW_BYTE_STRING => LiteralToken::RawByteString(RawByteString { syntax }), | ||
1840 | CHAR => LiteralToken::Char(Char { syntax }), | ||
1841 | BYTE => LiteralToken::Byte(Byte { syntax }), | ||
1842 | _ => return None, | ||
1843 | }; | ||
1844 | Some(res) | ||
1845 | } | ||
1846 | fn syntax(&self) -> &SyntaxToken { | ||
1847 | match self { | ||
1848 | LiteralToken::IntNumber(it) => &it.syntax, | ||
1849 | LiteralToken::FloatNumber(it) => &it.syntax, | ||
1850 | LiteralToken::String(it) => &it.syntax, | ||
1851 | LiteralToken::RawString(it) => &it.syntax, | ||
1852 | LiteralToken::ByteString(it) => &it.syntax, | ||
1853 | LiteralToken::RawByteString(it) => &it.syntax, | ||
1854 | LiteralToken::Char(it) => &it.syntax, | ||
1855 | LiteralToken::Byte(it) => &it.syntax, | ||
1856 | } | ||
1857 | } | ||
1858 | } | ||
1859 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
1860 | pub enum NameRefToken { | ||
1861 | Ident(Ident), | ||
1862 | IntNumber(IntNumber), | ||
1863 | } | ||
1864 | impl From<Ident> for NameRefToken { | ||
1865 | fn from(node: Ident) -> NameRefToken { NameRefToken::Ident(node) } | ||
1866 | } | ||
1867 | impl From<IntNumber> for NameRefToken { | ||
1868 | fn from(node: IntNumber) -> NameRefToken { NameRefToken::IntNumber(node) } | ||
1869 | } | ||
1870 | impl std::fmt::Display for NameRefToken { | ||
1871 | fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { | ||
1872 | std::fmt::Display::fmt(self.syntax(), f) | ||
1873 | } | ||
1874 | } | ||
1875 | impl AstToken for NameRefToken { | ||
1876 | fn can_cast(kind: SyntaxKind) -> bool { | ||
1877 | match kind { | ||
1878 | IDENT | INT_NUMBER => true, | ||
1879 | _ => false, | ||
1880 | } | ||
1881 | } | ||
1882 | fn cast(syntax: SyntaxToken) -> Option<Self> { | ||
1883 | let res = match syntax.kind() { | ||
1884 | IDENT => NameRefToken::Ident(Ident { syntax }), | ||
1885 | INT_NUMBER => NameRefToken::IntNumber(IntNumber { syntax }), | ||
1886 | _ => return None, | ||
1887 | }; | ||
1888 | Some(res) | ||
1889 | } | ||
1890 | fn syntax(&self) -> &SyntaxToken { | ||
1891 | match self { | ||
1892 | NameRefToken::Ident(it) => &it.syntax, | ||
1893 | NameRefToken::IntNumber(it) => &it.syntax, | ||
1894 | } | ||
1895 | } | ||
1896 | } | ||