From 25801c84eb9f22b65c94c90c4a29f3538d93a7fe Mon Sep 17 00:00:00 2001 From: Jeong YunWon Date: Thu, 1 Jun 2023 13:52:37 +0900 Subject: [PATCH] Refer cpython documentation --- ast/asdl_rs.py | 14 +- ast/src/gen/generic.rs | 2600 +++++++++++++++++++++------------------- ast/src/lib.rs | 8 + 3 files changed, 1359 insertions(+), 1263 deletions(-) diff --git a/ast/asdl_rs.py b/ast/asdl_rs.py index dc5976b..517a4b4 100755 --- a/ast/asdl_rs.py +++ b/ast/asdl_rs.py @@ -453,7 +453,9 @@ class StructVisitor(EmitVisitor): def visitType(self, type, depth=0): if hasattr(type, "doc"): doc = "/// " + type.doc.replace("\n", "\n/// ") + "\n" - self.emit(doc, depth) + else: + doc = f"/// See also [{type.name}](https://docs.python.org/3/library/ast.html#ast.{type.name})" + self.emit(doc, depth) self.visit(type.value, type, depth) def visitSum(self, sum, type, depth): @@ -534,11 +536,6 @@ class StructVisitor(EmitVisitor): def sum_with_constructors(self, sum, type, depth): type_info = self.type_info[type.name] rust_name = rust_type_name(type.name) - # all the attributes right now are for location, so if it has attrs we - # can just wrap it in Attributed<> - - for t in sum.types: - self.sum_subtype_struct(type_info, t, rust_name, depth) self.emit_attrs(depth) self.emit("#[derive(is_macro::Is)]", depth) @@ -554,7 +551,12 @@ class StructVisitor(EmitVisitor): self.emit("}", depth) self.emit("", depth) + for t in sum.types: + self.sum_subtype_struct(type_info, t, rust_name, depth) + + def sum_subtype_struct(self, sum_type_info, t, rust_name, depth): + self.emit(f"""/// See also [{t.name}](https://docs.python.org/3/library/ast.html#ast.{t.name})""", depth) self.emit_attrs(depth) payload_name = f"{rust_name}{t.name}" self.emit(f"pub struct {payload_name} {{", depth) diff --git a/ast/src/gen/generic.rs b/ast/src/gen/generic.rs index df9ea1a..3b193ec 100644 --- a/ast/src/gen/generic.rs +++ b/ast/src/gen/generic.rs @@ -137,6 +137,16 @@ impl From> for Ast { } } +/// See also [mod](https://docs.python.org/3/library/ast.html#ast.mod) +#[derive(Clone, Debug, PartialEq, is_macro::Is)] +pub enum Mod { + Module(ModModule), + Interactive(ModInteractive), + Expression(ModExpression), + FunctionType(ModFunctionType), +} + +/// See also [Module](https://docs.python.org/3/library/ast.html#ast.Module) #[derive(Clone, Debug, PartialEq)] pub struct ModModule { pub range: OptionalRange, @@ -159,6 +169,7 @@ impl From> for Ast { } } +/// See also [Interactive](https://docs.python.org/3/library/ast.html#ast.Interactive) #[derive(Clone, Debug, PartialEq)] pub struct ModInteractive { pub range: OptionalRange, @@ -180,6 +191,7 @@ impl From> for Ast { } } +/// See also [Expression](https://docs.python.org/3/library/ast.html#ast.Expression) #[derive(Clone, Debug, PartialEq)] pub struct ModExpression { pub range: OptionalRange, @@ -201,6 +213,7 @@ impl From> for Ast { } } +/// See also [FunctionType](https://docs.python.org/3/library/ast.html#ast.FunctionType) #[derive(Clone, Debug, PartialEq)] pub struct ModFunctionType { pub range: OptionalRange, @@ -223,648 +236,12 @@ impl From> for Ast { } } -#[derive(Clone, Debug, PartialEq, is_macro::Is)] -pub enum Mod { - Module(ModModule), - Interactive(ModInteractive), - Expression(ModExpression), - FunctionType(ModFunctionType), -} - impl Node for Mod { const NAME: &'static str = "mod"; const FIELD_NAMES: &'static [&'static str] = &[]; } -#[derive(Clone, Debug, PartialEq)] -pub struct StmtFunctionDef { - pub range: R, - pub name: Identifier, - pub args: Box>, - pub body: Vec>, - pub decorator_list: Vec>, - pub returns: Option>>, - pub type_comment: Option, -} - -impl Node for StmtFunctionDef { - const NAME: &'static str = "FunctionDef"; - const FIELD_NAMES: &'static [&'static str] = &[ - "name", - "args", - "body", - "decorator_list", - "returns", - "type_comment", - ]; -} -impl From> for Stmt { - fn from(payload: StmtFunctionDef) -> Self { - Stmt::FunctionDef(payload) - } -} -impl From> for Ast { - fn from(payload: StmtFunctionDef) -> Self { - Stmt::from(payload).into() - } -} - -#[derive(Clone, Debug, PartialEq)] -pub struct StmtAsyncFunctionDef { - pub range: R, - pub name: Identifier, - pub args: Box>, - pub body: Vec>, - pub decorator_list: Vec>, - pub returns: Option>>, - pub type_comment: Option, -} - -impl Node for StmtAsyncFunctionDef { - const NAME: &'static str = "AsyncFunctionDef"; - const FIELD_NAMES: &'static [&'static str] = &[ - "name", - "args", - "body", - "decorator_list", - "returns", - "type_comment", - ]; -} -impl From> for Stmt { - fn from(payload: StmtAsyncFunctionDef) -> Self { - Stmt::AsyncFunctionDef(payload) - } -} -impl From> for Ast { - fn from(payload: StmtAsyncFunctionDef) -> Self { - Stmt::from(payload).into() - } -} - -#[derive(Clone, Debug, PartialEq)] -pub struct StmtClassDef { - pub range: R, - pub name: Identifier, - pub bases: Vec>, - pub keywords: Vec>, - pub body: Vec>, - pub decorator_list: Vec>, -} - -impl Node for StmtClassDef { - const NAME: &'static str = "ClassDef"; - const FIELD_NAMES: &'static [&'static str] = - &["name", "bases", "keywords", "body", "decorator_list"]; -} -impl From> for Stmt { - fn from(payload: StmtClassDef) -> Self { - Stmt::ClassDef(payload) - } -} -impl From> for Ast { - fn from(payload: StmtClassDef) -> Self { - Stmt::from(payload).into() - } -} - -#[derive(Clone, Debug, PartialEq)] -pub struct StmtReturn { - pub range: R, - pub value: Option>>, -} - -impl Node for StmtReturn { - const NAME: &'static str = "Return"; - const FIELD_NAMES: &'static [&'static str] = &["value"]; -} -impl From> for Stmt { - fn from(payload: StmtReturn) -> Self { - Stmt::Return(payload) - } -} -impl From> for Ast { - fn from(payload: StmtReturn) -> Self { - Stmt::from(payload).into() - } -} - -#[derive(Clone, Debug, PartialEq)] -pub struct StmtDelete { - pub range: R, - pub targets: Vec>, -} - -impl Node for StmtDelete { - const NAME: &'static str = "Delete"; - const FIELD_NAMES: &'static [&'static str] = &["targets"]; -} -impl From> for Stmt { - fn from(payload: StmtDelete) -> Self { - Stmt::Delete(payload) - } -} -impl From> for Ast { - fn from(payload: StmtDelete) -> Self { - Stmt::from(payload).into() - } -} - -#[derive(Clone, Debug, PartialEq)] -pub struct StmtAssign { - pub range: R, - pub targets: Vec>, - pub value: Box>, - pub type_comment: Option, -} - -impl Node for StmtAssign { - const NAME: &'static str = "Assign"; - const FIELD_NAMES: &'static [&'static str] = &["targets", "value", "type_comment"]; -} -impl From> for Stmt { - fn from(payload: StmtAssign) -> Self { - Stmt::Assign(payload) - } -} -impl From> for Ast { - fn from(payload: StmtAssign) -> Self { - Stmt::from(payload).into() - } -} - -#[derive(Clone, Debug, PartialEq)] -pub struct StmtAugAssign { - pub range: R, - pub target: Box>, - pub op: Operator, - pub value: Box>, -} - -impl Node for StmtAugAssign { - const NAME: &'static str = "AugAssign"; - const FIELD_NAMES: &'static [&'static str] = &["target", "op", "value"]; -} -impl From> for Stmt { - fn from(payload: StmtAugAssign) -> Self { - Stmt::AugAssign(payload) - } -} -impl From> for Ast { - fn from(payload: StmtAugAssign) -> Self { - Stmt::from(payload).into() - } -} - -#[derive(Clone, Debug, PartialEq)] -pub struct StmtAnnAssign { - pub range: R, - pub target: Box>, - pub annotation: Box>, - pub value: Option>>, - pub simple: bool, -} - -impl Node for StmtAnnAssign { - const NAME: &'static str = "AnnAssign"; - const FIELD_NAMES: &'static [&'static str] = &["target", "annotation", "value", "simple"]; -} -impl From> for Stmt { - fn from(payload: StmtAnnAssign) -> Self { - Stmt::AnnAssign(payload) - } -} -impl From> for Ast { - fn from(payload: StmtAnnAssign) -> Self { - Stmt::from(payload).into() - } -} - -#[derive(Clone, Debug, PartialEq)] -pub struct StmtFor { - pub range: R, - pub target: Box>, - pub iter: Box>, - pub body: Vec>, - pub orelse: Vec>, - pub type_comment: Option, -} - -impl Node for StmtFor { - const NAME: &'static str = "For"; - const FIELD_NAMES: &'static [&'static str] = - &["target", "iter", "body", "orelse", "type_comment"]; -} -impl From> for Stmt { - fn from(payload: StmtFor) -> Self { - Stmt::For(payload) - } -} -impl From> for Ast { - fn from(payload: StmtFor) -> Self { - Stmt::from(payload).into() - } -} - -#[derive(Clone, Debug, PartialEq)] -pub struct StmtAsyncFor { - pub range: R, - pub target: Box>, - pub iter: Box>, - pub body: Vec>, - pub orelse: Vec>, - pub type_comment: Option, -} - -impl Node for StmtAsyncFor { - const NAME: &'static str = "AsyncFor"; - const FIELD_NAMES: &'static [&'static str] = - &["target", "iter", "body", "orelse", "type_comment"]; -} -impl From> for Stmt { - fn from(payload: StmtAsyncFor) -> Self { - Stmt::AsyncFor(payload) - } -} -impl From> for Ast { - fn from(payload: StmtAsyncFor) -> Self { - Stmt::from(payload).into() - } -} - -#[derive(Clone, Debug, PartialEq)] -pub struct StmtWhile { - pub range: R, - pub test: Box>, - pub body: Vec>, - pub orelse: Vec>, -} - -impl Node for StmtWhile { - const NAME: &'static str = "While"; - const FIELD_NAMES: &'static [&'static str] = &["test", "body", "orelse"]; -} -impl From> for Stmt { - fn from(payload: StmtWhile) -> Self { - Stmt::While(payload) - } -} -impl From> for Ast { - fn from(payload: StmtWhile) -> Self { - Stmt::from(payload).into() - } -} - -#[derive(Clone, Debug, PartialEq)] -pub struct StmtIf { - pub range: R, - pub test: Box>, - pub body: Vec>, - pub orelse: Vec>, -} - -impl Node for StmtIf { - const NAME: &'static str = "If"; - const FIELD_NAMES: &'static [&'static str] = &["test", "body", "orelse"]; -} -impl From> for Stmt { - fn from(payload: StmtIf) -> Self { - Stmt::If(payload) - } -} -impl From> for Ast { - fn from(payload: StmtIf) -> Self { - Stmt::from(payload).into() - } -} - -#[derive(Clone, Debug, PartialEq)] -pub struct StmtWith { - pub range: R, - pub items: Vec>, - pub body: Vec>, - pub type_comment: Option, -} - -impl Node for StmtWith { - const NAME: &'static str = "With"; - const FIELD_NAMES: &'static [&'static str] = &["items", "body", "type_comment"]; -} -impl From> for Stmt { - fn from(payload: StmtWith) -> Self { - Stmt::With(payload) - } -} -impl From> for Ast { - fn from(payload: StmtWith) -> Self { - Stmt::from(payload).into() - } -} - -#[derive(Clone, Debug, PartialEq)] -pub struct StmtAsyncWith { - pub range: R, - pub items: Vec>, - pub body: Vec>, - pub type_comment: Option, -} - -impl Node for StmtAsyncWith { - const NAME: &'static str = "AsyncWith"; - const FIELD_NAMES: &'static [&'static str] = &["items", "body", "type_comment"]; -} -impl From> for Stmt { - fn from(payload: StmtAsyncWith) -> Self { - Stmt::AsyncWith(payload) - } -} -impl From> for Ast { - fn from(payload: StmtAsyncWith) -> Self { - Stmt::from(payload).into() - } -} - -#[derive(Clone, Debug, PartialEq)] -pub struct StmtMatch { - pub range: R, - pub subject: Box>, - pub cases: Vec>, -} - -impl Node for StmtMatch { - const NAME: &'static str = "Match"; - const FIELD_NAMES: &'static [&'static str] = &["subject", "cases"]; -} -impl From> for Stmt { - fn from(payload: StmtMatch) -> Self { - Stmt::Match(payload) - } -} -impl From> for Ast { - fn from(payload: StmtMatch) -> Self { - Stmt::from(payload).into() - } -} - -#[derive(Clone, Debug, PartialEq)] -pub struct StmtRaise { - pub range: R, - pub exc: Option>>, - pub cause: Option>>, -} - -impl Node for StmtRaise { - const NAME: &'static str = "Raise"; - const FIELD_NAMES: &'static [&'static str] = &["exc", "cause"]; -} -impl From> for Stmt { - fn from(payload: StmtRaise) -> Self { - Stmt::Raise(payload) - } -} -impl From> for Ast { - fn from(payload: StmtRaise) -> Self { - Stmt::from(payload).into() - } -} - -#[derive(Clone, Debug, PartialEq)] -pub struct StmtTry { - pub range: R, - pub body: Vec>, - pub handlers: Vec>, - pub orelse: Vec>, - pub finalbody: Vec>, -} - -impl Node for StmtTry { - const NAME: &'static str = "Try"; - const FIELD_NAMES: &'static [&'static str] = &["body", "handlers", "orelse", "finalbody"]; -} -impl From> for Stmt { - fn from(payload: StmtTry) -> Self { - Stmt::Try(payload) - } -} -impl From> for Ast { - fn from(payload: StmtTry) -> Self { - Stmt::from(payload).into() - } -} - -#[derive(Clone, Debug, PartialEq)] -pub struct StmtTryStar { - pub range: R, - pub body: Vec>, - pub handlers: Vec>, - pub orelse: Vec>, - pub finalbody: Vec>, -} - -impl Node for StmtTryStar { - const NAME: &'static str = "TryStar"; - const FIELD_NAMES: &'static [&'static str] = &["body", "handlers", "orelse", "finalbody"]; -} -impl From> for Stmt { - fn from(payload: StmtTryStar) -> Self { - Stmt::TryStar(payload) - } -} -impl From> for Ast { - fn from(payload: StmtTryStar) -> Self { - Stmt::from(payload).into() - } -} - -#[derive(Clone, Debug, PartialEq)] -pub struct StmtAssert { - pub range: R, - pub test: Box>, - pub msg: Option>>, -} - -impl Node for StmtAssert { - const NAME: &'static str = "Assert"; - const FIELD_NAMES: &'static [&'static str] = &["test", "msg"]; -} -impl From> for Stmt { - fn from(payload: StmtAssert) -> Self { - Stmt::Assert(payload) - } -} -impl From> for Ast { - fn from(payload: StmtAssert) -> Self { - Stmt::from(payload).into() - } -} - -#[derive(Clone, Debug, PartialEq)] -pub struct StmtImport { - pub range: R, - pub names: Vec>, -} - -impl Node for StmtImport { - const NAME: &'static str = "Import"; - const FIELD_NAMES: &'static [&'static str] = &["names"]; -} -impl From> for Stmt { - fn from(payload: StmtImport) -> Self { - Stmt::Import(payload) - } -} -impl From> for Ast { - fn from(payload: StmtImport) -> Self { - Stmt::from(payload).into() - } -} - -#[derive(Clone, Debug, PartialEq)] -pub struct StmtImportFrom { - pub range: R, - pub module: Option, - pub names: Vec>, - pub level: Option, -} - -impl Node for StmtImportFrom { - const NAME: &'static str = "ImportFrom"; - const FIELD_NAMES: &'static [&'static str] = &["module", "names", "level"]; -} -impl From> for Stmt { - fn from(payload: StmtImportFrom) -> Self { - Stmt::ImportFrom(payload) - } -} -impl From> for Ast { - fn from(payload: StmtImportFrom) -> Self { - Stmt::from(payload).into() - } -} - -#[derive(Clone, Debug, PartialEq)] -pub struct StmtGlobal { - pub range: R, - pub names: Vec, -} - -impl Node for StmtGlobal { - const NAME: &'static str = "Global"; - const FIELD_NAMES: &'static [&'static str] = &["names"]; -} -impl From> for Stmt { - fn from(payload: StmtGlobal) -> Self { - Stmt::Global(payload) - } -} -impl From> for Ast { - fn from(payload: StmtGlobal) -> Self { - Stmt::from(payload).into() - } -} - -#[derive(Clone, Debug, PartialEq)] -pub struct StmtNonlocal { - pub range: R, - pub names: Vec, -} - -impl Node for StmtNonlocal { - const NAME: &'static str = "Nonlocal"; - const FIELD_NAMES: &'static [&'static str] = &["names"]; -} -impl From> for Stmt { - fn from(payload: StmtNonlocal) -> Self { - Stmt::Nonlocal(payload) - } -} -impl From> for Ast { - fn from(payload: StmtNonlocal) -> Self { - Stmt::from(payload).into() - } -} - -#[derive(Clone, Debug, PartialEq)] -pub struct StmtExpr { - pub range: R, - pub value: Box>, -} - -impl Node for StmtExpr { - const NAME: &'static str = "Expr"; - const FIELD_NAMES: &'static [&'static str] = &["value"]; -} -impl From> for Stmt { - fn from(payload: StmtExpr) -> Self { - Stmt::Expr(payload) - } -} -impl From> for Ast { - fn from(payload: StmtExpr) -> Self { - Stmt::from(payload).into() - } -} - -#[derive(Clone, Debug, PartialEq)] -pub struct StmtPass { - pub range: R, -} - -impl Node for StmtPass { - const NAME: &'static str = "Pass"; - const FIELD_NAMES: &'static [&'static str] = &[]; -} -impl From> for Stmt { - fn from(payload: StmtPass) -> Self { - Stmt::Pass(payload) - } -} -impl From> for Ast { - fn from(payload: StmtPass) -> Self { - Stmt::from(payload).into() - } -} - -#[derive(Clone, Debug, PartialEq)] -pub struct StmtBreak { - pub range: R, -} - -impl Node for StmtBreak { - const NAME: &'static str = "Break"; - const FIELD_NAMES: &'static [&'static str] = &[]; -} -impl From> for Stmt { - fn from(payload: StmtBreak) -> Self { - Stmt::Break(payload) - } -} -impl From> for Ast { - fn from(payload: StmtBreak) -> Self { - Stmt::from(payload).into() - } -} - -#[derive(Clone, Debug, PartialEq)] -pub struct StmtContinue { - pub range: R, -} - -impl Node for StmtContinue { - const NAME: &'static str = "Continue"; - const FIELD_NAMES: &'static [&'static str] = &[]; -} -impl From> for Stmt { - fn from(payload: StmtContinue) -> Self { - Stmt::Continue(payload) - } -} -impl From> for Ast { - fn from(payload: StmtContinue) -> Self { - Stmt::from(payload).into() - } -} - +/// See also [stmt](https://docs.python.org/3/library/ast.html#ast.stmt) #[derive(Clone, Debug, PartialEq, is_macro::Is)] pub enum Stmt { #[is(name = "function_def_stmt")] @@ -923,609 +300,668 @@ pub enum Stmt { Continue(StmtContinue), } +/// See also [FunctionDef](https://docs.python.org/3/library/ast.html#ast.FunctionDef) +#[derive(Clone, Debug, PartialEq)] +pub struct StmtFunctionDef { + pub range: R, + pub name: Identifier, + pub args: Box>, + pub body: Vec>, + pub decorator_list: Vec>, + pub returns: Option>>, + pub type_comment: Option, +} + +impl Node for StmtFunctionDef { + const NAME: &'static str = "FunctionDef"; + const FIELD_NAMES: &'static [&'static str] = &[ + "name", + "args", + "body", + "decorator_list", + "returns", + "type_comment", + ]; +} +impl From> for Stmt { + fn from(payload: StmtFunctionDef) -> Self { + Stmt::FunctionDef(payload) + } +} +impl From> for Ast { + fn from(payload: StmtFunctionDef) -> Self { + Stmt::from(payload).into() + } +} + +/// See also [AsyncFunctionDef](https://docs.python.org/3/library/ast.html#ast.AsyncFunctionDef) +#[derive(Clone, Debug, PartialEq)] +pub struct StmtAsyncFunctionDef { + pub range: R, + pub name: Identifier, + pub args: Box>, + pub body: Vec>, + pub decorator_list: Vec>, + pub returns: Option>>, + pub type_comment: Option, +} + +impl Node for StmtAsyncFunctionDef { + const NAME: &'static str = "AsyncFunctionDef"; + const FIELD_NAMES: &'static [&'static str] = &[ + "name", + "args", + "body", + "decorator_list", + "returns", + "type_comment", + ]; +} +impl From> for Stmt { + fn from(payload: StmtAsyncFunctionDef) -> Self { + Stmt::AsyncFunctionDef(payload) + } +} +impl From> for Ast { + fn from(payload: StmtAsyncFunctionDef) -> Self { + Stmt::from(payload).into() + } +} + +/// See also [ClassDef](https://docs.python.org/3/library/ast.html#ast.ClassDef) +#[derive(Clone, Debug, PartialEq)] +pub struct StmtClassDef { + pub range: R, + pub name: Identifier, + pub bases: Vec>, + pub keywords: Vec>, + pub body: Vec>, + pub decorator_list: Vec>, +} + +impl Node for StmtClassDef { + const NAME: &'static str = "ClassDef"; + const FIELD_NAMES: &'static [&'static str] = + &["name", "bases", "keywords", "body", "decorator_list"]; +} +impl From> for Stmt { + fn from(payload: StmtClassDef) -> Self { + Stmt::ClassDef(payload) + } +} +impl From> for Ast { + fn from(payload: StmtClassDef) -> Self { + Stmt::from(payload).into() + } +} + +/// See also [Return](https://docs.python.org/3/library/ast.html#ast.Return) +#[derive(Clone, Debug, PartialEq)] +pub struct StmtReturn { + pub range: R, + pub value: Option>>, +} + +impl Node for StmtReturn { + const NAME: &'static str = "Return"; + const FIELD_NAMES: &'static [&'static str] = &["value"]; +} +impl From> for Stmt { + fn from(payload: StmtReturn) -> Self { + Stmt::Return(payload) + } +} +impl From> for Ast { + fn from(payload: StmtReturn) -> Self { + Stmt::from(payload).into() + } +} + +/// See also [Delete](https://docs.python.org/3/library/ast.html#ast.Delete) +#[derive(Clone, Debug, PartialEq)] +pub struct StmtDelete { + pub range: R, + pub targets: Vec>, +} + +impl Node for StmtDelete { + const NAME: &'static str = "Delete"; + const FIELD_NAMES: &'static [&'static str] = &["targets"]; +} +impl From> for Stmt { + fn from(payload: StmtDelete) -> Self { + Stmt::Delete(payload) + } +} +impl From> for Ast { + fn from(payload: StmtDelete) -> Self { + Stmt::from(payload).into() + } +} + +/// See also [Assign](https://docs.python.org/3/library/ast.html#ast.Assign) +#[derive(Clone, Debug, PartialEq)] +pub struct StmtAssign { + pub range: R, + pub targets: Vec>, + pub value: Box>, + pub type_comment: Option, +} + +impl Node for StmtAssign { + const NAME: &'static str = "Assign"; + const FIELD_NAMES: &'static [&'static str] = &["targets", "value", "type_comment"]; +} +impl From> for Stmt { + fn from(payload: StmtAssign) -> Self { + Stmt::Assign(payload) + } +} +impl From> for Ast { + fn from(payload: StmtAssign) -> Self { + Stmt::from(payload).into() + } +} + +/// See also [AugAssign](https://docs.python.org/3/library/ast.html#ast.AugAssign) +#[derive(Clone, Debug, PartialEq)] +pub struct StmtAugAssign { + pub range: R, + pub target: Box>, + pub op: Operator, + pub value: Box>, +} + +impl Node for StmtAugAssign { + const NAME: &'static str = "AugAssign"; + const FIELD_NAMES: &'static [&'static str] = &["target", "op", "value"]; +} +impl From> for Stmt { + fn from(payload: StmtAugAssign) -> Self { + Stmt::AugAssign(payload) + } +} +impl From> for Ast { + fn from(payload: StmtAugAssign) -> Self { + Stmt::from(payload).into() + } +} + +/// See also [AnnAssign](https://docs.python.org/3/library/ast.html#ast.AnnAssign) +#[derive(Clone, Debug, PartialEq)] +pub struct StmtAnnAssign { + pub range: R, + pub target: Box>, + pub annotation: Box>, + pub value: Option>>, + pub simple: bool, +} + +impl Node for StmtAnnAssign { + const NAME: &'static str = "AnnAssign"; + const FIELD_NAMES: &'static [&'static str] = &["target", "annotation", "value", "simple"]; +} +impl From> for Stmt { + fn from(payload: StmtAnnAssign) -> Self { + Stmt::AnnAssign(payload) + } +} +impl From> for Ast { + fn from(payload: StmtAnnAssign) -> Self { + Stmt::from(payload).into() + } +} + +/// See also [For](https://docs.python.org/3/library/ast.html#ast.For) +#[derive(Clone, Debug, PartialEq)] +pub struct StmtFor { + pub range: R, + pub target: Box>, + pub iter: Box>, + pub body: Vec>, + pub orelse: Vec>, + pub type_comment: Option, +} + +impl Node for StmtFor { + const NAME: &'static str = "For"; + const FIELD_NAMES: &'static [&'static str] = + &["target", "iter", "body", "orelse", "type_comment"]; +} +impl From> for Stmt { + fn from(payload: StmtFor) -> Self { + Stmt::For(payload) + } +} +impl From> for Ast { + fn from(payload: StmtFor) -> Self { + Stmt::from(payload).into() + } +} + +/// See also [AsyncFor](https://docs.python.org/3/library/ast.html#ast.AsyncFor) +#[derive(Clone, Debug, PartialEq)] +pub struct StmtAsyncFor { + pub range: R, + pub target: Box>, + pub iter: Box>, + pub body: Vec>, + pub orelse: Vec>, + pub type_comment: Option, +} + +impl Node for StmtAsyncFor { + const NAME: &'static str = "AsyncFor"; + const FIELD_NAMES: &'static [&'static str] = + &["target", "iter", "body", "orelse", "type_comment"]; +} +impl From> for Stmt { + fn from(payload: StmtAsyncFor) -> Self { + Stmt::AsyncFor(payload) + } +} +impl From> for Ast { + fn from(payload: StmtAsyncFor) -> Self { + Stmt::from(payload).into() + } +} + +/// See also [While](https://docs.python.org/3/library/ast.html#ast.While) +#[derive(Clone, Debug, PartialEq)] +pub struct StmtWhile { + pub range: R, + pub test: Box>, + pub body: Vec>, + pub orelse: Vec>, +} + +impl Node for StmtWhile { + const NAME: &'static str = "While"; + const FIELD_NAMES: &'static [&'static str] = &["test", "body", "orelse"]; +} +impl From> for Stmt { + fn from(payload: StmtWhile) -> Self { + Stmt::While(payload) + } +} +impl From> for Ast { + fn from(payload: StmtWhile) -> Self { + Stmt::from(payload).into() + } +} + +/// See also [If](https://docs.python.org/3/library/ast.html#ast.If) +#[derive(Clone, Debug, PartialEq)] +pub struct StmtIf { + pub range: R, + pub test: Box>, + pub body: Vec>, + pub orelse: Vec>, +} + +impl Node for StmtIf { + const NAME: &'static str = "If"; + const FIELD_NAMES: &'static [&'static str] = &["test", "body", "orelse"]; +} +impl From> for Stmt { + fn from(payload: StmtIf) -> Self { + Stmt::If(payload) + } +} +impl From> for Ast { + fn from(payload: StmtIf) -> Self { + Stmt::from(payload).into() + } +} + +/// See also [With](https://docs.python.org/3/library/ast.html#ast.With) +#[derive(Clone, Debug, PartialEq)] +pub struct StmtWith { + pub range: R, + pub items: Vec>, + pub body: Vec>, + pub type_comment: Option, +} + +impl Node for StmtWith { + const NAME: &'static str = "With"; + const FIELD_NAMES: &'static [&'static str] = &["items", "body", "type_comment"]; +} +impl From> for Stmt { + fn from(payload: StmtWith) -> Self { + Stmt::With(payload) + } +} +impl From> for Ast { + fn from(payload: StmtWith) -> Self { + Stmt::from(payload).into() + } +} + +/// See also [AsyncWith](https://docs.python.org/3/library/ast.html#ast.AsyncWith) +#[derive(Clone, Debug, PartialEq)] +pub struct StmtAsyncWith { + pub range: R, + pub items: Vec>, + pub body: Vec>, + pub type_comment: Option, +} + +impl Node for StmtAsyncWith { + const NAME: &'static str = "AsyncWith"; + const FIELD_NAMES: &'static [&'static str] = &["items", "body", "type_comment"]; +} +impl From> for Stmt { + fn from(payload: StmtAsyncWith) -> Self { + Stmt::AsyncWith(payload) + } +} +impl From> for Ast { + fn from(payload: StmtAsyncWith) -> Self { + Stmt::from(payload).into() + } +} + +/// See also [Match](https://docs.python.org/3/library/ast.html#ast.Match) +#[derive(Clone, Debug, PartialEq)] +pub struct StmtMatch { + pub range: R, + pub subject: Box>, + pub cases: Vec>, +} + +impl Node for StmtMatch { + const NAME: &'static str = "Match"; + const FIELD_NAMES: &'static [&'static str] = &["subject", "cases"]; +} +impl From> for Stmt { + fn from(payload: StmtMatch) -> Self { + Stmt::Match(payload) + } +} +impl From> for Ast { + fn from(payload: StmtMatch) -> Self { + Stmt::from(payload).into() + } +} + +/// See also [Raise](https://docs.python.org/3/library/ast.html#ast.Raise) +#[derive(Clone, Debug, PartialEq)] +pub struct StmtRaise { + pub range: R, + pub exc: Option>>, + pub cause: Option>>, +} + +impl Node for StmtRaise { + const NAME: &'static str = "Raise"; + const FIELD_NAMES: &'static [&'static str] = &["exc", "cause"]; +} +impl From> for Stmt { + fn from(payload: StmtRaise) -> Self { + Stmt::Raise(payload) + } +} +impl From> for Ast { + fn from(payload: StmtRaise) -> Self { + Stmt::from(payload).into() + } +} + +/// See also [Try](https://docs.python.org/3/library/ast.html#ast.Try) +#[derive(Clone, Debug, PartialEq)] +pub struct StmtTry { + pub range: R, + pub body: Vec>, + pub handlers: Vec>, + pub orelse: Vec>, + pub finalbody: Vec>, +} + +impl Node for StmtTry { + const NAME: &'static str = "Try"; + const FIELD_NAMES: &'static [&'static str] = &["body", "handlers", "orelse", "finalbody"]; +} +impl From> for Stmt { + fn from(payload: StmtTry) -> Self { + Stmt::Try(payload) + } +} +impl From> for Ast { + fn from(payload: StmtTry) -> Self { + Stmt::from(payload).into() + } +} + +/// See also [TryStar](https://docs.python.org/3/library/ast.html#ast.TryStar) +#[derive(Clone, Debug, PartialEq)] +pub struct StmtTryStar { + pub range: R, + pub body: Vec>, + pub handlers: Vec>, + pub orelse: Vec>, + pub finalbody: Vec>, +} + +impl Node for StmtTryStar { + const NAME: &'static str = "TryStar"; + const FIELD_NAMES: &'static [&'static str] = &["body", "handlers", "orelse", "finalbody"]; +} +impl From> for Stmt { + fn from(payload: StmtTryStar) -> Self { + Stmt::TryStar(payload) + } +} +impl From> for Ast { + fn from(payload: StmtTryStar) -> Self { + Stmt::from(payload).into() + } +} + +/// See also [Assert](https://docs.python.org/3/library/ast.html#ast.Assert) +#[derive(Clone, Debug, PartialEq)] +pub struct StmtAssert { + pub range: R, + pub test: Box>, + pub msg: Option>>, +} + +impl Node for StmtAssert { + const NAME: &'static str = "Assert"; + const FIELD_NAMES: &'static [&'static str] = &["test", "msg"]; +} +impl From> for Stmt { + fn from(payload: StmtAssert) -> Self { + Stmt::Assert(payload) + } +} +impl From> for Ast { + fn from(payload: StmtAssert) -> Self { + Stmt::from(payload).into() + } +} + +/// See also [Import](https://docs.python.org/3/library/ast.html#ast.Import) +#[derive(Clone, Debug, PartialEq)] +pub struct StmtImport { + pub range: R, + pub names: Vec>, +} + +impl Node for StmtImport { + const NAME: &'static str = "Import"; + const FIELD_NAMES: &'static [&'static str] = &["names"]; +} +impl From> for Stmt { + fn from(payload: StmtImport) -> Self { + Stmt::Import(payload) + } +} +impl From> for Ast { + fn from(payload: StmtImport) -> Self { + Stmt::from(payload).into() + } +} + +/// See also [ImportFrom](https://docs.python.org/3/library/ast.html#ast.ImportFrom) +#[derive(Clone, Debug, PartialEq)] +pub struct StmtImportFrom { + pub range: R, + pub module: Option, + pub names: Vec>, + pub level: Option, +} + +impl Node for StmtImportFrom { + const NAME: &'static str = "ImportFrom"; + const FIELD_NAMES: &'static [&'static str] = &["module", "names", "level"]; +} +impl From> for Stmt { + fn from(payload: StmtImportFrom) -> Self { + Stmt::ImportFrom(payload) + } +} +impl From> for Ast { + fn from(payload: StmtImportFrom) -> Self { + Stmt::from(payload).into() + } +} + +/// See also [Global](https://docs.python.org/3/library/ast.html#ast.Global) +#[derive(Clone, Debug, PartialEq)] +pub struct StmtGlobal { + pub range: R, + pub names: Vec, +} + +impl Node for StmtGlobal { + const NAME: &'static str = "Global"; + const FIELD_NAMES: &'static [&'static str] = &["names"]; +} +impl From> for Stmt { + fn from(payload: StmtGlobal) -> Self { + Stmt::Global(payload) + } +} +impl From> for Ast { + fn from(payload: StmtGlobal) -> Self { + Stmt::from(payload).into() + } +} + +/// See also [Nonlocal](https://docs.python.org/3/library/ast.html#ast.Nonlocal) +#[derive(Clone, Debug, PartialEq)] +pub struct StmtNonlocal { + pub range: R, + pub names: Vec, +} + +impl Node for StmtNonlocal { + const NAME: &'static str = "Nonlocal"; + const FIELD_NAMES: &'static [&'static str] = &["names"]; +} +impl From> for Stmt { + fn from(payload: StmtNonlocal) -> Self { + Stmt::Nonlocal(payload) + } +} +impl From> for Ast { + fn from(payload: StmtNonlocal) -> Self { + Stmt::from(payload).into() + } +} + +/// See also [Expr](https://docs.python.org/3/library/ast.html#ast.Expr) +#[derive(Clone, Debug, PartialEq)] +pub struct StmtExpr { + pub range: R, + pub value: Box>, +} + +impl Node for StmtExpr { + const NAME: &'static str = "Expr"; + const FIELD_NAMES: &'static [&'static str] = &["value"]; +} +impl From> for Stmt { + fn from(payload: StmtExpr) -> Self { + Stmt::Expr(payload) + } +} +impl From> for Ast { + fn from(payload: StmtExpr) -> Self { + Stmt::from(payload).into() + } +} + +/// See also [Pass](https://docs.python.org/3/library/ast.html#ast.Pass) +#[derive(Clone, Debug, PartialEq)] +pub struct StmtPass { + pub range: R, +} + +impl Node for StmtPass { + const NAME: &'static str = "Pass"; + const FIELD_NAMES: &'static [&'static str] = &[]; +} +impl From> for Stmt { + fn from(payload: StmtPass) -> Self { + Stmt::Pass(payload) + } +} +impl From> for Ast { + fn from(payload: StmtPass) -> Self { + Stmt::from(payload).into() + } +} + +/// See also [Break](https://docs.python.org/3/library/ast.html#ast.Break) +#[derive(Clone, Debug, PartialEq)] +pub struct StmtBreak { + pub range: R, +} + +impl Node for StmtBreak { + const NAME: &'static str = "Break"; + const FIELD_NAMES: &'static [&'static str] = &[]; +} +impl From> for Stmt { + fn from(payload: StmtBreak) -> Self { + Stmt::Break(payload) + } +} +impl From> for Ast { + fn from(payload: StmtBreak) -> Self { + Stmt::from(payload).into() + } +} + +/// See also [Continue](https://docs.python.org/3/library/ast.html#ast.Continue) +#[derive(Clone, Debug, PartialEq)] +pub struct StmtContinue { + pub range: R, +} + +impl Node for StmtContinue { + const NAME: &'static str = "Continue"; + const FIELD_NAMES: &'static [&'static str] = &[]; +} +impl From> for Stmt { + fn from(payload: StmtContinue) -> Self { + Stmt::Continue(payload) + } +} +impl From> for Ast { + fn from(payload: StmtContinue) -> Self { + Stmt::from(payload).into() + } +} + impl Node for Stmt { const NAME: &'static str = "stmt"; const FIELD_NAMES: &'static [&'static str] = &[]; } -#[derive(Clone, Debug, PartialEq)] -pub struct ExprBoolOp { - pub range: R, - pub op: BoolOp, - pub values: Vec>, -} - -impl Node for ExprBoolOp { - const NAME: &'static str = "BoolOp"; - const FIELD_NAMES: &'static [&'static str] = &["op", "values"]; -} -impl From> for Expr { - fn from(payload: ExprBoolOp) -> Self { - Expr::BoolOp(payload) - } -} -impl From> for Ast { - fn from(payload: ExprBoolOp) -> Self { - Expr::from(payload).into() - } -} - -#[derive(Clone, Debug, PartialEq)] -pub struct ExprNamedExpr { - pub range: R, - pub target: Box>, - pub value: Box>, -} - -impl Node for ExprNamedExpr { - const NAME: &'static str = "NamedExpr"; - const FIELD_NAMES: &'static [&'static str] = &["target", "value"]; -} -impl From> for Expr { - fn from(payload: ExprNamedExpr) -> Self { - Expr::NamedExpr(payload) - } -} -impl From> for Ast { - fn from(payload: ExprNamedExpr) -> Self { - Expr::from(payload).into() - } -} - -#[derive(Clone, Debug, PartialEq)] -pub struct ExprBinOp { - pub range: R, - pub left: Box>, - pub op: Operator, - pub right: Box>, -} - -impl Node for ExprBinOp { - const NAME: &'static str = "BinOp"; - const FIELD_NAMES: &'static [&'static str] = &["left", "op", "right"]; -} -impl From> for Expr { - fn from(payload: ExprBinOp) -> Self { - Expr::BinOp(payload) - } -} -impl From> for Ast { - fn from(payload: ExprBinOp) -> Self { - Expr::from(payload).into() - } -} - -#[derive(Clone, Debug, PartialEq)] -pub struct ExprUnaryOp { - pub range: R, - pub op: UnaryOp, - pub operand: Box>, -} - -impl Node for ExprUnaryOp { - const NAME: &'static str = "UnaryOp"; - const FIELD_NAMES: &'static [&'static str] = &["op", "operand"]; -} -impl From> for Expr { - fn from(payload: ExprUnaryOp) -> Self { - Expr::UnaryOp(payload) - } -} -impl From> for Ast { - fn from(payload: ExprUnaryOp) -> Self { - Expr::from(payload).into() - } -} - -#[derive(Clone, Debug, PartialEq)] -pub struct ExprLambda { - pub range: R, - pub args: Box>, - pub body: Box>, -} - -impl Node for ExprLambda { - const NAME: &'static str = "Lambda"; - const FIELD_NAMES: &'static [&'static str] = &["args", "body"]; -} -impl From> for Expr { - fn from(payload: ExprLambda) -> Self { - Expr::Lambda(payload) - } -} -impl From> for Ast { - fn from(payload: ExprLambda) -> Self { - Expr::from(payload).into() - } -} - -#[derive(Clone, Debug, PartialEq)] -pub struct ExprIfExp { - pub range: R, - pub test: Box>, - pub body: Box>, - pub orelse: Box>, -} - -impl Node for ExprIfExp { - const NAME: &'static str = "IfExp"; - const FIELD_NAMES: &'static [&'static str] = &["test", "body", "orelse"]; -} -impl From> for Expr { - fn from(payload: ExprIfExp) -> Self { - Expr::IfExp(payload) - } -} -impl From> for Ast { - fn from(payload: ExprIfExp) -> Self { - Expr::from(payload).into() - } -} - -#[derive(Clone, Debug, PartialEq)] -pub struct ExprDict { - pub range: R, - pub keys: Vec>>, - pub values: Vec>, -} - -impl Node for ExprDict { - const NAME: &'static str = "Dict"; - const FIELD_NAMES: &'static [&'static str] = &["keys", "values"]; -} -impl From> for Expr { - fn from(payload: ExprDict) -> Self { - Expr::Dict(payload) - } -} -impl From> for Ast { - fn from(payload: ExprDict) -> Self { - Expr::from(payload).into() - } -} - -#[derive(Clone, Debug, PartialEq)] -pub struct ExprSet { - pub range: R, - pub elts: Vec>, -} - -impl Node for ExprSet { - const NAME: &'static str = "Set"; - const FIELD_NAMES: &'static [&'static str] = &["elts"]; -} -impl From> for Expr { - fn from(payload: ExprSet) -> Self { - Expr::Set(payload) - } -} -impl From> for Ast { - fn from(payload: ExprSet) -> Self { - Expr::from(payload).into() - } -} - -#[derive(Clone, Debug, PartialEq)] -pub struct ExprListComp { - pub range: R, - pub elt: Box>, - pub generators: Vec>, -} - -impl Node for ExprListComp { - const NAME: &'static str = "ListComp"; - const FIELD_NAMES: &'static [&'static str] = &["elt", "generators"]; -} -impl From> for Expr { - fn from(payload: ExprListComp) -> Self { - Expr::ListComp(payload) - } -} -impl From> for Ast { - fn from(payload: ExprListComp) -> Self { - Expr::from(payload).into() - } -} - -#[derive(Clone, Debug, PartialEq)] -pub struct ExprSetComp { - pub range: R, - pub elt: Box>, - pub generators: Vec>, -} - -impl Node for ExprSetComp { - const NAME: &'static str = "SetComp"; - const FIELD_NAMES: &'static [&'static str] = &["elt", "generators"]; -} -impl From> for Expr { - fn from(payload: ExprSetComp) -> Self { - Expr::SetComp(payload) - } -} -impl From> for Ast { - fn from(payload: ExprSetComp) -> Self { - Expr::from(payload).into() - } -} - -#[derive(Clone, Debug, PartialEq)] -pub struct ExprDictComp { - pub range: R, - pub key: Box>, - pub value: Box>, - pub generators: Vec>, -} - -impl Node for ExprDictComp { - const NAME: &'static str = "DictComp"; - const FIELD_NAMES: &'static [&'static str] = &["key", "value", "generators"]; -} -impl From> for Expr { - fn from(payload: ExprDictComp) -> Self { - Expr::DictComp(payload) - } -} -impl From> for Ast { - fn from(payload: ExprDictComp) -> Self { - Expr::from(payload).into() - } -} - -#[derive(Clone, Debug, PartialEq)] -pub struct ExprGeneratorExp { - pub range: R, - pub elt: Box>, - pub generators: Vec>, -} - -impl Node for ExprGeneratorExp { - const NAME: &'static str = "GeneratorExp"; - const FIELD_NAMES: &'static [&'static str] = &["elt", "generators"]; -} -impl From> for Expr { - fn from(payload: ExprGeneratorExp) -> Self { - Expr::GeneratorExp(payload) - } -} -impl From> for Ast { - fn from(payload: ExprGeneratorExp) -> Self { - Expr::from(payload).into() - } -} - -#[derive(Clone, Debug, PartialEq)] -pub struct ExprAwait { - pub range: R, - pub value: Box>, -} - -impl Node for ExprAwait { - const NAME: &'static str = "Await"; - const FIELD_NAMES: &'static [&'static str] = &["value"]; -} -impl From> for Expr { - fn from(payload: ExprAwait) -> Self { - Expr::Await(payload) - } -} -impl From> for Ast { - fn from(payload: ExprAwait) -> Self { - Expr::from(payload).into() - } -} - -#[derive(Clone, Debug, PartialEq)] -pub struct ExprYield { - pub range: R, - pub value: Option>>, -} - -impl Node for ExprYield { - const NAME: &'static str = "Yield"; - const FIELD_NAMES: &'static [&'static str] = &["value"]; -} -impl From> for Expr { - fn from(payload: ExprYield) -> Self { - Expr::Yield(payload) - } -} -impl From> for Ast { - fn from(payload: ExprYield) -> Self { - Expr::from(payload).into() - } -} - -#[derive(Clone, Debug, PartialEq)] -pub struct ExprYieldFrom { - pub range: R, - pub value: Box>, -} - -impl Node for ExprYieldFrom { - const NAME: &'static str = "YieldFrom"; - const FIELD_NAMES: &'static [&'static str] = &["value"]; -} -impl From> for Expr { - fn from(payload: ExprYieldFrom) -> Self { - Expr::YieldFrom(payload) - } -} -impl From> for Ast { - fn from(payload: ExprYieldFrom) -> Self { - Expr::from(payload).into() - } -} - -#[derive(Clone, Debug, PartialEq)] -pub struct ExprCompare { - pub range: R, - pub left: Box>, - pub ops: Vec, - pub comparators: Vec>, -} - -impl Node for ExprCompare { - const NAME: &'static str = "Compare"; - const FIELD_NAMES: &'static [&'static str] = &["left", "ops", "comparators"]; -} -impl From> for Expr { - fn from(payload: ExprCompare) -> Self { - Expr::Compare(payload) - } -} -impl From> for Ast { - fn from(payload: ExprCompare) -> Self { - Expr::from(payload).into() - } -} - -#[derive(Clone, Debug, PartialEq)] -pub struct ExprCall { - pub range: R, - pub func: Box>, - pub args: Vec>, - pub keywords: Vec>, -} - -impl Node for ExprCall { - const NAME: &'static str = "Call"; - const FIELD_NAMES: &'static [&'static str] = &["func", "args", "keywords"]; -} -impl From> for Expr { - fn from(payload: ExprCall) -> Self { - Expr::Call(payload) - } -} -impl From> for Ast { - fn from(payload: ExprCall) -> Self { - Expr::from(payload).into() - } -} - -#[derive(Clone, Debug, PartialEq)] -pub struct ExprFormattedValue { - pub range: R, - pub value: Box>, - pub conversion: ConversionFlag, - pub format_spec: Option>>, -} - -impl Node for ExprFormattedValue { - const NAME: &'static str = "FormattedValue"; - const FIELD_NAMES: &'static [&'static str] = &["value", "conversion", "format_spec"]; -} -impl From> for Expr { - fn from(payload: ExprFormattedValue) -> Self { - Expr::FormattedValue(payload) - } -} -impl From> for Ast { - fn from(payload: ExprFormattedValue) -> Self { - Expr::from(payload).into() - } -} - -#[derive(Clone, Debug, PartialEq)] -pub struct ExprJoinedStr { - pub range: R, - pub values: Vec>, -} - -impl Node for ExprJoinedStr { - const NAME: &'static str = "JoinedStr"; - const FIELD_NAMES: &'static [&'static str] = &["values"]; -} -impl From> for Expr { - fn from(payload: ExprJoinedStr) -> Self { - Expr::JoinedStr(payload) - } -} -impl From> for Ast { - fn from(payload: ExprJoinedStr) -> Self { - Expr::from(payload).into() - } -} - -#[derive(Clone, Debug, PartialEq)] -pub struct ExprConstant { - pub range: R, - pub value: Constant, - pub kind: Option, -} - -impl Node for ExprConstant { - const NAME: &'static str = "Constant"; - const FIELD_NAMES: &'static [&'static str] = &["value", "kind"]; -} -impl From> for Expr { - fn from(payload: ExprConstant) -> Self { - Expr::Constant(payload) - } -} -impl From> for Ast { - fn from(payload: ExprConstant) -> Self { - Expr::from(payload).into() - } -} - -#[derive(Clone, Debug, PartialEq)] -pub struct ExprAttribute { - pub range: R, - pub value: Box>, - pub attr: Identifier, - pub ctx: ExprContext, -} - -impl Node for ExprAttribute { - const NAME: &'static str = "Attribute"; - const FIELD_NAMES: &'static [&'static str] = &["value", "attr", "ctx"]; -} -impl From> for Expr { - fn from(payload: ExprAttribute) -> Self { - Expr::Attribute(payload) - } -} -impl From> for Ast { - fn from(payload: ExprAttribute) -> Self { - Expr::from(payload).into() - } -} - -#[derive(Clone, Debug, PartialEq)] -pub struct ExprSubscript { - pub range: R, - pub value: Box>, - pub slice: Box>, - pub ctx: ExprContext, -} - -impl Node for ExprSubscript { - const NAME: &'static str = "Subscript"; - const FIELD_NAMES: &'static [&'static str] = &["value", "slice", "ctx"]; -} -impl From> for Expr { - fn from(payload: ExprSubscript) -> Self { - Expr::Subscript(payload) - } -} -impl From> for Ast { - fn from(payload: ExprSubscript) -> Self { - Expr::from(payload).into() - } -} - -#[derive(Clone, Debug, PartialEq)] -pub struct ExprStarred { - pub range: R, - pub value: Box>, - pub ctx: ExprContext, -} - -impl Node for ExprStarred { - const NAME: &'static str = "Starred"; - const FIELD_NAMES: &'static [&'static str] = &["value", "ctx"]; -} -impl From> for Expr { - fn from(payload: ExprStarred) -> Self { - Expr::Starred(payload) - } -} -impl From> for Ast { - fn from(payload: ExprStarred) -> Self { - Expr::from(payload).into() - } -} - -#[derive(Clone, Debug, PartialEq)] -pub struct ExprName { - pub range: R, - pub id: Identifier, - pub ctx: ExprContext, -} - -impl Node for ExprName { - const NAME: &'static str = "Name"; - const FIELD_NAMES: &'static [&'static str] = &["id", "ctx"]; -} -impl From> for Expr { - fn from(payload: ExprName) -> Self { - Expr::Name(payload) - } -} -impl From> for Ast { - fn from(payload: ExprName) -> Self { - Expr::from(payload).into() - } -} - -#[derive(Clone, Debug, PartialEq)] -pub struct ExprList { - pub range: R, - pub elts: Vec>, - pub ctx: ExprContext, -} - -impl Node for ExprList { - const NAME: &'static str = "List"; - const FIELD_NAMES: &'static [&'static str] = &["elts", "ctx"]; -} -impl From> for Expr { - fn from(payload: ExprList) -> Self { - Expr::List(payload) - } -} -impl From> for Ast { - fn from(payload: ExprList) -> Self { - Expr::from(payload).into() - } -} - -#[derive(Clone, Debug, PartialEq)] -pub struct ExprTuple { - pub range: R, - pub elts: Vec>, - pub ctx: ExprContext, -} - -impl Node for ExprTuple { - const NAME: &'static str = "Tuple"; - const FIELD_NAMES: &'static [&'static str] = &["elts", "ctx"]; -} -impl From> for Expr { - fn from(payload: ExprTuple) -> Self { - Expr::Tuple(payload) - } -} -impl From> for Ast { - fn from(payload: ExprTuple) -> Self { - Expr::from(payload).into() - } -} - -#[derive(Clone, Debug, PartialEq)] -pub struct ExprSlice { - pub range: R, - pub lower: Option>>, - pub upper: Option>>, - pub step: Option>>, -} - -impl Node for ExprSlice { - const NAME: &'static str = "Slice"; - const FIELD_NAMES: &'static [&'static str] = &["lower", "upper", "step"]; -} -impl From> for Expr { - fn from(payload: ExprSlice) -> Self { - Expr::Slice(payload) - } -} -impl From> for Ast { - fn from(payload: ExprSlice) -> Self { - Expr::from(payload).into() - } -} - +/// See also [expr](https://docs.python.org/3/library/ast.html#ast.expr) #[derive(Clone, Debug, PartialEq, is_macro::Is)] pub enum Expr { #[is(name = "bool_op_expr")] @@ -1584,11 +1020,637 @@ pub enum Expr { Slice(ExprSlice), } +/// See also [BoolOp](https://docs.python.org/3/library/ast.html#ast.BoolOp) +#[derive(Clone, Debug, PartialEq)] +pub struct ExprBoolOp { + pub range: R, + pub op: BoolOp, + pub values: Vec>, +} + +impl Node for ExprBoolOp { + const NAME: &'static str = "BoolOp"; + const FIELD_NAMES: &'static [&'static str] = &["op", "values"]; +} +impl From> for Expr { + fn from(payload: ExprBoolOp) -> Self { + Expr::BoolOp(payload) + } +} +impl From> for Ast { + fn from(payload: ExprBoolOp) -> Self { + Expr::from(payload).into() + } +} + +/// See also [NamedExpr](https://docs.python.org/3/library/ast.html#ast.NamedExpr) +#[derive(Clone, Debug, PartialEq)] +pub struct ExprNamedExpr { + pub range: R, + pub target: Box>, + pub value: Box>, +} + +impl Node for ExprNamedExpr { + const NAME: &'static str = "NamedExpr"; + const FIELD_NAMES: &'static [&'static str] = &["target", "value"]; +} +impl From> for Expr { + fn from(payload: ExprNamedExpr) -> Self { + Expr::NamedExpr(payload) + } +} +impl From> for Ast { + fn from(payload: ExprNamedExpr) -> Self { + Expr::from(payload).into() + } +} + +/// See also [BinOp](https://docs.python.org/3/library/ast.html#ast.BinOp) +#[derive(Clone, Debug, PartialEq)] +pub struct ExprBinOp { + pub range: R, + pub left: Box>, + pub op: Operator, + pub right: Box>, +} + +impl Node for ExprBinOp { + const NAME: &'static str = "BinOp"; + const FIELD_NAMES: &'static [&'static str] = &["left", "op", "right"]; +} +impl From> for Expr { + fn from(payload: ExprBinOp) -> Self { + Expr::BinOp(payload) + } +} +impl From> for Ast { + fn from(payload: ExprBinOp) -> Self { + Expr::from(payload).into() + } +} + +/// See also [UnaryOp](https://docs.python.org/3/library/ast.html#ast.UnaryOp) +#[derive(Clone, Debug, PartialEq)] +pub struct ExprUnaryOp { + pub range: R, + pub op: UnaryOp, + pub operand: Box>, +} + +impl Node for ExprUnaryOp { + const NAME: &'static str = "UnaryOp"; + const FIELD_NAMES: &'static [&'static str] = &["op", "operand"]; +} +impl From> for Expr { + fn from(payload: ExprUnaryOp) -> Self { + Expr::UnaryOp(payload) + } +} +impl From> for Ast { + fn from(payload: ExprUnaryOp) -> Self { + Expr::from(payload).into() + } +} + +/// See also [Lambda](https://docs.python.org/3/library/ast.html#ast.Lambda) +#[derive(Clone, Debug, PartialEq)] +pub struct ExprLambda { + pub range: R, + pub args: Box>, + pub body: Box>, +} + +impl Node for ExprLambda { + const NAME: &'static str = "Lambda"; + const FIELD_NAMES: &'static [&'static str] = &["args", "body"]; +} +impl From> for Expr { + fn from(payload: ExprLambda) -> Self { + Expr::Lambda(payload) + } +} +impl From> for Ast { + fn from(payload: ExprLambda) -> Self { + Expr::from(payload).into() + } +} + +/// See also [IfExp](https://docs.python.org/3/library/ast.html#ast.IfExp) +#[derive(Clone, Debug, PartialEq)] +pub struct ExprIfExp { + pub range: R, + pub test: Box>, + pub body: Box>, + pub orelse: Box>, +} + +impl Node for ExprIfExp { + const NAME: &'static str = "IfExp"; + const FIELD_NAMES: &'static [&'static str] = &["test", "body", "orelse"]; +} +impl From> for Expr { + fn from(payload: ExprIfExp) -> Self { + Expr::IfExp(payload) + } +} +impl From> for Ast { + fn from(payload: ExprIfExp) -> Self { + Expr::from(payload).into() + } +} + +/// See also [Dict](https://docs.python.org/3/library/ast.html#ast.Dict) +#[derive(Clone, Debug, PartialEq)] +pub struct ExprDict { + pub range: R, + pub keys: Vec>>, + pub values: Vec>, +} + +impl Node for ExprDict { + const NAME: &'static str = "Dict"; + const FIELD_NAMES: &'static [&'static str] = &["keys", "values"]; +} +impl From> for Expr { + fn from(payload: ExprDict) -> Self { + Expr::Dict(payload) + } +} +impl From> for Ast { + fn from(payload: ExprDict) -> Self { + Expr::from(payload).into() + } +} + +/// See also [Set](https://docs.python.org/3/library/ast.html#ast.Set) +#[derive(Clone, Debug, PartialEq)] +pub struct ExprSet { + pub range: R, + pub elts: Vec>, +} + +impl Node for ExprSet { + const NAME: &'static str = "Set"; + const FIELD_NAMES: &'static [&'static str] = &["elts"]; +} +impl From> for Expr { + fn from(payload: ExprSet) -> Self { + Expr::Set(payload) + } +} +impl From> for Ast { + fn from(payload: ExprSet) -> Self { + Expr::from(payload).into() + } +} + +/// See also [ListComp](https://docs.python.org/3/library/ast.html#ast.ListComp) +#[derive(Clone, Debug, PartialEq)] +pub struct ExprListComp { + pub range: R, + pub elt: Box>, + pub generators: Vec>, +} + +impl Node for ExprListComp { + const NAME: &'static str = "ListComp"; + const FIELD_NAMES: &'static [&'static str] = &["elt", "generators"]; +} +impl From> for Expr { + fn from(payload: ExprListComp) -> Self { + Expr::ListComp(payload) + } +} +impl From> for Ast { + fn from(payload: ExprListComp) -> Self { + Expr::from(payload).into() + } +} + +/// See also [SetComp](https://docs.python.org/3/library/ast.html#ast.SetComp) +#[derive(Clone, Debug, PartialEq)] +pub struct ExprSetComp { + pub range: R, + pub elt: Box>, + pub generators: Vec>, +} + +impl Node for ExprSetComp { + const NAME: &'static str = "SetComp"; + const FIELD_NAMES: &'static [&'static str] = &["elt", "generators"]; +} +impl From> for Expr { + fn from(payload: ExprSetComp) -> Self { + Expr::SetComp(payload) + } +} +impl From> for Ast { + fn from(payload: ExprSetComp) -> Self { + Expr::from(payload).into() + } +} + +/// See also [DictComp](https://docs.python.org/3/library/ast.html#ast.DictComp) +#[derive(Clone, Debug, PartialEq)] +pub struct ExprDictComp { + pub range: R, + pub key: Box>, + pub value: Box>, + pub generators: Vec>, +} + +impl Node for ExprDictComp { + const NAME: &'static str = "DictComp"; + const FIELD_NAMES: &'static [&'static str] = &["key", "value", "generators"]; +} +impl From> for Expr { + fn from(payload: ExprDictComp) -> Self { + Expr::DictComp(payload) + } +} +impl From> for Ast { + fn from(payload: ExprDictComp) -> Self { + Expr::from(payload).into() + } +} + +/// See also [GeneratorExp](https://docs.python.org/3/library/ast.html#ast.GeneratorExp) +#[derive(Clone, Debug, PartialEq)] +pub struct ExprGeneratorExp { + pub range: R, + pub elt: Box>, + pub generators: Vec>, +} + +impl Node for ExprGeneratorExp { + const NAME: &'static str = "GeneratorExp"; + const FIELD_NAMES: &'static [&'static str] = &["elt", "generators"]; +} +impl From> for Expr { + fn from(payload: ExprGeneratorExp) -> Self { + Expr::GeneratorExp(payload) + } +} +impl From> for Ast { + fn from(payload: ExprGeneratorExp) -> Self { + Expr::from(payload).into() + } +} + +/// See also [Await](https://docs.python.org/3/library/ast.html#ast.Await) +#[derive(Clone, Debug, PartialEq)] +pub struct ExprAwait { + pub range: R, + pub value: Box>, +} + +impl Node for ExprAwait { + const NAME: &'static str = "Await"; + const FIELD_NAMES: &'static [&'static str] = &["value"]; +} +impl From> for Expr { + fn from(payload: ExprAwait) -> Self { + Expr::Await(payload) + } +} +impl From> for Ast { + fn from(payload: ExprAwait) -> Self { + Expr::from(payload).into() + } +} + +/// See also [Yield](https://docs.python.org/3/library/ast.html#ast.Yield) +#[derive(Clone, Debug, PartialEq)] +pub struct ExprYield { + pub range: R, + pub value: Option>>, +} + +impl Node for ExprYield { + const NAME: &'static str = "Yield"; + const FIELD_NAMES: &'static [&'static str] = &["value"]; +} +impl From> for Expr { + fn from(payload: ExprYield) -> Self { + Expr::Yield(payload) + } +} +impl From> for Ast { + fn from(payload: ExprYield) -> Self { + Expr::from(payload).into() + } +} + +/// See also [YieldFrom](https://docs.python.org/3/library/ast.html#ast.YieldFrom) +#[derive(Clone, Debug, PartialEq)] +pub struct ExprYieldFrom { + pub range: R, + pub value: Box>, +} + +impl Node for ExprYieldFrom { + const NAME: &'static str = "YieldFrom"; + const FIELD_NAMES: &'static [&'static str] = &["value"]; +} +impl From> for Expr { + fn from(payload: ExprYieldFrom) -> Self { + Expr::YieldFrom(payload) + } +} +impl From> for Ast { + fn from(payload: ExprYieldFrom) -> Self { + Expr::from(payload).into() + } +} + +/// See also [Compare](https://docs.python.org/3/library/ast.html#ast.Compare) +#[derive(Clone, Debug, PartialEq)] +pub struct ExprCompare { + pub range: R, + pub left: Box>, + pub ops: Vec, + pub comparators: Vec>, +} + +impl Node for ExprCompare { + const NAME: &'static str = "Compare"; + const FIELD_NAMES: &'static [&'static str] = &["left", "ops", "comparators"]; +} +impl From> for Expr { + fn from(payload: ExprCompare) -> Self { + Expr::Compare(payload) + } +} +impl From> for Ast { + fn from(payload: ExprCompare) -> Self { + Expr::from(payload).into() + } +} + +/// See also [Call](https://docs.python.org/3/library/ast.html#ast.Call) +#[derive(Clone, Debug, PartialEq)] +pub struct ExprCall { + pub range: R, + pub func: Box>, + pub args: Vec>, + pub keywords: Vec>, +} + +impl Node for ExprCall { + const NAME: &'static str = "Call"; + const FIELD_NAMES: &'static [&'static str] = &["func", "args", "keywords"]; +} +impl From> for Expr { + fn from(payload: ExprCall) -> Self { + Expr::Call(payload) + } +} +impl From> for Ast { + fn from(payload: ExprCall) -> Self { + Expr::from(payload).into() + } +} + +/// See also [FormattedValue](https://docs.python.org/3/library/ast.html#ast.FormattedValue) +#[derive(Clone, Debug, PartialEq)] +pub struct ExprFormattedValue { + pub range: R, + pub value: Box>, + pub conversion: ConversionFlag, + pub format_spec: Option>>, +} + +impl Node for ExprFormattedValue { + const NAME: &'static str = "FormattedValue"; + const FIELD_NAMES: &'static [&'static str] = &["value", "conversion", "format_spec"]; +} +impl From> for Expr { + fn from(payload: ExprFormattedValue) -> Self { + Expr::FormattedValue(payload) + } +} +impl From> for Ast { + fn from(payload: ExprFormattedValue) -> Self { + Expr::from(payload).into() + } +} + +/// See also [JoinedStr](https://docs.python.org/3/library/ast.html#ast.JoinedStr) +#[derive(Clone, Debug, PartialEq)] +pub struct ExprJoinedStr { + pub range: R, + pub values: Vec>, +} + +impl Node for ExprJoinedStr { + const NAME: &'static str = "JoinedStr"; + const FIELD_NAMES: &'static [&'static str] = &["values"]; +} +impl From> for Expr { + fn from(payload: ExprJoinedStr) -> Self { + Expr::JoinedStr(payload) + } +} +impl From> for Ast { + fn from(payload: ExprJoinedStr) -> Self { + Expr::from(payload).into() + } +} + +/// See also [Constant](https://docs.python.org/3/library/ast.html#ast.Constant) +#[derive(Clone, Debug, PartialEq)] +pub struct ExprConstant { + pub range: R, + pub value: Constant, + pub kind: Option, +} + +impl Node for ExprConstant { + const NAME: &'static str = "Constant"; + const FIELD_NAMES: &'static [&'static str] = &["value", "kind"]; +} +impl From> for Expr { + fn from(payload: ExprConstant) -> Self { + Expr::Constant(payload) + } +} +impl From> for Ast { + fn from(payload: ExprConstant) -> Self { + Expr::from(payload).into() + } +} + +/// See also [Attribute](https://docs.python.org/3/library/ast.html#ast.Attribute) +#[derive(Clone, Debug, PartialEq)] +pub struct ExprAttribute { + pub range: R, + pub value: Box>, + pub attr: Identifier, + pub ctx: ExprContext, +} + +impl Node for ExprAttribute { + const NAME: &'static str = "Attribute"; + const FIELD_NAMES: &'static [&'static str] = &["value", "attr", "ctx"]; +} +impl From> for Expr { + fn from(payload: ExprAttribute) -> Self { + Expr::Attribute(payload) + } +} +impl From> for Ast { + fn from(payload: ExprAttribute) -> Self { + Expr::from(payload).into() + } +} + +/// See also [Subscript](https://docs.python.org/3/library/ast.html#ast.Subscript) +#[derive(Clone, Debug, PartialEq)] +pub struct ExprSubscript { + pub range: R, + pub value: Box>, + pub slice: Box>, + pub ctx: ExprContext, +} + +impl Node for ExprSubscript { + const NAME: &'static str = "Subscript"; + const FIELD_NAMES: &'static [&'static str] = &["value", "slice", "ctx"]; +} +impl From> for Expr { + fn from(payload: ExprSubscript) -> Self { + Expr::Subscript(payload) + } +} +impl From> for Ast { + fn from(payload: ExprSubscript) -> Self { + Expr::from(payload).into() + } +} + +/// See also [Starred](https://docs.python.org/3/library/ast.html#ast.Starred) +#[derive(Clone, Debug, PartialEq)] +pub struct ExprStarred { + pub range: R, + pub value: Box>, + pub ctx: ExprContext, +} + +impl Node for ExprStarred { + const NAME: &'static str = "Starred"; + const FIELD_NAMES: &'static [&'static str] = &["value", "ctx"]; +} +impl From> for Expr { + fn from(payload: ExprStarred) -> Self { + Expr::Starred(payload) + } +} +impl From> for Ast { + fn from(payload: ExprStarred) -> Self { + Expr::from(payload).into() + } +} + +/// See also [Name](https://docs.python.org/3/library/ast.html#ast.Name) +#[derive(Clone, Debug, PartialEq)] +pub struct ExprName { + pub range: R, + pub id: Identifier, + pub ctx: ExprContext, +} + +impl Node for ExprName { + const NAME: &'static str = "Name"; + const FIELD_NAMES: &'static [&'static str] = &["id", "ctx"]; +} +impl From> for Expr { + fn from(payload: ExprName) -> Self { + Expr::Name(payload) + } +} +impl From> for Ast { + fn from(payload: ExprName) -> Self { + Expr::from(payload).into() + } +} + +/// See also [List](https://docs.python.org/3/library/ast.html#ast.List) +#[derive(Clone, Debug, PartialEq)] +pub struct ExprList { + pub range: R, + pub elts: Vec>, + pub ctx: ExprContext, +} + +impl Node for ExprList { + const NAME: &'static str = "List"; + const FIELD_NAMES: &'static [&'static str] = &["elts", "ctx"]; +} +impl From> for Expr { + fn from(payload: ExprList) -> Self { + Expr::List(payload) + } +} +impl From> for Ast { + fn from(payload: ExprList) -> Self { + Expr::from(payload).into() + } +} + +/// See also [Tuple](https://docs.python.org/3/library/ast.html#ast.Tuple) +#[derive(Clone, Debug, PartialEq)] +pub struct ExprTuple { + pub range: R, + pub elts: Vec>, + pub ctx: ExprContext, +} + +impl Node for ExprTuple { + const NAME: &'static str = "Tuple"; + const FIELD_NAMES: &'static [&'static str] = &["elts", "ctx"]; +} +impl From> for Expr { + fn from(payload: ExprTuple) -> Self { + Expr::Tuple(payload) + } +} +impl From> for Ast { + fn from(payload: ExprTuple) -> Self { + Expr::from(payload).into() + } +} + +/// See also [Slice](https://docs.python.org/3/library/ast.html#ast.Slice) +#[derive(Clone, Debug, PartialEq)] +pub struct ExprSlice { + pub range: R, + pub lower: Option>>, + pub upper: Option>>, + pub step: Option>>, +} + +impl Node for ExprSlice { + const NAME: &'static str = "Slice"; + const FIELD_NAMES: &'static [&'static str] = &["lower", "upper", "step"]; +} +impl From> for Expr { + fn from(payload: ExprSlice) -> Self { + Expr::Slice(payload) + } +} +impl From> for Ast { + fn from(payload: ExprSlice) -> Self { + Expr::from(payload).into() + } +} + impl Node for Expr { const NAME: &'static str = "expr"; const FIELD_NAMES: &'static [&'static str] = &[]; } +/// See also [expr_context](https://docs.python.org/3/library/ast.html#ast.expr_context) #[derive(Clone, Debug, PartialEq, is_macro::Is, Copy, Hash, Eq)] pub enum ExprContext { Load, @@ -1692,6 +1754,7 @@ impl Node for ExprContext { const FIELD_NAMES: &'static [&'static str] = &[]; } +/// See also [boolop](https://docs.python.org/3/library/ast.html#ast.boolop) #[derive(Clone, Debug, PartialEq, is_macro::Is, Copy, Hash, Eq)] pub enum BoolOp { And, @@ -1764,6 +1827,7 @@ impl Node for BoolOp { const FIELD_NAMES: &'static [&'static str] = &[]; } +/// See also [operator](https://docs.python.org/3/library/ast.html#ast.operator) #[derive(Clone, Debug, PartialEq, is_macro::Is, Copy, Hash, Eq)] pub enum Operator { Add, @@ -2177,6 +2241,7 @@ impl Node for Operator { const FIELD_NAMES: &'static [&'static str] = &[]; } +/// See also [unaryop](https://docs.python.org/3/library/ast.html#ast.unaryop) #[derive(Clone, Debug, PartialEq, is_macro::Is, Copy, Hash, Eq)] pub enum UnaryOp { Invert, @@ -2311,6 +2376,7 @@ impl Node for UnaryOp { const FIELD_NAMES: &'static [&'static str] = &[]; } +/// See also [cmpop](https://docs.python.org/3/library/ast.html#ast.cmpop) #[derive(Clone, Debug, PartialEq, is_macro::Is, Copy, Hash, Eq)] pub enum CmpOp { Eq, @@ -2631,6 +2697,7 @@ impl Node for CmpOp { const FIELD_NAMES: &'static [&'static str] = &[]; } +/// See also [comprehension](https://docs.python.org/3/library/ast.html#ast.comprehension) #[derive(Clone, Debug, PartialEq)] pub struct Comprehension { pub range: OptionalRange, @@ -2645,6 +2712,13 @@ impl Node for Comprehension { const FIELD_NAMES: &'static [&'static str] = &["target", "iter", "ifs", "is_async"]; } +/// See also [excepthandler](https://docs.python.org/3/library/ast.html#ast.excepthandler) +#[derive(Clone, Debug, PartialEq, is_macro::Is)] +pub enum ExceptHandler { + ExceptHandler(ExceptHandlerExceptHandler), +} + +/// See also [ExceptHandler](https://docs.python.org/3/library/ast.html#ast.ExceptHandler) #[derive(Clone, Debug, PartialEq)] pub struct ExceptHandlerExceptHandler { pub range: R, @@ -2668,16 +2742,12 @@ impl From> for Ast { } } -#[derive(Clone, Debug, PartialEq, is_macro::Is)] -pub enum ExceptHandler { - ExceptHandler(ExceptHandlerExceptHandler), -} - impl Node for ExceptHandler { const NAME: &'static str = "excepthandler"; const FIELD_NAMES: &'static [&'static str] = &[]; } +/// See also [arguments](https://docs.python.org/3/library/ast.html#ast.arguments) #[derive(Clone, Debug, PartialEq)] pub struct PythonArguments { pub range: OptionalRange, @@ -2703,6 +2773,7 @@ impl Node for PythonArguments { ]; } +/// See also [arg](https://docs.python.org/3/library/ast.html#ast.arg) #[derive(Clone, Debug, PartialEq)] pub struct Arg { pub range: R, @@ -2716,6 +2787,7 @@ impl Node for Arg { const FIELD_NAMES: &'static [&'static str] = &["arg", "annotation", "type_comment"]; } +/// See also [keyword](https://docs.python.org/3/library/ast.html#ast.keyword) #[derive(Clone, Debug, PartialEq)] pub struct Keyword { pub range: R, @@ -2728,6 +2800,7 @@ impl Node for Keyword { const FIELD_NAMES: &'static [&'static str] = &["arg", "value"]; } +/// See also [alias](https://docs.python.org/3/library/ast.html#ast.alias) #[derive(Clone, Debug, PartialEq)] pub struct Alias { pub range: R, @@ -2740,6 +2813,7 @@ impl Node for Alias { const FIELD_NAMES: &'static [&'static str] = &["name", "asname"]; } +/// See also [withitem](https://docs.python.org/3/library/ast.html#ast.withitem) #[derive(Clone, Debug, PartialEq)] pub struct WithItem { pub range: OptionalRange, @@ -2752,6 +2826,7 @@ impl Node for WithItem { const FIELD_NAMES: &'static [&'static str] = &["context_expr", "optional_vars"]; } +/// See also [match_case](https://docs.python.org/3/library/ast.html#ast.match_case) #[derive(Clone, Debug, PartialEq)] pub struct MatchCase { pub range: OptionalRange, @@ -2765,6 +2840,20 @@ impl Node for MatchCase { const FIELD_NAMES: &'static [&'static str] = &["pattern", "guard", "body"]; } +/// See also [pattern](https://docs.python.org/3/library/ast.html#ast.pattern) +#[derive(Clone, Debug, PartialEq, is_macro::Is)] +pub enum Pattern { + MatchValue(PatternMatchValue), + MatchSingleton(PatternMatchSingleton), + MatchSequence(PatternMatchSequence), + MatchMapping(PatternMatchMapping), + MatchClass(PatternMatchClass), + MatchStar(PatternMatchStar), + MatchAs(PatternMatchAs), + MatchOr(PatternMatchOr), +} + +/// See also [MatchValue](https://docs.python.org/3/library/ast.html#ast.MatchValue) #[derive(Clone, Debug, PartialEq)] pub struct PatternMatchValue { pub range: R, @@ -2786,6 +2875,7 @@ impl From> for Ast { } } +/// See also [MatchSingleton](https://docs.python.org/3/library/ast.html#ast.MatchSingleton) #[derive(Clone, Debug, PartialEq)] pub struct PatternMatchSingleton { pub range: R, @@ -2807,6 +2897,7 @@ impl From> for Ast { } } +/// See also [MatchSequence](https://docs.python.org/3/library/ast.html#ast.MatchSequence) #[derive(Clone, Debug, PartialEq)] pub struct PatternMatchSequence { pub range: R, @@ -2828,6 +2919,7 @@ impl From> for Ast { } } +/// See also [MatchMapping](https://docs.python.org/3/library/ast.html#ast.MatchMapping) #[derive(Clone, Debug, PartialEq)] pub struct PatternMatchMapping { pub range: R, @@ -2851,6 +2943,7 @@ impl From> for Ast { } } +/// See also [MatchClass](https://docs.python.org/3/library/ast.html#ast.MatchClass) #[derive(Clone, Debug, PartialEq)] pub struct PatternMatchClass { pub range: R, @@ -2875,6 +2968,7 @@ impl From> for Ast { } } +/// See also [MatchStar](https://docs.python.org/3/library/ast.html#ast.MatchStar) #[derive(Clone, Debug, PartialEq)] pub struct PatternMatchStar { pub range: R, @@ -2896,6 +2990,7 @@ impl From> for Ast { } } +/// See also [MatchAs](https://docs.python.org/3/library/ast.html#ast.MatchAs) #[derive(Clone, Debug, PartialEq)] pub struct PatternMatchAs { pub range: R, @@ -2918,6 +3013,7 @@ impl From> for Ast { } } +/// See also [MatchOr](https://docs.python.org/3/library/ast.html#ast.MatchOr) #[derive(Clone, Debug, PartialEq)] pub struct PatternMatchOr { pub range: R, @@ -2939,23 +3035,18 @@ impl From> for Ast { } } -#[derive(Clone, Debug, PartialEq, is_macro::Is)] -pub enum Pattern { - MatchValue(PatternMatchValue), - MatchSingleton(PatternMatchSingleton), - MatchSequence(PatternMatchSequence), - MatchMapping(PatternMatchMapping), - MatchClass(PatternMatchClass), - MatchStar(PatternMatchStar), - MatchAs(PatternMatchAs), - MatchOr(PatternMatchOr), -} - impl Node for Pattern { const NAME: &'static str = "pattern"; const FIELD_NAMES: &'static [&'static str] = &[]; } +/// See also [type_ignore](https://docs.python.org/3/library/ast.html#ast.type_ignore) +#[derive(Clone, Debug, PartialEq, is_macro::Is)] +pub enum TypeIgnore { + TypeIgnore(TypeIgnoreTypeIgnore), +} + +/// See also [TypeIgnore](https://docs.python.org/3/library/ast.html#ast.TypeIgnore) #[derive(Clone, Debug, PartialEq)] pub struct TypeIgnoreTypeIgnore { pub range: OptionalRange, @@ -2978,11 +3069,6 @@ impl From> for Ast { } } -#[derive(Clone, Debug, PartialEq, is_macro::Is)] -pub enum TypeIgnore { - TypeIgnore(TypeIgnoreTypeIgnore), -} - impl Node for TypeIgnore { const NAME: &'static str = "type_ignore"; const FIELD_NAMES: &'static [&'static str] = &[]; diff --git a/ast/src/lib.rs b/ast/src/lib.rs index b55266c..4e5d371 100644 --- a/ast/src/lib.rs +++ b/ast/src/lib.rs @@ -6,6 +6,14 @@ //! //! [PythonArguments] is replaced by [Arguments]. The new [Arguments] type representation uses a new type //! [ArgWithDefault] to represent arguments with default values. See each type documentation for more details. +//! +//! A few top-level sum types are renamed to human friendly names. +//! [CmpOp] refers `cmpop` +//! [UnaryOp] refers `unaryop` +//! [BoolOp] refers `boolop` +//! [WithItem] refers `withitem` +//! [ExceptHandler] refers `excepthandler` +//! mod builtin; mod generic;