1use crate::text_size::TextRange;
4#[derive(Clone, Debug, PartialEq, is_macro::Is)]
5pub enum Ast<R = TextRange> {
6 #[is(name = "module")]
7 Mod(Mod<R>),
8 Stmt(Stmt<R>),
9 Expr(Expr<R>),
10 ExprContext(ExprContext),
11 BoolOp(BoolOp),
12 Operator(Operator),
13 UnaryOp(UnaryOp),
14 CmpOp(CmpOp),
15 Comprehension(Comprehension<R>),
16 ExceptHandler(ExceptHandler<R>),
17 Arguments(Arguments<R>),
18 Arg(Arg<R>),
19 Keyword(Keyword<R>),
20 Alias(Alias<R>),
21 WithItem(WithItem<R>),
22 MatchCase(MatchCase<R>),
23 Pattern(Pattern<R>),
24 TypeIgnore(TypeIgnore<R>),
25 TypeParam(TypeParam<R>),
26}
27impl<R> Node for Ast<R> {
28 const NAME: &'static str = "AST";
29 const FIELD_NAMES: &'static [&'static str] = &[];
30}
31
32impl<R> From<Mod<R>> for Ast<R> {
33 fn from(node: Mod<R>) -> Self {
34 Ast::Mod(node)
35 }
36}
37
38impl<R> From<Stmt<R>> for Ast<R> {
39 fn from(node: Stmt<R>) -> Self {
40 Ast::Stmt(node)
41 }
42}
43
44impl<R> From<Expr<R>> for Ast<R> {
45 fn from(node: Expr<R>) -> Self {
46 Ast::Expr(node)
47 }
48}
49
50impl<R> From<ExprContext> for Ast<R> {
51 fn from(node: ExprContext) -> Self {
52 Ast::ExprContext(node)
53 }
54}
55
56impl<R> From<BoolOp> for Ast<R> {
57 fn from(node: BoolOp) -> Self {
58 Ast::BoolOp(node)
59 }
60}
61
62impl<R> From<Operator> for Ast<R> {
63 fn from(node: Operator) -> Self {
64 Ast::Operator(node)
65 }
66}
67
68impl<R> From<UnaryOp> for Ast<R> {
69 fn from(node: UnaryOp) -> Self {
70 Ast::UnaryOp(node)
71 }
72}
73
74impl<R> From<CmpOp> for Ast<R> {
75 fn from(node: CmpOp) -> Self {
76 Ast::CmpOp(node)
77 }
78}
79
80impl<R> From<Comprehension<R>> for Ast<R> {
81 fn from(node: Comprehension<R>) -> Self {
82 Ast::Comprehension(node)
83 }
84}
85
86impl<R> From<ExceptHandler<R>> for Ast<R> {
87 fn from(node: ExceptHandler<R>) -> Self {
88 Ast::ExceptHandler(node)
89 }
90}
91
92impl<R> From<Arguments<R>> for Ast<R> {
93 fn from(node: Arguments<R>) -> Self {
94 Ast::Arguments(node)
95 }
96}
97
98impl<R> From<Arg<R>> for Ast<R> {
99 fn from(node: Arg<R>) -> Self {
100 Ast::Arg(node)
101 }
102}
103
104impl<R> From<Keyword<R>> for Ast<R> {
105 fn from(node: Keyword<R>) -> Self {
106 Ast::Keyword(node)
107 }
108}
109
110impl<R> From<Alias<R>> for Ast<R> {
111 fn from(node: Alias<R>) -> Self {
112 Ast::Alias(node)
113 }
114}
115
116impl<R> From<WithItem<R>> for Ast<R> {
117 fn from(node: WithItem<R>) -> Self {
118 Ast::WithItem(node)
119 }
120}
121
122impl<R> From<MatchCase<R>> for Ast<R> {
123 fn from(node: MatchCase<R>) -> Self {
124 Ast::MatchCase(node)
125 }
126}
127
128impl<R> From<Pattern<R>> for Ast<R> {
129 fn from(node: Pattern<R>) -> Self {
130 Ast::Pattern(node)
131 }
132}
133
134impl<R> From<TypeIgnore<R>> for Ast<R> {
135 fn from(node: TypeIgnore<R>) -> Self {
136 Ast::TypeIgnore(node)
137 }
138}
139
140impl<R> From<TypeParam<R>> for Ast<R> {
141 fn from(node: TypeParam<R>) -> Self {
142 Ast::TypeParam(node)
143 }
144}
145
146#[derive(Clone, Debug, PartialEq, is_macro::Is)]
148pub enum Mod<R = TextRange> {
149 Module(ModModule<R>),
150 Interactive(ModInteractive<R>),
151 Expression(ModExpression<R>),
152 FunctionType(ModFunctionType<R>),
153}
154
155#[derive(Clone, Debug, PartialEq)]
157pub struct ModModule<R = TextRange> {
158 pub range: OptionalRange<R>,
159 pub body: Vec<Stmt<R>>,
160 pub type_ignores: Vec<TypeIgnore<R>>,
161}
162
163impl<R> Node for ModModule<R> {
164 const NAME: &'static str = "Module";
165 const FIELD_NAMES: &'static [&'static str] = &["body", "type_ignores"];
166}
167impl<R> From<ModModule<R>> for Mod<R> {
168 fn from(payload: ModModule<R>) -> Self {
169 Mod::Module(payload)
170 }
171}
172impl<R> From<ModModule<R>> for Ast<R> {
173 fn from(payload: ModModule<R>) -> Self {
174 Mod::from(payload).into()
175 }
176}
177
178#[derive(Clone, Debug, PartialEq)]
180pub struct ModInteractive<R = TextRange> {
181 pub range: OptionalRange<R>,
182 pub body: Vec<Stmt<R>>,
183}
184
185impl<R> Node for ModInteractive<R> {
186 const NAME: &'static str = "Interactive";
187 const FIELD_NAMES: &'static [&'static str] = &["body"];
188}
189impl<R> From<ModInteractive<R>> for Mod<R> {
190 fn from(payload: ModInteractive<R>) -> Self {
191 Mod::Interactive(payload)
192 }
193}
194impl<R> From<ModInteractive<R>> for Ast<R> {
195 fn from(payload: ModInteractive<R>) -> Self {
196 Mod::from(payload).into()
197 }
198}
199
200#[derive(Clone, Debug, PartialEq)]
202pub struct ModExpression<R = TextRange> {
203 pub range: OptionalRange<R>,
204 pub body: Box<Expr<R>>,
205}
206
207impl<R> Node for ModExpression<R> {
208 const NAME: &'static str = "Expression";
209 const FIELD_NAMES: &'static [&'static str] = &["body"];
210}
211impl<R> From<ModExpression<R>> for Mod<R> {
212 fn from(payload: ModExpression<R>) -> Self {
213 Mod::Expression(payload)
214 }
215}
216impl<R> From<ModExpression<R>> for Ast<R> {
217 fn from(payload: ModExpression<R>) -> Self {
218 Mod::from(payload).into()
219 }
220}
221
222#[derive(Clone, Debug, PartialEq)]
224pub struct ModFunctionType<R = TextRange> {
225 pub range: OptionalRange<R>,
226 pub argtypes: Vec<Expr<R>>,
227 pub returns: Box<Expr<R>>,
228}
229
230impl<R> Node for ModFunctionType<R> {
231 const NAME: &'static str = "FunctionType";
232 const FIELD_NAMES: &'static [&'static str] = &["argtypes", "returns"];
233}
234impl<R> From<ModFunctionType<R>> for Mod<R> {
235 fn from(payload: ModFunctionType<R>) -> Self {
236 Mod::FunctionType(payload)
237 }
238}
239impl<R> From<ModFunctionType<R>> for Ast<R> {
240 fn from(payload: ModFunctionType<R>) -> Self {
241 Mod::from(payload).into()
242 }
243}
244
245impl<R> Node for Mod<R> {
246 const NAME: &'static str = "mod";
247 const FIELD_NAMES: &'static [&'static str] = &[];
248}
249
250#[derive(Clone, Debug, PartialEq, is_macro::Is)]
252pub enum Stmt<R = TextRange> {
253 #[is(name = "function_def_stmt")]
254 FunctionDef(StmtFunctionDef<R>),
255 #[is(name = "async_function_def_stmt")]
256 AsyncFunctionDef(StmtAsyncFunctionDef<R>),
257 #[is(name = "class_def_stmt")]
258 ClassDef(StmtClassDef<R>),
259 #[is(name = "return_stmt")]
260 Return(StmtReturn<R>),
261 #[is(name = "delete_stmt")]
262 Delete(StmtDelete<R>),
263 #[is(name = "assign_stmt")]
264 Assign(StmtAssign<R>),
265 #[is(name = "type_alias_stmt")]
266 TypeAlias(StmtTypeAlias<R>),
267 #[is(name = "aug_assign_stmt")]
268 AugAssign(StmtAugAssign<R>),
269 #[is(name = "ann_assign_stmt")]
270 AnnAssign(StmtAnnAssign<R>),
271 #[is(name = "for_stmt")]
272 For(StmtFor<R>),
273 #[is(name = "async_for_stmt")]
274 AsyncFor(StmtAsyncFor<R>),
275 #[is(name = "while_stmt")]
276 While(StmtWhile<R>),
277 #[is(name = "if_stmt")]
278 If(StmtIf<R>),
279 #[is(name = "with_stmt")]
280 With(StmtWith<R>),
281 #[is(name = "async_with_stmt")]
282 AsyncWith(StmtAsyncWith<R>),
283 #[is(name = "match_stmt")]
284 Match(StmtMatch<R>),
285 #[is(name = "raise_stmt")]
286 Raise(StmtRaise<R>),
287 #[is(name = "try_stmt")]
288 Try(StmtTry<R>),
289 #[is(name = "try_star_stmt")]
290 TryStar(StmtTryStar<R>),
291 #[is(name = "assert_stmt")]
292 Assert(StmtAssert<R>),
293 #[is(name = "import_stmt")]
294 Import(StmtImport<R>),
295 #[is(name = "import_from_stmt")]
296 ImportFrom(StmtImportFrom<R>),
297 #[is(name = "global_stmt")]
298 Global(StmtGlobal<R>),
299 #[is(name = "nonlocal_stmt")]
300 Nonlocal(StmtNonlocal<R>),
301 #[is(name = "expr_stmt")]
302 Expr(StmtExpr<R>),
303 #[is(name = "pass_stmt")]
304 Pass(StmtPass<R>),
305 #[is(name = "break_stmt")]
306 Break(StmtBreak<R>),
307 #[is(name = "continue_stmt")]
308 Continue(StmtContinue<R>),
309}
310
311#[derive(Clone, Debug, PartialEq)]
313pub struct StmtFunctionDef<R = TextRange> {
314 pub range: R,
315 pub name: Identifier,
316 pub args: Box<Arguments<R>>,
317 pub body: Vec<Stmt<R>>,
318 pub decorator_list: Vec<Expr<R>>,
319 pub returns: Option<Box<Expr<R>>>,
320 pub type_comment: Option<String>,
321 pub type_params: Vec<TypeParam<R>>,
322}
323
324impl<R> Node for StmtFunctionDef<R> {
325 const NAME: &'static str = "FunctionDef";
326 const FIELD_NAMES: &'static [&'static str] = &[
327 "name",
328 "args",
329 "body",
330 "decorator_list",
331 "returns",
332 "type_comment",
333 "type_params",
334 ];
335}
336impl<R> From<StmtFunctionDef<R>> for Stmt<R> {
337 fn from(payload: StmtFunctionDef<R>) -> Self {
338 Stmt::FunctionDef(payload)
339 }
340}
341impl<R> From<StmtFunctionDef<R>> for Ast<R> {
342 fn from(payload: StmtFunctionDef<R>) -> Self {
343 Stmt::from(payload).into()
344 }
345}
346
347#[derive(Clone, Debug, PartialEq)]
349pub struct StmtAsyncFunctionDef<R = TextRange> {
350 pub range: R,
351 pub name: Identifier,
352 pub args: Box<Arguments<R>>,
353 pub body: Vec<Stmt<R>>,
354 pub decorator_list: Vec<Expr<R>>,
355 pub returns: Option<Box<Expr<R>>>,
356 pub type_comment: Option<String>,
357 pub type_params: Vec<TypeParam<R>>,
358}
359
360impl<R> Node for StmtAsyncFunctionDef<R> {
361 const NAME: &'static str = "AsyncFunctionDef";
362 const FIELD_NAMES: &'static [&'static str] = &[
363 "name",
364 "args",
365 "body",
366 "decorator_list",
367 "returns",
368 "type_comment",
369 "type_params",
370 ];
371}
372impl<R> From<StmtAsyncFunctionDef<R>> for Stmt<R> {
373 fn from(payload: StmtAsyncFunctionDef<R>) -> Self {
374 Stmt::AsyncFunctionDef(payload)
375 }
376}
377impl<R> From<StmtAsyncFunctionDef<R>> for Ast<R> {
378 fn from(payload: StmtAsyncFunctionDef<R>) -> Self {
379 Stmt::from(payload).into()
380 }
381}
382
383#[derive(Clone, Debug, PartialEq)]
385pub struct StmtClassDef<R = TextRange> {
386 pub range: R,
387 pub name: Identifier,
388 pub bases: Vec<Expr<R>>,
389 pub keywords: Vec<Keyword<R>>,
390 pub body: Vec<Stmt<R>>,
391 pub decorator_list: Vec<Expr<R>>,
392 pub type_params: Vec<TypeParam<R>>,
393}
394
395impl<R> Node for StmtClassDef<R> {
396 const NAME: &'static str = "ClassDef";
397 const FIELD_NAMES: &'static [&'static str] = &[
398 "name",
399 "bases",
400 "keywords",
401 "body",
402 "decorator_list",
403 "type_params",
404 ];
405}
406impl<R> From<StmtClassDef<R>> for Stmt<R> {
407 fn from(payload: StmtClassDef<R>) -> Self {
408 Stmt::ClassDef(payload)
409 }
410}
411impl<R> From<StmtClassDef<R>> for Ast<R> {
412 fn from(payload: StmtClassDef<R>) -> Self {
413 Stmt::from(payload).into()
414 }
415}
416
417#[derive(Clone, Debug, PartialEq)]
419pub struct StmtReturn<R = TextRange> {
420 pub range: R,
421 pub value: Option<Box<Expr<R>>>,
422}
423
424impl<R> Node for StmtReturn<R> {
425 const NAME: &'static str = "Return";
426 const FIELD_NAMES: &'static [&'static str] = &["value"];
427}
428impl<R> From<StmtReturn<R>> for Stmt<R> {
429 fn from(payload: StmtReturn<R>) -> Self {
430 Stmt::Return(payload)
431 }
432}
433impl<R> From<StmtReturn<R>> for Ast<R> {
434 fn from(payload: StmtReturn<R>) -> Self {
435 Stmt::from(payload).into()
436 }
437}
438
439#[derive(Clone, Debug, PartialEq)]
441pub struct StmtDelete<R = TextRange> {
442 pub range: R,
443 pub targets: Vec<Expr<R>>,
444}
445
446impl<R> Node for StmtDelete<R> {
447 const NAME: &'static str = "Delete";
448 const FIELD_NAMES: &'static [&'static str] = &["targets"];
449}
450impl<R> From<StmtDelete<R>> for Stmt<R> {
451 fn from(payload: StmtDelete<R>) -> Self {
452 Stmt::Delete(payload)
453 }
454}
455impl<R> From<StmtDelete<R>> for Ast<R> {
456 fn from(payload: StmtDelete<R>) -> Self {
457 Stmt::from(payload).into()
458 }
459}
460
461#[derive(Clone, Debug, PartialEq)]
463pub struct StmtAssign<R = TextRange> {
464 pub range: R,
465 pub targets: Vec<Expr<R>>,
466 pub value: Box<Expr<R>>,
467 pub type_comment: Option<String>,
468}
469
470impl<R> Node for StmtAssign<R> {
471 const NAME: &'static str = "Assign";
472 const FIELD_NAMES: &'static [&'static str] = &["targets", "value", "type_comment"];
473}
474impl<R> From<StmtAssign<R>> for Stmt<R> {
475 fn from(payload: StmtAssign<R>) -> Self {
476 Stmt::Assign(payload)
477 }
478}
479impl<R> From<StmtAssign<R>> for Ast<R> {
480 fn from(payload: StmtAssign<R>) -> Self {
481 Stmt::from(payload).into()
482 }
483}
484
485#[derive(Clone, Debug, PartialEq)]
487pub struct StmtTypeAlias<R = TextRange> {
488 pub range: R,
489 pub name: Box<Expr<R>>,
490 pub type_params: Vec<TypeParam<R>>,
491 pub value: Box<Expr<R>>,
492}
493
494impl<R> Node for StmtTypeAlias<R> {
495 const NAME: &'static str = "TypeAlias";
496 const FIELD_NAMES: &'static [&'static str] = &["name", "type_params", "value"];
497}
498impl<R> From<StmtTypeAlias<R>> for Stmt<R> {
499 fn from(payload: StmtTypeAlias<R>) -> Self {
500 Stmt::TypeAlias(payload)
501 }
502}
503impl<R> From<StmtTypeAlias<R>> for Ast<R> {
504 fn from(payload: StmtTypeAlias<R>) -> Self {
505 Stmt::from(payload).into()
506 }
507}
508
509#[derive(Clone, Debug, PartialEq)]
511pub struct StmtAugAssign<R = TextRange> {
512 pub range: R,
513 pub target: Box<Expr<R>>,
514 pub op: Operator,
515 pub value: Box<Expr<R>>,
516}
517
518impl<R> Node for StmtAugAssign<R> {
519 const NAME: &'static str = "AugAssign";
520 const FIELD_NAMES: &'static [&'static str] = &["target", "op", "value"];
521}
522impl<R> From<StmtAugAssign<R>> for Stmt<R> {
523 fn from(payload: StmtAugAssign<R>) -> Self {
524 Stmt::AugAssign(payload)
525 }
526}
527impl<R> From<StmtAugAssign<R>> for Ast<R> {
528 fn from(payload: StmtAugAssign<R>) -> Self {
529 Stmt::from(payload).into()
530 }
531}
532
533#[derive(Clone, Debug, PartialEq)]
535pub struct StmtAnnAssign<R = TextRange> {
536 pub range: R,
537 pub target: Box<Expr<R>>,
538 pub annotation: Box<Expr<R>>,
539 pub value: Option<Box<Expr<R>>>,
540 pub simple: bool,
541}
542
543impl<R> Node for StmtAnnAssign<R> {
544 const NAME: &'static str = "AnnAssign";
545 const FIELD_NAMES: &'static [&'static str] = &["target", "annotation", "value", "simple"];
546}
547impl<R> From<StmtAnnAssign<R>> for Stmt<R> {
548 fn from(payload: StmtAnnAssign<R>) -> Self {
549 Stmt::AnnAssign(payload)
550 }
551}
552impl<R> From<StmtAnnAssign<R>> for Ast<R> {
553 fn from(payload: StmtAnnAssign<R>) -> Self {
554 Stmt::from(payload).into()
555 }
556}
557
558#[derive(Clone, Debug, PartialEq)]
560pub struct StmtFor<R = TextRange> {
561 pub range: R,
562 pub target: Box<Expr<R>>,
563 pub iter: Box<Expr<R>>,
564 pub body: Vec<Stmt<R>>,
565 pub orelse: Vec<Stmt<R>>,
566 pub type_comment: Option<String>,
567}
568
569impl<R> Node for StmtFor<R> {
570 const NAME: &'static str = "For";
571 const FIELD_NAMES: &'static [&'static str] =
572 &["target", "iter", "body", "orelse", "type_comment"];
573}
574impl<R> From<StmtFor<R>> for Stmt<R> {
575 fn from(payload: StmtFor<R>) -> Self {
576 Stmt::For(payload)
577 }
578}
579impl<R> From<StmtFor<R>> for Ast<R> {
580 fn from(payload: StmtFor<R>) -> Self {
581 Stmt::from(payload).into()
582 }
583}
584
585#[derive(Clone, Debug, PartialEq)]
587pub struct StmtAsyncFor<R = TextRange> {
588 pub range: R,
589 pub target: Box<Expr<R>>,
590 pub iter: Box<Expr<R>>,
591 pub body: Vec<Stmt<R>>,
592 pub orelse: Vec<Stmt<R>>,
593 pub type_comment: Option<String>,
594}
595
596impl<R> Node for StmtAsyncFor<R> {
597 const NAME: &'static str = "AsyncFor";
598 const FIELD_NAMES: &'static [&'static str] =
599 &["target", "iter", "body", "orelse", "type_comment"];
600}
601impl<R> From<StmtAsyncFor<R>> for Stmt<R> {
602 fn from(payload: StmtAsyncFor<R>) -> Self {
603 Stmt::AsyncFor(payload)
604 }
605}
606impl<R> From<StmtAsyncFor<R>> for Ast<R> {
607 fn from(payload: StmtAsyncFor<R>) -> Self {
608 Stmt::from(payload).into()
609 }
610}
611
612#[derive(Clone, Debug, PartialEq)]
614pub struct StmtWhile<R = TextRange> {
615 pub range: R,
616 pub test: Box<Expr<R>>,
617 pub body: Vec<Stmt<R>>,
618 pub orelse: Vec<Stmt<R>>,
619}
620
621impl<R> Node for StmtWhile<R> {
622 const NAME: &'static str = "While";
623 const FIELD_NAMES: &'static [&'static str] = &["test", "body", "orelse"];
624}
625impl<R> From<StmtWhile<R>> for Stmt<R> {
626 fn from(payload: StmtWhile<R>) -> Self {
627 Stmt::While(payload)
628 }
629}
630impl<R> From<StmtWhile<R>> for Ast<R> {
631 fn from(payload: StmtWhile<R>) -> Self {
632 Stmt::from(payload).into()
633 }
634}
635
636#[derive(Clone, Debug, PartialEq)]
638pub struct StmtIf<R = TextRange> {
639 pub range: R,
640 pub test: Box<Expr<R>>,
641 pub body: Vec<Stmt<R>>,
642 pub orelse: Vec<Stmt<R>>,
643}
644
645impl<R> Node for StmtIf<R> {
646 const NAME: &'static str = "If";
647 const FIELD_NAMES: &'static [&'static str] = &["test", "body", "orelse"];
648}
649impl<R> From<StmtIf<R>> for Stmt<R> {
650 fn from(payload: StmtIf<R>) -> Self {
651 Stmt::If(payload)
652 }
653}
654impl<R> From<StmtIf<R>> for Ast<R> {
655 fn from(payload: StmtIf<R>) -> Self {
656 Stmt::from(payload).into()
657 }
658}
659
660#[derive(Clone, Debug, PartialEq)]
662pub struct StmtWith<R = TextRange> {
663 pub range: R,
664 pub items: Vec<WithItem<R>>,
665 pub body: Vec<Stmt<R>>,
666 pub type_comment: Option<String>,
667}
668
669impl<R> Node for StmtWith<R> {
670 const NAME: &'static str = "With";
671 const FIELD_NAMES: &'static [&'static str] = &["items", "body", "type_comment"];
672}
673impl<R> From<StmtWith<R>> for Stmt<R> {
674 fn from(payload: StmtWith<R>) -> Self {
675 Stmt::With(payload)
676 }
677}
678impl<R> From<StmtWith<R>> for Ast<R> {
679 fn from(payload: StmtWith<R>) -> Self {
680 Stmt::from(payload).into()
681 }
682}
683
684#[derive(Clone, Debug, PartialEq)]
686pub struct StmtAsyncWith<R = TextRange> {
687 pub range: R,
688 pub items: Vec<WithItem<R>>,
689 pub body: Vec<Stmt<R>>,
690 pub type_comment: Option<String>,
691}
692
693impl<R> Node for StmtAsyncWith<R> {
694 const NAME: &'static str = "AsyncWith";
695 const FIELD_NAMES: &'static [&'static str] = &["items", "body", "type_comment"];
696}
697impl<R> From<StmtAsyncWith<R>> for Stmt<R> {
698 fn from(payload: StmtAsyncWith<R>) -> Self {
699 Stmt::AsyncWith(payload)
700 }
701}
702impl<R> From<StmtAsyncWith<R>> for Ast<R> {
703 fn from(payload: StmtAsyncWith<R>) -> Self {
704 Stmt::from(payload).into()
705 }
706}
707
708#[derive(Clone, Debug, PartialEq)]
710pub struct StmtMatch<R = TextRange> {
711 pub range: R,
712 pub subject: Box<Expr<R>>,
713 pub cases: Vec<MatchCase<R>>,
714}
715
716impl<R> Node for StmtMatch<R> {
717 const NAME: &'static str = "Match";
718 const FIELD_NAMES: &'static [&'static str] = &["subject", "cases"];
719}
720impl<R> From<StmtMatch<R>> for Stmt<R> {
721 fn from(payload: StmtMatch<R>) -> Self {
722 Stmt::Match(payload)
723 }
724}
725impl<R> From<StmtMatch<R>> for Ast<R> {
726 fn from(payload: StmtMatch<R>) -> Self {
727 Stmt::from(payload).into()
728 }
729}
730
731#[derive(Clone, Debug, PartialEq)]
733pub struct StmtRaise<R = TextRange> {
734 pub range: R,
735 pub exc: Option<Box<Expr<R>>>,
736 pub cause: Option<Box<Expr<R>>>,
737}
738
739impl<R> Node for StmtRaise<R> {
740 const NAME: &'static str = "Raise";
741 const FIELD_NAMES: &'static [&'static str] = &["exc", "cause"];
742}
743impl<R> From<StmtRaise<R>> for Stmt<R> {
744 fn from(payload: StmtRaise<R>) -> Self {
745 Stmt::Raise(payload)
746 }
747}
748impl<R> From<StmtRaise<R>> for Ast<R> {
749 fn from(payload: StmtRaise<R>) -> Self {
750 Stmt::from(payload).into()
751 }
752}
753
754#[derive(Clone, Debug, PartialEq)]
756pub struct StmtTry<R = TextRange> {
757 pub range: R,
758 pub body: Vec<Stmt<R>>,
759 pub handlers: Vec<ExceptHandler<R>>,
760 pub orelse: Vec<Stmt<R>>,
761 pub finalbody: Vec<Stmt<R>>,
762}
763
764impl<R> Node for StmtTry<R> {
765 const NAME: &'static str = "Try";
766 const FIELD_NAMES: &'static [&'static str] = &["body", "handlers", "orelse", "finalbody"];
767}
768impl<R> From<StmtTry<R>> for Stmt<R> {
769 fn from(payload: StmtTry<R>) -> Self {
770 Stmt::Try(payload)
771 }
772}
773impl<R> From<StmtTry<R>> for Ast<R> {
774 fn from(payload: StmtTry<R>) -> Self {
775 Stmt::from(payload).into()
776 }
777}
778
779#[derive(Clone, Debug, PartialEq)]
781pub struct StmtTryStar<R = TextRange> {
782 pub range: R,
783 pub body: Vec<Stmt<R>>,
784 pub handlers: Vec<ExceptHandler<R>>,
785 pub orelse: Vec<Stmt<R>>,
786 pub finalbody: Vec<Stmt<R>>,
787}
788
789impl<R> Node for StmtTryStar<R> {
790 const NAME: &'static str = "TryStar";
791 const FIELD_NAMES: &'static [&'static str] = &["body", "handlers", "orelse", "finalbody"];
792}
793impl<R> From<StmtTryStar<R>> for Stmt<R> {
794 fn from(payload: StmtTryStar<R>) -> Self {
795 Stmt::TryStar(payload)
796 }
797}
798impl<R> From<StmtTryStar<R>> for Ast<R> {
799 fn from(payload: StmtTryStar<R>) -> Self {
800 Stmt::from(payload).into()
801 }
802}
803
804#[derive(Clone, Debug, PartialEq)]
806pub struct StmtAssert<R = TextRange> {
807 pub range: R,
808 pub test: Box<Expr<R>>,
809 pub msg: Option<Box<Expr<R>>>,
810}
811
812impl<R> Node for StmtAssert<R> {
813 const NAME: &'static str = "Assert";
814 const FIELD_NAMES: &'static [&'static str] = &["test", "msg"];
815}
816impl<R> From<StmtAssert<R>> for Stmt<R> {
817 fn from(payload: StmtAssert<R>) -> Self {
818 Stmt::Assert(payload)
819 }
820}
821impl<R> From<StmtAssert<R>> for Ast<R> {
822 fn from(payload: StmtAssert<R>) -> Self {
823 Stmt::from(payload).into()
824 }
825}
826
827#[derive(Clone, Debug, PartialEq)]
829pub struct StmtImport<R = TextRange> {
830 pub range: R,
831 pub names: Vec<Alias<R>>,
832}
833
834impl<R> Node for StmtImport<R> {
835 const NAME: &'static str = "Import";
836 const FIELD_NAMES: &'static [&'static str] = &["names"];
837}
838impl<R> From<StmtImport<R>> for Stmt<R> {
839 fn from(payload: StmtImport<R>) -> Self {
840 Stmt::Import(payload)
841 }
842}
843impl<R> From<StmtImport<R>> for Ast<R> {
844 fn from(payload: StmtImport<R>) -> Self {
845 Stmt::from(payload).into()
846 }
847}
848
849#[derive(Clone, Debug, PartialEq)]
851pub struct StmtImportFrom<R = TextRange> {
852 pub range: R,
853 pub module: Option<Identifier>,
854 pub names: Vec<Alias<R>>,
855 pub level: Option<Int>,
856}
857
858impl<R> Node for StmtImportFrom<R> {
859 const NAME: &'static str = "ImportFrom";
860 const FIELD_NAMES: &'static [&'static str] = &["module", "names", "level"];
861}
862impl<R> From<StmtImportFrom<R>> for Stmt<R> {
863 fn from(payload: StmtImportFrom<R>) -> Self {
864 Stmt::ImportFrom(payload)
865 }
866}
867impl<R> From<StmtImportFrom<R>> for Ast<R> {
868 fn from(payload: StmtImportFrom<R>) -> Self {
869 Stmt::from(payload).into()
870 }
871}
872
873#[derive(Clone, Debug, PartialEq)]
875pub struct StmtGlobal<R = TextRange> {
876 pub range: R,
877 pub names: Vec<Identifier>,
878}
879
880impl<R> Node for StmtGlobal<R> {
881 const NAME: &'static str = "Global";
882 const FIELD_NAMES: &'static [&'static str] = &["names"];
883}
884impl<R> From<StmtGlobal<R>> for Stmt<R> {
885 fn from(payload: StmtGlobal<R>) -> Self {
886 Stmt::Global(payload)
887 }
888}
889impl<R> From<StmtGlobal<R>> for Ast<R> {
890 fn from(payload: StmtGlobal<R>) -> Self {
891 Stmt::from(payload).into()
892 }
893}
894
895#[derive(Clone, Debug, PartialEq)]
897pub struct StmtNonlocal<R = TextRange> {
898 pub range: R,
899 pub names: Vec<Identifier>,
900}
901
902impl<R> Node for StmtNonlocal<R> {
903 const NAME: &'static str = "Nonlocal";
904 const FIELD_NAMES: &'static [&'static str] = &["names"];
905}
906impl<R> From<StmtNonlocal<R>> for Stmt<R> {
907 fn from(payload: StmtNonlocal<R>) -> Self {
908 Stmt::Nonlocal(payload)
909 }
910}
911impl<R> From<StmtNonlocal<R>> for Ast<R> {
912 fn from(payload: StmtNonlocal<R>) -> Self {
913 Stmt::from(payload).into()
914 }
915}
916
917#[derive(Clone, Debug, PartialEq)]
919pub struct StmtExpr<R = TextRange> {
920 pub range: R,
921 pub value: Box<Expr<R>>,
922}
923
924impl<R> Node for StmtExpr<R> {
925 const NAME: &'static str = "Expr";
926 const FIELD_NAMES: &'static [&'static str] = &["value"];
927}
928impl<R> From<StmtExpr<R>> for Stmt<R> {
929 fn from(payload: StmtExpr<R>) -> Self {
930 Stmt::Expr(payload)
931 }
932}
933impl<R> From<StmtExpr<R>> for Ast<R> {
934 fn from(payload: StmtExpr<R>) -> Self {
935 Stmt::from(payload).into()
936 }
937}
938
939#[derive(Clone, Debug, PartialEq)]
941pub struct StmtPass<R = TextRange> {
942 pub range: R,
943}
944
945impl<R> Node for StmtPass<R> {
946 const NAME: &'static str = "Pass";
947 const FIELD_NAMES: &'static [&'static str] = &[];
948}
949impl<R> From<StmtPass<R>> for Stmt<R> {
950 fn from(payload: StmtPass<R>) -> Self {
951 Stmt::Pass(payload)
952 }
953}
954impl<R> From<StmtPass<R>> for Ast<R> {
955 fn from(payload: StmtPass<R>) -> Self {
956 Stmt::from(payload).into()
957 }
958}
959
960#[derive(Clone, Debug, PartialEq)]
962pub struct StmtBreak<R = TextRange> {
963 pub range: R,
964}
965
966impl<R> Node for StmtBreak<R> {
967 const NAME: &'static str = "Break";
968 const FIELD_NAMES: &'static [&'static str] = &[];
969}
970impl<R> From<StmtBreak<R>> for Stmt<R> {
971 fn from(payload: StmtBreak<R>) -> Self {
972 Stmt::Break(payload)
973 }
974}
975impl<R> From<StmtBreak<R>> for Ast<R> {
976 fn from(payload: StmtBreak<R>) -> Self {
977 Stmt::from(payload).into()
978 }
979}
980
981#[derive(Clone, Debug, PartialEq)]
983pub struct StmtContinue<R = TextRange> {
984 pub range: R,
985}
986
987impl<R> Node for StmtContinue<R> {
988 const NAME: &'static str = "Continue";
989 const FIELD_NAMES: &'static [&'static str] = &[];
990}
991impl<R> From<StmtContinue<R>> for Stmt<R> {
992 fn from(payload: StmtContinue<R>) -> Self {
993 Stmt::Continue(payload)
994 }
995}
996impl<R> From<StmtContinue<R>> for Ast<R> {
997 fn from(payload: StmtContinue<R>) -> Self {
998 Stmt::from(payload).into()
999 }
1000}
1001
1002impl<R> Node for Stmt<R> {
1003 const NAME: &'static str = "stmt";
1004 const FIELD_NAMES: &'static [&'static str] = &[];
1005}
1006
1007#[derive(Clone, Debug, PartialEq, is_macro::Is)]
1009pub enum Expr<R = TextRange> {
1010 #[is(name = "bool_op_expr")]
1011 BoolOp(ExprBoolOp<R>),
1012 #[is(name = "named_expr_expr")]
1013 NamedExpr(ExprNamedExpr<R>),
1014 #[is(name = "bin_op_expr")]
1015 BinOp(ExprBinOp<R>),
1016 #[is(name = "unary_op_expr")]
1017 UnaryOp(ExprUnaryOp<R>),
1018 #[is(name = "lambda_expr")]
1019 Lambda(ExprLambda<R>),
1020 #[is(name = "if_exp_expr")]
1021 IfExp(ExprIfExp<R>),
1022 #[is(name = "dict_expr")]
1023 Dict(ExprDict<R>),
1024 #[is(name = "set_expr")]
1025 Set(ExprSet<R>),
1026 #[is(name = "list_comp_expr")]
1027 ListComp(ExprListComp<R>),
1028 #[is(name = "set_comp_expr")]
1029 SetComp(ExprSetComp<R>),
1030 #[is(name = "dict_comp_expr")]
1031 DictComp(ExprDictComp<R>),
1032 #[is(name = "generator_exp_expr")]
1033 GeneratorExp(ExprGeneratorExp<R>),
1034 #[is(name = "await_expr")]
1035 Await(ExprAwait<R>),
1036 #[is(name = "yield_expr")]
1037 Yield(ExprYield<R>),
1038 #[is(name = "yield_from_expr")]
1039 YieldFrom(ExprYieldFrom<R>),
1040 #[is(name = "compare_expr")]
1041 Compare(ExprCompare<R>),
1042 #[is(name = "call_expr")]
1043 Call(ExprCall<R>),
1044 #[is(name = "formatted_value_expr")]
1045 FormattedValue(ExprFormattedValue<R>),
1046 #[is(name = "joined_str_expr")]
1047 JoinedStr(ExprJoinedStr<R>),
1048 #[is(name = "constant_expr")]
1049 Constant(ExprConstant<R>),
1050 #[is(name = "attribute_expr")]
1051 Attribute(ExprAttribute<R>),
1052 #[is(name = "subscript_expr")]
1053 Subscript(ExprSubscript<R>),
1054 #[is(name = "starred_expr")]
1055 Starred(ExprStarred<R>),
1056 #[is(name = "name_expr")]
1057 Name(ExprName<R>),
1058 #[is(name = "list_expr")]
1059 List(ExprList<R>),
1060 #[is(name = "tuple_expr")]
1061 Tuple(ExprTuple<R>),
1062 #[is(name = "slice_expr")]
1063 Slice(ExprSlice<R>),
1064}
1065
1066#[derive(Clone, Debug, PartialEq)]
1068pub struct ExprBoolOp<R = TextRange> {
1069 pub range: R,
1070 pub op: BoolOp,
1071 pub values: Vec<Expr<R>>,
1072}
1073
1074impl<R> Node for ExprBoolOp<R> {
1075 const NAME: &'static str = "BoolOp";
1076 const FIELD_NAMES: &'static [&'static str] = &["op", "values"];
1077}
1078impl<R> From<ExprBoolOp<R>> for Expr<R> {
1079 fn from(payload: ExprBoolOp<R>) -> Self {
1080 Expr::BoolOp(payload)
1081 }
1082}
1083impl<R> From<ExprBoolOp<R>> for Ast<R> {
1084 fn from(payload: ExprBoolOp<R>) -> Self {
1085 Expr::from(payload).into()
1086 }
1087}
1088
1089#[derive(Clone, Debug, PartialEq)]
1091pub struct ExprNamedExpr<R = TextRange> {
1092 pub range: R,
1093 pub target: Box<Expr<R>>,
1094 pub value: Box<Expr<R>>,
1095}
1096
1097impl<R> Node for ExprNamedExpr<R> {
1098 const NAME: &'static str = "NamedExpr";
1099 const FIELD_NAMES: &'static [&'static str] = &["target", "value"];
1100}
1101impl<R> From<ExprNamedExpr<R>> for Expr<R> {
1102 fn from(payload: ExprNamedExpr<R>) -> Self {
1103 Expr::NamedExpr(payload)
1104 }
1105}
1106impl<R> From<ExprNamedExpr<R>> for Ast<R> {
1107 fn from(payload: ExprNamedExpr<R>) -> Self {
1108 Expr::from(payload).into()
1109 }
1110}
1111
1112#[derive(Clone, Debug, PartialEq)]
1114pub struct ExprBinOp<R = TextRange> {
1115 pub range: R,
1116 pub left: Box<Expr<R>>,
1117 pub op: Operator,
1118 pub right: Box<Expr<R>>,
1119}
1120
1121impl<R> Node for ExprBinOp<R> {
1122 const NAME: &'static str = "BinOp";
1123 const FIELD_NAMES: &'static [&'static str] = &["left", "op", "right"];
1124}
1125impl<R> From<ExprBinOp<R>> for Expr<R> {
1126 fn from(payload: ExprBinOp<R>) -> Self {
1127 Expr::BinOp(payload)
1128 }
1129}
1130impl<R> From<ExprBinOp<R>> for Ast<R> {
1131 fn from(payload: ExprBinOp<R>) -> Self {
1132 Expr::from(payload).into()
1133 }
1134}
1135
1136#[derive(Clone, Debug, PartialEq)]
1138pub struct ExprUnaryOp<R = TextRange> {
1139 pub range: R,
1140 pub op: UnaryOp,
1141 pub operand: Box<Expr<R>>,
1142}
1143
1144impl<R> Node for ExprUnaryOp<R> {
1145 const NAME: &'static str = "UnaryOp";
1146 const FIELD_NAMES: &'static [&'static str] = &["op", "operand"];
1147}
1148impl<R> From<ExprUnaryOp<R>> for Expr<R> {
1149 fn from(payload: ExprUnaryOp<R>) -> Self {
1150 Expr::UnaryOp(payload)
1151 }
1152}
1153impl<R> From<ExprUnaryOp<R>> for Ast<R> {
1154 fn from(payload: ExprUnaryOp<R>) -> Self {
1155 Expr::from(payload).into()
1156 }
1157}
1158
1159#[derive(Clone, Debug, PartialEq)]
1161pub struct ExprLambda<R = TextRange> {
1162 pub range: R,
1163 pub args: Box<Arguments<R>>,
1164 pub body: Box<Expr<R>>,
1165}
1166
1167impl<R> Node for ExprLambda<R> {
1168 const NAME: &'static str = "Lambda";
1169 const FIELD_NAMES: &'static [&'static str] = &["args", "body"];
1170}
1171impl<R> From<ExprLambda<R>> for Expr<R> {
1172 fn from(payload: ExprLambda<R>) -> Self {
1173 Expr::Lambda(payload)
1174 }
1175}
1176impl<R> From<ExprLambda<R>> for Ast<R> {
1177 fn from(payload: ExprLambda<R>) -> Self {
1178 Expr::from(payload).into()
1179 }
1180}
1181
1182#[derive(Clone, Debug, PartialEq)]
1184pub struct ExprIfExp<R = TextRange> {
1185 pub range: R,
1186 pub test: Box<Expr<R>>,
1187 pub body: Box<Expr<R>>,
1188 pub orelse: Box<Expr<R>>,
1189}
1190
1191impl<R> Node for ExprIfExp<R> {
1192 const NAME: &'static str = "IfExp";
1193 const FIELD_NAMES: &'static [&'static str] = &["test", "body", "orelse"];
1194}
1195impl<R> From<ExprIfExp<R>> for Expr<R> {
1196 fn from(payload: ExprIfExp<R>) -> Self {
1197 Expr::IfExp(payload)
1198 }
1199}
1200impl<R> From<ExprIfExp<R>> for Ast<R> {
1201 fn from(payload: ExprIfExp<R>) -> Self {
1202 Expr::from(payload).into()
1203 }
1204}
1205
1206#[derive(Clone, Debug, PartialEq)]
1208pub struct ExprDict<R = TextRange> {
1209 pub range: R,
1210 pub keys: Vec<Option<Expr<R>>>,
1211 pub values: Vec<Expr<R>>,
1212}
1213
1214impl<R> Node for ExprDict<R> {
1215 const NAME: &'static str = "Dict";
1216 const FIELD_NAMES: &'static [&'static str] = &["keys", "values"];
1217}
1218impl<R> From<ExprDict<R>> for Expr<R> {
1219 fn from(payload: ExprDict<R>) -> Self {
1220 Expr::Dict(payload)
1221 }
1222}
1223impl<R> From<ExprDict<R>> for Ast<R> {
1224 fn from(payload: ExprDict<R>) -> Self {
1225 Expr::from(payload).into()
1226 }
1227}
1228
1229#[derive(Clone, Debug, PartialEq)]
1231pub struct ExprSet<R = TextRange> {
1232 pub range: R,
1233 pub elts: Vec<Expr<R>>,
1234}
1235
1236impl<R> Node for ExprSet<R> {
1237 const NAME: &'static str = "Set";
1238 const FIELD_NAMES: &'static [&'static str] = &["elts"];
1239}
1240impl<R> From<ExprSet<R>> for Expr<R> {
1241 fn from(payload: ExprSet<R>) -> Self {
1242 Expr::Set(payload)
1243 }
1244}
1245impl<R> From<ExprSet<R>> for Ast<R> {
1246 fn from(payload: ExprSet<R>) -> Self {
1247 Expr::from(payload).into()
1248 }
1249}
1250
1251#[derive(Clone, Debug, PartialEq)]
1253pub struct ExprListComp<R = TextRange> {
1254 pub range: R,
1255 pub elt: Box<Expr<R>>,
1256 pub generators: Vec<Comprehension<R>>,
1257}
1258
1259impl<R> Node for ExprListComp<R> {
1260 const NAME: &'static str = "ListComp";
1261 const FIELD_NAMES: &'static [&'static str] = &["elt", "generators"];
1262}
1263impl<R> From<ExprListComp<R>> for Expr<R> {
1264 fn from(payload: ExprListComp<R>) -> Self {
1265 Expr::ListComp(payload)
1266 }
1267}
1268impl<R> From<ExprListComp<R>> for Ast<R> {
1269 fn from(payload: ExprListComp<R>) -> Self {
1270 Expr::from(payload).into()
1271 }
1272}
1273
1274#[derive(Clone, Debug, PartialEq)]
1276pub struct ExprSetComp<R = TextRange> {
1277 pub range: R,
1278 pub elt: Box<Expr<R>>,
1279 pub generators: Vec<Comprehension<R>>,
1280}
1281
1282impl<R> Node for ExprSetComp<R> {
1283 const NAME: &'static str = "SetComp";
1284 const FIELD_NAMES: &'static [&'static str] = &["elt", "generators"];
1285}
1286impl<R> From<ExprSetComp<R>> for Expr<R> {
1287 fn from(payload: ExprSetComp<R>) -> Self {
1288 Expr::SetComp(payload)
1289 }
1290}
1291impl<R> From<ExprSetComp<R>> for Ast<R> {
1292 fn from(payload: ExprSetComp<R>) -> Self {
1293 Expr::from(payload).into()
1294 }
1295}
1296
1297#[derive(Clone, Debug, PartialEq)]
1299pub struct ExprDictComp<R = TextRange> {
1300 pub range: R,
1301 pub key: Box<Expr<R>>,
1302 pub value: Box<Expr<R>>,
1303 pub generators: Vec<Comprehension<R>>,
1304}
1305
1306impl<R> Node for ExprDictComp<R> {
1307 const NAME: &'static str = "DictComp";
1308 const FIELD_NAMES: &'static [&'static str] = &["key", "value", "generators"];
1309}
1310impl<R> From<ExprDictComp<R>> for Expr<R> {
1311 fn from(payload: ExprDictComp<R>) -> Self {
1312 Expr::DictComp(payload)
1313 }
1314}
1315impl<R> From<ExprDictComp<R>> for Ast<R> {
1316 fn from(payload: ExprDictComp<R>) -> Self {
1317 Expr::from(payload).into()
1318 }
1319}
1320
1321#[derive(Clone, Debug, PartialEq)]
1323pub struct ExprGeneratorExp<R = TextRange> {
1324 pub range: R,
1325 pub elt: Box<Expr<R>>,
1326 pub generators: Vec<Comprehension<R>>,
1327}
1328
1329impl<R> Node for ExprGeneratorExp<R> {
1330 const NAME: &'static str = "GeneratorExp";
1331 const FIELD_NAMES: &'static [&'static str] = &["elt", "generators"];
1332}
1333impl<R> From<ExprGeneratorExp<R>> for Expr<R> {
1334 fn from(payload: ExprGeneratorExp<R>) -> Self {
1335 Expr::GeneratorExp(payload)
1336 }
1337}
1338impl<R> From<ExprGeneratorExp<R>> for Ast<R> {
1339 fn from(payload: ExprGeneratorExp<R>) -> Self {
1340 Expr::from(payload).into()
1341 }
1342}
1343
1344#[derive(Clone, Debug, PartialEq)]
1346pub struct ExprAwait<R = TextRange> {
1347 pub range: R,
1348 pub value: Box<Expr<R>>,
1349}
1350
1351impl<R> Node for ExprAwait<R> {
1352 const NAME: &'static str = "Await";
1353 const FIELD_NAMES: &'static [&'static str] = &["value"];
1354}
1355impl<R> From<ExprAwait<R>> for Expr<R> {
1356 fn from(payload: ExprAwait<R>) -> Self {
1357 Expr::Await(payload)
1358 }
1359}
1360impl<R> From<ExprAwait<R>> for Ast<R> {
1361 fn from(payload: ExprAwait<R>) -> Self {
1362 Expr::from(payload).into()
1363 }
1364}
1365
1366#[derive(Clone, Debug, PartialEq)]
1368pub struct ExprYield<R = TextRange> {
1369 pub range: R,
1370 pub value: Option<Box<Expr<R>>>,
1371}
1372
1373impl<R> Node for ExprYield<R> {
1374 const NAME: &'static str = "Yield";
1375 const FIELD_NAMES: &'static [&'static str] = &["value"];
1376}
1377impl<R> From<ExprYield<R>> for Expr<R> {
1378 fn from(payload: ExprYield<R>) -> Self {
1379 Expr::Yield(payload)
1380 }
1381}
1382impl<R> From<ExprYield<R>> for Ast<R> {
1383 fn from(payload: ExprYield<R>) -> Self {
1384 Expr::from(payload).into()
1385 }
1386}
1387
1388#[derive(Clone, Debug, PartialEq)]
1390pub struct ExprYieldFrom<R = TextRange> {
1391 pub range: R,
1392 pub value: Box<Expr<R>>,
1393}
1394
1395impl<R> Node for ExprYieldFrom<R> {
1396 const NAME: &'static str = "YieldFrom";
1397 const FIELD_NAMES: &'static [&'static str] = &["value"];
1398}
1399impl<R> From<ExprYieldFrom<R>> for Expr<R> {
1400 fn from(payload: ExprYieldFrom<R>) -> Self {
1401 Expr::YieldFrom(payload)
1402 }
1403}
1404impl<R> From<ExprYieldFrom<R>> for Ast<R> {
1405 fn from(payload: ExprYieldFrom<R>) -> Self {
1406 Expr::from(payload).into()
1407 }
1408}
1409
1410#[derive(Clone, Debug, PartialEq)]
1412pub struct ExprCompare<R = TextRange> {
1413 pub range: R,
1414 pub left: Box<Expr<R>>,
1415 pub ops: Vec<CmpOp>,
1416 pub comparators: Vec<Expr<R>>,
1417}
1418
1419impl<R> Node for ExprCompare<R> {
1420 const NAME: &'static str = "Compare";
1421 const FIELD_NAMES: &'static [&'static str] = &["left", "ops", "comparators"];
1422}
1423impl<R> From<ExprCompare<R>> for Expr<R> {
1424 fn from(payload: ExprCompare<R>) -> Self {
1425 Expr::Compare(payload)
1426 }
1427}
1428impl<R> From<ExprCompare<R>> for Ast<R> {
1429 fn from(payload: ExprCompare<R>) -> Self {
1430 Expr::from(payload).into()
1431 }
1432}
1433
1434#[derive(Clone, Debug, PartialEq)]
1436pub struct ExprCall<R = TextRange> {
1437 pub range: R,
1438 pub func: Box<Expr<R>>,
1439 pub args: Vec<Expr<R>>,
1440 pub keywords: Vec<Keyword<R>>,
1441}
1442
1443impl<R> Node for ExprCall<R> {
1444 const NAME: &'static str = "Call";
1445 const FIELD_NAMES: &'static [&'static str] = &["func", "args", "keywords"];
1446}
1447impl<R> From<ExprCall<R>> for Expr<R> {
1448 fn from(payload: ExprCall<R>) -> Self {
1449 Expr::Call(payload)
1450 }
1451}
1452impl<R> From<ExprCall<R>> for Ast<R> {
1453 fn from(payload: ExprCall<R>) -> Self {
1454 Expr::from(payload).into()
1455 }
1456}
1457
1458#[derive(Clone, Debug, PartialEq)]
1460pub struct ExprFormattedValue<R = TextRange> {
1461 pub range: R,
1462 pub value: Box<Expr<R>>,
1463 pub conversion: ConversionFlag,
1464 pub format_spec: Option<Box<Expr<R>>>,
1465}
1466
1467impl<R> Node for ExprFormattedValue<R> {
1468 const NAME: &'static str = "FormattedValue";
1469 const FIELD_NAMES: &'static [&'static str] = &["value", "conversion", "format_spec"];
1470}
1471impl<R> From<ExprFormattedValue<R>> for Expr<R> {
1472 fn from(payload: ExprFormattedValue<R>) -> Self {
1473 Expr::FormattedValue(payload)
1474 }
1475}
1476impl<R> From<ExprFormattedValue<R>> for Ast<R> {
1477 fn from(payload: ExprFormattedValue<R>) -> Self {
1478 Expr::from(payload).into()
1479 }
1480}
1481
1482#[derive(Clone, Debug, PartialEq)]
1484pub struct ExprJoinedStr<R = TextRange> {
1485 pub range: R,
1486 pub values: Vec<Expr<R>>,
1487}
1488
1489impl<R> Node for ExprJoinedStr<R> {
1490 const NAME: &'static str = "JoinedStr";
1491 const FIELD_NAMES: &'static [&'static str] = &["values"];
1492}
1493impl<R> From<ExprJoinedStr<R>> for Expr<R> {
1494 fn from(payload: ExprJoinedStr<R>) -> Self {
1495 Expr::JoinedStr(payload)
1496 }
1497}
1498impl<R> From<ExprJoinedStr<R>> for Ast<R> {
1499 fn from(payload: ExprJoinedStr<R>) -> Self {
1500 Expr::from(payload).into()
1501 }
1502}
1503
1504#[derive(Clone, Debug, PartialEq)]
1506pub struct ExprConstant<R = TextRange> {
1507 pub range: R,
1508 pub value: Constant,
1509 pub kind: Option<String>,
1510}
1511
1512impl<R> Node for ExprConstant<R> {
1513 const NAME: &'static str = "Constant";
1514 const FIELD_NAMES: &'static [&'static str] = &["value", "kind"];
1515}
1516impl<R> From<ExprConstant<R>> for Expr<R> {
1517 fn from(payload: ExprConstant<R>) -> Self {
1518 Expr::Constant(payload)
1519 }
1520}
1521impl<R> From<ExprConstant<R>> for Ast<R> {
1522 fn from(payload: ExprConstant<R>) -> Self {
1523 Expr::from(payload).into()
1524 }
1525}
1526
1527#[derive(Clone, Debug, PartialEq)]
1529pub struct ExprAttribute<R = TextRange> {
1530 pub range: R,
1531 pub value: Box<Expr<R>>,
1532 pub attr: Identifier,
1533 pub ctx: ExprContext,
1534}
1535
1536impl<R> Node for ExprAttribute<R> {
1537 const NAME: &'static str = "Attribute";
1538 const FIELD_NAMES: &'static [&'static str] = &["value", "attr", "ctx"];
1539}
1540impl<R> From<ExprAttribute<R>> for Expr<R> {
1541 fn from(payload: ExprAttribute<R>) -> Self {
1542 Expr::Attribute(payload)
1543 }
1544}
1545impl<R> From<ExprAttribute<R>> for Ast<R> {
1546 fn from(payload: ExprAttribute<R>) -> Self {
1547 Expr::from(payload).into()
1548 }
1549}
1550
1551#[derive(Clone, Debug, PartialEq)]
1553pub struct ExprSubscript<R = TextRange> {
1554 pub range: R,
1555 pub value: Box<Expr<R>>,
1556 pub slice: Box<Expr<R>>,
1557 pub ctx: ExprContext,
1558}
1559
1560impl<R> Node for ExprSubscript<R> {
1561 const NAME: &'static str = "Subscript";
1562 const FIELD_NAMES: &'static [&'static str] = &["value", "slice", "ctx"];
1563}
1564impl<R> From<ExprSubscript<R>> for Expr<R> {
1565 fn from(payload: ExprSubscript<R>) -> Self {
1566 Expr::Subscript(payload)
1567 }
1568}
1569impl<R> From<ExprSubscript<R>> for Ast<R> {
1570 fn from(payload: ExprSubscript<R>) -> Self {
1571 Expr::from(payload).into()
1572 }
1573}
1574
1575#[derive(Clone, Debug, PartialEq)]
1577pub struct ExprStarred<R = TextRange> {
1578 pub range: R,
1579 pub value: Box<Expr<R>>,
1580 pub ctx: ExprContext,
1581}
1582
1583impl<R> Node for ExprStarred<R> {
1584 const NAME: &'static str = "Starred";
1585 const FIELD_NAMES: &'static [&'static str] = &["value", "ctx"];
1586}
1587impl<R> From<ExprStarred<R>> for Expr<R> {
1588 fn from(payload: ExprStarred<R>) -> Self {
1589 Expr::Starred(payload)
1590 }
1591}
1592impl<R> From<ExprStarred<R>> for Ast<R> {
1593 fn from(payload: ExprStarred<R>) -> Self {
1594 Expr::from(payload).into()
1595 }
1596}
1597
1598#[derive(Clone, Debug, PartialEq)]
1600pub struct ExprName<R = TextRange> {
1601 pub range: R,
1602 pub id: Identifier,
1603 pub ctx: ExprContext,
1604}
1605
1606impl<R> Node for ExprName<R> {
1607 const NAME: &'static str = "Name";
1608 const FIELD_NAMES: &'static [&'static str] = &["id", "ctx"];
1609}
1610impl<R> From<ExprName<R>> for Expr<R> {
1611 fn from(payload: ExprName<R>) -> Self {
1612 Expr::Name(payload)
1613 }
1614}
1615impl<R> From<ExprName<R>> for Ast<R> {
1616 fn from(payload: ExprName<R>) -> Self {
1617 Expr::from(payload).into()
1618 }
1619}
1620
1621#[derive(Clone, Debug, PartialEq)]
1623pub struct ExprList<R = TextRange> {
1624 pub range: R,
1625 pub elts: Vec<Expr<R>>,
1626 pub ctx: ExprContext,
1627}
1628
1629impl<R> Node for ExprList<R> {
1630 const NAME: &'static str = "List";
1631 const FIELD_NAMES: &'static [&'static str] = &["elts", "ctx"];
1632}
1633impl<R> From<ExprList<R>> for Expr<R> {
1634 fn from(payload: ExprList<R>) -> Self {
1635 Expr::List(payload)
1636 }
1637}
1638impl<R> From<ExprList<R>> for Ast<R> {
1639 fn from(payload: ExprList<R>) -> Self {
1640 Expr::from(payload).into()
1641 }
1642}
1643
1644#[derive(Clone, Debug, PartialEq)]
1646pub struct ExprTuple<R = TextRange> {
1647 pub range: R,
1648 pub elts: Vec<Expr<R>>,
1649 pub ctx: ExprContext,
1650}
1651
1652impl<R> Node for ExprTuple<R> {
1653 const NAME: &'static str = "Tuple";
1654 const FIELD_NAMES: &'static [&'static str] = &["elts", "ctx"];
1655}
1656impl<R> From<ExprTuple<R>> for Expr<R> {
1657 fn from(payload: ExprTuple<R>) -> Self {
1658 Expr::Tuple(payload)
1659 }
1660}
1661impl<R> From<ExprTuple<R>> for Ast<R> {
1662 fn from(payload: ExprTuple<R>) -> Self {
1663 Expr::from(payload).into()
1664 }
1665}
1666
1667#[derive(Clone, Debug, PartialEq)]
1669pub struct ExprSlice<R = TextRange> {
1670 pub range: R,
1671 pub lower: Option<Box<Expr<R>>>,
1672 pub upper: Option<Box<Expr<R>>>,
1673 pub step: Option<Box<Expr<R>>>,
1674}
1675
1676impl<R> Node for ExprSlice<R> {
1677 const NAME: &'static str = "Slice";
1678 const FIELD_NAMES: &'static [&'static str] = &["lower", "upper", "step"];
1679}
1680impl<R> From<ExprSlice<R>> for Expr<R> {
1681 fn from(payload: ExprSlice<R>) -> Self {
1682 Expr::Slice(payload)
1683 }
1684}
1685impl<R> From<ExprSlice<R>> for Ast<R> {
1686 fn from(payload: ExprSlice<R>) -> Self {
1687 Expr::from(payload).into()
1688 }
1689}
1690
1691impl<R> Node for Expr<R> {
1692 const NAME: &'static str = "expr";
1693 const FIELD_NAMES: &'static [&'static str] = &[];
1694}
1695
1696#[derive(Clone, Debug, PartialEq, is_macro::Is, Copy, Hash, Eq)]
1698pub enum ExprContext {
1699 Load,
1700 Store,
1701 Del,
1702}
1703impl ExprContext {
1704 #[inline]
1705 pub const fn load(&self) -> Option<ExprContextLoad> {
1706 match self {
1707 ExprContext::Load => Some(ExprContextLoad),
1708 _ => None,
1709 }
1710 }
1711
1712 #[inline]
1713 pub const fn store(&self) -> Option<ExprContextStore> {
1714 match self {
1715 ExprContext::Store => Some(ExprContextStore),
1716 _ => None,
1717 }
1718 }
1719
1720 #[inline]
1721 pub const fn del(&self) -> Option<ExprContextDel> {
1722 match self {
1723 ExprContext::Del => Some(ExprContextDel),
1724 _ => None,
1725 }
1726 }
1727}
1728
1729pub struct ExprContextLoad;
1730impl From<ExprContextLoad> for ExprContext {
1731 fn from(_: ExprContextLoad) -> Self {
1732 ExprContext::Load
1733 }
1734}
1735impl<R> From<ExprContextLoad> for Ast<R> {
1736 fn from(_: ExprContextLoad) -> Self {
1737 ExprContext::Load.into()
1738 }
1739}
1740impl Node for ExprContextLoad {
1741 const NAME: &'static str = "Load";
1742 const FIELD_NAMES: &'static [&'static str] = &[];
1743}
1744impl std::cmp::PartialEq<ExprContext> for ExprContextLoad {
1745 #[inline]
1746 fn eq(&self, other: &ExprContext) -> bool {
1747 matches!(other, ExprContext::Load)
1748 }
1749}
1750
1751pub struct ExprContextStore;
1752impl From<ExprContextStore> for ExprContext {
1753 fn from(_: ExprContextStore) -> Self {
1754 ExprContext::Store
1755 }
1756}
1757impl<R> From<ExprContextStore> for Ast<R> {
1758 fn from(_: ExprContextStore) -> Self {
1759 ExprContext::Store.into()
1760 }
1761}
1762impl Node for ExprContextStore {
1763 const NAME: &'static str = "Store";
1764 const FIELD_NAMES: &'static [&'static str] = &[];
1765}
1766impl std::cmp::PartialEq<ExprContext> for ExprContextStore {
1767 #[inline]
1768 fn eq(&self, other: &ExprContext) -> bool {
1769 matches!(other, ExprContext::Store)
1770 }
1771}
1772
1773pub struct ExprContextDel;
1774impl From<ExprContextDel> for ExprContext {
1775 fn from(_: ExprContextDel) -> Self {
1776 ExprContext::Del
1777 }
1778}
1779impl<R> From<ExprContextDel> for Ast<R> {
1780 fn from(_: ExprContextDel) -> Self {
1781 ExprContext::Del.into()
1782 }
1783}
1784impl Node for ExprContextDel {
1785 const NAME: &'static str = "Del";
1786 const FIELD_NAMES: &'static [&'static str] = &[];
1787}
1788impl std::cmp::PartialEq<ExprContext> for ExprContextDel {
1789 #[inline]
1790 fn eq(&self, other: &ExprContext) -> bool {
1791 matches!(other, ExprContext::Del)
1792 }
1793}
1794
1795impl Node for ExprContext {
1796 const NAME: &'static str = "expr_context";
1797 const FIELD_NAMES: &'static [&'static str] = &[];
1798}
1799
1800#[derive(Clone, Debug, PartialEq, is_macro::Is, Copy, Hash, Eq)]
1802pub enum BoolOp {
1803 And,
1804 Or,
1805}
1806impl BoolOp {
1807 #[inline]
1808 pub const fn and(&self) -> Option<BoolOpAnd> {
1809 match self {
1810 BoolOp::And => Some(BoolOpAnd),
1811 _ => None,
1812 }
1813 }
1814
1815 #[inline]
1816 pub const fn or(&self) -> Option<BoolOpOr> {
1817 match self {
1818 BoolOp::Or => Some(BoolOpOr),
1819 _ => None,
1820 }
1821 }
1822}
1823
1824pub struct BoolOpAnd;
1825impl From<BoolOpAnd> for BoolOp {
1826 fn from(_: BoolOpAnd) -> Self {
1827 BoolOp::And
1828 }
1829}
1830impl<R> From<BoolOpAnd> for Ast<R> {
1831 fn from(_: BoolOpAnd) -> Self {
1832 BoolOp::And.into()
1833 }
1834}
1835impl Node for BoolOpAnd {
1836 const NAME: &'static str = "And";
1837 const FIELD_NAMES: &'static [&'static str] = &[];
1838}
1839impl std::cmp::PartialEq<BoolOp> for BoolOpAnd {
1840 #[inline]
1841 fn eq(&self, other: &BoolOp) -> bool {
1842 matches!(other, BoolOp::And)
1843 }
1844}
1845
1846pub struct BoolOpOr;
1847impl From<BoolOpOr> for BoolOp {
1848 fn from(_: BoolOpOr) -> Self {
1849 BoolOp::Or
1850 }
1851}
1852impl<R> From<BoolOpOr> for Ast<R> {
1853 fn from(_: BoolOpOr) -> Self {
1854 BoolOp::Or.into()
1855 }
1856}
1857impl Node for BoolOpOr {
1858 const NAME: &'static str = "Or";
1859 const FIELD_NAMES: &'static [&'static str] = &[];
1860}
1861impl std::cmp::PartialEq<BoolOp> for BoolOpOr {
1862 #[inline]
1863 fn eq(&self, other: &BoolOp) -> bool {
1864 matches!(other, BoolOp::Or)
1865 }
1866}
1867
1868impl Node for BoolOp {
1869 const NAME: &'static str = "boolop";
1870 const FIELD_NAMES: &'static [&'static str] = &[];
1871}
1872
1873#[derive(Clone, Debug, PartialEq, is_macro::Is, Copy, Hash, Eq)]
1875pub enum Operator {
1876 Add,
1877 Sub,
1878 Mult,
1879 MatMult,
1880 Div,
1881 Mod,
1882 Pow,
1883 LShift,
1884 RShift,
1885 BitOr,
1886 BitXor,
1887 BitAnd,
1888 FloorDiv,
1889}
1890impl Operator {
1891 #[inline]
1892 pub const fn operator_add(&self) -> Option<OperatorAdd> {
1893 match self {
1894 Operator::Add => Some(OperatorAdd),
1895 _ => None,
1896 }
1897 }
1898
1899 #[inline]
1900 pub const fn operator_sub(&self) -> Option<OperatorSub> {
1901 match self {
1902 Operator::Sub => Some(OperatorSub),
1903 _ => None,
1904 }
1905 }
1906
1907 #[inline]
1908 pub const fn operator_mult(&self) -> Option<OperatorMult> {
1909 match self {
1910 Operator::Mult => Some(OperatorMult),
1911 _ => None,
1912 }
1913 }
1914
1915 #[inline]
1916 pub const fn operator_mat_mult(&self) -> Option<OperatorMatMult> {
1917 match self {
1918 Operator::MatMult => Some(OperatorMatMult),
1919 _ => None,
1920 }
1921 }
1922
1923 #[inline]
1924 pub const fn operator_div(&self) -> Option<OperatorDiv> {
1925 match self {
1926 Operator::Div => Some(OperatorDiv),
1927 _ => None,
1928 }
1929 }
1930
1931 #[inline]
1932 pub const fn operator_mod(&self) -> Option<OperatorMod> {
1933 match self {
1934 Operator::Mod => Some(OperatorMod),
1935 _ => None,
1936 }
1937 }
1938
1939 #[inline]
1940 pub const fn operator_pow(&self) -> Option<OperatorPow> {
1941 match self {
1942 Operator::Pow => Some(OperatorPow),
1943 _ => None,
1944 }
1945 }
1946
1947 #[inline]
1948 pub const fn operator_l_shift(&self) -> Option<OperatorLShift> {
1949 match self {
1950 Operator::LShift => Some(OperatorLShift),
1951 _ => None,
1952 }
1953 }
1954
1955 #[inline]
1956 pub const fn operator_r_shift(&self) -> Option<OperatorRShift> {
1957 match self {
1958 Operator::RShift => Some(OperatorRShift),
1959 _ => None,
1960 }
1961 }
1962
1963 #[inline]
1964 pub const fn operator_bit_or(&self) -> Option<OperatorBitOr> {
1965 match self {
1966 Operator::BitOr => Some(OperatorBitOr),
1967 _ => None,
1968 }
1969 }
1970
1971 #[inline]
1972 pub const fn operator_bit_xor(&self) -> Option<OperatorBitXor> {
1973 match self {
1974 Operator::BitXor => Some(OperatorBitXor),
1975 _ => None,
1976 }
1977 }
1978
1979 #[inline]
1980 pub const fn operator_bit_and(&self) -> Option<OperatorBitAnd> {
1981 match self {
1982 Operator::BitAnd => Some(OperatorBitAnd),
1983 _ => None,
1984 }
1985 }
1986
1987 #[inline]
1988 pub const fn operator_floor_div(&self) -> Option<OperatorFloorDiv> {
1989 match self {
1990 Operator::FloorDiv => Some(OperatorFloorDiv),
1991 _ => None,
1992 }
1993 }
1994}
1995
1996pub struct OperatorAdd;
1997impl From<OperatorAdd> for Operator {
1998 fn from(_: OperatorAdd) -> Self {
1999 Operator::Add
2000 }
2001}
2002impl<R> From<OperatorAdd> for Ast<R> {
2003 fn from(_: OperatorAdd) -> Self {
2004 Operator::Add.into()
2005 }
2006}
2007impl Node for OperatorAdd {
2008 const NAME: &'static str = "Add";
2009 const FIELD_NAMES: &'static [&'static str] = &[];
2010}
2011impl std::cmp::PartialEq<Operator> for OperatorAdd {
2012 #[inline]
2013 fn eq(&self, other: &Operator) -> bool {
2014 matches!(other, Operator::Add)
2015 }
2016}
2017
2018pub struct OperatorSub;
2019impl From<OperatorSub> for Operator {
2020 fn from(_: OperatorSub) -> Self {
2021 Operator::Sub
2022 }
2023}
2024impl<R> From<OperatorSub> for Ast<R> {
2025 fn from(_: OperatorSub) -> Self {
2026 Operator::Sub.into()
2027 }
2028}
2029impl Node for OperatorSub {
2030 const NAME: &'static str = "Sub";
2031 const FIELD_NAMES: &'static [&'static str] = &[];
2032}
2033impl std::cmp::PartialEq<Operator> for OperatorSub {
2034 #[inline]
2035 fn eq(&self, other: &Operator) -> bool {
2036 matches!(other, Operator::Sub)
2037 }
2038}
2039
2040pub struct OperatorMult;
2041impl From<OperatorMult> for Operator {
2042 fn from(_: OperatorMult) -> Self {
2043 Operator::Mult
2044 }
2045}
2046impl<R> From<OperatorMult> for Ast<R> {
2047 fn from(_: OperatorMult) -> Self {
2048 Operator::Mult.into()
2049 }
2050}
2051impl Node for OperatorMult {
2052 const NAME: &'static str = "Mult";
2053 const FIELD_NAMES: &'static [&'static str] = &[];
2054}
2055impl std::cmp::PartialEq<Operator> for OperatorMult {
2056 #[inline]
2057 fn eq(&self, other: &Operator) -> bool {
2058 matches!(other, Operator::Mult)
2059 }
2060}
2061
2062pub struct OperatorMatMult;
2063impl From<OperatorMatMult> for Operator {
2064 fn from(_: OperatorMatMult) -> Self {
2065 Operator::MatMult
2066 }
2067}
2068impl<R> From<OperatorMatMult> for Ast<R> {
2069 fn from(_: OperatorMatMult) -> Self {
2070 Operator::MatMult.into()
2071 }
2072}
2073impl Node for OperatorMatMult {
2074 const NAME: &'static str = "MatMult";
2075 const FIELD_NAMES: &'static [&'static str] = &[];
2076}
2077impl std::cmp::PartialEq<Operator> for OperatorMatMult {
2078 #[inline]
2079 fn eq(&self, other: &Operator) -> bool {
2080 matches!(other, Operator::MatMult)
2081 }
2082}
2083
2084pub struct OperatorDiv;
2085impl From<OperatorDiv> for Operator {
2086 fn from(_: OperatorDiv) -> Self {
2087 Operator::Div
2088 }
2089}
2090impl<R> From<OperatorDiv> for Ast<R> {
2091 fn from(_: OperatorDiv) -> Self {
2092 Operator::Div.into()
2093 }
2094}
2095impl Node for OperatorDiv {
2096 const NAME: &'static str = "Div";
2097 const FIELD_NAMES: &'static [&'static str] = &[];
2098}
2099impl std::cmp::PartialEq<Operator> for OperatorDiv {
2100 #[inline]
2101 fn eq(&self, other: &Operator) -> bool {
2102 matches!(other, Operator::Div)
2103 }
2104}
2105
2106pub struct OperatorMod;
2107impl From<OperatorMod> for Operator {
2108 fn from(_: OperatorMod) -> Self {
2109 Operator::Mod
2110 }
2111}
2112impl<R> From<OperatorMod> for Ast<R> {
2113 fn from(_: OperatorMod) -> Self {
2114 Operator::Mod.into()
2115 }
2116}
2117impl Node for OperatorMod {
2118 const NAME: &'static str = "Mod";
2119 const FIELD_NAMES: &'static [&'static str] = &[];
2120}
2121impl std::cmp::PartialEq<Operator> for OperatorMod {
2122 #[inline]
2123 fn eq(&self, other: &Operator) -> bool {
2124 matches!(other, Operator::Mod)
2125 }
2126}
2127
2128pub struct OperatorPow;
2129impl From<OperatorPow> for Operator {
2130 fn from(_: OperatorPow) -> Self {
2131 Operator::Pow
2132 }
2133}
2134impl<R> From<OperatorPow> for Ast<R> {
2135 fn from(_: OperatorPow) -> Self {
2136 Operator::Pow.into()
2137 }
2138}
2139impl Node for OperatorPow {
2140 const NAME: &'static str = "Pow";
2141 const FIELD_NAMES: &'static [&'static str] = &[];
2142}
2143impl std::cmp::PartialEq<Operator> for OperatorPow {
2144 #[inline]
2145 fn eq(&self, other: &Operator) -> bool {
2146 matches!(other, Operator::Pow)
2147 }
2148}
2149
2150pub struct OperatorLShift;
2151impl From<OperatorLShift> for Operator {
2152 fn from(_: OperatorLShift) -> Self {
2153 Operator::LShift
2154 }
2155}
2156impl<R> From<OperatorLShift> for Ast<R> {
2157 fn from(_: OperatorLShift) -> Self {
2158 Operator::LShift.into()
2159 }
2160}
2161impl Node for OperatorLShift {
2162 const NAME: &'static str = "LShift";
2163 const FIELD_NAMES: &'static [&'static str] = &[];
2164}
2165impl std::cmp::PartialEq<Operator> for OperatorLShift {
2166 #[inline]
2167 fn eq(&self, other: &Operator) -> bool {
2168 matches!(other, Operator::LShift)
2169 }
2170}
2171
2172pub struct OperatorRShift;
2173impl From<OperatorRShift> for Operator {
2174 fn from(_: OperatorRShift) -> Self {
2175 Operator::RShift
2176 }
2177}
2178impl<R> From<OperatorRShift> for Ast<R> {
2179 fn from(_: OperatorRShift) -> Self {
2180 Operator::RShift.into()
2181 }
2182}
2183impl Node for OperatorRShift {
2184 const NAME: &'static str = "RShift";
2185 const FIELD_NAMES: &'static [&'static str] = &[];
2186}
2187impl std::cmp::PartialEq<Operator> for OperatorRShift {
2188 #[inline]
2189 fn eq(&self, other: &Operator) -> bool {
2190 matches!(other, Operator::RShift)
2191 }
2192}
2193
2194pub struct OperatorBitOr;
2195impl From<OperatorBitOr> for Operator {
2196 fn from(_: OperatorBitOr) -> Self {
2197 Operator::BitOr
2198 }
2199}
2200impl<R> From<OperatorBitOr> for Ast<R> {
2201 fn from(_: OperatorBitOr) -> Self {
2202 Operator::BitOr.into()
2203 }
2204}
2205impl Node for OperatorBitOr {
2206 const NAME: &'static str = "BitOr";
2207 const FIELD_NAMES: &'static [&'static str] = &[];
2208}
2209impl std::cmp::PartialEq<Operator> for OperatorBitOr {
2210 #[inline]
2211 fn eq(&self, other: &Operator) -> bool {
2212 matches!(other, Operator::BitOr)
2213 }
2214}
2215
2216pub struct OperatorBitXor;
2217impl From<OperatorBitXor> for Operator {
2218 fn from(_: OperatorBitXor) -> Self {
2219 Operator::BitXor
2220 }
2221}
2222impl<R> From<OperatorBitXor> for Ast<R> {
2223 fn from(_: OperatorBitXor) -> Self {
2224 Operator::BitXor.into()
2225 }
2226}
2227impl Node for OperatorBitXor {
2228 const NAME: &'static str = "BitXor";
2229 const FIELD_NAMES: &'static [&'static str] = &[];
2230}
2231impl std::cmp::PartialEq<Operator> for OperatorBitXor {
2232 #[inline]
2233 fn eq(&self, other: &Operator) -> bool {
2234 matches!(other, Operator::BitXor)
2235 }
2236}
2237
2238pub struct OperatorBitAnd;
2239impl From<OperatorBitAnd> for Operator {
2240 fn from(_: OperatorBitAnd) -> Self {
2241 Operator::BitAnd
2242 }
2243}
2244impl<R> From<OperatorBitAnd> for Ast<R> {
2245 fn from(_: OperatorBitAnd) -> Self {
2246 Operator::BitAnd.into()
2247 }
2248}
2249impl Node for OperatorBitAnd {
2250 const NAME: &'static str = "BitAnd";
2251 const FIELD_NAMES: &'static [&'static str] = &[];
2252}
2253impl std::cmp::PartialEq<Operator> for OperatorBitAnd {
2254 #[inline]
2255 fn eq(&self, other: &Operator) -> bool {
2256 matches!(other, Operator::BitAnd)
2257 }
2258}
2259
2260pub struct OperatorFloorDiv;
2261impl From<OperatorFloorDiv> for Operator {
2262 fn from(_: OperatorFloorDiv) -> Self {
2263 Operator::FloorDiv
2264 }
2265}
2266impl<R> From<OperatorFloorDiv> for Ast<R> {
2267 fn from(_: OperatorFloorDiv) -> Self {
2268 Operator::FloorDiv.into()
2269 }
2270}
2271impl Node for OperatorFloorDiv {
2272 const NAME: &'static str = "FloorDiv";
2273 const FIELD_NAMES: &'static [&'static str] = &[];
2274}
2275impl std::cmp::PartialEq<Operator> for OperatorFloorDiv {
2276 #[inline]
2277 fn eq(&self, other: &Operator) -> bool {
2278 matches!(other, Operator::FloorDiv)
2279 }
2280}
2281
2282impl Node for Operator {
2283 const NAME: &'static str = "operator";
2284 const FIELD_NAMES: &'static [&'static str] = &[];
2285}
2286
2287#[derive(Clone, Debug, PartialEq, is_macro::Is, Copy, Hash, Eq)]
2289pub enum UnaryOp {
2290 Invert,
2291 Not,
2292 UAdd,
2293 USub,
2294}
2295impl UnaryOp {
2296 #[inline]
2297 pub const fn invert(&self) -> Option<UnaryOpInvert> {
2298 match self {
2299 UnaryOp::Invert => Some(UnaryOpInvert),
2300 _ => None,
2301 }
2302 }
2303
2304 #[inline]
2305 pub const fn not(&self) -> Option<UnaryOpNot> {
2306 match self {
2307 UnaryOp::Not => Some(UnaryOpNot),
2308 _ => None,
2309 }
2310 }
2311
2312 #[inline]
2313 pub const fn u_add(&self) -> Option<UnaryOpUAdd> {
2314 match self {
2315 UnaryOp::UAdd => Some(UnaryOpUAdd),
2316 _ => None,
2317 }
2318 }
2319
2320 #[inline]
2321 pub const fn u_sub(&self) -> Option<UnaryOpUSub> {
2322 match self {
2323 UnaryOp::USub => Some(UnaryOpUSub),
2324 _ => None,
2325 }
2326 }
2327}
2328
2329pub struct UnaryOpInvert;
2330impl From<UnaryOpInvert> for UnaryOp {
2331 fn from(_: UnaryOpInvert) -> Self {
2332 UnaryOp::Invert
2333 }
2334}
2335impl<R> From<UnaryOpInvert> for Ast<R> {
2336 fn from(_: UnaryOpInvert) -> Self {
2337 UnaryOp::Invert.into()
2338 }
2339}
2340impl Node for UnaryOpInvert {
2341 const NAME: &'static str = "Invert";
2342 const FIELD_NAMES: &'static [&'static str] = &[];
2343}
2344impl std::cmp::PartialEq<UnaryOp> for UnaryOpInvert {
2345 #[inline]
2346 fn eq(&self, other: &UnaryOp) -> bool {
2347 matches!(other, UnaryOp::Invert)
2348 }
2349}
2350
2351pub struct UnaryOpNot;
2352impl From<UnaryOpNot> for UnaryOp {
2353 fn from(_: UnaryOpNot) -> Self {
2354 UnaryOp::Not
2355 }
2356}
2357impl<R> From<UnaryOpNot> for Ast<R> {
2358 fn from(_: UnaryOpNot) -> Self {
2359 UnaryOp::Not.into()
2360 }
2361}
2362impl Node for UnaryOpNot {
2363 const NAME: &'static str = "Not";
2364 const FIELD_NAMES: &'static [&'static str] = &[];
2365}
2366impl std::cmp::PartialEq<UnaryOp> for UnaryOpNot {
2367 #[inline]
2368 fn eq(&self, other: &UnaryOp) -> bool {
2369 matches!(other, UnaryOp::Not)
2370 }
2371}
2372
2373pub struct UnaryOpUAdd;
2374impl From<UnaryOpUAdd> for UnaryOp {
2375 fn from(_: UnaryOpUAdd) -> Self {
2376 UnaryOp::UAdd
2377 }
2378}
2379impl<R> From<UnaryOpUAdd> for Ast<R> {
2380 fn from(_: UnaryOpUAdd) -> Self {
2381 UnaryOp::UAdd.into()
2382 }
2383}
2384impl Node for UnaryOpUAdd {
2385 const NAME: &'static str = "UAdd";
2386 const FIELD_NAMES: &'static [&'static str] = &[];
2387}
2388impl std::cmp::PartialEq<UnaryOp> for UnaryOpUAdd {
2389 #[inline]
2390 fn eq(&self, other: &UnaryOp) -> bool {
2391 matches!(other, UnaryOp::UAdd)
2392 }
2393}
2394
2395pub struct UnaryOpUSub;
2396impl From<UnaryOpUSub> for UnaryOp {
2397 fn from(_: UnaryOpUSub) -> Self {
2398 UnaryOp::USub
2399 }
2400}
2401impl<R> From<UnaryOpUSub> for Ast<R> {
2402 fn from(_: UnaryOpUSub) -> Self {
2403 UnaryOp::USub.into()
2404 }
2405}
2406impl Node for UnaryOpUSub {
2407 const NAME: &'static str = "USub";
2408 const FIELD_NAMES: &'static [&'static str] = &[];
2409}
2410impl std::cmp::PartialEq<UnaryOp> for UnaryOpUSub {
2411 #[inline]
2412 fn eq(&self, other: &UnaryOp) -> bool {
2413 matches!(other, UnaryOp::USub)
2414 }
2415}
2416
2417impl Node for UnaryOp {
2418 const NAME: &'static str = "unaryop";
2419 const FIELD_NAMES: &'static [&'static str] = &[];
2420}
2421
2422#[derive(Clone, Debug, PartialEq, is_macro::Is, Copy, Hash, Eq)]
2424pub enum CmpOp {
2425 Eq,
2426 NotEq,
2427 Lt,
2428 LtE,
2429 Gt,
2430 GtE,
2431 Is,
2432 IsNot,
2433 In,
2434 NotIn,
2435}
2436impl CmpOp {
2437 #[inline]
2438 pub const fn cmp_op_eq(&self) -> Option<CmpOpEq> {
2439 match self {
2440 CmpOp::Eq => Some(CmpOpEq),
2441 _ => None,
2442 }
2443 }
2444
2445 #[inline]
2446 pub const fn cmp_op_not_eq(&self) -> Option<CmpOpNotEq> {
2447 match self {
2448 CmpOp::NotEq => Some(CmpOpNotEq),
2449 _ => None,
2450 }
2451 }
2452
2453 #[inline]
2454 pub const fn cmp_op_lt(&self) -> Option<CmpOpLt> {
2455 match self {
2456 CmpOp::Lt => Some(CmpOpLt),
2457 _ => None,
2458 }
2459 }
2460
2461 #[inline]
2462 pub const fn cmp_op_lt_e(&self) -> Option<CmpOpLtE> {
2463 match self {
2464 CmpOp::LtE => Some(CmpOpLtE),
2465 _ => None,
2466 }
2467 }
2468
2469 #[inline]
2470 pub const fn cmp_op_gt(&self) -> Option<CmpOpGt> {
2471 match self {
2472 CmpOp::Gt => Some(CmpOpGt),
2473 _ => None,
2474 }
2475 }
2476
2477 #[inline]
2478 pub const fn cmp_op_gt_e(&self) -> Option<CmpOpGtE> {
2479 match self {
2480 CmpOp::GtE => Some(CmpOpGtE),
2481 _ => None,
2482 }
2483 }
2484
2485 #[inline]
2486 pub const fn cmp_op_is(&self) -> Option<CmpOpIs> {
2487 match self {
2488 CmpOp::Is => Some(CmpOpIs),
2489 _ => None,
2490 }
2491 }
2492
2493 #[inline]
2494 pub const fn cmp_op_is_not(&self) -> Option<CmpOpIsNot> {
2495 match self {
2496 CmpOp::IsNot => Some(CmpOpIsNot),
2497 _ => None,
2498 }
2499 }
2500
2501 #[inline]
2502 pub const fn cmp_op_in(&self) -> Option<CmpOpIn> {
2503 match self {
2504 CmpOp::In => Some(CmpOpIn),
2505 _ => None,
2506 }
2507 }
2508
2509 #[inline]
2510 pub const fn cmp_op_not_in(&self) -> Option<CmpOpNotIn> {
2511 match self {
2512 CmpOp::NotIn => Some(CmpOpNotIn),
2513 _ => None,
2514 }
2515 }
2516}
2517
2518pub struct CmpOpEq;
2519impl From<CmpOpEq> for CmpOp {
2520 fn from(_: CmpOpEq) -> Self {
2521 CmpOp::Eq
2522 }
2523}
2524impl<R> From<CmpOpEq> for Ast<R> {
2525 fn from(_: CmpOpEq) -> Self {
2526 CmpOp::Eq.into()
2527 }
2528}
2529impl Node for CmpOpEq {
2530 const NAME: &'static str = "Eq";
2531 const FIELD_NAMES: &'static [&'static str] = &[];
2532}
2533impl std::cmp::PartialEq<CmpOp> for CmpOpEq {
2534 #[inline]
2535 fn eq(&self, other: &CmpOp) -> bool {
2536 matches!(other, CmpOp::Eq)
2537 }
2538}
2539
2540pub struct CmpOpNotEq;
2541impl From<CmpOpNotEq> for CmpOp {
2542 fn from(_: CmpOpNotEq) -> Self {
2543 CmpOp::NotEq
2544 }
2545}
2546impl<R> From<CmpOpNotEq> for Ast<R> {
2547 fn from(_: CmpOpNotEq) -> Self {
2548 CmpOp::NotEq.into()
2549 }
2550}
2551impl Node for CmpOpNotEq {
2552 const NAME: &'static str = "NotEq";
2553 const FIELD_NAMES: &'static [&'static str] = &[];
2554}
2555impl std::cmp::PartialEq<CmpOp> for CmpOpNotEq {
2556 #[inline]
2557 fn eq(&self, other: &CmpOp) -> bool {
2558 matches!(other, CmpOp::NotEq)
2559 }
2560}
2561
2562pub struct CmpOpLt;
2563impl From<CmpOpLt> for CmpOp {
2564 fn from(_: CmpOpLt) -> Self {
2565 CmpOp::Lt
2566 }
2567}
2568impl<R> From<CmpOpLt> for Ast<R> {
2569 fn from(_: CmpOpLt) -> Self {
2570 CmpOp::Lt.into()
2571 }
2572}
2573impl Node for CmpOpLt {
2574 const NAME: &'static str = "Lt";
2575 const FIELD_NAMES: &'static [&'static str] = &[];
2576}
2577impl std::cmp::PartialEq<CmpOp> for CmpOpLt {
2578 #[inline]
2579 fn eq(&self, other: &CmpOp) -> bool {
2580 matches!(other, CmpOp::Lt)
2581 }
2582}
2583
2584pub struct CmpOpLtE;
2585impl From<CmpOpLtE> for CmpOp {
2586 fn from(_: CmpOpLtE) -> Self {
2587 CmpOp::LtE
2588 }
2589}
2590impl<R> From<CmpOpLtE> for Ast<R> {
2591 fn from(_: CmpOpLtE) -> Self {
2592 CmpOp::LtE.into()
2593 }
2594}
2595impl Node for CmpOpLtE {
2596 const NAME: &'static str = "LtE";
2597 const FIELD_NAMES: &'static [&'static str] = &[];
2598}
2599impl std::cmp::PartialEq<CmpOp> for CmpOpLtE {
2600 #[inline]
2601 fn eq(&self, other: &CmpOp) -> bool {
2602 matches!(other, CmpOp::LtE)
2603 }
2604}
2605
2606pub struct CmpOpGt;
2607impl From<CmpOpGt> for CmpOp {
2608 fn from(_: CmpOpGt) -> Self {
2609 CmpOp::Gt
2610 }
2611}
2612impl<R> From<CmpOpGt> for Ast<R> {
2613 fn from(_: CmpOpGt) -> Self {
2614 CmpOp::Gt.into()
2615 }
2616}
2617impl Node for CmpOpGt {
2618 const NAME: &'static str = "Gt";
2619 const FIELD_NAMES: &'static [&'static str] = &[];
2620}
2621impl std::cmp::PartialEq<CmpOp> for CmpOpGt {
2622 #[inline]
2623 fn eq(&self, other: &CmpOp) -> bool {
2624 matches!(other, CmpOp::Gt)
2625 }
2626}
2627
2628pub struct CmpOpGtE;
2629impl From<CmpOpGtE> for CmpOp {
2630 fn from(_: CmpOpGtE) -> Self {
2631 CmpOp::GtE
2632 }
2633}
2634impl<R> From<CmpOpGtE> for Ast<R> {
2635 fn from(_: CmpOpGtE) -> Self {
2636 CmpOp::GtE.into()
2637 }
2638}
2639impl Node for CmpOpGtE {
2640 const NAME: &'static str = "GtE";
2641 const FIELD_NAMES: &'static [&'static str] = &[];
2642}
2643impl std::cmp::PartialEq<CmpOp> for CmpOpGtE {
2644 #[inline]
2645 fn eq(&self, other: &CmpOp) -> bool {
2646 matches!(other, CmpOp::GtE)
2647 }
2648}
2649
2650pub struct CmpOpIs;
2651impl From<CmpOpIs> for CmpOp {
2652 fn from(_: CmpOpIs) -> Self {
2653 CmpOp::Is
2654 }
2655}
2656impl<R> From<CmpOpIs> for Ast<R> {
2657 fn from(_: CmpOpIs) -> Self {
2658 CmpOp::Is.into()
2659 }
2660}
2661impl Node for CmpOpIs {
2662 const NAME: &'static str = "Is";
2663 const FIELD_NAMES: &'static [&'static str] = &[];
2664}
2665impl std::cmp::PartialEq<CmpOp> for CmpOpIs {
2666 #[inline]
2667 fn eq(&self, other: &CmpOp) -> bool {
2668 matches!(other, CmpOp::Is)
2669 }
2670}
2671
2672pub struct CmpOpIsNot;
2673impl From<CmpOpIsNot> for CmpOp {
2674 fn from(_: CmpOpIsNot) -> Self {
2675 CmpOp::IsNot
2676 }
2677}
2678impl<R> From<CmpOpIsNot> for Ast<R> {
2679 fn from(_: CmpOpIsNot) -> Self {
2680 CmpOp::IsNot.into()
2681 }
2682}
2683impl Node for CmpOpIsNot {
2684 const NAME: &'static str = "IsNot";
2685 const FIELD_NAMES: &'static [&'static str] = &[];
2686}
2687impl std::cmp::PartialEq<CmpOp> for CmpOpIsNot {
2688 #[inline]
2689 fn eq(&self, other: &CmpOp) -> bool {
2690 matches!(other, CmpOp::IsNot)
2691 }
2692}
2693
2694pub struct CmpOpIn;
2695impl From<CmpOpIn> for CmpOp {
2696 fn from(_: CmpOpIn) -> Self {
2697 CmpOp::In
2698 }
2699}
2700impl<R> From<CmpOpIn> for Ast<R> {
2701 fn from(_: CmpOpIn) -> Self {
2702 CmpOp::In.into()
2703 }
2704}
2705impl Node for CmpOpIn {
2706 const NAME: &'static str = "In";
2707 const FIELD_NAMES: &'static [&'static str] = &[];
2708}
2709impl std::cmp::PartialEq<CmpOp> for CmpOpIn {
2710 #[inline]
2711 fn eq(&self, other: &CmpOp) -> bool {
2712 matches!(other, CmpOp::In)
2713 }
2714}
2715
2716pub struct CmpOpNotIn;
2717impl From<CmpOpNotIn> for CmpOp {
2718 fn from(_: CmpOpNotIn) -> Self {
2719 CmpOp::NotIn
2720 }
2721}
2722impl<R> From<CmpOpNotIn> for Ast<R> {
2723 fn from(_: CmpOpNotIn) -> Self {
2724 CmpOp::NotIn.into()
2725 }
2726}
2727impl Node for CmpOpNotIn {
2728 const NAME: &'static str = "NotIn";
2729 const FIELD_NAMES: &'static [&'static str] = &[];
2730}
2731impl std::cmp::PartialEq<CmpOp> for CmpOpNotIn {
2732 #[inline]
2733 fn eq(&self, other: &CmpOp) -> bool {
2734 matches!(other, CmpOp::NotIn)
2735 }
2736}
2737
2738impl Node for CmpOp {
2739 const NAME: &'static str = "cmpop";
2740 const FIELD_NAMES: &'static [&'static str] = &[];
2741}
2742
2743#[derive(Clone, Debug, PartialEq)]
2745pub struct Comprehension<R = TextRange> {
2746 pub range: OptionalRange<R>,
2747 pub target: Expr<R>,
2748 pub iter: Expr<R>,
2749 pub ifs: Vec<Expr<R>>,
2750 pub is_async: bool,
2751}
2752
2753impl<R> Node for Comprehension<R> {
2754 const NAME: &'static str = "comprehension";
2755 const FIELD_NAMES: &'static [&'static str] = &["target", "iter", "ifs", "is_async"];
2756}
2757
2758#[derive(Clone, Debug, PartialEq, is_macro::Is)]
2760pub enum ExceptHandler<R = TextRange> {
2761 ExceptHandler(ExceptHandlerExceptHandler<R>),
2762}
2763
2764#[derive(Clone, Debug, PartialEq)]
2766pub struct ExceptHandlerExceptHandler<R = TextRange> {
2767 pub range: R,
2768 pub type_: Option<Box<Expr<R>>>,
2769 pub name: Option<Identifier>,
2770 pub body: Vec<Stmt<R>>,
2771}
2772
2773impl<R> Node for ExceptHandlerExceptHandler<R> {
2774 const NAME: &'static str = "ExceptHandler";
2775 const FIELD_NAMES: &'static [&'static str] = &["type", "name", "body"];
2776}
2777impl<R> From<ExceptHandlerExceptHandler<R>> for ExceptHandler<R> {
2778 fn from(payload: ExceptHandlerExceptHandler<R>) -> Self {
2779 ExceptHandler::ExceptHandler(payload)
2780 }
2781}
2782impl<R> From<ExceptHandlerExceptHandler<R>> for Ast<R> {
2783 fn from(payload: ExceptHandlerExceptHandler<R>) -> Self {
2784 ExceptHandler::from(payload).into()
2785 }
2786}
2787
2788impl<R> Node for ExceptHandler<R> {
2789 const NAME: &'static str = "excepthandler";
2790 const FIELD_NAMES: &'static [&'static str] = &[];
2791}
2792
2793#[derive(Clone, Debug, PartialEq)]
2795pub struct PythonArguments<R = TextRange> {
2796 pub range: OptionalRange<R>,
2797 pub posonlyargs: Vec<Arg<R>>,
2798 pub args: Vec<Arg<R>>,
2799 pub vararg: Option<Box<Arg<R>>>,
2800 pub kwonlyargs: Vec<Arg<R>>,
2801 pub kw_defaults: Vec<Expr<R>>,
2802 pub kwarg: Option<Box<Arg<R>>>,
2803 pub defaults: Vec<Expr<R>>,
2804}
2805
2806impl<R> Node for PythonArguments<R> {
2807 const NAME: &'static str = "arguments";
2808 const FIELD_NAMES: &'static [&'static str] = &[
2809 "posonlyargs",
2810 "args",
2811 "vararg",
2812 "kwonlyargs",
2813 "kw_defaults",
2814 "kwarg",
2815 "defaults",
2816 ];
2817}
2818
2819#[derive(Clone, Debug, PartialEq)]
2821pub struct Arg<R = TextRange> {
2822 pub range: R,
2823 pub arg: Identifier,
2824 pub annotation: Option<Box<Expr<R>>>,
2825 pub type_comment: Option<String>,
2826}
2827
2828impl<R> Node for Arg<R> {
2829 const NAME: &'static str = "arg";
2830 const FIELD_NAMES: &'static [&'static str] = &["arg", "annotation", "type_comment"];
2831}
2832
2833#[derive(Clone, Debug, PartialEq)]
2835pub struct Keyword<R = TextRange> {
2836 pub range: R,
2837 pub arg: Option<Identifier>,
2838 pub value: Expr<R>,
2839}
2840
2841impl<R> Node for Keyword<R> {
2842 const NAME: &'static str = "keyword";
2843 const FIELD_NAMES: &'static [&'static str] = &["arg", "value"];
2844}
2845
2846#[derive(Clone, Debug, PartialEq)]
2848pub struct Alias<R = TextRange> {
2849 pub range: R,
2850 pub name: Identifier,
2851 pub asname: Option<Identifier>,
2852}
2853
2854impl<R> Node for Alias<R> {
2855 const NAME: &'static str = "alias";
2856 const FIELD_NAMES: &'static [&'static str] = &["name", "asname"];
2857}
2858
2859#[derive(Clone, Debug, PartialEq)]
2861pub struct WithItem<R = TextRange> {
2862 pub range: OptionalRange<R>,
2863 pub context_expr: Expr<R>,
2864 pub optional_vars: Option<Box<Expr<R>>>,
2865}
2866
2867impl<R> Node for WithItem<R> {
2868 const NAME: &'static str = "withitem";
2869 const FIELD_NAMES: &'static [&'static str] = &["context_expr", "optional_vars"];
2870}
2871
2872#[derive(Clone, Debug, PartialEq)]
2874pub struct MatchCase<R = TextRange> {
2875 pub range: OptionalRange<R>,
2876 pub pattern: Pattern<R>,
2877 pub guard: Option<Box<Expr<R>>>,
2878 pub body: Vec<Stmt<R>>,
2879}
2880
2881impl<R> Node for MatchCase<R> {
2882 const NAME: &'static str = "match_case";
2883 const FIELD_NAMES: &'static [&'static str] = &["pattern", "guard", "body"];
2884}
2885
2886#[derive(Clone, Debug, PartialEq, is_macro::Is)]
2888pub enum Pattern<R = TextRange> {
2889 MatchValue(PatternMatchValue<R>),
2890 MatchSingleton(PatternMatchSingleton<R>),
2891 MatchSequence(PatternMatchSequence<R>),
2892 MatchMapping(PatternMatchMapping<R>),
2893 MatchClass(PatternMatchClass<R>),
2894 MatchStar(PatternMatchStar<R>),
2895 MatchAs(PatternMatchAs<R>),
2896 MatchOr(PatternMatchOr<R>),
2897}
2898
2899#[derive(Clone, Debug, PartialEq)]
2901pub struct PatternMatchValue<R = TextRange> {
2902 pub range: R,
2903 pub value: Box<Expr<R>>,
2904}
2905
2906impl<R> Node for PatternMatchValue<R> {
2907 const NAME: &'static str = "MatchValue";
2908 const FIELD_NAMES: &'static [&'static str] = &["value"];
2909}
2910impl<R> From<PatternMatchValue<R>> for Pattern<R> {
2911 fn from(payload: PatternMatchValue<R>) -> Self {
2912 Pattern::MatchValue(payload)
2913 }
2914}
2915impl<R> From<PatternMatchValue<R>> for Ast<R> {
2916 fn from(payload: PatternMatchValue<R>) -> Self {
2917 Pattern::from(payload).into()
2918 }
2919}
2920
2921#[derive(Clone, Debug, PartialEq)]
2923pub struct PatternMatchSingleton<R = TextRange> {
2924 pub range: R,
2925 pub value: Constant,
2926}
2927
2928impl<R> Node for PatternMatchSingleton<R> {
2929 const NAME: &'static str = "MatchSingleton";
2930 const FIELD_NAMES: &'static [&'static str] = &["value"];
2931}
2932impl<R> From<PatternMatchSingleton<R>> for Pattern<R> {
2933 fn from(payload: PatternMatchSingleton<R>) -> Self {
2934 Pattern::MatchSingleton(payload)
2935 }
2936}
2937impl<R> From<PatternMatchSingleton<R>> for Ast<R> {
2938 fn from(payload: PatternMatchSingleton<R>) -> Self {
2939 Pattern::from(payload).into()
2940 }
2941}
2942
2943#[derive(Clone, Debug, PartialEq)]
2945pub struct PatternMatchSequence<R = TextRange> {
2946 pub range: R,
2947 pub patterns: Vec<Pattern<R>>,
2948}
2949
2950impl<R> Node for PatternMatchSequence<R> {
2951 const NAME: &'static str = "MatchSequence";
2952 const FIELD_NAMES: &'static [&'static str] = &["patterns"];
2953}
2954impl<R> From<PatternMatchSequence<R>> for Pattern<R> {
2955 fn from(payload: PatternMatchSequence<R>) -> Self {
2956 Pattern::MatchSequence(payload)
2957 }
2958}
2959impl<R> From<PatternMatchSequence<R>> for Ast<R> {
2960 fn from(payload: PatternMatchSequence<R>) -> Self {
2961 Pattern::from(payload).into()
2962 }
2963}
2964
2965#[derive(Clone, Debug, PartialEq)]
2967pub struct PatternMatchMapping<R = TextRange> {
2968 pub range: R,
2969 pub keys: Vec<Expr<R>>,
2970 pub patterns: Vec<Pattern<R>>,
2971 pub rest: Option<Identifier>,
2972}
2973
2974impl<R> Node for PatternMatchMapping<R> {
2975 const NAME: &'static str = "MatchMapping";
2976 const FIELD_NAMES: &'static [&'static str] = &["keys", "patterns", "rest"];
2977}
2978impl<R> From<PatternMatchMapping<R>> for Pattern<R> {
2979 fn from(payload: PatternMatchMapping<R>) -> Self {
2980 Pattern::MatchMapping(payload)
2981 }
2982}
2983impl<R> From<PatternMatchMapping<R>> for Ast<R> {
2984 fn from(payload: PatternMatchMapping<R>) -> Self {
2985 Pattern::from(payload).into()
2986 }
2987}
2988
2989#[derive(Clone, Debug, PartialEq)]
2991pub struct PatternMatchClass<R = TextRange> {
2992 pub range: R,
2993 pub cls: Box<Expr<R>>,
2994 pub patterns: Vec<Pattern<R>>,
2995 pub kwd_attrs: Vec<Identifier>,
2996 pub kwd_patterns: Vec<Pattern<R>>,
2997}
2998
2999impl<R> Node for PatternMatchClass<R> {
3000 const NAME: &'static str = "MatchClass";
3001 const FIELD_NAMES: &'static [&'static str] = &["cls", "patterns", "kwd_attrs", "kwd_patterns"];
3002}
3003impl<R> From<PatternMatchClass<R>> for Pattern<R> {
3004 fn from(payload: PatternMatchClass<R>) -> Self {
3005 Pattern::MatchClass(payload)
3006 }
3007}
3008impl<R> From<PatternMatchClass<R>> for Ast<R> {
3009 fn from(payload: PatternMatchClass<R>) -> Self {
3010 Pattern::from(payload).into()
3011 }
3012}
3013
3014#[derive(Clone, Debug, PartialEq)]
3016pub struct PatternMatchStar<R = TextRange> {
3017 pub range: R,
3018 pub name: Option<Identifier>,
3019}
3020
3021impl<R> Node for PatternMatchStar<R> {
3022 const NAME: &'static str = "MatchStar";
3023 const FIELD_NAMES: &'static [&'static str] = &["name"];
3024}
3025impl<R> From<PatternMatchStar<R>> for Pattern<R> {
3026 fn from(payload: PatternMatchStar<R>) -> Self {
3027 Pattern::MatchStar(payload)
3028 }
3029}
3030impl<R> From<PatternMatchStar<R>> for Ast<R> {
3031 fn from(payload: PatternMatchStar<R>) -> Self {
3032 Pattern::from(payload).into()
3033 }
3034}
3035
3036#[derive(Clone, Debug, PartialEq)]
3038pub struct PatternMatchAs<R = TextRange> {
3039 pub range: R,
3040 pub pattern: Option<Box<Pattern<R>>>,
3041 pub name: Option<Identifier>,
3042}
3043
3044impl<R> Node for PatternMatchAs<R> {
3045 const NAME: &'static str = "MatchAs";
3046 const FIELD_NAMES: &'static [&'static str] = &["pattern", "name"];
3047}
3048impl<R> From<PatternMatchAs<R>> for Pattern<R> {
3049 fn from(payload: PatternMatchAs<R>) -> Self {
3050 Pattern::MatchAs(payload)
3051 }
3052}
3053impl<R> From<PatternMatchAs<R>> for Ast<R> {
3054 fn from(payload: PatternMatchAs<R>) -> Self {
3055 Pattern::from(payload).into()
3056 }
3057}
3058
3059#[derive(Clone, Debug, PartialEq)]
3061pub struct PatternMatchOr<R = TextRange> {
3062 pub range: R,
3063 pub patterns: Vec<Pattern<R>>,
3064}
3065
3066impl<R> Node for PatternMatchOr<R> {
3067 const NAME: &'static str = "MatchOr";
3068 const FIELD_NAMES: &'static [&'static str] = &["patterns"];
3069}
3070impl<R> From<PatternMatchOr<R>> for Pattern<R> {
3071 fn from(payload: PatternMatchOr<R>) -> Self {
3072 Pattern::MatchOr(payload)
3073 }
3074}
3075impl<R> From<PatternMatchOr<R>> for Ast<R> {
3076 fn from(payload: PatternMatchOr<R>) -> Self {
3077 Pattern::from(payload).into()
3078 }
3079}
3080
3081impl<R> Node for Pattern<R> {
3082 const NAME: &'static str = "pattern";
3083 const FIELD_NAMES: &'static [&'static str] = &[];
3084}
3085
3086#[derive(Clone, Debug, PartialEq, is_macro::Is)]
3088pub enum TypeIgnore<R = TextRange> {
3089 TypeIgnore(TypeIgnoreTypeIgnore<R>),
3090}
3091
3092#[derive(Clone, Debug, PartialEq)]
3094pub struct TypeIgnoreTypeIgnore<R = TextRange> {
3095 pub range: OptionalRange<R>,
3096 pub lineno: Int,
3097 pub tag: String,
3098}
3099
3100impl<R> Node for TypeIgnoreTypeIgnore<R> {
3101 const NAME: &'static str = "TypeIgnore";
3102 const FIELD_NAMES: &'static [&'static str] = &["lineno", "tag"];
3103}
3104impl<R> From<TypeIgnoreTypeIgnore<R>> for TypeIgnore<R> {
3105 fn from(payload: TypeIgnoreTypeIgnore<R>) -> Self {
3106 TypeIgnore::TypeIgnore(payload)
3107 }
3108}
3109impl<R> From<TypeIgnoreTypeIgnore<R>> for Ast<R> {
3110 fn from(payload: TypeIgnoreTypeIgnore<R>) -> Self {
3111 TypeIgnore::from(payload).into()
3112 }
3113}
3114
3115impl<R> Node for TypeIgnore<R> {
3116 const NAME: &'static str = "type_ignore";
3117 const FIELD_NAMES: &'static [&'static str] = &[];
3118}
3119
3120#[derive(Clone, Debug, PartialEq, is_macro::Is)]
3122pub enum TypeParam<R = TextRange> {
3123 TypeVar(TypeParamTypeVar<R>),
3124 ParamSpec(TypeParamParamSpec<R>),
3125 TypeVarTuple(TypeParamTypeVarTuple<R>),
3126}
3127
3128#[derive(Clone, Debug, PartialEq)]
3130pub struct TypeParamTypeVar<R = TextRange> {
3131 pub range: R,
3132 pub name: Identifier,
3133 pub bound: Option<Box<Expr<R>>>,
3134}
3135
3136impl<R> Node for TypeParamTypeVar<R> {
3137 const NAME: &'static str = "TypeVar";
3138 const FIELD_NAMES: &'static [&'static str] = &["name", "bound"];
3139}
3140impl<R> From<TypeParamTypeVar<R>> for TypeParam<R> {
3141 fn from(payload: TypeParamTypeVar<R>) -> Self {
3142 TypeParam::TypeVar(payload)
3143 }
3144}
3145impl<R> From<TypeParamTypeVar<R>> for Ast<R> {
3146 fn from(payload: TypeParamTypeVar<R>) -> Self {
3147 TypeParam::from(payload).into()
3148 }
3149}
3150
3151#[derive(Clone, Debug, PartialEq)]
3153pub struct TypeParamParamSpec<R = TextRange> {
3154 pub range: R,
3155 pub name: Identifier,
3156}
3157
3158impl<R> Node for TypeParamParamSpec<R> {
3159 const NAME: &'static str = "ParamSpec";
3160 const FIELD_NAMES: &'static [&'static str] = &["name"];
3161}
3162impl<R> From<TypeParamParamSpec<R>> for TypeParam<R> {
3163 fn from(payload: TypeParamParamSpec<R>) -> Self {
3164 TypeParam::ParamSpec(payload)
3165 }
3166}
3167impl<R> From<TypeParamParamSpec<R>> for Ast<R> {
3168 fn from(payload: TypeParamParamSpec<R>) -> Self {
3169 TypeParam::from(payload).into()
3170 }
3171}
3172
3173#[derive(Clone, Debug, PartialEq)]
3175pub struct TypeParamTypeVarTuple<R = TextRange> {
3176 pub range: R,
3177 pub name: Identifier,
3178}
3179
3180impl<R> Node for TypeParamTypeVarTuple<R> {
3181 const NAME: &'static str = "TypeVarTuple";
3182 const FIELD_NAMES: &'static [&'static str] = &["name"];
3183}
3184impl<R> From<TypeParamTypeVarTuple<R>> for TypeParam<R> {
3185 fn from(payload: TypeParamTypeVarTuple<R>) -> Self {
3186 TypeParam::TypeVarTuple(payload)
3187 }
3188}
3189impl<R> From<TypeParamTypeVarTuple<R>> for Ast<R> {
3190 fn from(payload: TypeParamTypeVarTuple<R>) -> Self {
3191 TypeParam::from(payload).into()
3192 }
3193}
3194
3195impl<R> Node for TypeParam<R> {
3196 const NAME: &'static str = "type_param";
3197 const FIELD_NAMES: &'static [&'static str] = &[];
3198}
3199
3200#[derive(Clone, Debug, PartialEq)]
3211pub struct Arguments<R = TextRange> {
3212 pub range: OptionalRange<R>,
3213 pub posonlyargs: Vec<ArgWithDefault<R>>,
3214 pub args: Vec<ArgWithDefault<R>>,
3215 pub vararg: Option<Box<Arg<R>>>,
3216 pub kwonlyargs: Vec<ArgWithDefault<R>>,
3217 pub kwarg: Option<Box<Arg<R>>>,
3218}
3219
3220impl<R> Node for Arguments<R> {
3221 const NAME: &'static str = "alt:arguments";
3222 const FIELD_NAMES: &'static [&'static str] =
3223 &["posonlyargs", "args", "vararg", "kwonlyargs", "kwarg"];
3224}
3225
3226#[derive(Clone, Debug, PartialEq)]
3232pub struct ArgWithDefault<R = TextRange> {
3233 pub range: OptionalRange<R>,
3234 pub def: Arg<R>,
3235 pub default: Option<Box<Expr<R>>>,
3236}
3237
3238impl<R> Node for ArgWithDefault<R> {
3239 const NAME: &'static str = "arg_with_default";
3240 const FIELD_NAMES: &'static [&'static str] = &["def", "default"];
3241}