diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 00000000..e1a7c56f --- /dev/null +++ b/.gitattributes @@ -0,0 +1,5 @@ +parser/src/python.rs linguist-generated +**/*.snap linguist-generated -merge +**/*.lalrpop text eol=LF +**/*.py text working-tree-encoding=UTF-8 eol=LF +**/*.rs text working-tree-encoding=UTF-8 eol=LF diff --git a/ast/asdl_rs.py b/ast/asdl_rs.py index ea66ca40..d74d730b 100755 --- a/ast/asdl_rs.py +++ b/ast/asdl_rs.py @@ -131,6 +131,9 @@ def visitSum(self, sum, name): if is_simple(sum): info.has_userdata = False else: + for t in sum.types: + self.typeinfo[t.name] = TypeInfo(t.name) + self.add_children(t.name, t.fields) if len(sum.types) > 1: info.boxed = True if sum.attributes: @@ -205,16 +208,49 @@ def simple_sum(self, sum, name, depth): def sum_with_constructors(self, sum, name, depth): typeinfo = self.typeinfo[name] - generics, generics_applied = self.get_generics(name, "U = ()", "U") enumname = rustname = get_rust_type(name) # all the attributes right now are for location, so if it has attrs we # can just wrap it in Located<> if sum.attributes: enumname = rustname + "Kind" + + for t in sum.types: + if not t.fields: + continue + self.emit_attrs(depth) + self.typeinfo[t] = TypeInfo(t) + t_generics, t_generics_applied = self.get_generics(t.name, "U = ()", "U") + payload_name = f"{rustname}{t.name}" + self.emit(f"pub struct {payload_name}{t_generics} {{", depth) + for f in t.fields: + self.visit(f, typeinfo, "pub ", depth + 1, t.name) + self.emit("}", depth) + self.emit( + textwrap.dedent( + f""" + impl{t_generics_applied} From<{payload_name}{t_generics_applied}> for {enumname}{t_generics_applied} {{ + fn from(payload: {payload_name}{t_generics_applied}) -> Self {{ + {enumname}::{t.name}(payload) + }} + }} + """ + ), + depth, + ) + + generics, generics_applied = self.get_generics(name, "U = ()", "U") self.emit_attrs(depth) self.emit(f"pub enum {enumname}{generics} {{", depth) for t in sum.types: - self.visit(t, typeinfo, depth + 1) + if t.fields: + t_generics, t_generics_applied = self.get_generics( + t.name, "U = ()", "U" + ) + self.emit( + f"{t.name}({rustname}{t.name}{t_generics_applied}),", depth + 1 + ) + else: + self.emit(f"{t.name},", depth + 1) self.emit("}", depth) if sum.attributes: self.emit( @@ -238,13 +274,18 @@ def visitField(self, field, parent, vis, depth, constructor=None): if fieldtype and fieldtype.has_userdata: typ = f"{typ}" # don't box if we're doing Vec, but do box if we're doing Vec>> - if fieldtype and fieldtype.boxed and (not (parent.product or field.seq) or field.opt): + if ( + fieldtype + and fieldtype.boxed + and (not (parent.product or field.seq) or field.opt) + ): typ = f"Box<{typ}>" if field.opt or ( # When a dictionary literal contains dictionary unpacking (e.g., `{**d}`), # the expression to be unpacked goes in `values` with a `None` at the corresponding # position in `keys`. To handle this, the type of `keys` needs to be `Option>`. - constructor == "Dict" and field.name == "keys" + constructor == "Dict" + and field.name == "keys" ): typ = f"Option<{typ}>" if field.seq: @@ -344,14 +385,21 @@ def visitSum(self, sum, name, depth): ) if is_located: self.emit("fold_located(folder, node, |folder, node| {", depth) - enumname += "Kind" + rustname = enumname + "Kind" + else: + rustname = enumname self.emit("match node {", depth + 1) for cons in sum.types: - fields_pattern = self.make_pattern(cons.fields) + fields_pattern = self.make_pattern( + enumname, rustname, cons.name, cons.fields + ) self.emit( - f"{enumname}::{cons.name} {{ {fields_pattern} }} => {{", depth + 2 + f"{fields_pattern[0]} {{ {fields_pattern[1]} }} {fields_pattern[2]} => {{", + depth + 2, + ) + self.gen_construction( + fields_pattern[0], cons.fields, fields_pattern[2], depth + 3 ) - self.gen_construction(f"{enumname}::{cons.name}", cons.fields, depth + 3) self.emit("}", depth + 2) self.emit("}", depth + 1) if is_located: @@ -381,23 +429,33 @@ def visitProduct(self, product, name, depth): ) if is_located: self.emit("fold_located(folder, node, |folder, node| {", depth) - structname += "Data" - fields_pattern = self.make_pattern(product.fields) - self.emit(f"let {structname} {{ {fields_pattern} }} = node;", depth + 1) - self.gen_construction(structname, product.fields, depth + 1) + rustname = structname + "Data" + else: + rustname = structname + fields_pattern = self.make_pattern(rustname, structname, None, product.fields) + self.emit(f"let {rustname} {{ {fields_pattern[1]} }} = node;", depth + 1) + self.gen_construction(rustname, product.fields, "", depth + 1) if is_located: self.emit("})", depth) self.emit("}", depth) - def make_pattern(self, fields): - return ",".join(rust_field(f.name) for f in fields) + def make_pattern(self, rustname, pyname, fieldname, fields): + if fields: + header = f"{pyname}::{fieldname}({rustname}{fieldname}" + footer = ")" + else: + header = f"{pyname}::{fieldname}" + footer = "" - def gen_construction(self, cons_path, fields, depth): - self.emit(f"Ok({cons_path} {{", depth) + body = ",".join(rust_field(f.name) for f in fields) + return header, body, footer + + def gen_construction(self, header, fields, footer, depth): + self.emit(f"Ok({header} {{", depth) for field in fields: name = rust_field(field.name) self.emit(f"{name}: Foldable::fold({name}, folder)?,", depth + 1) - self.emit("})", depth) + self.emit(f"}}{footer})", depth) class FoldModuleVisitor(TypeInfoEmitVisitor): @@ -514,33 +572,36 @@ def visitType(self, type, depth=0): self.visit(type.value, type.name, depth) def visitSum(self, sum, name, depth): - enumname = get_rust_type(name) + rustname = enumname = get_rust_type(name) if sum.attributes: - enumname += "Kind" + rustname = enumname + "Kind" - self.emit(f"impl NamedNode for ast::{enumname} {{", depth) + self.emit(f"impl NamedNode for ast::{rustname} {{", depth) self.emit(f"const NAME: &'static str = {json.dumps(name)};", depth + 1) self.emit("}", depth) - self.emit(f"impl Node for ast::{enumname} {{", depth) + self.emit(f"impl Node for ast::{rustname} {{", depth) self.emit( "fn ast_to_object(self, _vm: &VirtualMachine) -> PyObjectRef {", depth + 1 ) self.emit("match self {", depth + 2) for variant in sum.types: - self.constructor_to_object(variant, enumname, depth + 3) + self.constructor_to_object(variant, enumname, rustname, depth + 3) self.emit("}", depth + 2) self.emit("}", depth + 1) self.emit( "fn ast_from_object(_vm: &VirtualMachine, _object: PyObjectRef) -> PyResult {", depth + 1, ) - self.gen_sum_fromobj(sum, name, enumname, depth + 2) + self.gen_sum_fromobj(sum, name, enumname, rustname, depth + 2) self.emit("}", depth + 1) self.emit("}", depth) - def constructor_to_object(self, cons, enumname, depth): - fields_pattern = self.make_pattern(cons.fields) - self.emit(f"ast::{enumname}::{cons.name} {{ {fields_pattern} }} => {{", depth) + def constructor_to_object(self, cons, enumname, rustname, depth): + self.emit(f"ast::{rustname}::{cons.name}", depth) + if cons.fields: + fields_pattern = self.make_pattern(cons.fields) + self.emit(f"( ast::{enumname}{cons.name} {{ {fields_pattern} }} )", depth) + self.emit(" => {", depth) self.make_node(cons.name, cons.fields, depth + 1) self.emit("}", depth) @@ -586,7 +647,7 @@ def make_node(self, variant, fields, depth): def make_pattern(self, fields): return ",".join(rust_field(f.name) for f in fields) - def gen_sum_fromobj(self, sum, sumname, enumname, depth): + def gen_sum_fromobj(self, sum, sumname, enumname, rustname, depth): if sum.attributes: self.extract_location(sumname, depth) @@ -594,7 +655,12 @@ def gen_sum_fromobj(self, sum, sumname, enumname, depth): self.emit("Ok(", depth) for cons in sum.types: self.emit(f"if _cls.is(Node{cons.name}::static_type()) {{", depth) - self.gen_construction(f"{enumname}::{cons.name}", cons, sumname, depth + 1) + if cons.fields: + self.emit(f"ast::{rustname}::{cons.name} (ast::{enumname}{cons.name} {{", depth + 1) + self.gen_construction_fields(cons, sumname, depth + 1) + self.emit("})", depth + 1) + else: + self.emit(f"ast::{rustname}::{cons.name}", depth + 1) self.emit("} else", depth) self.emit("{", depth) @@ -610,13 +676,16 @@ def gen_product_fromobj(self, product, prodname, structname, depth): self.gen_construction(structname, product, prodname, depth + 1) self.emit(")", depth) - def gen_construction(self, cons_path, cons, name, depth): - self.emit(f"ast::{cons_path} {{", depth) + def gen_construction_fields(self, cons, name, depth): for field in cons.fields: self.emit( f"{rust_field(field.name)}: {self.decode_field(field, name)},", depth + 1, ) + + def gen_construction(self, cons_path, cons, name, depth): + self.emit(f"ast::{cons_path} {{", depth) + self.gen_construction_fields(cons, name, depth + 1) self.emit("}", depth) def extract_location(self, typename, depth): diff --git a/ast/src/ast_gen.rs b/ast/src/ast_gen.rs index 6771dd0e..5e22f95e 100644 --- a/ast/src/ast_gen.rs +++ b/ast/src/ast_gen.rs @@ -44,266 +44,761 @@ impl std::ops::Deref for Located { } } +#[derive(Clone, Debug, PartialEq)] +pub struct ModModule { + pub body: Vec>, + pub type_ignores: Vec, +} + +impl From> for Mod { + fn from(payload: ModModule) -> Self { + Mod::Module(payload) + } +} + +#[derive(Clone, Debug, PartialEq)] +pub struct ModInteractive { + pub body: Vec>, +} + +impl From> for Mod { + fn from(payload: ModInteractive) -> Self { + Mod::Interactive(payload) + } +} + +#[derive(Clone, Debug, PartialEq)] +pub struct ModExpression { + pub body: Box>, +} + +impl From> for Mod { + fn from(payload: ModExpression) -> Self { + Mod::Expression(payload) + } +} + +#[derive(Clone, Debug, PartialEq)] +pub struct ModFunctionType { + pub argtypes: Vec>, + pub returns: Box>, +} + +impl From> for Mod { + fn from(payload: ModFunctionType) -> Self { + Mod::FunctionType(payload) + } +} + #[derive(Clone, Debug, PartialEq)] pub enum Mod { - Module { - body: Vec>, - type_ignores: Vec, - }, - Interactive { - body: Vec>, - }, - Expression { - body: Box>, - }, - FunctionType { - argtypes: Vec>, - returns: Box>, - }, + Module(ModModule), + Interactive(ModInteractive), + Expression(ModExpression), + FunctionType(ModFunctionType), +} + +#[derive(Clone, Debug, PartialEq)] +pub struct StmtFunctionDef { + pub name: Ident, + pub args: Box>, + pub body: Vec>, + pub decorator_list: Vec>, + pub returns: Option>>, + pub type_comment: Option, +} + +impl From> for StmtKind { + fn from(payload: StmtFunctionDef) -> Self { + StmtKind::FunctionDef(payload) + } +} + +#[derive(Clone, Debug, PartialEq)] +pub struct StmtAsyncFunctionDef { + pub name: Ident, + pub args: Box>, + pub body: Vec>, + pub decorator_list: Vec>, + pub returns: Option>>, + pub type_comment: Option, +} + +impl From> for StmtKind { + fn from(payload: StmtAsyncFunctionDef) -> Self { + StmtKind::AsyncFunctionDef(payload) + } +} + +#[derive(Clone, Debug, PartialEq)] +pub struct StmtClassDef { + pub name: Ident, + pub bases: Vec>, + pub keywords: Vec>, + pub body: Vec>, + pub decorator_list: Vec>, +} + +impl From> for StmtKind { + fn from(payload: StmtClassDef) -> Self { + StmtKind::ClassDef(payload) + } +} + +#[derive(Clone, Debug, PartialEq)] +pub struct StmtReturn { + pub value: Option>>, +} + +impl From> for StmtKind { + fn from(payload: StmtReturn) -> Self { + StmtKind::Return(payload) + } +} + +#[derive(Clone, Debug, PartialEq)] +pub struct StmtDelete { + pub targets: Vec>, +} + +impl From> for StmtKind { + fn from(payload: StmtDelete) -> Self { + StmtKind::Delete(payload) + } +} + +#[derive(Clone, Debug, PartialEq)] +pub struct StmtAssign { + pub targets: Vec>, + pub value: Box>, + pub type_comment: Option, +} + +impl From> for StmtKind { + fn from(payload: StmtAssign) -> Self { + StmtKind::Assign(payload) + } +} + +#[derive(Clone, Debug, PartialEq)] +pub struct StmtAugAssign { + pub target: Box>, + pub op: Operator, + pub value: Box>, +} + +impl From> for StmtKind { + fn from(payload: StmtAugAssign) -> Self { + StmtKind::AugAssign(payload) + } +} + +#[derive(Clone, Debug, PartialEq)] +pub struct StmtAnnAssign { + pub target: Box>, + pub annotation: Box>, + pub value: Option>>, + pub simple: usize, +} + +impl From> for StmtKind { + fn from(payload: StmtAnnAssign) -> Self { + StmtKind::AnnAssign(payload) + } +} + +#[derive(Clone, Debug, PartialEq)] +pub struct StmtFor { + pub target: Box>, + pub iter: Box>, + pub body: Vec>, + pub orelse: Vec>, + pub type_comment: Option, +} + +impl From> for StmtKind { + fn from(payload: StmtFor) -> Self { + StmtKind::For(payload) + } +} + +#[derive(Clone, Debug, PartialEq)] +pub struct StmtAsyncFor { + pub target: Box>, + pub iter: Box>, + pub body: Vec>, + pub orelse: Vec>, + pub type_comment: Option, +} + +impl From> for StmtKind { + fn from(payload: StmtAsyncFor) -> Self { + StmtKind::AsyncFor(payload) + } +} + +#[derive(Clone, Debug, PartialEq)] +pub struct StmtWhile { + pub test: Box>, + pub body: Vec>, + pub orelse: Vec>, +} + +impl From> for StmtKind { + fn from(payload: StmtWhile) -> Self { + StmtKind::While(payload) + } +} + +#[derive(Clone, Debug, PartialEq)] +pub struct StmtIf { + pub test: Box>, + pub body: Vec>, + pub orelse: Vec>, +} + +impl From> for StmtKind { + fn from(payload: StmtIf) -> Self { + StmtKind::If(payload) + } +} + +#[derive(Clone, Debug, PartialEq)] +pub struct StmtWith { + pub items: Vec>, + pub body: Vec>, + pub type_comment: Option, +} + +impl From> for StmtKind { + fn from(payload: StmtWith) -> Self { + StmtKind::With(payload) + } +} + +#[derive(Clone, Debug, PartialEq)] +pub struct StmtAsyncWith { + pub items: Vec>, + pub body: Vec>, + pub type_comment: Option, +} + +impl From> for StmtKind { + fn from(payload: StmtAsyncWith) -> Self { + StmtKind::AsyncWith(payload) + } +} + +#[derive(Clone, Debug, PartialEq)] +pub struct StmtMatch { + pub subject: Box>, + pub cases: Vec>, +} + +impl From> for StmtKind { + fn from(payload: StmtMatch) -> Self { + StmtKind::Match(payload) + } +} + +#[derive(Clone, Debug, PartialEq)] +pub struct StmtRaise { + pub exc: Option>>, + pub cause: Option>>, +} + +impl From> for StmtKind { + fn from(payload: StmtRaise) -> Self { + StmtKind::Raise(payload) + } +} + +#[derive(Clone, Debug, PartialEq)] +pub struct StmtTry { + pub body: Vec>, + pub handlers: Vec>, + pub orelse: Vec>, + pub finalbody: Vec>, +} + +impl From> for StmtKind { + fn from(payload: StmtTry) -> Self { + StmtKind::Try(payload) + } +} + +#[derive(Clone, Debug, PartialEq)] +pub struct StmtTryStar { + pub body: Vec>, + pub handlers: Vec>, + pub orelse: Vec>, + pub finalbody: Vec>, +} + +impl From> for StmtKind { + fn from(payload: StmtTryStar) -> Self { + StmtKind::TryStar(payload) + } +} + +#[derive(Clone, Debug, PartialEq)] +pub struct StmtAssert { + pub test: Box>, + pub msg: Option>>, +} + +impl From> for StmtKind { + fn from(payload: StmtAssert) -> Self { + StmtKind::Assert(payload) + } +} + +#[derive(Clone, Debug, PartialEq)] +pub struct StmtImport { + pub names: Vec>, +} + +impl From> for StmtKind { + fn from(payload: StmtImport) -> Self { + StmtKind::Import(payload) + } +} + +#[derive(Clone, Debug, PartialEq)] +pub struct StmtImportFrom { + pub module: Option, + pub names: Vec>, + pub level: Option, +} + +impl From> for StmtKind { + fn from(payload: StmtImportFrom) -> Self { + StmtKind::ImportFrom(payload) + } +} + +#[derive(Clone, Debug, PartialEq)] +pub struct StmtGlobal { + pub names: Vec, +} + +impl From for StmtKind { + fn from(payload: StmtGlobal) -> Self { + StmtKind::Global(payload) + } +} + +#[derive(Clone, Debug, PartialEq)] +pub struct StmtNonlocal { + pub names: Vec, +} + +impl From for StmtKind { + fn from(payload: StmtNonlocal) -> Self { + StmtKind::Nonlocal(payload) + } +} + +#[derive(Clone, Debug, PartialEq)] +pub struct StmtExpr { + pub value: Box>, +} + +impl From> for StmtKind { + fn from(payload: StmtExpr) -> Self { + StmtKind::Expr(payload) + } } #[derive(Clone, Debug, PartialEq)] pub enum StmtKind { - FunctionDef { - name: Ident, - args: Box>, - body: Vec>, - decorator_list: Vec>, - returns: Option>>, - type_comment: Option, - }, - AsyncFunctionDef { - name: Ident, - args: Box>, - body: Vec>, - decorator_list: Vec>, - returns: Option>>, - type_comment: Option, - }, - ClassDef { - name: Ident, - bases: Vec>, - keywords: Vec>, - body: Vec>, - decorator_list: Vec>, - }, - Return { - value: Option>>, - }, - Delete { - targets: Vec>, - }, - Assign { - targets: Vec>, - value: Box>, - type_comment: Option, - }, - AugAssign { - target: Box>, - op: Operator, - value: Box>, - }, - AnnAssign { - target: Box>, - annotation: Box>, - value: Option>>, - simple: usize, - }, - For { - target: Box>, - iter: Box>, - body: Vec>, - orelse: Vec>, - type_comment: Option, - }, - AsyncFor { - target: Box>, - iter: Box>, - body: Vec>, - orelse: Vec>, - type_comment: Option, - }, - While { - test: Box>, - body: Vec>, - orelse: Vec>, - }, - If { - test: Box>, - body: Vec>, - orelse: Vec>, - }, - With { - items: Vec>, - body: Vec>, - type_comment: Option, - }, - AsyncWith { - items: Vec>, - body: Vec>, - type_comment: Option, - }, - Match { - subject: Box>, - cases: Vec>, - }, - Raise { - exc: Option>>, - cause: Option>>, - }, - Try { - body: Vec>, - handlers: Vec>, - orelse: Vec>, - finalbody: Vec>, - }, - TryStar { - body: Vec>, - handlers: Vec>, - orelse: Vec>, - finalbody: Vec>, - }, - Assert { - test: Box>, - msg: Option>>, - }, - Import { - names: Vec>, - }, - ImportFrom { - module: Option, - names: Vec>, - level: Option, - }, - Global { - names: Vec, - }, - Nonlocal { - names: Vec, - }, - Expr { - value: Box>, - }, + FunctionDef(StmtFunctionDef), + AsyncFunctionDef(StmtAsyncFunctionDef), + ClassDef(StmtClassDef), + Return(StmtReturn), + Delete(StmtDelete), + Assign(StmtAssign), + AugAssign(StmtAugAssign), + AnnAssign(StmtAnnAssign), + For(StmtFor), + AsyncFor(StmtAsyncFor), + While(StmtWhile), + If(StmtIf), + With(StmtWith), + AsyncWith(StmtAsyncWith), + Match(StmtMatch), + Raise(StmtRaise), + Try(StmtTry), + TryStar(StmtTryStar), + Assert(StmtAssert), + Import(StmtImport), + ImportFrom(StmtImportFrom), + Global(StmtGlobal), + Nonlocal(StmtNonlocal), + Expr(StmtExpr), Pass, Break, Continue, } pub type Stmt = Located, U>; +#[derive(Clone, Debug, PartialEq)] +pub struct ExprBoolOp { + pub op: Boolop, + pub values: Vec>, +} + +impl From> for ExprKind { + fn from(payload: ExprBoolOp) -> Self { + ExprKind::BoolOp(payload) + } +} + +#[derive(Clone, Debug, PartialEq)] +pub struct ExprNamedExpr { + pub target: Box>, + pub value: Box>, +} + +impl From> for ExprKind { + fn from(payload: ExprNamedExpr) -> Self { + ExprKind::NamedExpr(payload) + } +} + +#[derive(Clone, Debug, PartialEq)] +pub struct ExprBinOp { + pub left: Box>, + pub op: Operator, + pub right: Box>, +} + +impl From> for ExprKind { + fn from(payload: ExprBinOp) -> Self { + ExprKind::BinOp(payload) + } +} + +#[derive(Clone, Debug, PartialEq)] +pub struct ExprUnaryOp { + pub op: Unaryop, + pub operand: Box>, +} + +impl From> for ExprKind { + fn from(payload: ExprUnaryOp) -> Self { + ExprKind::UnaryOp(payload) + } +} + +#[derive(Clone, Debug, PartialEq)] +pub struct ExprLambda { + pub args: Box>, + pub body: Box>, +} + +impl From> for ExprKind { + fn from(payload: ExprLambda) -> Self { + ExprKind::Lambda(payload) + } +} + +#[derive(Clone, Debug, PartialEq)] +pub struct ExprIfExp { + pub test: Box>, + pub body: Box>, + pub orelse: Box>, +} + +impl From> for ExprKind { + fn from(payload: ExprIfExp) -> Self { + ExprKind::IfExp(payload) + } +} + +#[derive(Clone, Debug, PartialEq)] +pub struct ExprDict { + pub keys: Vec>>, + pub values: Vec>, +} + +impl From> for ExprKind { + fn from(payload: ExprDict) -> Self { + ExprKind::Dict(payload) + } +} + +#[derive(Clone, Debug, PartialEq)] +pub struct ExprSet { + pub elts: Vec>, +} + +impl From> for ExprKind { + fn from(payload: ExprSet) -> Self { + ExprKind::Set(payload) + } +} + +#[derive(Clone, Debug, PartialEq)] +pub struct ExprListComp { + pub elt: Box>, + pub generators: Vec>, +} + +impl From> for ExprKind { + fn from(payload: ExprListComp) -> Self { + ExprKind::ListComp(payload) + } +} + +#[derive(Clone, Debug, PartialEq)] +pub struct ExprSetComp { + pub elt: Box>, + pub generators: Vec>, +} + +impl From> for ExprKind { + fn from(payload: ExprSetComp) -> Self { + ExprKind::SetComp(payload) + } +} + +#[derive(Clone, Debug, PartialEq)] +pub struct ExprDictComp { + pub key: Box>, + pub value: Box>, + pub generators: Vec>, +} + +impl From> for ExprKind { + fn from(payload: ExprDictComp) -> Self { + ExprKind::DictComp(payload) + } +} + +#[derive(Clone, Debug, PartialEq)] +pub struct ExprGeneratorExp { + pub elt: Box>, + pub generators: Vec>, +} + +impl From> for ExprKind { + fn from(payload: ExprGeneratorExp) -> Self { + ExprKind::GeneratorExp(payload) + } +} + +#[derive(Clone, Debug, PartialEq)] +pub struct ExprAwait { + pub value: Box>, +} + +impl From> for ExprKind { + fn from(payload: ExprAwait) -> Self { + ExprKind::Await(payload) + } +} + +#[derive(Clone, Debug, PartialEq)] +pub struct ExprYield { + pub value: Option>>, +} + +impl From> for ExprKind { + fn from(payload: ExprYield) -> Self { + ExprKind::Yield(payload) + } +} + +#[derive(Clone, Debug, PartialEq)] +pub struct ExprYieldFrom { + pub value: Box>, +} + +impl From> for ExprKind { + fn from(payload: ExprYieldFrom) -> Self { + ExprKind::YieldFrom(payload) + } +} + +#[derive(Clone, Debug, PartialEq)] +pub struct ExprCompare { + pub left: Box>, + pub ops: Vec, + pub comparators: Vec>, +} + +impl From> for ExprKind { + fn from(payload: ExprCompare) -> Self { + ExprKind::Compare(payload) + } +} + +#[derive(Clone, Debug, PartialEq)] +pub struct ExprCall { + pub func: Box>, + pub args: Vec>, + pub keywords: Vec>, +} + +impl From> for ExprKind { + fn from(payload: ExprCall) -> Self { + ExprKind::Call(payload) + } +} + +#[derive(Clone, Debug, PartialEq)] +pub struct ExprFormattedValue { + pub value: Box>, + pub conversion: usize, + pub format_spec: Option>>, +} + +impl From> for ExprKind { + fn from(payload: ExprFormattedValue) -> Self { + ExprKind::FormattedValue(payload) + } +} + +#[derive(Clone, Debug, PartialEq)] +pub struct ExprJoinedStr { + pub values: Vec>, +} + +impl From> for ExprKind { + fn from(payload: ExprJoinedStr) -> Self { + ExprKind::JoinedStr(payload) + } +} + +#[derive(Clone, Debug, PartialEq)] +pub struct ExprConstant { + pub value: Constant, + pub kind: Option, +} + +impl From for ExprKind { + fn from(payload: ExprConstant) -> Self { + ExprKind::Constant(payload) + } +} + +#[derive(Clone, Debug, PartialEq)] +pub struct ExprAttribute { + pub value: Box>, + pub attr: Ident, + pub ctx: ExprContext, +} + +impl From> for ExprKind { + fn from(payload: ExprAttribute) -> Self { + ExprKind::Attribute(payload) + } +} + +#[derive(Clone, Debug, PartialEq)] +pub struct ExprSubscript { + pub value: Box>, + pub slice: Box>, + pub ctx: ExprContext, +} + +impl From> for ExprKind { + fn from(payload: ExprSubscript) -> Self { + ExprKind::Subscript(payload) + } +} + +#[derive(Clone, Debug, PartialEq)] +pub struct ExprStarred { + pub value: Box>, + pub ctx: ExprContext, +} + +impl From> for ExprKind { + fn from(payload: ExprStarred) -> Self { + ExprKind::Starred(payload) + } +} + +#[derive(Clone, Debug, PartialEq)] +pub struct ExprName { + pub id: Ident, + pub ctx: ExprContext, +} + +impl From for ExprKind { + fn from(payload: ExprName) -> Self { + ExprKind::Name(payload) + } +} + +#[derive(Clone, Debug, PartialEq)] +pub struct ExprList { + pub elts: Vec>, + pub ctx: ExprContext, +} + +impl From> for ExprKind { + fn from(payload: ExprList) -> Self { + ExprKind::List(payload) + } +} + +#[derive(Clone, Debug, PartialEq)] +pub struct ExprTuple { + pub elts: Vec>, + pub ctx: ExprContext, +} + +impl From> for ExprKind { + fn from(payload: ExprTuple) -> Self { + ExprKind::Tuple(payload) + } +} + +#[derive(Clone, Debug, PartialEq)] +pub struct ExprSlice { + pub lower: Option>>, + pub upper: Option>>, + pub step: Option>>, +} + +impl From> for ExprKind { + fn from(payload: ExprSlice) -> Self { + ExprKind::Slice(payload) + } +} + #[derive(Clone, Debug, PartialEq)] pub enum ExprKind { - BoolOp { - op: Boolop, - values: Vec>, - }, - NamedExpr { - target: Box>, - value: Box>, - }, - BinOp { - left: Box>, - op: Operator, - right: Box>, - }, - UnaryOp { - op: Unaryop, - operand: Box>, - }, - Lambda { - args: Box>, - body: Box>, - }, - IfExp { - test: Box>, - body: Box>, - orelse: Box>, - }, - Dict { - keys: Vec>>, - values: Vec>, - }, - Set { - elts: Vec>, - }, - ListComp { - elt: Box>, - generators: Vec>, - }, - SetComp { - elt: Box>, - generators: Vec>, - }, - DictComp { - key: Box>, - value: Box>, - generators: Vec>, - }, - GeneratorExp { - elt: Box>, - generators: Vec>, - }, - Await { - value: Box>, - }, - Yield { - value: Option>>, - }, - YieldFrom { - value: Box>, - }, - Compare { - left: Box>, - ops: Vec, - comparators: Vec>, - }, - Call { - func: Box>, - args: Vec>, - keywords: Vec>, - }, - FormattedValue { - value: Box>, - conversion: usize, - format_spec: Option>>, - }, - JoinedStr { - values: Vec>, - }, - Constant { - value: Constant, - kind: Option, - }, - Attribute { - value: Box>, - attr: Ident, - ctx: ExprContext, - }, - Subscript { - value: Box>, - slice: Box>, - ctx: ExprContext, - }, - Starred { - value: Box>, - ctx: ExprContext, - }, - Name { - id: Ident, - ctx: ExprContext, - }, - List { - elts: Vec>, - ctx: ExprContext, - }, - Tuple { - elts: Vec>, - ctx: ExprContext, - }, - Slice { - lower: Option>>, - upper: Option>>, - step: Option>>, - }, + BoolOp(ExprBoolOp), + NamedExpr(ExprNamedExpr), + BinOp(ExprBinOp), + UnaryOp(ExprUnaryOp), + Lambda(ExprLambda), + IfExp(ExprIfExp), + Dict(ExprDict), + Set(ExprSet), + ListComp(ExprListComp), + SetComp(ExprSetComp), + DictComp(ExprDictComp), + GeneratorExp(ExprGeneratorExp), + Await(ExprAwait), + Yield(ExprYield), + YieldFrom(ExprYieldFrom), + Compare(ExprCompare), + Call(ExprCall), + FormattedValue(ExprFormattedValue), + JoinedStr(ExprJoinedStr), + Constant(ExprConstant), + Attribute(ExprAttribute), + Subscript(ExprSubscript), + Starred(ExprStarred), + Name(ExprName), + List(ExprList), + Tuple(ExprTuple), + Slice(ExprSlice), } pub type Expr = Located, U>; @@ -367,13 +862,22 @@ pub struct Comprehension { pub is_async: usize, } +#[derive(Clone, Debug, PartialEq)] +pub struct ExcepthandlerExceptHandler { + pub type_: Option>>, + pub name: Option, + pub body: Vec>, +} + +impl From> for ExcepthandlerKind { + fn from(payload: ExcepthandlerExceptHandler) -> Self { + ExcepthandlerKind::ExceptHandler(payload) + } +} + #[derive(Clone, Debug, PartialEq)] pub enum ExcepthandlerKind { - ExceptHandler { - type_: Option>>, - name: Option, - body: Vec>, - }, + ExceptHandler(ExcepthandlerExceptHandler), } pub type Excepthandler = Located, U>; @@ -423,44 +927,128 @@ pub struct MatchCase { pub body: Vec>, } +#[derive(Clone, Debug, PartialEq)] +pub struct PatternMatchValue { + pub value: Box>, +} + +impl From> for PatternKind { + fn from(payload: PatternMatchValue) -> Self { + PatternKind::MatchValue(payload) + } +} + +#[derive(Clone, Debug, PartialEq)] +pub struct PatternMatchSingleton { + pub value: Constant, +} + +impl From for PatternKind { + fn from(payload: PatternMatchSingleton) -> Self { + PatternKind::MatchSingleton(payload) + } +} + +#[derive(Clone, Debug, PartialEq)] +pub struct PatternMatchSequence { + pub patterns: Vec>, +} + +impl From> for PatternKind { + fn from(payload: PatternMatchSequence) -> Self { + PatternKind::MatchSequence(payload) + } +} + +#[derive(Clone, Debug, PartialEq)] +pub struct PatternMatchMapping { + pub keys: Vec>, + pub patterns: Vec>, + pub rest: Option, +} + +impl From> for PatternKind { + fn from(payload: PatternMatchMapping) -> Self { + PatternKind::MatchMapping(payload) + } +} + +#[derive(Clone, Debug, PartialEq)] +pub struct PatternMatchClass { + pub cls: Box>, + pub patterns: Vec>, + pub kwd_attrs: Vec, + pub kwd_patterns: Vec>, +} + +impl From> for PatternKind { + fn from(payload: PatternMatchClass) -> Self { + PatternKind::MatchClass(payload) + } +} + +#[derive(Clone, Debug, PartialEq)] +pub struct PatternMatchStar { + pub name: Option, +} + +impl From for PatternKind { + fn from(payload: PatternMatchStar) -> Self { + PatternKind::MatchStar(payload) + } +} + +#[derive(Clone, Debug, PartialEq)] +pub struct PatternMatchAs { + pub pattern: Option>>, + pub name: Option, +} + +impl From> for PatternKind { + fn from(payload: PatternMatchAs) -> Self { + PatternKind::MatchAs(payload) + } +} + +#[derive(Clone, Debug, PartialEq)] +pub struct PatternMatchOr { + pub patterns: Vec>, +} + +impl From> for PatternKind { + fn from(payload: PatternMatchOr) -> Self { + PatternKind::MatchOr(payload) + } +} + #[derive(Clone, Debug, PartialEq)] pub enum PatternKind { - MatchValue { - value: Box>, - }, - MatchSingleton { - value: Constant, - }, - MatchSequence { - patterns: Vec>, - }, - MatchMapping { - keys: Vec>, - patterns: Vec>, - rest: Option, - }, - MatchClass { - cls: Box>, - patterns: Vec>, - kwd_attrs: Vec, - kwd_patterns: Vec>, - }, - MatchStar { - name: Option, - }, - MatchAs { - pattern: Option>>, - name: Option, - }, - MatchOr { - patterns: Vec>, - }, + MatchValue(PatternMatchValue), + MatchSingleton(PatternMatchSingleton), + MatchSequence(PatternMatchSequence), + MatchMapping(PatternMatchMapping), + MatchClass(PatternMatchClass), + MatchStar(PatternMatchStar), + MatchAs(PatternMatchAs), + MatchOr(PatternMatchOr), } pub type Pattern = Located, U>; +#[derive(Clone, Debug, PartialEq)] +pub struct TypeIgnoreTypeIgnore { + pub lineno: usize, + pub tag: String, +} + +impl From for TypeIgnore { + fn from(payload: TypeIgnoreTypeIgnore) -> Self { + TypeIgnore::TypeIgnore(payload) + } +} + #[derive(Clone, Debug, PartialEq)] pub enum TypeIgnore { - TypeIgnore { lineno: usize, tag: String }, + TypeIgnore(TypeIgnoreTypeIgnore), } #[cfg(feature = "fold")] @@ -573,20 +1161,22 @@ pub mod fold { node: Mod, ) -> Result, F::Error> { match node { - Mod::Module { body, type_ignores } => Ok(Mod::Module { + Mod::Module(ModModule { body, type_ignores }) => Ok(Mod::Module(ModModule { body: Foldable::fold(body, folder)?, type_ignores: Foldable::fold(type_ignores, folder)?, - }), - Mod::Interactive { body } => Ok(Mod::Interactive { + })), + Mod::Interactive(ModInteractive { body }) => Ok(Mod::Interactive(ModInteractive { body: Foldable::fold(body, folder)?, - }), - Mod::Expression { body } => Ok(Mod::Expression { + })), + Mod::Expression(ModExpression { body }) => Ok(Mod::Expression(ModExpression { body: Foldable::fold(body, folder)?, - }), - Mod::FunctionType { argtypes, returns } => Ok(Mod::FunctionType { - argtypes: Foldable::fold(argtypes, folder)?, - returns: Foldable::fold(returns, folder)?, - }), + })), + Mod::FunctionType(ModFunctionType { argtypes, returns }) => { + Ok(Mod::FunctionType(ModFunctionType { + argtypes: Foldable::fold(argtypes, folder)?, + returns: Foldable::fold(returns, folder)?, + })) + } } } impl Foldable for Stmt { @@ -603,189 +1193,191 @@ pub mod fold { node: Stmt, ) -> Result, F::Error> { fold_located(folder, node, |folder, node| match node { - StmtKind::FunctionDef { + StmtKind::FunctionDef(StmtFunctionDef { name, args, body, decorator_list, returns, type_comment, - } => Ok(StmtKind::FunctionDef { + }) => Ok(StmtKind::FunctionDef(StmtFunctionDef { name: Foldable::fold(name, folder)?, args: Foldable::fold(args, folder)?, body: Foldable::fold(body, folder)?, decorator_list: Foldable::fold(decorator_list, folder)?, returns: Foldable::fold(returns, folder)?, type_comment: Foldable::fold(type_comment, folder)?, - }), - StmtKind::AsyncFunctionDef { + })), + StmtKind::AsyncFunctionDef(StmtAsyncFunctionDef { name, args, body, decorator_list, returns, type_comment, - } => Ok(StmtKind::AsyncFunctionDef { + }) => Ok(StmtKind::AsyncFunctionDef(StmtAsyncFunctionDef { name: Foldable::fold(name, folder)?, args: Foldable::fold(args, folder)?, body: Foldable::fold(body, folder)?, decorator_list: Foldable::fold(decorator_list, folder)?, returns: Foldable::fold(returns, folder)?, type_comment: Foldable::fold(type_comment, folder)?, - }), - StmtKind::ClassDef { + })), + StmtKind::ClassDef(StmtClassDef { name, bases, keywords, body, decorator_list, - } => Ok(StmtKind::ClassDef { + }) => Ok(StmtKind::ClassDef(StmtClassDef { name: Foldable::fold(name, folder)?, bases: Foldable::fold(bases, folder)?, keywords: Foldable::fold(keywords, folder)?, body: Foldable::fold(body, folder)?, decorator_list: Foldable::fold(decorator_list, folder)?, - }), - StmtKind::Return { value } => Ok(StmtKind::Return { + })), + StmtKind::Return(StmtReturn { value }) => Ok(StmtKind::Return(StmtReturn { value: Foldable::fold(value, folder)?, - }), - StmtKind::Delete { targets } => Ok(StmtKind::Delete { + })), + StmtKind::Delete(StmtDelete { targets }) => Ok(StmtKind::Delete(StmtDelete { targets: Foldable::fold(targets, folder)?, - }), - StmtKind::Assign { + })), + StmtKind::Assign(StmtAssign { targets, value, type_comment, - } => Ok(StmtKind::Assign { + }) => Ok(StmtKind::Assign(StmtAssign { targets: Foldable::fold(targets, folder)?, value: Foldable::fold(value, folder)?, type_comment: Foldable::fold(type_comment, folder)?, - }), - StmtKind::AugAssign { target, op, value } => Ok(StmtKind::AugAssign { - target: Foldable::fold(target, folder)?, - op: Foldable::fold(op, folder)?, - value: Foldable::fold(value, folder)?, - }), - StmtKind::AnnAssign { + })), + StmtKind::AugAssign(StmtAugAssign { target, op, value }) => { + Ok(StmtKind::AugAssign(StmtAugAssign { + target: Foldable::fold(target, folder)?, + op: Foldable::fold(op, folder)?, + value: Foldable::fold(value, folder)?, + })) + } + StmtKind::AnnAssign(StmtAnnAssign { target, annotation, value, simple, - } => Ok(StmtKind::AnnAssign { + }) => Ok(StmtKind::AnnAssign(StmtAnnAssign { target: Foldable::fold(target, folder)?, annotation: Foldable::fold(annotation, folder)?, value: Foldable::fold(value, folder)?, simple: Foldable::fold(simple, folder)?, - }), - StmtKind::For { + })), + StmtKind::For(StmtFor { target, iter, body, orelse, type_comment, - } => Ok(StmtKind::For { + }) => Ok(StmtKind::For(StmtFor { target: Foldable::fold(target, folder)?, iter: Foldable::fold(iter, folder)?, body: Foldable::fold(body, folder)?, orelse: Foldable::fold(orelse, folder)?, type_comment: Foldable::fold(type_comment, folder)?, - }), - StmtKind::AsyncFor { + })), + StmtKind::AsyncFor(StmtAsyncFor { target, iter, body, orelse, type_comment, - } => Ok(StmtKind::AsyncFor { + }) => Ok(StmtKind::AsyncFor(StmtAsyncFor { target: Foldable::fold(target, folder)?, iter: Foldable::fold(iter, folder)?, body: Foldable::fold(body, folder)?, orelse: Foldable::fold(orelse, folder)?, type_comment: Foldable::fold(type_comment, folder)?, - }), - StmtKind::While { test, body, orelse } => Ok(StmtKind::While { + })), + StmtKind::While(StmtWhile { test, body, orelse }) => Ok(StmtKind::While(StmtWhile { test: Foldable::fold(test, folder)?, body: Foldable::fold(body, folder)?, orelse: Foldable::fold(orelse, folder)?, - }), - StmtKind::If { test, body, orelse } => Ok(StmtKind::If { + })), + StmtKind::If(StmtIf { test, body, orelse }) => Ok(StmtKind::If(StmtIf { test: Foldable::fold(test, folder)?, body: Foldable::fold(body, folder)?, orelse: Foldable::fold(orelse, folder)?, - }), - StmtKind::With { + })), + StmtKind::With(StmtWith { items, body, type_comment, - } => Ok(StmtKind::With { + }) => Ok(StmtKind::With(StmtWith { items: Foldable::fold(items, folder)?, body: Foldable::fold(body, folder)?, type_comment: Foldable::fold(type_comment, folder)?, - }), - StmtKind::AsyncWith { + })), + StmtKind::AsyncWith(StmtAsyncWith { items, body, type_comment, - } => Ok(StmtKind::AsyncWith { + }) => Ok(StmtKind::AsyncWith(StmtAsyncWith { items: Foldable::fold(items, folder)?, body: Foldable::fold(body, folder)?, type_comment: Foldable::fold(type_comment, folder)?, - }), - StmtKind::Match { subject, cases } => Ok(StmtKind::Match { + })), + StmtKind::Match(StmtMatch { subject, cases }) => Ok(StmtKind::Match(StmtMatch { subject: Foldable::fold(subject, folder)?, cases: Foldable::fold(cases, folder)?, - }), - StmtKind::Raise { exc, cause } => Ok(StmtKind::Raise { + })), + StmtKind::Raise(StmtRaise { exc, cause }) => Ok(StmtKind::Raise(StmtRaise { exc: Foldable::fold(exc, folder)?, cause: Foldable::fold(cause, folder)?, - }), - StmtKind::Try { + })), + StmtKind::Try(StmtTry { body, handlers, orelse, finalbody, - } => Ok(StmtKind::Try { + }) => Ok(StmtKind::Try(StmtTry { body: Foldable::fold(body, folder)?, handlers: Foldable::fold(handlers, folder)?, orelse: Foldable::fold(orelse, folder)?, finalbody: Foldable::fold(finalbody, folder)?, - }), - StmtKind::TryStar { + })), + StmtKind::TryStar(StmtTryStar { body, handlers, orelse, finalbody, - } => Ok(StmtKind::TryStar { + }) => Ok(StmtKind::TryStar(StmtTryStar { body: Foldable::fold(body, folder)?, handlers: Foldable::fold(handlers, folder)?, orelse: Foldable::fold(orelse, folder)?, finalbody: Foldable::fold(finalbody, folder)?, - }), - StmtKind::Assert { test, msg } => Ok(StmtKind::Assert { + })), + StmtKind::Assert(StmtAssert { test, msg }) => Ok(StmtKind::Assert(StmtAssert { test: Foldable::fold(test, folder)?, msg: Foldable::fold(msg, folder)?, - }), - StmtKind::Import { names } => Ok(StmtKind::Import { + })), + StmtKind::Import(StmtImport { names }) => Ok(StmtKind::Import(StmtImport { names: Foldable::fold(names, folder)?, - }), - StmtKind::ImportFrom { + })), + StmtKind::ImportFrom(StmtImportFrom { module, names, level, - } => Ok(StmtKind::ImportFrom { + }) => Ok(StmtKind::ImportFrom(StmtImportFrom { module: Foldable::fold(module, folder)?, names: Foldable::fold(names, folder)?, level: Foldable::fold(level, folder)?, - }), - StmtKind::Global { names } => Ok(StmtKind::Global { + })), + StmtKind::Global(StmtGlobal { names }) => Ok(StmtKind::Global(StmtGlobal { names: Foldable::fold(names, folder)?, - }), - StmtKind::Nonlocal { names } => Ok(StmtKind::Nonlocal { + })), + StmtKind::Nonlocal(StmtNonlocal { names }) => Ok(StmtKind::Nonlocal(StmtNonlocal { names: Foldable::fold(names, folder)?, - }), - StmtKind::Expr { value } => Ok(StmtKind::Expr { + })), + StmtKind::Expr(StmtExpr { value }) => Ok(StmtKind::Expr(StmtExpr { value: Foldable::fold(value, folder)?, - }), + })), StmtKind::Pass {} => Ok(StmtKind::Pass {}), StmtKind::Break {} => Ok(StmtKind::Break {}), StmtKind::Continue {} => Ok(StmtKind::Continue {}), @@ -805,134 +1397,152 @@ pub mod fold { node: Expr, ) -> Result, F::Error> { fold_located(folder, node, |folder, node| match node { - ExprKind::BoolOp { op, values } => Ok(ExprKind::BoolOp { + ExprKind::BoolOp(ExprBoolOp { op, values }) => Ok(ExprKind::BoolOp(ExprBoolOp { op: Foldable::fold(op, folder)?, values: Foldable::fold(values, folder)?, - }), - ExprKind::NamedExpr { target, value } => Ok(ExprKind::NamedExpr { - target: Foldable::fold(target, folder)?, - value: Foldable::fold(value, folder)?, - }), - ExprKind::BinOp { left, op, right } => Ok(ExprKind::BinOp { + })), + ExprKind::NamedExpr(ExprNamedExpr { target, value }) => { + Ok(ExprKind::NamedExpr(ExprNamedExpr { + target: Foldable::fold(target, folder)?, + value: Foldable::fold(value, folder)?, + })) + } + ExprKind::BinOp(ExprBinOp { left, op, right }) => Ok(ExprKind::BinOp(ExprBinOp { left: Foldable::fold(left, folder)?, op: Foldable::fold(op, folder)?, right: Foldable::fold(right, folder)?, - }), - ExprKind::UnaryOp { op, operand } => Ok(ExprKind::UnaryOp { + })), + ExprKind::UnaryOp(ExprUnaryOp { op, operand }) => Ok(ExprKind::UnaryOp(ExprUnaryOp { op: Foldable::fold(op, folder)?, operand: Foldable::fold(operand, folder)?, - }), - ExprKind::Lambda { args, body } => Ok(ExprKind::Lambda { + })), + ExprKind::Lambda(ExprLambda { args, body }) => Ok(ExprKind::Lambda(ExprLambda { args: Foldable::fold(args, folder)?, body: Foldable::fold(body, folder)?, - }), - ExprKind::IfExp { test, body, orelse } => Ok(ExprKind::IfExp { + })), + ExprKind::IfExp(ExprIfExp { test, body, orelse }) => Ok(ExprKind::IfExp(ExprIfExp { test: Foldable::fold(test, folder)?, body: Foldable::fold(body, folder)?, orelse: Foldable::fold(orelse, folder)?, - }), - ExprKind::Dict { keys, values } => Ok(ExprKind::Dict { + })), + ExprKind::Dict(ExprDict { keys, values }) => Ok(ExprKind::Dict(ExprDict { keys: Foldable::fold(keys, folder)?, values: Foldable::fold(values, folder)?, - }), - ExprKind::Set { elts } => Ok(ExprKind::Set { + })), + ExprKind::Set(ExprSet { elts }) => Ok(ExprKind::Set(ExprSet { elts: Foldable::fold(elts, folder)?, - }), - ExprKind::ListComp { elt, generators } => Ok(ExprKind::ListComp { - elt: Foldable::fold(elt, folder)?, - generators: Foldable::fold(generators, folder)?, - }), - ExprKind::SetComp { elt, generators } => Ok(ExprKind::SetComp { - elt: Foldable::fold(elt, folder)?, - generators: Foldable::fold(generators, folder)?, - }), - ExprKind::DictComp { + })), + ExprKind::ListComp(ExprListComp { elt, generators }) => { + Ok(ExprKind::ListComp(ExprListComp { + elt: Foldable::fold(elt, folder)?, + generators: Foldable::fold(generators, folder)?, + })) + } + ExprKind::SetComp(ExprSetComp { elt, generators }) => { + Ok(ExprKind::SetComp(ExprSetComp { + elt: Foldable::fold(elt, folder)?, + generators: Foldable::fold(generators, folder)?, + })) + } + ExprKind::DictComp(ExprDictComp { key, value, generators, - } => Ok(ExprKind::DictComp { + }) => Ok(ExprKind::DictComp(ExprDictComp { key: Foldable::fold(key, folder)?, value: Foldable::fold(value, folder)?, generators: Foldable::fold(generators, folder)?, - }), - ExprKind::GeneratorExp { elt, generators } => Ok(ExprKind::GeneratorExp { - elt: Foldable::fold(elt, folder)?, - generators: Foldable::fold(generators, folder)?, - }), - ExprKind::Await { value } => Ok(ExprKind::Await { - value: Foldable::fold(value, folder)?, - }), - ExprKind::Yield { value } => Ok(ExprKind::Yield { + })), + ExprKind::GeneratorExp(ExprGeneratorExp { elt, generators }) => { + Ok(ExprKind::GeneratorExp(ExprGeneratorExp { + elt: Foldable::fold(elt, folder)?, + generators: Foldable::fold(generators, folder)?, + })) + } + ExprKind::Await(ExprAwait { value }) => Ok(ExprKind::Await(ExprAwait { value: Foldable::fold(value, folder)?, - }), - ExprKind::YieldFrom { value } => Ok(ExprKind::YieldFrom { + })), + ExprKind::Yield(ExprYield { value }) => Ok(ExprKind::Yield(ExprYield { value: Foldable::fold(value, folder)?, - }), - ExprKind::Compare { + })), + ExprKind::YieldFrom(ExprYieldFrom { value }) => { + Ok(ExprKind::YieldFrom(ExprYieldFrom { + value: Foldable::fold(value, folder)?, + })) + } + ExprKind::Compare(ExprCompare { left, ops, comparators, - } => Ok(ExprKind::Compare { + }) => Ok(ExprKind::Compare(ExprCompare { left: Foldable::fold(left, folder)?, ops: Foldable::fold(ops, folder)?, comparators: Foldable::fold(comparators, folder)?, - }), - ExprKind::Call { + })), + ExprKind::Call(ExprCall { func, args, keywords, - } => Ok(ExprKind::Call { + }) => Ok(ExprKind::Call(ExprCall { func: Foldable::fold(func, folder)?, args: Foldable::fold(args, folder)?, keywords: Foldable::fold(keywords, folder)?, - }), - ExprKind::FormattedValue { + })), + ExprKind::FormattedValue(ExprFormattedValue { value, conversion, format_spec, - } => Ok(ExprKind::FormattedValue { + }) => Ok(ExprKind::FormattedValue(ExprFormattedValue { value: Foldable::fold(value, folder)?, conversion: Foldable::fold(conversion, folder)?, format_spec: Foldable::fold(format_spec, folder)?, - }), - ExprKind::JoinedStr { values } => Ok(ExprKind::JoinedStr { - values: Foldable::fold(values, folder)?, - }), - ExprKind::Constant { value, kind } => Ok(ExprKind::Constant { - value: Foldable::fold(value, folder)?, - kind: Foldable::fold(kind, folder)?, - }), - ExprKind::Attribute { value, attr, ctx } => Ok(ExprKind::Attribute { - value: Foldable::fold(value, folder)?, - attr: Foldable::fold(attr, folder)?, - ctx: Foldable::fold(ctx, folder)?, - }), - ExprKind::Subscript { value, slice, ctx } => Ok(ExprKind::Subscript { - value: Foldable::fold(value, folder)?, - slice: Foldable::fold(slice, folder)?, - ctx: Foldable::fold(ctx, folder)?, - }), - ExprKind::Starred { value, ctx } => Ok(ExprKind::Starred { + })), + ExprKind::JoinedStr(ExprJoinedStr { values }) => { + Ok(ExprKind::JoinedStr(ExprJoinedStr { + values: Foldable::fold(values, folder)?, + })) + } + ExprKind::Constant(ExprConstant { value, kind }) => { + Ok(ExprKind::Constant(ExprConstant { + value: Foldable::fold(value, folder)?, + kind: Foldable::fold(kind, folder)?, + })) + } + ExprKind::Attribute(ExprAttribute { value, attr, ctx }) => { + Ok(ExprKind::Attribute(ExprAttribute { + value: Foldable::fold(value, folder)?, + attr: Foldable::fold(attr, folder)?, + ctx: Foldable::fold(ctx, folder)?, + })) + } + ExprKind::Subscript(ExprSubscript { value, slice, ctx }) => { + Ok(ExprKind::Subscript(ExprSubscript { + value: Foldable::fold(value, folder)?, + slice: Foldable::fold(slice, folder)?, + ctx: Foldable::fold(ctx, folder)?, + })) + } + ExprKind::Starred(ExprStarred { value, ctx }) => Ok(ExprKind::Starred(ExprStarred { value: Foldable::fold(value, folder)?, ctx: Foldable::fold(ctx, folder)?, - }), - ExprKind::Name { id, ctx } => Ok(ExprKind::Name { + })), + ExprKind::Name(ExprName { id, ctx }) => Ok(ExprKind::Name(ExprName { id: Foldable::fold(id, folder)?, ctx: Foldable::fold(ctx, folder)?, - }), - ExprKind::List { elts, ctx } => Ok(ExprKind::List { + })), + ExprKind::List(ExprList { elts, ctx }) => Ok(ExprKind::List(ExprList { elts: Foldable::fold(elts, folder)?, ctx: Foldable::fold(ctx, folder)?, - }), - ExprKind::Tuple { elts, ctx } => Ok(ExprKind::Tuple { + })), + ExprKind::Tuple(ExprTuple { elts, ctx }) => Ok(ExprKind::Tuple(ExprTuple { elts: Foldable::fold(elts, folder)?, ctx: Foldable::fold(ctx, folder)?, - }), - ExprKind::Slice { lower, upper, step } => Ok(ExprKind::Slice { + })), + ExprKind::Slice(ExprSlice { lower, upper, step }) => Ok(ExprKind::Slice(ExprSlice { lower: Foldable::fold(lower, folder)?, upper: Foldable::fold(upper, folder)?, step: Foldable::fold(step, folder)?, - }), + })), }) } impl Foldable for ExprContext { @@ -1087,12 +1697,14 @@ pub mod fold { node: Excepthandler, ) -> Result, F::Error> { fold_located(folder, node, |folder, node| match node { - ExcepthandlerKind::ExceptHandler { type_, name, body } => { - Ok(ExcepthandlerKind::ExceptHandler { - type_: Foldable::fold(type_, folder)?, - name: Foldable::fold(name, folder)?, - body: Foldable::fold(body, folder)?, - }) + ExcepthandlerKind::ExceptHandler(ExcepthandlerExceptHandler { type_, name, body }) => { + Ok(ExcepthandlerKind::ExceptHandler( + ExcepthandlerExceptHandler { + type_: Foldable::fold(type_, folder)?, + name: Foldable::fold(name, folder)?, + body: Foldable::fold(body, folder)?, + }, + )) } }) } @@ -1256,45 +1868,57 @@ pub mod fold { node: Pattern, ) -> Result, F::Error> { fold_located(folder, node, |folder, node| match node { - PatternKind::MatchValue { value } => Ok(PatternKind::MatchValue { - value: Foldable::fold(value, folder)?, - }), - PatternKind::MatchSingleton { value } => Ok(PatternKind::MatchSingleton { - value: Foldable::fold(value, folder)?, - }), - PatternKind::MatchSequence { patterns } => Ok(PatternKind::MatchSequence { - patterns: Foldable::fold(patterns, folder)?, - }), - PatternKind::MatchMapping { + PatternKind::MatchValue(PatternMatchValue { value }) => { + Ok(PatternKind::MatchValue(PatternMatchValue { + value: Foldable::fold(value, folder)?, + })) + } + PatternKind::MatchSingleton(PatternMatchSingleton { value }) => { + Ok(PatternKind::MatchSingleton(PatternMatchSingleton { + value: Foldable::fold(value, folder)?, + })) + } + PatternKind::MatchSequence(PatternMatchSequence { patterns }) => { + Ok(PatternKind::MatchSequence(PatternMatchSequence { + patterns: Foldable::fold(patterns, folder)?, + })) + } + PatternKind::MatchMapping(PatternMatchMapping { keys, patterns, rest, - } => Ok(PatternKind::MatchMapping { + }) => Ok(PatternKind::MatchMapping(PatternMatchMapping { keys: Foldable::fold(keys, folder)?, patterns: Foldable::fold(patterns, folder)?, rest: Foldable::fold(rest, folder)?, - }), - PatternKind::MatchClass { + })), + PatternKind::MatchClass(PatternMatchClass { cls, patterns, kwd_attrs, kwd_patterns, - } => Ok(PatternKind::MatchClass { + }) => Ok(PatternKind::MatchClass(PatternMatchClass { cls: Foldable::fold(cls, folder)?, patterns: Foldable::fold(patterns, folder)?, kwd_attrs: Foldable::fold(kwd_attrs, folder)?, kwd_patterns: Foldable::fold(kwd_patterns, folder)?, - }), - PatternKind::MatchStar { name } => Ok(PatternKind::MatchStar { - name: Foldable::fold(name, folder)?, - }), - PatternKind::MatchAs { pattern, name } => Ok(PatternKind::MatchAs { - pattern: Foldable::fold(pattern, folder)?, - name: Foldable::fold(name, folder)?, - }), - PatternKind::MatchOr { patterns } => Ok(PatternKind::MatchOr { - patterns: Foldable::fold(patterns, folder)?, - }), + })), + PatternKind::MatchStar(PatternMatchStar { name }) => { + Ok(PatternKind::MatchStar(PatternMatchStar { + name: Foldable::fold(name, folder)?, + })) + } + PatternKind::MatchAs(PatternMatchAs { pattern, name }) => { + Ok(PatternKind::MatchAs(PatternMatchAs { + pattern: Foldable::fold(pattern, folder)?, + name: Foldable::fold(name, folder)?, + })) + } + PatternKind::MatchOr(PatternMatchOr { patterns }) => { + Ok(PatternKind::MatchOr(PatternMatchOr { + patterns: Foldable::fold(patterns, folder)?, + })) + } }) } impl Foldable for TypeIgnore { @@ -1311,10 +1935,12 @@ pub mod fold { node: TypeIgnore, ) -> Result { match node { - TypeIgnore::TypeIgnore { lineno, tag } => Ok(TypeIgnore::TypeIgnore { - lineno: Foldable::fold(lineno, folder)?, - tag: Foldable::fold(tag, folder)?, - }), + TypeIgnore::TypeIgnore(TypeIgnoreTypeIgnore { lineno, tag }) => { + Ok(TypeIgnore::TypeIgnore(TypeIgnoreTypeIgnore { + lineno: Foldable::fold(lineno, folder)?, + tag: Foldable::fold(tag, folder)?, + })) + } } } } diff --git a/ast/src/constant.rs b/ast/src/constant.rs index 3514e521..0b9a9958 100644 --- a/ast/src/constant.rs +++ b/ast/src/constant.rs @@ -100,7 +100,7 @@ impl crate::fold::Fold for ConstantOptimizer { } fn fold_expr(&mut self, node: crate::Expr) -> Result, Self::Error> { match node.node { - crate::ExprKind::Tuple { elts, ctx } => { + crate::ExprKind::Tuple(crate::ExprTuple { elts, ctx }) => { let elts = elts .into_iter() .map(|x| self.fold_expr(x)) @@ -112,16 +112,16 @@ impl crate::fold::Fold for ConstantOptimizer { let tuple = elts .into_iter() .map(|e| match e.node { - crate::ExprKind::Constant { value, .. } => value, + crate::ExprKind::Constant(crate::ExprConstant { value, .. }) => value, _ => unreachable!(), }) .collect(); - crate::ExprKind::Constant { + crate::ExprKind::Constant(crate::ExprConstant { value: Constant::Tuple(tuple), kind: None, - } + }) } else { - crate::ExprKind::Tuple { elts, ctx } + crate::ExprKind::Tuple(crate::ExprTuple { elts, ctx }) }; Ok(crate::Expr { node: expr, @@ -151,66 +151,73 @@ mod tests { location: start, end_location: end, custom, - node: ExprKind::Tuple { + node: ExprTuple { ctx: ExprContext::Load, elts: vec![ Located { location: start, end_location: end, custom, - node: ExprKind::Constant { + node: ExprConstant { value: BigInt::from(1).into(), kind: None, - }, + } + .into(), }, Located { location: start, end_location: end, custom, - node: ExprKind::Constant { + node: ExprConstant { value: BigInt::from(2).into(), kind: None, - }, + } + .into(), }, Located { location: start, end_location: end, custom, - node: ExprKind::Tuple { + node: ExprTuple { ctx: ExprContext::Load, elts: vec![ Located { location: start, end_location: end, custom, - node: ExprKind::Constant { + node: ExprConstant { value: BigInt::from(3).into(), kind: None, - }, + } + .into(), }, Located { location: start, end_location: end, custom, - node: ExprKind::Constant { + node: ExprConstant { value: BigInt::from(4).into(), kind: None, - }, + } + .into(), }, Located { location: start, end_location: end, custom, - node: ExprKind::Constant { + node: ExprConstant { value: BigInt::from(5).into(), kind: None, - }, + } + .into(), }, ], - }, + } + .into(), }, ], - }, + } + .into(), }; let new_ast = ConstantOptimizer::new() .fold_expr(ast) @@ -221,7 +228,7 @@ mod tests { location: start, end_location: end, custom, - node: ExprKind::Constant { + node: ExprConstant { value: Constant::Tuple(vec![ BigInt::from(1).into(), BigInt::from(2).into(), @@ -232,7 +239,8 @@ mod tests { ]) ]), kind: None - }, + } + .into(), } ); } diff --git a/ast/src/impls.rs b/ast/src/impls.rs index a9302887..e3e827a7 100644 --- a/ast/src/impls.rs +++ b/ast/src/impls.rs @@ -13,7 +13,7 @@ impl ExprKind { ExprKind::Compare { .. } => "comparison", ExprKind::Attribute { .. } => "attribute", ExprKind::Call { .. } => "function call", - ExprKind::Constant { value, .. } => match value { + ExprKind::Constant(crate::ExprConstant { value, .. }) => match value { Constant::Str(_) | Constant::Int(_) | Constant::Float(_) @@ -40,7 +40,7 @@ impl ExprKind { ExprKind::GeneratorExp { .. } => "generator expression", ExprKind::Starred { .. } => "starred", ExprKind::Slice { .. } => "slice", - ExprKind::JoinedStr { values } => { + ExprKind::JoinedStr(crate::ExprJoinedStr { values }) => { if values .iter() .any(|e| matches!(e.node, ExprKind::JoinedStr { .. })) diff --git a/ast/src/unparse.rs b/ast/src/unparse.rs index 40570fc7..807b0f16 100644 --- a/ast/src/unparse.rs +++ b/ast/src/unparse.rs @@ -71,7 +71,7 @@ impl<'a> Unparser<'a> { }}; } match &ast.node { - ExprKind::BoolOp { op, values } => { + ExprKind::BoolOp(crate::ExprBoolOp { op, values }) => { let (op, prec) = op_prec!(bin, op, Boolop, And("and", AND), Or("or", OR)); group_if!(prec, { let mut first = true; @@ -81,14 +81,14 @@ impl<'a> Unparser<'a> { } }) } - ExprKind::NamedExpr { target, value } => { + ExprKind::NamedExpr(crate::ExprNamedExpr { target, value }) => { group_if!(precedence::TUPLE, { self.unparse_expr(target, precedence::ATOM)?; self.p(" := ")?; self.unparse_expr(value, precedence::ATOM)?; }) } - ExprKind::BinOp { left, op, right } => { + ExprKind::BinOp(crate::ExprBinOp { left, op, right }) => { let right_associative = matches!(op, Operator::Pow); let (op, prec) = op_prec!( bin, @@ -114,7 +114,7 @@ impl<'a> Unparser<'a> { self.unparse_expr(right, prec + !right_associative as u8)?; }) } - ExprKind::UnaryOp { op, operand } => { + ExprKind::UnaryOp(crate::ExprUnaryOp { op, operand }) => { let (op, prec) = op_prec!( un, op, @@ -129,7 +129,7 @@ impl<'a> Unparser<'a> { self.unparse_expr(operand, prec)?; }) } - ExprKind::Lambda { args, body } => { + ExprKind::Lambda(crate::ExprLambda { args, body }) => { group_if!(precedence::TEST, { let pos = args.args.len() + args.posonlyargs.len(); self.p(if pos > 0 { "lambda " } else { "lambda" })?; @@ -137,7 +137,7 @@ impl<'a> Unparser<'a> { write!(self, ": {}", **body)?; }) } - ExprKind::IfExp { test, body, orelse } => { + ExprKind::IfExp(crate::ExprIfExp { test, body, orelse }) => { group_if!(precedence::TEST, { self.unparse_expr(body, precedence::TEST + 1)?; self.p(" if ")?; @@ -146,7 +146,7 @@ impl<'a> Unparser<'a> { self.unparse_expr(orelse, precedence::TEST)?; }) } - ExprKind::Dict { keys, values } => { + ExprKind::Dict(crate::ExprDict { keys, values }) => { self.p("{")?; let mut first = true; let (packed, unpacked) = values.split_at(keys.len()); @@ -164,7 +164,7 @@ impl<'a> Unparser<'a> { } self.p("}")?; } - ExprKind::Set { elts } => { + ExprKind::Set(crate::ExprSet { elts }) => { self.p("{")?; let mut first = true; for v in elts { @@ -173,23 +173,23 @@ impl<'a> Unparser<'a> { } self.p("}")?; } - ExprKind::ListComp { elt, generators } => { + ExprKind::ListComp(crate::ExprListComp { elt, generators }) => { self.p("[")?; self.unparse_expr(elt, precedence::TEST)?; self.unparse_comp(generators)?; self.p("]")?; } - ExprKind::SetComp { elt, generators } => { + ExprKind::SetComp(crate::ExprSetComp { elt, generators }) => { self.p("{")?; self.unparse_expr(elt, precedence::TEST)?; self.unparse_comp(generators)?; self.p("}")?; } - ExprKind::DictComp { + ExprKind::DictComp(crate::ExprDictComp { key, value, generators, - } => { + }) => { self.p("{")?; self.unparse_expr(key, precedence::TEST)?; self.p(": ")?; @@ -197,33 +197,33 @@ impl<'a> Unparser<'a> { self.unparse_comp(generators)?; self.p("}")?; } - ExprKind::GeneratorExp { elt, generators } => { + ExprKind::GeneratorExp(crate::ExprGeneratorExp { elt, generators }) => { self.p("(")?; self.unparse_expr(elt, precedence::TEST)?; self.unparse_comp(generators)?; self.p(")")?; } - ExprKind::Await { value } => { + ExprKind::Await(crate::ExprAwait { value }) => { group_if!(precedence::AWAIT, { self.p("await ")?; self.unparse_expr(value, precedence::ATOM)?; }) } - ExprKind::Yield { value } => { + ExprKind::Yield(crate::ExprYield { value }) => { if let Some(value) = value { write!(self, "(yield {})", **value)?; } else { self.p("(yield)")?; } } - ExprKind::YieldFrom { value } => { + ExprKind::YieldFrom(crate::ExprYieldFrom { value }) => { write!(self, "(yield from {})", **value)?; } - ExprKind::Compare { + ExprKind::Compare(crate::ExprCompare { left, ops, comparators, - } => { + }) => { group_if!(precedence::CMP, { let new_lvl = precedence::CMP + 1; self.unparse_expr(left, new_lvl)?; @@ -245,16 +245,16 @@ impl<'a> Unparser<'a> { } }) } - ExprKind::Call { + ExprKind::Call(crate::ExprCall { func, args, keywords, - } => { + }) => { self.unparse_expr(func, precedence::ATOM)?; self.p("(")?; if let ( [Expr { - node: ExprKind::GeneratorExp { elt, generators }, + node: ExprKind::GeneratorExp(crate::ExprGeneratorExp { elt, generators }), .. }], [], @@ -282,13 +282,15 @@ impl<'a> Unparser<'a> { } self.p(")")?; } - ExprKind::FormattedValue { + ExprKind::FormattedValue(crate::ExprFormattedValue { value, conversion, format_spec, - } => self.unparse_formatted(value, *conversion, format_spec.as_deref())?, - ExprKind::JoinedStr { values } => self.unparse_joined_str(values, false)?, - ExprKind::Constant { value, kind } => { + }) => self.unparse_formatted(value, *conversion, format_spec.as_deref())?, + ExprKind::JoinedStr(crate::ExprJoinedStr { values }) => { + self.unparse_joined_str(values, false)? + } + ExprKind::Constant(crate::ExprConstant { value, kind }) => { if let Some(kind) = kind { self.p(kind)?; } @@ -304,12 +306,12 @@ impl<'a> Unparser<'a> { _ => fmt::Display::fmt(value, &mut self.f)?, } } - ExprKind::Attribute { value, attr, .. } => { + ExprKind::Attribute(crate::ExprAttribute { value, attr, .. }) => { self.unparse_expr(value, precedence::ATOM)?; - let period = if let ExprKind::Constant { + let period = if let ExprKind::Constant(crate::ExprConstant { value: Constant::Int(_), .. - } = &value.node + }) = &value.node { " ." } else { @@ -318,10 +320,10 @@ impl<'a> Unparser<'a> { self.p(period)?; self.p(attr)?; } - ExprKind::Subscript { value, slice, .. } => { + ExprKind::Subscript(crate::ExprSubscript { value, slice, .. }) => { self.unparse_expr(value, precedence::ATOM)?; let mut lvl = precedence::TUPLE; - if let ExprKind::Tuple { elts, .. } = &slice.node { + if let ExprKind::Tuple(crate::ExprTuple { elts, .. }) = &slice.node { if elts .iter() .any(|expr| matches!(expr.node, ExprKind::Starred { .. })) @@ -333,12 +335,12 @@ impl<'a> Unparser<'a> { self.unparse_expr(slice, lvl)?; self.p("]")?; } - ExprKind::Starred { value, .. } => { + ExprKind::Starred(crate::ExprStarred { value, .. }) => { self.p("*")?; self.unparse_expr(value, precedence::EXPR)?; } - ExprKind::Name { id, .. } => self.p(id)?, - ExprKind::List { elts, .. } => { + ExprKind::Name(crate::ExprName { id, .. }) => self.p(id)?, + ExprKind::List(crate::ExprList { elts, .. }) => { self.p("[")?; let mut first = true; for elt in elts { @@ -347,7 +349,7 @@ impl<'a> Unparser<'a> { } self.p("]")?; } - ExprKind::Tuple { elts, .. } => { + ExprKind::Tuple(crate::ExprTuple { elts, .. }) => { if elts.is_empty() { self.p("()")?; } else { @@ -361,7 +363,7 @@ impl<'a> Unparser<'a> { }) } } - ExprKind::Slice { lower, upper, step } => { + ExprKind::Slice(crate::ExprSlice { lower, upper, step }) => { if let Some(lower) = lower { self.unparse_expr(lower, precedence::TEST)?; } @@ -483,19 +485,21 @@ impl<'a> Unparser<'a> { fn unparse_fstring_elem(&mut self, expr: &Expr, is_spec: bool) -> fmt::Result { match &expr.node { - ExprKind::Constant { value, .. } => { + ExprKind::Constant(crate::ExprConstant { value, .. }) => { if let Constant::Str(s) = value { self.unparse_fstring_str(s) } else { unreachable!() } } - ExprKind::JoinedStr { values } => self.unparse_joined_str(values, is_spec), - ExprKind::FormattedValue { + ExprKind::JoinedStr(crate::ExprJoinedStr { values }) => { + self.unparse_joined_str(values, is_spec) + } + ExprKind::FormattedValue(crate::ExprFormattedValue { value, conversion, format_spec, - } => self.unparse_formatted(value, *conversion, format_spec.as_deref()), + }) => self.unparse_formatted(value, *conversion, format_spec.as_deref()), _ => unreachable!(), } } diff --git a/parser/src/context.rs b/parser/src/context.rs index eb1953f6..c1b1cbf1 100644 --- a/parser/src/context.rs +++ b/parser/src/context.rs @@ -1,44 +1,47 @@ -use rustpython_ast::{Expr, ExprContext, ExprKind}; +use crate::ast::{self, Expr, ExprContext, ExprKind}; pub(crate) fn set_context(expr: Expr, ctx: ExprContext) -> Expr { match expr.node { - ExprKind::Name { id, .. } => Expr { - node: ExprKind::Name { id, ctx }, + ExprKind::Name(ast::ExprName { id, .. }) => Expr { + node: ast::ExprName { id, ctx }.into(), ..expr }, - ExprKind::Tuple { elts, .. } => Expr { - node: ExprKind::Tuple { + ExprKind::Tuple(ast::ExprTuple { elts, .. }) => Expr { + node: ast::ExprTuple { elts: elts .into_iter() .map(|elt| set_context(elt, ctx.clone())) .collect(), ctx, - }, + } + .into(), ..expr }, - ExprKind::List { elts, .. } => Expr { - node: ExprKind::List { + ExprKind::List(ast::ExprList { elts, .. }) => Expr { + node: ast::ExprList { elts: elts .into_iter() .map(|elt| set_context(elt, ctx.clone())) .collect(), ctx, - }, + } + .into(), ..expr }, - ExprKind::Attribute { value, attr, .. } => Expr { - node: ExprKind::Attribute { value, attr, ctx }, + ExprKind::Attribute(ast::ExprAttribute { value, attr, .. }) => Expr { + node: ast::ExprAttribute { value, attr, ctx }.into(), ..expr }, - ExprKind::Subscript { value, slice, .. } => Expr { - node: ExprKind::Subscript { value, slice, ctx }, + ExprKind::Subscript(ast::ExprSubscript { value, slice, .. }) => Expr { + node: ast::ExprSubscript { value, slice, ctx }.into(), ..expr }, - ExprKind::Starred { value, .. } => Expr { - node: ExprKind::Starred { + ExprKind::Starred(ast::ExprStarred { value, .. }) => Expr { + node: ast::ExprStarred { value: Box::new(set_context(*value, ctx.clone())), ctx, - }, + } + .into(), ..expr }, _ => expr, diff --git a/parser/src/parser.rs b/parser/src/parser.rs index 74173a2a..6e61cf9b 100644 --- a/parser/src/parser.rs +++ b/parser/src/parser.rs @@ -46,7 +46,7 @@ pub(super) use lalrpop_util::ParseError as LalrpopError; /// ``` pub fn parse_program(source: &str, source_path: &str) -> Result { parse(source, Mode::Module, source_path).map(|top| match top { - ast::Mod::Module { body, .. } => body, + ast::Mod::Module(ast::ModModule { body, .. }) => body, _ => unreachable!(), }) } @@ -94,7 +94,7 @@ pub fn parse_expression_located( location: Location, ) -> Result { parse_located(source, Mode::Expression, path, location).map(|top| match top { - ast::Mod::Expression { body } => *body, + ast::Mod::Expression(ast::ModExpression { body }) => *body, _ => unreachable!(), }) } diff --git a/parser/src/python.lalrpop b/parser/src/python.lalrpop index 45113a3c..85c5490c 100644 --- a/parser/src/python.lalrpop +++ b/parser/src/python.lalrpop @@ -19,9 +19,9 @@ grammar; // For each public entry point, a full parse table is generated. // By having only a single pub function, we reduce this to one. pub Top: ast::Mod = { - StartModule => ast::Mod::Module { body, type_ignores: vec![] }, - StartInteractive => ast::Mod::Interactive { body }, - StartExpression ("\n")* => ast::Mod::Expression { body: Box::new(body) }, + StartModule => ast::ModModule { body, type_ignores: vec![] }.into(), + StartInteractive => ast::ModInteractive { body }.into(), + StartExpression ("\n")* => ast::ModExpression { body: Box::new(body) }.into(), }; Program: ast::Suite = { @@ -80,7 +80,7 @@ DelStatement: ast::Stmt = { ast::Stmt::new( location, end_location, - ast::StmtKind::Delete { targets: targets.into_iter().map(|expr| set_context(expr, ast::ExprContext::Del)).collect() }, + ast::StmtDelete { targets: targets.into_iter().map(|expr| set_context(expr, ast::ExprContext::Del)).collect() }.into() ) }, }; @@ -92,7 +92,7 @@ ExpressionStatement: ast::Stmt = { ast::Stmt::new( location, end_location, - ast::StmtKind::Expr { value: Box::new(expression) } + ast::StmtExpr { value: Box::new(expression) }.into() ) } else { let mut targets = vec![set_context(expression, ast::ExprContext::Store)]; @@ -107,7 +107,7 @@ ExpressionStatement: ast::Stmt = { ast::Stmt::new( location, end_location, - ast::StmtKind::Assign { targets, value, type_comment: None }, + ast::StmtAssign { targets, value, type_comment: None }.into() ) } }, @@ -115,11 +115,11 @@ ExpressionStatement: ast::Stmt = { ast::Stmt::new( location, end_location, - ast::StmtKind::AugAssign { + ast::StmtAugAssign { target: Box::new(set_context(target, ast::ExprContext::Store)), op, value: Box::new(rhs) - }, + }.into(), ) }, > ":" > => { @@ -127,12 +127,12 @@ ExpressionStatement: ast::Stmt = { ast::Stmt::new( location, end_location, - ast::StmtKind::AnnAssign { + ast::StmtAnnAssign { target: Box::new(set_context(target, ast::ExprContext::Store)), annotation: Box::new(annotation), value: rhs.map(Box::new), simple: if simple { 1 } else { 0 }, - }, + }.into(), ) }, }; @@ -202,14 +202,14 @@ FlowStatement: ast::Stmt = { ast::Stmt::new( location, end_location, - ast::StmtKind::Return { value: value.map(Box::new) }, + ast::StmtReturn { value: value.map(Box::new) }.into() ) }, => { ast::Stmt::new( location, end_location, - ast::StmtKind::Expr { value: Box::new(expression) }, + ast::StmtExpr { value: Box::new(expression) }.into() ) }, RaiseStatement, @@ -220,14 +220,14 @@ RaiseStatement: ast::Stmt = { ast::Stmt::new( location, end_location, - ast::StmtKind::Raise { exc: None, cause: None }, + ast::StmtRaise { exc: None, cause: None }.into() ) }, "raise" > )?> => { ast::Stmt::new( location, end_location, - ast::StmtKind::Raise { exc: Some(Box::new(t)), cause: c.map(|x| Box::new(x.1)) }, + ast::StmtRaise { exc: Some(Box::new(t)), cause: c.map(|x| Box::new(x.1)) }.into() ) }, }; @@ -237,7 +237,7 @@ ImportStatement: ast::Stmt = { ast::Stmt::new( location, end_location, - ast::StmtKind::Import { names }, + ast::StmtImport { names }.into() ) }, "from" "import" => { @@ -245,11 +245,11 @@ ImportStatement: ast::Stmt = { ast::Stmt::new( location, end_location, - ast::StmtKind::ImportFrom { + ast::StmtImportFrom { level, module, names - }, + }.into(), ) }, }; @@ -301,7 +301,7 @@ GlobalStatement: ast::Stmt = { ast::Stmt::new( location, end_location, - ast::StmtKind::Global { names } + ast::StmtGlobal { names }.into() ) }, }; @@ -311,7 +311,7 @@ NonlocalStatement: ast::Stmt = { ast::Stmt::new( location, end_location, - ast::StmtKind::Nonlocal { names } + ast::StmtNonlocal { names }.into() ) }, }; @@ -321,10 +321,10 @@ AssertStatement: ast::Stmt = { ast::Stmt::new( location, end_location, - ast::StmtKind::Assert { + ast::StmtAssert { test: Box::new(test), msg: msg.map(|e| Box::new(e.1)) - } + }.into() ) }, }; @@ -352,10 +352,10 @@ MatchStatement: ast::Stmt = { ast::Stmt::new( location, end_location, - ast::StmtKind::Match { + ast::StmtMatch { subject: Box::new(subject), cases - } + }.into() ) }, "match" "," ":" "\n" Indent Dedent => { @@ -369,10 +369,10 @@ MatchStatement: ast::Stmt = { ast::Stmt::new( location, end_location, - ast::StmtKind::Match { + ast::StmtMatch { subject: Box::new(subject), cases - } + }.into() ) }, "match" "," > ","? ":" "\n" Indent Dedent => { @@ -388,17 +388,17 @@ MatchStatement: ast::Stmt = { ast::Stmt::new( location, end_location, - ast::StmtKind::Match { + ast::StmtMatch { subject: Box::new(ast::Expr::new( location, end_location, - ast::ExprKind::Tuple { + ast::ExprTuple { elts: subjects, ctx: ast::ExprContext::Load, - }, + }.into(), )), cases - } + }.into() ) } } @@ -423,9 +423,9 @@ Patterns: ast::Pattern = { "," => ast::Pattern::new( location, end_location, - ast::PatternKind::MatchSequence { + ast::PatternMatchSequence { patterns: vec![pattern] - }, + }.into(), ), "," > ","? => { let mut patterns = patterns; @@ -433,9 +433,9 @@ Patterns: ast::Pattern = { ast::Pattern::new( location, end_location, - ast::PatternKind::MatchSequence { + ast::PatternMatchSequence { patterns - }, + }.into(), ) }, => pattern @@ -457,10 +457,10 @@ AsPattern: ast::Pattern = { Ok(ast::Pattern::new( location, end_location, - ast::PatternKind::MatchAs { + ast::PatternMatchAs { pattern: Some(Box::new(pattern)), name: Some(name), - }, + }.into(), )) } }, @@ -474,7 +474,7 @@ OrPattern: ast::Pattern = { ast::Pattern::new( location, end_location, - ast::PatternKind::MatchOr { patterns } + ast::PatternMatchOr { patterns }.into() ) } } @@ -520,32 +520,32 @@ ClosedPattern: ast::Pattern = { SequencePattern: ast::PatternKind = { // A single-item tuple is a special case: it's a group pattern, _not_ a sequence pattern. "(" ")" => pattern.node, - "(" ")" => ast::PatternKind::MatchSequence { + "(" ")" => ast::PatternMatchSequence { patterns: vec![], - }, + }.into(), "(" "," > ")" => { let mut patterns = patterns; patterns.insert(0, pattern); - ast::PatternKind::MatchSequence { + ast::PatternMatchSequence { patterns - } + }.into() }, - "[" > "]" => ast::PatternKind::MatchSequence { + "[" > "]" => ast::PatternMatchSequence { patterns - }, + }.into(), } StarPattern: ast::PatternKind = { - "*" => ast::PatternKind::MatchStar { + "*" => ast::PatternMatchStar { name: if name == "_" { None } else { Some(name) } - }, + }.into(), } ConstantAtom: ast::Expr = { => ast::Expr::new( location, end_location, - ast::ExprKind::Constant { value, kind: None } + ast::ExprConstant { value, kind: None }.into() ), } @@ -554,10 +554,10 @@ ConstantExpr: ast::Expr = { "-" => ast::Expr::new( location, end_location, - ast::ExprKind::UnaryOp { + ast::ExprUnaryOp { op: ast::Unaryop::USub, operand: Box::new(operand) - } + }.into() ), } @@ -565,47 +565,47 @@ AddOpExpr: ast::Expr = { => ast::Expr::new( location, end_location, - ast::ExprKind::BinOp { + ast::ExprBinOp { left: Box::new(left), op, right: Box::new(right), - } + }.into() ), } LiteralPattern: ast::PatternKind = { - "None" => ast::PatternKind::MatchSingleton { + "None" => ast::PatternMatchSingleton { value: ast::Constant::None - }, - "True" => ast::PatternKind::MatchSingleton { + }.into(), + "True" => ast::PatternMatchSingleton { value: true.into() - }, - "False" => ast::PatternKind::MatchSingleton { + }.into(), + "False" => ast::PatternMatchSingleton { value: false.into() - }, - => ast::PatternKind::MatchValue { + }.into(), + => ast::PatternMatchValue { value: Box::new(value) - }, - => ast::PatternKind::MatchValue { + }.into(), + => ast::PatternMatchValue { value: Box::new(value) - }, - =>? Ok(ast::PatternKind::MatchValue { + }.into(), + =>? Ok(ast::PatternMatchValue { value: Box::new(parse_strings(s)?) - }), + }.into()), } CapturePattern: ast::PatternKind = { - => ast::PatternKind::MatchAs { + => ast::PatternMatchAs { pattern: None, name: if name == "_" { None } else { Some(name) } - }, + }.into(), } MatchName: ast::Expr = { => ast::Expr::new( location, end_location, - ast::ExprKind::Name { id: name, ctx: ast::ExprContext::Load }, + ast::ExprName { id: name, ctx: ast::ExprContext::Load }.into(), ), } @@ -613,27 +613,27 @@ MatchNameOrAttr: ast::Expr = { "." => ast::Expr::new( location, end_location, - ast::ExprKind::Attribute { + ast::ExprAttribute { value: Box::new(name), attr, ctx: ast::ExprContext::Load, - }, + }.into(), ), "." => ast::Expr::new( location, end_location, - ast::ExprKind::Attribute { + ast::ExprAttribute { value: Box::new(e), attr, ctx: ast::ExprContext::Load, - } + }.into(), ) } ValuePattern: ast::PatternKind = { - => ast::PatternKind::MatchValue { + => ast::PatternMatchValue { value: Box::new(e) - }, + }.into(), } MappingKey: ast::Expr = { @@ -643,26 +643,26 @@ MappingKey: ast::Expr = { "None" => ast::Expr::new( location, end_location, - ast::ExprKind::Constant { + ast::ExprConstant { value: ast::Constant::None, kind: None, - }, + }.into(), ), "True" => ast::Expr::new( location, end_location, - ast::ExprKind::Constant { + ast::ExprConstant { value: true.into(), kind: None, - }, + }.into(), ), "False" => ast::Expr::new( location, end_location, - ast::ExprKind::Constant { + ast::ExprConstant { value: false.into(), kind: None, - }, + }.into(), ), =>? Ok(parse_strings(s)?), } @@ -673,38 +673,38 @@ MatchMappingEntry: (ast::Expr, ast::Pattern) = { MappingPattern: ast::PatternKind = { "{" "}" => { - return ast::PatternKind::MatchMapping { + return ast::PatternMatchMapping { keys: vec![], patterns: vec![], rest: None, - }; + }.into(); }, "{" > ","? "}" => { let (keys, patterns) = e .into_iter() .unzip(); - return ast::PatternKind::MatchMapping { + return ast::PatternMatchMapping { keys, patterns, rest: None, - }; + }.into(); }, "{" "**" ","? "}" => { - return ast::PatternKind::MatchMapping { + return ast::PatternMatchMapping { keys: vec![], patterns: vec![], rest: Some(rest), - }; + }.into(); }, "{" > "," "**" ","? "}" => { let (keys, patterns) = e .into_iter() .unzip(); - return ast::PatternKind::MatchMapping { + return ast::PatternMatchMapping { keys, patterns, rest: Some(rest), - }; + }.into(); }, } @@ -717,77 +717,77 @@ ClassPattern: ast::PatternKind = { let (kwd_attrs, kwd_patterns) = kwds .into_iter() .unzip(); - ast::PatternKind::MatchClass { + ast::PatternMatchClass { cls: Box::new(e), patterns, kwd_attrs, kwd_patterns, - } + }.into() }, "(" > ","? ")" => { - ast::PatternKind::MatchClass { + ast::PatternMatchClass { cls: Box::new(e), patterns, kwd_attrs: vec![], kwd_patterns: vec![], - } + }.into() }, "(" > ","? ")" => { let (kwd_attrs, kwd_patterns) = kwds .into_iter() .unzip(); - ast::PatternKind::MatchClass { + ast::PatternMatchClass { cls: Box::new(e), patterns: vec![], kwd_attrs, kwd_patterns, - } + }.into() }, "(" ")" => { - ast::PatternKind::MatchClass { + ast::PatternMatchClass { cls: Box::new(e), patterns: vec![], kwd_attrs: vec![], kwd_patterns: vec![], - } + }.into() }, "(" > "," > ","? ")" => { let (kwd_attrs, kwd_patterns) = kwds .into_iter() .unzip(); - ast::PatternKind::MatchClass { + ast::PatternMatchClass { cls: Box::new(e), patterns, kwd_attrs, kwd_patterns, - } + }.into() }, "(" > ","? ")" => { - ast::PatternKind::MatchClass { + ast::PatternMatchClass { cls: Box::new(e), patterns, kwd_attrs: vec![], kwd_patterns: vec![], - } + }.into() }, "(" > ","? ")" => { let (kwd_attrs, kwd_patterns) = kwds .into_iter() .unzip(); - ast::PatternKind::MatchClass { + ast::PatternMatchClass { cls: Box::new(e), patterns: vec![], kwd_attrs, kwd_patterns, - } + }.into() }, "(" ")" => { - ast::PatternKind::MatchClass { + ast::PatternMatchClass { cls: Box::new(e), patterns: vec![], kwd_attrs: vec![], kwd_patterns: vec![], - } + }.into() }, } @@ -806,7 +806,7 @@ IfStatement: ast::Stmt = { let x = ast::Stmt::new( i.0, end_location, - ast::StmtKind::If { test: Box::new(i.2), body: i.4, orelse: last }, + ast::StmtIf { test: Box::new(i.2), body: i.4, orelse: last }.into() ); last = vec![x]; } @@ -814,7 +814,7 @@ IfStatement: ast::Stmt = { ast::Stmt::new( location, end_location, - ast::StmtKind::If { test: Box::new(test), body, orelse: last } + ast::StmtIf { test: Box::new(test), body, orelse: last }.into() ) }, }; @@ -830,11 +830,11 @@ WhileStatement: ast::Stmt = { ast::Stmt::new( location, end_location, - ast::StmtKind::While { + ast::StmtWhile { test: Box::new(test), body, orelse - }, + }.into(), ) }, }; @@ -851,9 +851,9 @@ ForStatement: ast::Stmt = { let iter = Box::new(iter); let type_comment = None; let node = if is_async.is_some() { - ast::StmtKind::AsyncFor { target, iter, body, orelse, type_comment } + ast::StmtAsyncFor { target, iter, body, orelse, type_comment }.into() } else { - ast::StmtKind::For { target, iter, body, orelse, type_comment } + ast::StmtFor { target, iter, body, orelse, type_comment }.into() }; ast::Stmt::new(location, end_location, node) }, @@ -872,12 +872,12 @@ TryStatement: ast::Stmt = { ast::Stmt::new( location, end_location, - ast::StmtKind::Try { + ast::StmtTry { body, handlers, orelse, finalbody, - }, + }.into(), ) }, "try" ":" => { @@ -892,12 +892,12 @@ TryStatement: ast::Stmt = { ast::Stmt::new( location, end_location, - ast::StmtKind::TryStar { + ast::StmtTryStar { body, handlers, orelse, finalbody, - }, + }.into(), ) }, "try" ":" => { @@ -908,12 +908,12 @@ TryStatement: ast::Stmt = { ast::Stmt::new( location, end_location, - ast::StmtKind::Try { + ast::StmtTry { body, handlers, orelse, finalbody, - }, + }.into(), ) }, }; @@ -924,11 +924,11 @@ ExceptStarClause: ast::Excepthandler = { ast::Excepthandler::new( location, end_location, - ast::ExcepthandlerKind::ExceptHandler { + ast::ExcepthandlerExceptHandler { type_: Some(Box::new(typ)), name: None, body, - }, + }.into(), ) }, "except" "*" "as" Identifier)> ":" => { @@ -936,11 +936,11 @@ ExceptStarClause: ast::Excepthandler = { ast::Excepthandler::new( location, end_location, - ast::ExcepthandlerKind::ExceptHandler { + ast::ExcepthandlerExceptHandler { type_: Some(Box::new(x.0)), name: Some(x.2), body, - }, + }.into(), ) }, }; @@ -952,11 +952,11 @@ ExceptClause: ast::Excepthandler = { ast::Excepthandler::new( location, end_location, - ast::ExcepthandlerKind::ExceptHandler { + ast::ExcepthandlerExceptHandler { type_: typ.map(Box::new), name: None, body, - }, + }.into(), ) }, "except" "as" Identifier)> ":" => { @@ -964,11 +964,11 @@ ExceptClause: ast::Excepthandler = { ast::Excepthandler::new( location, end_location, - ast::ExcepthandlerKind::ExceptHandler { + ast::ExcepthandlerExceptHandler { type_: Some(Box::new(x.0)), name: Some(x.2), body, - }, + }.into(), ) }, }; @@ -978,9 +978,9 @@ WithStatement: ast::Stmt = { let end_location = body.last().unwrap().end(); let type_comment = None; let node = if is_async.is_some() { - ast::StmtKind::AsyncWith { items, body, type_comment } + ast::StmtAsyncWith { items, body, type_comment }.into() } else { - ast::StmtKind::With { items, body, type_comment } + ast::StmtWith { items, body, type_comment }.into() }; ast::Stmt::new(location, end_location, node) }, @@ -1019,9 +1019,9 @@ FuncDef: ast::Stmt = { let end_location = body.last().unwrap().end(); let type_comment = None; let node = if is_async.is_some() { - ast::StmtKind::AsyncFunctionDef { name, args, body, decorator_list, returns, type_comment } + ast::StmtAsyncFunctionDef { name, args, body, decorator_list, returns, type_comment }.into() } else { - ast::StmtKind::FunctionDef { name, args, body, decorator_list, returns, type_comment } + ast::StmtFunctionDef { name, args, body, decorator_list, returns, type_comment }.into() }; ast::Stmt::new(location, end_location, node) }, @@ -1195,13 +1195,13 @@ ClassDef: ast::Stmt = { ast::Stmt::new( location, end_location, - ast::StmtKind::ClassDef { + ast::StmtClassDef { name, bases, keywords, body, decorator_list, - }, + }.into(), ) }, }; @@ -1217,12 +1217,12 @@ YieldExpr: ast::Expr = { "yield" => ast::Expr::new( location, end_location, - ast::ExprKind::Yield { value: value.map(Box::new) } + ast::ExprYield { value: value.map(Box::new) }.into() ), "yield" "from" > => ast::Expr::new( location, end_location, - ast::ExprKind::YieldFrom { value: Box::new(e) } + ast::ExprYieldFrom { value: Box::new(e) }.into() ), }; @@ -1230,11 +1230,11 @@ Test: ast::Expr = { > "if" > "else" > => ast::Expr::new( location, end_location, - ast::ExprKind::IfExp { + ast::ExprIfExp { test: Box::new(test), body: Box::new(body), orelse: Box::new(orelse), - } + }.into() ), OrTest, LambdaDef, @@ -1250,14 +1250,14 @@ NamedExpression: ast::Expr = { ast::Expr::new( location, value.end(), - ast::ExprKind::NamedExpr { + ast::ExprNamedExpr { target: Box::new(ast::Expr::new( location, end_location, - ast::ExprKind::Name { id, ctx: ast::ExprContext::Store }, + ast::ExprName { id, ctx: ast::ExprContext::Store }.into(), )), value: Box::new(value), - } + }.into() ) }, }; @@ -1281,10 +1281,10 @@ LambdaDef: ast::Expr = { Ok(ast::Expr::new( location, end_location, - ast::ExprKind::Lambda { + ast::ExprLambda { args: Box::new(p), body: Box::new(body) - } + }.into() )) } } @@ -1296,7 +1296,7 @@ OrTest: ast::Expr = { ast::Expr::new( location, end_location, - ast::ExprKind::BoolOp { op: ast::Boolop::Or, values } + ast::ExprBoolOp { op: ast::Boolop::Or, values }.into() ) }, AndTest, @@ -1309,7 +1309,7 @@ AndTest: ast::Expr = { ast::Expr::new( location, end_location, - ast::ExprKind::BoolOp { op: ast::Boolop::And, values } + ast::ExprBoolOp { op: ast::Boolop::And, values }.into() ) }, NotTest, @@ -1319,7 +1319,7 @@ NotTest: ast::Expr = { "not" > => ast::Expr::new( location, end_location, - ast::ExprKind::UnaryOp { operand: Box::new(e), op: ast::Unaryop::Not } + ast::ExprUnaryOp { operand: Box::new(e), op: ast::Unaryop::Not }.into() ), Comparison, }; @@ -1330,7 +1330,7 @@ Comparison: ast::Expr = { ast::Expr::new( location, end_location, - ast::ExprKind::Compare { left: Box::new(left), ops, comparators } + ast::ExprCompare { left: Box::new(left), ops, comparators }.into() ) }, Expression, @@ -1353,7 +1353,7 @@ Expression: ast::Expr = { > "|" > => ast::Expr::new( location, end_location, - ast::ExprKind::BinOp { left: Box::new(e1), op: ast::Operator::BitOr, right: Box::new(e2) } + ast::ExprBinOp { left: Box::new(e1), op: ast::Operator::BitOr, right: Box::new(e2) }.into() ), XorExpression, }; @@ -1362,7 +1362,7 @@ XorExpression: ast::Expr = { > "^" > => ast::Expr::new( location, end_location, - ast::ExprKind::BinOp { left: Box::new(e1), op: ast::Operator::BitXor, right: Box::new(e2) } + ast::ExprBinOp { left: Box::new(e1), op: ast::Operator::BitXor, right: Box::new(e2) }.into() ), AndExpression, }; @@ -1371,7 +1371,7 @@ AndExpression: ast::Expr = { > "&" > => ast::Expr::new( location, end_location, - ast::ExprKind::BinOp { left: Box::new(e1), op: ast::Operator::BitAnd, right: Box::new(e2) } + ast::ExprBinOp { left: Box::new(e1), op: ast::Operator::BitAnd, right: Box::new(e2) }.into() ), ShiftExpression, }; @@ -1380,7 +1380,7 @@ ShiftExpression: ast::Expr = { > > => ast::Expr::new( location, end_location, - ast::ExprKind::BinOp { left: Box::new(e1), op, right: Box::new(e2) } + ast::ExprBinOp { left: Box::new(e1), op, right: Box::new(e2) }.into() ), ArithmeticExpression, }; @@ -1394,7 +1394,7 @@ ArithmeticExpression: ast::Expr = { > > => ast::Expr::new( location, end_location, - ast::ExprKind::BinOp { left: Box::new(a), op, right: Box::new(b) } + ast::ExprBinOp { left: Box::new(a), op, right: Box::new(b) }.into() ), Term, }; @@ -1408,7 +1408,7 @@ Term: ast::Expr = { > > => ast::Expr::new( location, end_location, - ast::ExprKind::BinOp { left: Box::new(a), op, right: Box::new(b) } + ast::ExprBinOp { left: Box::new(a), op, right: Box::new(b) }.into() ), Factor, }; @@ -1425,7 +1425,7 @@ Factor: ast::Expr = { > => ast::Expr::new( location, end_location, - ast::ExprKind::UnaryOp { operand: Box::new(e), op } + ast::ExprUnaryOp { operand: Box::new(e), op }.into() ), Power, }; @@ -1440,7 +1440,7 @@ Power: ast::Expr = { > "**" > => ast::Expr::new( location, end_location, - ast::ExprKind::BinOp { left: Box::new(e), op: ast::Operator::Pow, right: Box::new(b) } + ast::ExprBinOp { left: Box::new(e), op: ast::Operator::Pow, right: Box::new(b) }.into() ), AtomExpr, }; @@ -1450,7 +1450,7 @@ AtomExpr: ast::Expr = { ast::Expr::new( location, end_location, - ast::ExprKind::Await { value: Box::new(atom) } + ast::ExprAwait { value: Box::new(atom) }.into() ) }, AtomExpr2, @@ -1462,18 +1462,18 @@ AtomExpr2: ast::Expr = { ast::Expr::new( location, end_location, - ast::ExprKind::Call { func: Box::new(f), args: a.args, keywords: a.keywords } + ast::ExprCall { func: Box::new(f), args: a.args, keywords: a.keywords }.into() ) }, > "[" "]" => ast::Expr::new( location, end_location, - ast::ExprKind::Subscript { value: Box::new(e), slice: Box::new(s), ctx: ast::ExprContext::Load } + ast::ExprSubscript { value: Box::new(e), slice: Box::new(s), ctx: ast::ExprContext::Load }.into() ), > "." => ast::Expr::new( location, end_location, - ast::ExprKind::Attribute { value: Box::new(e), attr, ctx: ast::ExprContext::Load } + ast::ExprAttribute { value: Box::new(e), attr, ctx: ast::ExprContext::Load }.into() ), }; @@ -1490,7 +1490,7 @@ SubscriptList: ast::Expr = { ast::Expr::new( location, end_location, - ast::ExprKind::Tuple { elts: dims, ctx: ast::ExprContext::Load }, + ast::ExprTuple { elts: dims, ctx: ast::ExprContext::Load }.into(), ) } } @@ -1505,7 +1505,7 @@ Subscript: ast::Expr = { ast::Expr::new( location, end_location, - ast::ExprKind::Slice { lower, upper, step } + ast::ExprSlice { lower, upper, step }.into() ) } }; @@ -1519,26 +1519,26 @@ Atom: ast::Expr = { => ast::Expr::new( location, end_location, - ast::ExprKind::Constant { value, kind: None } + ast::ExprConstant { value, kind: None }.into() ), => ast::Expr::new( location, end_location, - ast::ExprKind::Name { id: name, ctx: ast::ExprContext::Load } + ast::ExprName { id: name, ctx: ast::ExprContext::Load }.into() ), "[" "]" => { let elts = e.unwrap_or_default(); ast::Expr::new( location, end_location, - ast::ExprKind::List { elts, ctx: ast::ExprContext::Load } + ast::ExprList { elts, ctx: ast::ExprContext::Load }.into() ) }, "[" "]" => { ast::Expr::new( location, end_location, - ast::ExprKind::ListComp { elt: Box::new(elt), generators } + ast::ExprListComp { elt: Box::new(elt), generators }.into() ) }, "(" >> ")" if Goal != "no-withitems" => { @@ -1548,7 +1548,7 @@ Atom: ast::Expr = { ast::Expr::new( location, end_location, - ast::ExprKind::Tuple { elts, ctx: ast::ExprContext::Load }, + ast::ExprTuple { elts, ctx: ast::ExprContext::Load }.into() ) } }, @@ -1566,21 +1566,21 @@ Atom: ast::Expr = { Ok(ast::Expr::new( location, end_location, - ast::ExprKind::Tuple { elts, ctx: ast::ExprContext::Load }, + ast::ExprTuple { elts, ctx: ast::ExprContext::Load }.into(), )) } }, "(" ")" => ast::Expr::new( location, end_location, - ast::ExprKind::Tuple { elts: Vec::new(), ctx: ast::ExprContext::Load } + ast::ExprTuple { elts: Vec::new(), ctx: ast::ExprContext::Load }.into() ), "(" ")" => e, "(" ")" => { ast::Expr::new( location, end_location, - ast::ExprKind::GeneratorExp { elt: Box::new(elt), generators } + ast::ExprGeneratorExp { elt: Box::new(elt), generators }.into() ) }, "(" "**" > ")" =>? { @@ -1598,36 +1598,36 @@ Atom: ast::Expr = { ast::Expr::new( location, end_location, - ast::ExprKind::Dict { keys, values } + ast::ExprDict { keys, values }.into() ) }, "{" "}" => { ast::Expr::new( location, end_location, - ast::ExprKind::DictComp { + ast::ExprDictComp { key: Box::new(e1.0), value: Box::new(e1.1), generators, - } + }.into() ) }, "{" "}" => ast::Expr::new( location, end_location, - ast::ExprKind::Set { elts } + ast::ExprSet { elts }.into() ), "{" "}" => { ast::Expr::new( location, end_location, - ast::ExprKind::SetComp { elt: Box::new(elt), generators } + ast::ExprSetComp { elt: Box::new(elt), generators }.into() ) }, - "True" => ast::Expr::new(location, end_location, ast::ExprKind::Constant { value: true.into(), kind: None }), - "False" => ast::Expr::new(location, end_location, ast::ExprKind::Constant { value: false.into(), kind: None }), - "None" => ast::Expr::new(location, end_location, ast::ExprKind::Constant { value: ast::Constant::None, kind: None }), - "..." => ast::Expr::new(location, end_location, ast::ExprKind::Constant { value: ast::Constant::Ellipsis, kind: None }), + "True" => ast::Expr::new(location, end_location, ast::ExprConstant { value: true.into(), kind: None }.into()), + "False" => ast::Expr::new(location, end_location, ast::ExprConstant { value: false.into(), kind: None }.into()), + "None" => ast::Expr::new(location, end_location, ast::ExprConstant { value: ast::Constant::None, kind: None }.into()), + "..." => ast::Expr::new(location, end_location, ast::ExprConstant { value: ast::Constant::Ellipsis, kind: None }.into()), }; ListLiteralValues: Vec = { @@ -1681,7 +1681,7 @@ GenericList: ast::Expr = { ast::Expr::new( location, end_location, - ast::ExprKind::Tuple { elts, ctx: ast::ExprContext::Load } + ast::ExprTuple { elts, ctx: ast::ExprContext::Load }.into() ) } } @@ -1692,7 +1692,7 @@ StarExpr: ast::Expr = { "*" > => ast::Expr::new( location, end_location, - ast::ExprKind::Starred { value: Box::new(e), ctx: ast::ExprContext::Load }, + ast::ExprStarred { value: Box::new(e), ctx: ast::ExprContext::Load }.into(), ) }; @@ -1727,10 +1727,10 @@ FunctionArgument: (Option<(ast::Location, ast::Location, Option)>, ast:: Some(c) => ast::Expr::new( location, end_location, - ast::ExprKind::GeneratorExp { + ast::ExprGeneratorExp { elt: Box::new(e), generators: c, - } + }.into() ), None => e, }; @@ -1741,7 +1741,7 @@ FunctionArgument: (Option<(ast::Location, ast::Location, Option)>, ast:: let expr = ast::Expr::new( location, end_location, - ast::ExprKind::Starred { value: Box::new(e), ctx: ast::ExprContext::Load }, + ast::ExprStarred { value: Box::new(e), ctx: ast::ExprContext::Load }.into(), ); (None, expr) }, diff --git a/parser/src/python.rs b/parser/src/python.rs index 23e1194e..cc7be2a4 100644 --- a/parser/src/python.rs +++ b/parser/src/python.rs @@ -1,5 +1,5 @@ // auto-generated: "lalrpop 0.19.10" -// sha3: a2d8b110535da22be1ce5534b7cc3067d378bddb73b8293fc5bd30c5156f9af3 +// sha3: 6eaaf5ad18de54b31c9737d9badcd4e14d83550ebce2ded6e83285e2273a35cc use crate::{ ast, lexer::{LexicalError, LexicalErrorType}, @@ -36619,7 +36619,7 @@ fn __action1< (_, body, _): (ast::Location, ast::Suite, ast::Location), ) -> ast::Mod { - ast::Mod::Module { body, type_ignores: vec![] } + ast::ModModule { body, type_ignores: vec![] }.into() } #[allow(clippy::too_many_arguments)] @@ -36629,7 +36629,7 @@ fn __action2< (_, body, _): (ast::Location, ast::Suite, ast::Location), ) -> ast::Mod { - ast::Mod::Interactive { body } + ast::ModInteractive { body }.into() } #[allow(clippy::too_many_arguments)] @@ -36640,7 +36640,7 @@ fn __action3< (_, _, _): (ast::Location, alloc::vec::Vec, ast::Location), ) -> ast::Mod { - ast::Mod::Expression { body: Box::new(body) } + ast::ModExpression { body: Box::new(body) }.into() } #[allow(clippy::too_many_arguments)] @@ -36829,7 +36829,7 @@ fn __action21< ast::Stmt::new( location, end_location, - ast::StmtKind::Delete { targets: targets.into_iter().map(|expr| set_context(expr, ast::ExprContext::Del)).collect() }, + ast::StmtDelete { targets: targets.into_iter().map(|expr| set_context(expr, ast::ExprContext::Del)).collect() }.into() ) } } @@ -36849,7 +36849,7 @@ fn __action22< ast::Stmt::new( location, end_location, - ast::StmtKind::Expr { value: Box::new(expression) } + ast::StmtExpr { value: Box::new(expression) }.into() ) } else { let mut targets = vec![set_context(expression, ast::ExprContext::Store)]; @@ -36864,7 +36864,7 @@ fn __action22< ast::Stmt::new( location, end_location, - ast::StmtKind::Assign { targets, value, type_comment: None }, + ast::StmtAssign { targets, value, type_comment: None }.into() ) } } @@ -36884,11 +36884,11 @@ fn __action23< ast::Stmt::new( location, end_location, - ast::StmtKind::AugAssign { + ast::StmtAugAssign { target: Box::new(set_context(target, ast::ExprContext::Store)), op, value: Box::new(rhs) - }, + }.into(), ) } } @@ -36909,12 +36909,12 @@ fn __action24< ast::Stmt::new( location, end_location, - ast::StmtKind::AnnAssign { + ast::StmtAnnAssign { target: Box::new(set_context(target, ast::ExprContext::Store)), annotation: Box::new(annotation), value: rhs.map(Box::new), simple: if simple { 1 } else { 0 }, - }, + }.into(), ) } } @@ -37174,7 +37174,7 @@ fn __action50< ast::Stmt::new( location, end_location, - ast::StmtKind::Return { value: value.map(Box::new) }, + ast::StmtReturn { value: value.map(Box::new) }.into() ) } } @@ -37191,7 +37191,7 @@ fn __action51< ast::Stmt::new( location, end_location, - ast::StmtKind::Expr { value: Box::new(expression) }, + ast::StmtExpr { value: Box::new(expression) }.into() ) } } @@ -37217,7 +37217,7 @@ fn __action53< ast::Stmt::new( location, end_location, - ast::StmtKind::Raise { exc: None, cause: None }, + ast::StmtRaise { exc: None, cause: None }.into() ) } } @@ -37236,7 +37236,7 @@ fn __action54< ast::Stmt::new( location, end_location, - ast::StmtKind::Raise { exc: Some(Box::new(t)), cause: c.map(|x| Box::new(x.1)) }, + ast::StmtRaise { exc: Some(Box::new(t)), cause: c.map(|x| Box::new(x.1)) }.into() ) } } @@ -37254,7 +37254,7 @@ fn __action55< ast::Stmt::new( location, end_location, - ast::StmtKind::Import { names }, + ast::StmtImport { names }.into() ) } } @@ -37275,11 +37275,11 @@ fn __action56< ast::Stmt::new( location, end_location, - ast::StmtKind::ImportFrom { + ast::StmtImportFrom { level, module, names - }, + }.into(), ) } } @@ -37403,7 +37403,7 @@ fn __action66< ast::Stmt::new( location, end_location, - ast::StmtKind::Global { names } + ast::StmtGlobal { names }.into() ) } } @@ -37421,7 +37421,7 @@ fn __action67< ast::Stmt::new( location, end_location, - ast::StmtKind::Nonlocal { names } + ast::StmtNonlocal { names }.into() ) } } @@ -37440,10 +37440,10 @@ fn __action68< ast::Stmt::new( location, end_location, - ast::StmtKind::Assert { + ast::StmtAssert { test: Box::new(test), msg: msg.map(|e| Box::new(e.1)) - } + }.into() ) } } @@ -37544,10 +37544,10 @@ fn __action77< ast::Stmt::new( location, end_location, - ast::StmtKind::Match { + ast::StmtMatch { subject: Box::new(subject), cases - } + }.into() ) } } @@ -37577,10 +37577,10 @@ fn __action78< ast::Stmt::new( location, end_location, - ast::StmtKind::Match { + ast::StmtMatch { subject: Box::new(subject), cases - } + }.into() ) } } @@ -37614,17 +37614,17 @@ fn __action79< ast::Stmt::new( location, end_location, - ast::StmtKind::Match { + ast::StmtMatch { subject: Box::new(ast::Expr::new( location, end_location, - ast::ExprKind::Tuple { + ast::ExprTuple { elts: subjects, ctx: ast::ExprContext::Load, - }, + }.into(), )), cases - } + }.into() ) } } @@ -37672,9 +37672,9 @@ fn __action82< ast::Pattern::new( location, end_location, - ast::PatternKind::MatchSequence { + ast::PatternMatchSequence { patterns: vec![pattern] - }, + }.into(), ) } @@ -37695,9 +37695,9 @@ fn __action83< ast::Pattern::new( location, end_location, - ast::PatternKind::MatchSequence { + ast::PatternMatchSequence { patterns - }, + }.into(), ) } } @@ -37749,10 +37749,10 @@ fn __action87< Ok(ast::Pattern::new( location, end_location, - ast::PatternKind::MatchAs { + ast::PatternMatchAs { pattern: Some(Box::new(pattern)), name: Some(name), - }, + }.into(), )) } } @@ -37782,7 +37782,7 @@ fn __action89< ast::Pattern::new( location, end_location, - ast::PatternKind::MatchOr { patterns } + ast::PatternMatchOr { patterns }.into() ) } } @@ -37914,9 +37914,9 @@ fn __action98< (_, end_location, _): (ast::Location, ast::Location, ast::Location), ) -> ast::PatternKind { - ast::PatternKind::MatchSequence { + ast::PatternMatchSequence { patterns: vec![], - } + }.into() } #[allow(clippy::too_many_arguments)] @@ -37934,9 +37934,9 @@ fn __action99< { let mut patterns = patterns; patterns.insert(0, pattern); - ast::PatternKind::MatchSequence { + ast::PatternMatchSequence { patterns - } + }.into() } } @@ -37950,9 +37950,9 @@ fn __action100< (_, end_location, _): (ast::Location, ast::Location, ast::Location), ) -> ast::PatternKind { - ast::PatternKind::MatchSequence { + ast::PatternMatchSequence { patterns - } + }.into() } #[allow(clippy::too_many_arguments)] @@ -37964,9 +37964,9 @@ fn __action101< (_, end_location, _): (ast::Location, ast::Location, ast::Location), ) -> ast::PatternKind { - ast::PatternKind::MatchStar { + ast::PatternMatchStar { name: if name == "_" { None } else { Some(name) } - } + }.into() } #[allow(clippy::too_many_arguments)] @@ -37980,7 +37980,7 @@ fn __action102< ast::Expr::new( location, end_location, - ast::ExprKind::Constant { value, kind: None } + ast::ExprConstant { value, kind: None }.into() ) } @@ -38005,10 +38005,10 @@ fn __action104< ast::Expr::new( location, end_location, - ast::ExprKind::UnaryOp { + ast::ExprUnaryOp { op: ast::Unaryop::USub, operand: Box::new(operand) - } + }.into() ) } @@ -38025,11 +38025,11 @@ fn __action105< ast::Expr::new( location, end_location, - ast::ExprKind::BinOp { + ast::ExprBinOp { left: Box::new(left), op, right: Box::new(right), - } + }.into() ) } @@ -38039,9 +38039,9 @@ fn __action106< (_, __0, _): (ast::Location, token::Tok, ast::Location), ) -> ast::PatternKind { - ast::PatternKind::MatchSingleton { + ast::PatternMatchSingleton { value: ast::Constant::None - } + }.into() } #[allow(clippy::too_many_arguments)] @@ -38050,9 +38050,9 @@ fn __action107< (_, __0, _): (ast::Location, token::Tok, ast::Location), ) -> ast::PatternKind { - ast::PatternKind::MatchSingleton { + ast::PatternMatchSingleton { value: true.into() - } + }.into() } #[allow(clippy::too_many_arguments)] @@ -38061,9 +38061,9 @@ fn __action108< (_, __0, _): (ast::Location, token::Tok, ast::Location), ) -> ast::PatternKind { - ast::PatternKind::MatchSingleton { + ast::PatternMatchSingleton { value: false.into() - } + }.into() } #[allow(clippy::too_many_arguments)] @@ -38074,9 +38074,9 @@ fn __action109< (_, end_location, _): (ast::Location, ast::Location, ast::Location), ) -> ast::PatternKind { - ast::PatternKind::MatchValue { + ast::PatternMatchValue { value: Box::new(value) - } + }.into() } #[allow(clippy::too_many_arguments)] @@ -38086,9 +38086,9 @@ fn __action110< (_, value, _): (ast::Location, ast::Expr, ast::Location), ) -> ast::PatternKind { - ast::PatternKind::MatchValue { + ast::PatternMatchValue { value: Box::new(value) - } + }.into() } #[allow(clippy::too_many_arguments)] @@ -38098,9 +38098,9 @@ fn __action111< (_, s, _): (ast::Location, alloc::vec::Vec<(ast::Location, (String, StringKind, bool), ast::Location)>, ast::Location), ) -> Result> { - Ok(ast::PatternKind::MatchValue { + Ok(ast::PatternMatchValue { value: Box::new(parse_strings(s)?) - }) + }.into()) } #[allow(clippy::too_many_arguments)] @@ -38111,10 +38111,10 @@ fn __action112< (_, end_location, _): (ast::Location, ast::Location, ast::Location), ) -> ast::PatternKind { - ast::PatternKind::MatchAs { + ast::PatternMatchAs { pattern: None, name: if name == "_" { None } else { Some(name) } - } + }.into() } #[allow(clippy::too_many_arguments)] @@ -38128,7 +38128,7 @@ fn __action113< ast::Expr::new( location, end_location, - ast::ExprKind::Name { id: name, ctx: ast::ExprContext::Load }, + ast::ExprName { id: name, ctx: ast::ExprContext::Load }.into(), ) } @@ -38145,11 +38145,11 @@ fn __action114< ast::Expr::new( location, end_location, - ast::ExprKind::Attribute { + ast::ExprAttribute { value: Box::new(name), attr, ctx: ast::ExprContext::Load, - }, + }.into(), ) } @@ -38166,11 +38166,11 @@ fn __action115< ast::Expr::new( location, end_location, - ast::ExprKind::Attribute { + ast::ExprAttribute { value: Box::new(e), attr, ctx: ast::ExprContext::Load, - } + }.into(), ) } @@ -38180,9 +38180,9 @@ fn __action116< (_, e, _): (ast::Location, ast::Expr, ast::Location), ) -> ast::PatternKind { - ast::PatternKind::MatchValue { + ast::PatternMatchValue { value: Box::new(e) - } + }.into() } #[allow(clippy::too_many_arguments)] @@ -38223,10 +38223,10 @@ fn __action120< ast::Expr::new( location, end_location, - ast::ExprKind::Constant { + ast::ExprConstant { value: ast::Constant::None, kind: None, - }, + }.into(), ) } @@ -38241,10 +38241,10 @@ fn __action121< ast::Expr::new( location, end_location, - ast::ExprKind::Constant { + ast::ExprConstant { value: true.into(), kind: None, - }, + }.into(), ) } @@ -38259,10 +38259,10 @@ fn __action122< ast::Expr::new( location, end_location, - ast::ExprKind::Constant { + ast::ExprConstant { value: false.into(), kind: None, - }, + }.into(), ) } @@ -38297,11 +38297,11 @@ fn __action125< ) -> ast::PatternKind { { - return ast::PatternKind::MatchMapping { + return ast::PatternMatchMapping { keys: vec![], patterns: vec![], rest: None, - }; + }.into(); } } @@ -38320,11 +38320,11 @@ fn __action126< let (keys, patterns) = e .into_iter() .unzip(); - return ast::PatternKind::MatchMapping { + return ast::PatternMatchMapping { keys, patterns, rest: None, - }; + }.into(); } } @@ -38341,11 +38341,11 @@ fn __action127< ) -> ast::PatternKind { { - return ast::PatternKind::MatchMapping { + return ast::PatternMatchMapping { keys: vec![], patterns: vec![], rest: Some(rest), - }; + }.into(); } } @@ -38367,11 +38367,11 @@ fn __action128< let (keys, patterns) = e .into_iter() .unzip(); - return ast::PatternKind::MatchMapping { + return ast::PatternMatchMapping { keys, patterns, rest: Some(rest), - }; + }.into(); } } @@ -38404,12 +38404,12 @@ fn __action130< let (kwd_attrs, kwd_patterns) = kwds .into_iter() .unzip(); - ast::PatternKind::MatchClass { + ast::PatternMatchClass { cls: Box::new(e), patterns, kwd_attrs, kwd_patterns, - } + }.into() } } @@ -38426,12 +38426,12 @@ fn __action131< ) -> ast::PatternKind { { - ast::PatternKind::MatchClass { + ast::PatternMatchClass { cls: Box::new(e), patterns, kwd_attrs: vec![], kwd_patterns: vec![], - } + }.into() } } @@ -38451,12 +38451,12 @@ fn __action132< let (kwd_attrs, kwd_patterns) = kwds .into_iter() .unzip(); - ast::PatternKind::MatchClass { + ast::PatternMatchClass { cls: Box::new(e), patterns: vec![], kwd_attrs, kwd_patterns, - } + }.into() } } @@ -38471,12 +38471,12 @@ fn __action133< ) -> ast::PatternKind { { - ast::PatternKind::MatchClass { + ast::PatternMatchClass { cls: Box::new(e), patterns: vec![], kwd_attrs: vec![], kwd_patterns: vec![], - } + }.into() } } @@ -38498,12 +38498,12 @@ fn __action134< let (kwd_attrs, kwd_patterns) = kwds .into_iter() .unzip(); - ast::PatternKind::MatchClass { + ast::PatternMatchClass { cls: Box::new(e), patterns, kwd_attrs, kwd_patterns, - } + }.into() } } @@ -38520,12 +38520,12 @@ fn __action135< ) -> ast::PatternKind { { - ast::PatternKind::MatchClass { + ast::PatternMatchClass { cls: Box::new(e), patterns, kwd_attrs: vec![], kwd_patterns: vec![], - } + }.into() } } @@ -38545,12 +38545,12 @@ fn __action136< let (kwd_attrs, kwd_patterns) = kwds .into_iter() .unzip(); - ast::PatternKind::MatchClass { + ast::PatternMatchClass { cls: Box::new(e), patterns: vec![], kwd_attrs, kwd_patterns, - } + }.into() } } @@ -38565,12 +38565,12 @@ fn __action137< ) -> ast::PatternKind { { - ast::PatternKind::MatchClass { + ast::PatternMatchClass { cls: Box::new(e), patterns: vec![], kwd_attrs: vec![], kwd_patterns: vec![], - } + }.into() } } @@ -38600,7 +38600,7 @@ fn __action138< let x = ast::Stmt::new( i.0, end_location, - ast::StmtKind::If { test: Box::new(i.2), body: i.4, orelse: last }, + ast::StmtIf { test: Box::new(i.2), body: i.4, orelse: last }.into() ); last = vec![x]; } @@ -38608,7 +38608,7 @@ fn __action138< ast::Stmt::new( location, end_location, - ast::StmtKind::If { test: Box::new(test), body, orelse: last } + ast::StmtIf { test: Box::new(test), body, orelse: last }.into() ) } } @@ -38634,11 +38634,11 @@ fn __action139< ast::Stmt::new( location, end_location, - ast::StmtKind::While { + ast::StmtWhile { test: Box::new(test), body, orelse - }, + }.into(), ) } } @@ -38668,9 +38668,9 @@ fn __action140< let iter = Box::new(iter); let type_comment = None; let node = if is_async.is_some() { - ast::StmtKind::AsyncFor { target, iter, body, orelse, type_comment } + ast::StmtAsyncFor { target, iter, body, orelse, type_comment }.into() } else { - ast::StmtKind::For { target, iter, body, orelse, type_comment } + ast::StmtFor { target, iter, body, orelse, type_comment }.into() }; ast::Stmt::new(location, end_location, node) } @@ -38701,12 +38701,12 @@ fn __action141< ast::Stmt::new( location, end_location, - ast::StmtKind::Try { + ast::StmtTry { body, handlers, orelse, finalbody, - }, + }.into(), ) } } @@ -38736,12 +38736,12 @@ fn __action142< ast::Stmt::new( location, end_location, - ast::StmtKind::TryStar { + ast::StmtTryStar { body, handlers, orelse, finalbody, - }, + }.into(), ) } } @@ -38764,12 +38764,12 @@ fn __action143< ast::Stmt::new( location, end_location, - ast::StmtKind::Try { + ast::StmtTry { body, handlers, orelse, finalbody, - }, + }.into(), ) } } @@ -38790,11 +38790,11 @@ fn __action144< ast::Excepthandler::new( location, end_location, - ast::ExcepthandlerKind::ExceptHandler { + ast::ExcepthandlerExceptHandler { type_: Some(Box::new(typ)), name: None, body, - }, + }.into(), ) } } @@ -38815,11 +38815,11 @@ fn __action145< ast::Excepthandler::new( location, end_location, - ast::ExcepthandlerKind::ExceptHandler { + ast::ExcepthandlerExceptHandler { type_: Some(Box::new(x.0)), name: Some(x.2), body, - }, + }.into(), ) } } @@ -38839,11 +38839,11 @@ fn __action146< ast::Excepthandler::new( location, end_location, - ast::ExcepthandlerKind::ExceptHandler { + ast::ExcepthandlerExceptHandler { type_: typ.map(Box::new), name: None, body, - }, + }.into(), ) } } @@ -38863,11 +38863,11 @@ fn __action147< ast::Excepthandler::new( location, end_location, - ast::ExcepthandlerKind::ExceptHandler { + ast::ExcepthandlerExceptHandler { type_: Some(Box::new(x.0)), name: Some(x.2), body, - }, + }.into(), ) } } @@ -38887,9 +38887,9 @@ fn __action148< let end_location = body.last().unwrap().end(); let type_comment = None; let node = if is_async.is_some() { - ast::StmtKind::AsyncWith { items, body, type_comment } + ast::StmtAsyncWith { items, body, type_comment }.into() } else { - ast::StmtKind::With { items, body, type_comment } + ast::StmtWith { items, body, type_comment }.into() }; ast::Stmt::new(location, end_location, node) } @@ -38975,9 +38975,9 @@ fn __action154< let end_location = body.last().unwrap().end(); let type_comment = None; let node = if is_async.is_some() { - ast::StmtKind::AsyncFunctionDef { name, args, body, decorator_list, returns, type_comment } + ast::StmtAsyncFunctionDef { name, args, body, decorator_list, returns, type_comment }.into() } else { - ast::StmtKind::FunctionDef { name, args, body, decorator_list, returns, type_comment } + ast::StmtFunctionDef { name, args, body, decorator_list, returns, type_comment }.into() }; ast::Stmt::new(location, end_location, node) } @@ -39074,13 +39074,13 @@ fn __action159< ast::Stmt::new( location, end_location, - ast::StmtKind::ClassDef { + ast::StmtClassDef { name, bases, keywords, body, decorator_list, - }, + }.into(), ) } } @@ -39111,7 +39111,7 @@ fn __action161< ast::Expr::new( location, end_location, - ast::ExprKind::Yield { value: value.map(Box::new) } + ast::ExprYield { value: value.map(Box::new) }.into() ) } @@ -39128,7 +39128,7 @@ fn __action162< ast::Expr::new( location, end_location, - ast::ExprKind::YieldFrom { value: Box::new(e) } + ast::ExprYieldFrom { value: Box::new(e) }.into() ) } @@ -39164,14 +39164,14 @@ fn __action165< ast::Expr::new( location, value.end(), - ast::ExprKind::NamedExpr { + ast::ExprNamedExpr { target: Box::new(ast::Expr::new( location, end_location, - ast::ExprKind::Name { id, ctx: ast::ExprContext::Store }, + ast::ExprName { id, ctx: ast::ExprContext::Store }.into(), )), value: Box::new(value), - } + }.into() ) } } @@ -39205,10 +39205,10 @@ fn __action166< Ok(ast::Expr::new( location, end_location, - ast::ExprKind::Lambda { + ast::ExprLambda { args: Box::new(p), body: Box::new(body) - } + }.into() )) } } @@ -39435,7 +39435,7 @@ fn __action189< ast::Expr::new( location, end_location, - ast::ExprKind::Tuple { elts: dims, ctx: ast::ExprContext::Load }, + ast::ExprTuple { elts: dims, ctx: ast::ExprContext::Load }.into(), ) } } @@ -39468,7 +39468,7 @@ fn __action191< ast::Expr::new( location, end_location, - ast::ExprKind::Slice { lower, upper, step } + ast::ExprSlice { lower, upper, step }.into() ) } } @@ -39602,7 +39602,7 @@ fn __action204< ast::Expr::new( location, end_location, - ast::ExprKind::Starred { value: Box::new(e), ctx: ast::ExprContext::Load }, + ast::ExprStarred { value: Box::new(e), ctx: ast::ExprContext::Load }.into(), ) } @@ -39684,10 +39684,10 @@ fn __action210< Some(c) => ast::Expr::new( location, end_location, - ast::ExprKind::GeneratorExp { + ast::ExprGeneratorExp { elt: Box::new(e), generators: c, - } + }.into() ), None => e, }; @@ -39721,7 +39721,7 @@ fn __action212< let expr = ast::Expr::new( location, end_location, - ast::ExprKind::Starred { value: Box::new(e), ctx: ast::ExprContext::Load }, + ast::ExprStarred { value: Box::new(e), ctx: ast::ExprContext::Load }.into(), ); (None, expr) } @@ -39842,7 +39842,7 @@ fn __action223< ast::Expr::new( location, end_location, - ast::ExprKind::BoolOp { op: ast::Boolop::Or, values } + ast::ExprBoolOp { op: ast::Boolop::Or, values }.into() ) } } @@ -39891,7 +39891,7 @@ fn __action227< ast::Expr::new( location, end_location, - ast::ExprKind::Tuple { elts, ctx: ast::ExprContext::Load } + ast::ExprTuple { elts, ctx: ast::ExprContext::Load }.into() ) } } @@ -39927,7 +39927,7 @@ fn __action229< ast::Expr::new( location, end_location, - ast::ExprKind::Tuple { elts, ctx: ast::ExprContext::Load } + ast::ExprTuple { elts, ctx: ast::ExprContext::Load }.into() ) } } @@ -39946,7 +39946,7 @@ fn __action230< ast::Expr::new( location, end_location, - ast::ExprKind::BinOp { left: Box::new(e1), op: ast::Operator::BitOr, right: Box::new(e2) } + ast::ExprBinOp { left: Box::new(e1), op: ast::Operator::BitOr, right: Box::new(e2) }.into() ) } @@ -41165,11 +41165,11 @@ fn __action337< ast::Expr::new( location, end_location, - ast::ExprKind::IfExp { + ast::ExprIfExp { test: Box::new(test), body: Box::new(body), orelse: Box::new(orelse), - } + }.into() ) } @@ -41732,11 +41732,11 @@ fn __action395< ast::Expr::new( location, end_location, - ast::ExprKind::IfExp { + ast::ExprIfExp { test: Box::new(test), body: Box::new(body), orelse: Box::new(orelse), - } + }.into() ) } @@ -42087,7 +42087,7 @@ fn __action423< ast::Expr::new( location, end_location, - ast::ExprKind::BinOp { left: Box::new(e1), op: ast::Operator::BitXor, right: Box::new(e2) } + ast::ExprBinOp { left: Box::new(e1), op: ast::Operator::BitXor, right: Box::new(e2) }.into() ) } @@ -42187,7 +42187,7 @@ fn __action432< ast::Expr::new( location, end_location, - ast::ExprKind::BoolOp { op: ast::Boolop::And, values } + ast::ExprBoolOp { op: ast::Boolop::And, values }.into() ) } } @@ -42328,7 +42328,7 @@ fn __action446< ast::Expr::new( location, end_location, - ast::ExprKind::UnaryOp { operand: Box::new(e), op: ast::Unaryop::Not } + ast::ExprUnaryOp { operand: Box::new(e), op: ast::Unaryop::Not }.into() ) } @@ -42402,7 +42402,7 @@ fn __action453< ast::Expr::new( location, end_location, - ast::ExprKind::BinOp { left: Box::new(e1), op: ast::Operator::BitAnd, right: Box::new(e2) } + ast::ExprBinOp { left: Box::new(e1), op: ast::Operator::BitAnd, right: Box::new(e2) }.into() ) } @@ -42689,7 +42689,7 @@ fn __action481< ast::Expr::new( location, end_location, - ast::ExprKind::BoolOp { op: ast::Boolop::Or, values } + ast::ExprBoolOp { op: ast::Boolop::Or, values }.into() ) } } @@ -42870,7 +42870,7 @@ fn __action499< ast::Expr::new( location, end_location, - ast::ExprKind::BoolOp { op: ast::Boolop::And, values } + ast::ExprBoolOp { op: ast::Boolop::And, values }.into() ) } } @@ -42935,7 +42935,7 @@ fn __action505< ast::Expr::new( location, end_location, - ast::ExprKind::BinOp { left: Box::new(e1), op, right: Box::new(e2) } + ast::ExprBinOp { left: Box::new(e1), op, right: Box::new(e2) }.into() ) } @@ -42981,7 +42981,7 @@ fn __action509< ast::Expr::new( location, end_location, - ast::ExprKind::Compare { left: Box::new(left), ops, comparators } + ast::ExprCompare { left: Box::new(left), ops, comparators }.into() ) } } @@ -43037,7 +43037,7 @@ fn __action514< ast::Expr::new( location, end_location, - ast::ExprKind::BinOp { left: Box::new(a), op, right: Box::new(b) } + ast::ExprBinOp { left: Box::new(a), op, right: Box::new(b) }.into() ) } @@ -43062,7 +43062,7 @@ fn __action516< ast::Expr::new( location, end_location, - ast::ExprKind::UnaryOp { operand: Box::new(e), op: ast::Unaryop::Not } + ast::ExprUnaryOp { operand: Box::new(e), op: ast::Unaryop::Not }.into() ) } @@ -43089,7 +43089,7 @@ fn __action518< ast::Expr::new( location, end_location, - ast::ExprKind::Compare { left: Box::new(left), ops, comparators } + ast::ExprCompare { left: Box::new(left), ops, comparators }.into() ) } } @@ -43116,7 +43116,7 @@ fn __action520< ast::Expr::new( location, end_location, - ast::ExprKind::BinOp { left: Box::new(a), op, right: Box::new(b) } + ast::ExprBinOp { left: Box::new(a), op, right: Box::new(b) }.into() ) } @@ -43141,7 +43141,7 @@ fn __action522< ast::Expr::new( location, end_location, - ast::ExprKind::UnaryOp { operand: Box::new(e), op } + ast::ExprUnaryOp { operand: Box::new(e), op }.into() ) } @@ -43167,7 +43167,7 @@ fn __action524< ast::Expr::new( location, end_location, - ast::ExprKind::BinOp { left: Box::new(e1), op: ast::Operator::BitOr, right: Box::new(e2) } + ast::ExprBinOp { left: Box::new(e1), op: ast::Operator::BitOr, right: Box::new(e2) }.into() ) } @@ -43193,7 +43193,7 @@ fn __action526< ast::Expr::new( location, end_location, - ast::ExprKind::BinOp { left: Box::new(e1), op: ast::Operator::BitXor, right: Box::new(e2) } + ast::ExprBinOp { left: Box::new(e1), op: ast::Operator::BitXor, right: Box::new(e2) }.into() ) } @@ -43219,7 +43219,7 @@ fn __action528< ast::Expr::new( location, end_location, - ast::ExprKind::BinOp { left: Box::new(e), op: ast::Operator::Pow, right: Box::new(b) } + ast::ExprBinOp { left: Box::new(e), op: ast::Operator::Pow, right: Box::new(b) }.into() ) } @@ -43245,7 +43245,7 @@ fn __action530< ast::Expr::new( location, end_location, - ast::ExprKind::Await { value: Box::new(atom) } + ast::ExprAwait { value: Box::new(atom) }.into() ) } } @@ -43272,7 +43272,7 @@ fn __action532< ast::Expr::new( location, end_location, - ast::ExprKind::BinOp { left: Box::new(e1), op: ast::Operator::BitAnd, right: Box::new(e2) } + ast::ExprBinOp { left: Box::new(e1), op: ast::Operator::BitAnd, right: Box::new(e2) }.into() ) } @@ -43298,7 +43298,7 @@ fn __action534< ast::Expr::new( location, end_location, - ast::ExprKind::BinOp { left: Box::new(e1), op, right: Box::new(e2) } + ast::ExprBinOp { left: Box::new(e1), op, right: Box::new(e2) }.into() ) } @@ -43335,7 +43335,7 @@ fn __action537< ast::Expr::new( location, end_location, - ast::ExprKind::Call { func: Box::new(f), args: a.args, keywords: a.keywords } + ast::ExprCall { func: Box::new(f), args: a.args, keywords: a.keywords }.into() ) } } @@ -43354,7 +43354,7 @@ fn __action538< ast::Expr::new( location, end_location, - ast::ExprKind::Subscript { value: Box::new(e), slice: Box::new(s), ctx: ast::ExprContext::Load } + ast::ExprSubscript { value: Box::new(e), slice: Box::new(s), ctx: ast::ExprContext::Load }.into() ) } @@ -43371,7 +43371,7 @@ fn __action539< ast::Expr::new( location, end_location, - ast::ExprKind::Attribute { value: Box::new(e), attr, ctx: ast::ExprContext::Load } + ast::ExprAttribute { value: Box::new(e), attr, ctx: ast::ExprContext::Load }.into() ) } @@ -43396,7 +43396,7 @@ fn __action541< ast::Expr::new( location, end_location, - ast::ExprKind::Constant { value, kind: None } + ast::ExprConstant { value, kind: None }.into() ) } @@ -43411,7 +43411,7 @@ fn __action542< ast::Expr::new( location, end_location, - ast::ExprKind::Name { id: name, ctx: ast::ExprContext::Load } + ast::ExprName { id: name, ctx: ast::ExprContext::Load }.into() ) } @@ -43430,7 +43430,7 @@ fn __action543< ast::Expr::new( location, end_location, - ast::ExprKind::List { elts, ctx: ast::ExprContext::Load } + ast::ExprList { elts, ctx: ast::ExprContext::Load }.into() ) } } @@ -43450,7 +43450,7 @@ fn __action544< ast::Expr::new( location, end_location, - ast::ExprKind::ListComp { elt: Box::new(elt), generators } + ast::ExprListComp { elt: Box::new(elt), generators }.into() ) } } @@ -43473,7 +43473,7 @@ fn __action545< ast::Expr::new( location, end_location, - ast::ExprKind::Tuple { elts, ctx: ast::ExprContext::Load }, + ast::ExprTuple { elts, ctx: ast::ExprContext::Load }.into() ) } } @@ -43506,7 +43506,7 @@ fn __action546< Ok(ast::Expr::new( location, end_location, - ast::ExprKind::Tuple { elts, ctx: ast::ExprContext::Load }, + ast::ExprTuple { elts, ctx: ast::ExprContext::Load }.into(), )) } } @@ -43524,7 +43524,7 @@ fn __action547< ast::Expr::new( location, end_location, - ast::ExprKind::Tuple { elts: Vec::new(), ctx: ast::ExprContext::Load } + ast::ExprTuple { elts: Vec::new(), ctx: ast::ExprContext::Load }.into() ) } @@ -43554,7 +43554,7 @@ fn __action549< ast::Expr::new( location, end_location, - ast::ExprKind::GeneratorExp { elt: Box::new(elt), generators } + ast::ExprGeneratorExp { elt: Box::new(elt), generators }.into() ) } } @@ -43597,7 +43597,7 @@ fn __action551< ast::Expr::new( location, end_location, - ast::ExprKind::Dict { keys, values } + ast::ExprDict { keys, values }.into() ) } } @@ -43617,11 +43617,11 @@ fn __action552< ast::Expr::new( location, end_location, - ast::ExprKind::DictComp { + ast::ExprDictComp { key: Box::new(e1.0), value: Box::new(e1.1), generators, - } + }.into() ) } } @@ -43639,7 +43639,7 @@ fn __action553< ast::Expr::new( location, end_location, - ast::ExprKind::Set { elts } + ast::ExprSet { elts }.into() ) } @@ -43658,7 +43658,7 @@ fn __action554< ast::Expr::new( location, end_location, - ast::ExprKind::SetComp { elt: Box::new(elt), generators } + ast::ExprSetComp { elt: Box::new(elt), generators }.into() ) } } @@ -43671,7 +43671,7 @@ fn __action555< (_, end_location, _): (ast::Location, ast::Location, ast::Location), ) -> ast::Expr { - ast::Expr::new(location, end_location, ast::ExprKind::Constant { value: true.into(), kind: None }) + ast::Expr::new(location, end_location, ast::ExprConstant { value: true.into(), kind: None }.into()) } #[allow(clippy::too_many_arguments)] @@ -43682,7 +43682,7 @@ fn __action556< (_, end_location, _): (ast::Location, ast::Location, ast::Location), ) -> ast::Expr { - ast::Expr::new(location, end_location, ast::ExprKind::Constant { value: false.into(), kind: None }) + ast::Expr::new(location, end_location, ast::ExprConstant { value: false.into(), kind: None }.into()) } #[allow(clippy::too_many_arguments)] @@ -43693,7 +43693,7 @@ fn __action557< (_, end_location, _): (ast::Location, ast::Location, ast::Location), ) -> ast::Expr { - ast::Expr::new(location, end_location, ast::ExprKind::Constant { value: ast::Constant::None, kind: None }) + ast::Expr::new(location, end_location, ast::ExprConstant { value: ast::Constant::None, kind: None }.into()) } #[allow(clippy::too_many_arguments)] @@ -43704,7 +43704,7 @@ fn __action558< (_, end_location, _): (ast::Location, ast::Location, ast::Location), ) -> ast::Expr { - ast::Expr::new(location, end_location, ast::ExprKind::Constant { value: ast::Constant::Ellipsis, kind: None }) + ast::Expr::new(location, end_location, ast::ExprConstant { value: ast::Constant::Ellipsis, kind: None }.into()) } #[allow(clippy::too_many_arguments)] @@ -43720,7 +43720,7 @@ fn __action559< ast::Expr::new( location, end_location, - ast::ExprKind::BinOp { left: Box::new(a), op, right: Box::new(b) } + ast::ExprBinOp { left: Box::new(a), op, right: Box::new(b) }.into() ) } @@ -43746,7 +43746,7 @@ fn __action561< ast::Expr::new( location, end_location, - ast::ExprKind::BinOp { left: Box::new(a), op, right: Box::new(b) } + ast::ExprBinOp { left: Box::new(a), op, right: Box::new(b) }.into() ) } @@ -43886,7 +43886,7 @@ fn __action575< ast::Expr::new( location, end_location, - ast::ExprKind::UnaryOp { operand: Box::new(e), op } + ast::ExprUnaryOp { operand: Box::new(e), op }.into() ) } @@ -43912,7 +43912,7 @@ fn __action577< ast::Expr::new( location, end_location, - ast::ExprKind::BinOp { left: Box::new(e), op: ast::Operator::Pow, right: Box::new(b) } + ast::ExprBinOp { left: Box::new(e), op: ast::Operator::Pow, right: Box::new(b) }.into() ) } @@ -43938,7 +43938,7 @@ fn __action579< ast::Expr::new( location, end_location, - ast::ExprKind::Await { value: Box::new(atom) } + ast::ExprAwait { value: Box::new(atom) }.into() ) } } @@ -43976,7 +43976,7 @@ fn __action582< ast::Expr::new( location, end_location, - ast::ExprKind::Call { func: Box::new(f), args: a.args, keywords: a.keywords } + ast::ExprCall { func: Box::new(f), args: a.args, keywords: a.keywords }.into() ) } } @@ -43995,7 +43995,7 @@ fn __action583< ast::Expr::new( location, end_location, - ast::ExprKind::Subscript { value: Box::new(e), slice: Box::new(s), ctx: ast::ExprContext::Load } + ast::ExprSubscript { value: Box::new(e), slice: Box::new(s), ctx: ast::ExprContext::Load }.into() ) } @@ -44012,7 +44012,7 @@ fn __action584< ast::Expr::new( location, end_location, - ast::ExprKind::Attribute { value: Box::new(e), attr, ctx: ast::ExprContext::Load } + ast::ExprAttribute { value: Box::new(e), attr, ctx: ast::ExprContext::Load }.into() ) } @@ -44037,7 +44037,7 @@ fn __action586< ast::Expr::new( location, end_location, - ast::ExprKind::Constant { value, kind: None } + ast::ExprConstant { value, kind: None }.into() ) } @@ -44052,7 +44052,7 @@ fn __action587< ast::Expr::new( location, end_location, - ast::ExprKind::Name { id: name, ctx: ast::ExprContext::Load } + ast::ExprName { id: name, ctx: ast::ExprContext::Load }.into() ) } @@ -44071,7 +44071,7 @@ fn __action588< ast::Expr::new( location, end_location, - ast::ExprKind::List { elts, ctx: ast::ExprContext::Load } + ast::ExprList { elts, ctx: ast::ExprContext::Load }.into() ) } } @@ -44091,7 +44091,7 @@ fn __action589< ast::Expr::new( location, end_location, - ast::ExprKind::ListComp { elt: Box::new(elt), generators } + ast::ExprListComp { elt: Box::new(elt), generators }.into() ) } } @@ -44123,7 +44123,7 @@ fn __action590< Ok(ast::Expr::new( location, end_location, - ast::ExprKind::Tuple { elts, ctx: ast::ExprContext::Load }, + ast::ExprTuple { elts, ctx: ast::ExprContext::Load }.into(), )) } } @@ -44141,7 +44141,7 @@ fn __action591< ast::Expr::new( location, end_location, - ast::ExprKind::Tuple { elts: Vec::new(), ctx: ast::ExprContext::Load } + ast::ExprTuple { elts: Vec::new(), ctx: ast::ExprContext::Load }.into() ) } @@ -44171,7 +44171,7 @@ fn __action593< ast::Expr::new( location, end_location, - ast::ExprKind::GeneratorExp { elt: Box::new(elt), generators } + ast::ExprGeneratorExp { elt: Box::new(elt), generators }.into() ) } } @@ -44214,7 +44214,7 @@ fn __action595< ast::Expr::new( location, end_location, - ast::ExprKind::Dict { keys, values } + ast::ExprDict { keys, values }.into() ) } } @@ -44234,11 +44234,11 @@ fn __action596< ast::Expr::new( location, end_location, - ast::ExprKind::DictComp { + ast::ExprDictComp { key: Box::new(e1.0), value: Box::new(e1.1), generators, - } + }.into() ) } } @@ -44256,7 +44256,7 @@ fn __action597< ast::Expr::new( location, end_location, - ast::ExprKind::Set { elts } + ast::ExprSet { elts }.into() ) } @@ -44275,7 +44275,7 @@ fn __action598< ast::Expr::new( location, end_location, - ast::ExprKind::SetComp { elt: Box::new(elt), generators } + ast::ExprSetComp { elt: Box::new(elt), generators }.into() ) } } @@ -44288,7 +44288,7 @@ fn __action599< (_, end_location, _): (ast::Location, ast::Location, ast::Location), ) -> ast::Expr { - ast::Expr::new(location, end_location, ast::ExprKind::Constant { value: true.into(), kind: None }) + ast::Expr::new(location, end_location, ast::ExprConstant { value: true.into(), kind: None }.into()) } #[allow(clippy::too_many_arguments)] @@ -44299,7 +44299,7 @@ fn __action600< (_, end_location, _): (ast::Location, ast::Location, ast::Location), ) -> ast::Expr { - ast::Expr::new(location, end_location, ast::ExprKind::Constant { value: false.into(), kind: None }) + ast::Expr::new(location, end_location, ast::ExprConstant { value: false.into(), kind: None }.into()) } #[allow(clippy::too_many_arguments)] @@ -44310,7 +44310,7 @@ fn __action601< (_, end_location, _): (ast::Location, ast::Location, ast::Location), ) -> ast::Expr { - ast::Expr::new(location, end_location, ast::ExprKind::Constant { value: ast::Constant::None, kind: None }) + ast::Expr::new(location, end_location, ast::ExprConstant { value: ast::Constant::None, kind: None }.into()) } #[allow(clippy::too_many_arguments)] @@ -44321,7 +44321,7 @@ fn __action602< (_, end_location, _): (ast::Location, ast::Location, ast::Location), ) -> ast::Expr { - ast::Expr::new(location, end_location, ast::ExprKind::Constant { value: ast::Constant::Ellipsis, kind: None }) + ast::Expr::new(location, end_location, ast::ExprConstant { value: ast::Constant::Ellipsis, kind: None }.into()) } #[allow(clippy::too_many_arguments)] diff --git a/parser/src/snapshots/rustpython_parser__context__tests__ann_assign_name.snap b/parser/src/snapshots/rustpython_parser__context__tests__ann_assign_name.snap index 78ccf768..d19ed9ac 100644 --- a/parser/src/snapshots/rustpython_parser__context__tests__ann_assign_name.snap +++ b/parser/src/snapshots/rustpython_parser__context__tests__ann_assign_name.snap @@ -1,5 +1,5 @@ --- -source: compiler/parser/src/context.rs +source: parser/src/context.rs expression: parse_ast --- [ @@ -15,63 +15,71 @@ expression: parse_ast }, ), custom: (), - node: AnnAssign { - target: Located { - location: Location { - row: 1, - column: 0, - }, - end_location: Some( - Location { - row: 1, - column: 1, - }, - ), - custom: (), - node: Name { - id: "x", - ctx: Store, - }, - }, - annotation: Located { - location: Location { - row: 1, - column: 3, - }, - end_location: Some( - Location { + node: AnnAssign( + StmtAnnAssign { + target: Located { + location: Location { row: 1, - column: 6, + column: 0, }, - ), - custom: (), - node: Name { - id: "int", - ctx: Load, + end_location: Some( + Location { + row: 1, + column: 1, + }, + ), + custom: (), + node: Name( + ExprName { + id: "x", + ctx: Store, + }, + ), }, - }, - value: Some( - Located { + annotation: Located { location: Location { row: 1, - column: 9, + column: 3, }, end_location: Some( Location { row: 1, - column: 10, + column: 6, }, ), custom: (), - node: Constant { - value: Int( - 1, + node: Name( + ExprName { + id: "int", + ctx: Load, + }, + ), + }, + value: Some( + Located { + location: Location { + row: 1, + column: 9, + }, + end_location: Some( + Location { + row: 1, + column: 10, + }, + ), + custom: (), + node: Constant( + ExprConstant { + value: Int( + 1, + ), + kind: None, + }, ), - kind: None, }, - }, - ), - simple: 1, - }, + ), + simple: 1, + }, + ), }, ] diff --git a/parser/src/snapshots/rustpython_parser__context__tests__assign_attribute.snap b/parser/src/snapshots/rustpython_parser__context__tests__assign_attribute.snap index 984cb7a3..a9a45d0a 100644 --- a/parser/src/snapshots/rustpython_parser__context__tests__assign_attribute.snap +++ b/parser/src/snapshots/rustpython_parser__context__tests__assign_attribute.snap @@ -1,5 +1,5 @@ --- -source: compiler/parser/src/context.rs +source: parser/src/context.rs expression: parse_ast --- [ @@ -15,119 +15,133 @@ expression: parse_ast }, ), custom: (), - node: Assign { - targets: [ - Located { - location: Location { - row: 1, - column: 0, - }, - end_location: Some( - Location { + node: Assign( + StmtAssign { + targets: [ + Located { + location: Location { row: 1, - column: 3, + column: 0, }, - ), - custom: (), - node: Attribute { - value: Located { - location: Location { + end_location: Some( + Location { row: 1, - column: 0, + column: 3, }, - end_location: Some( - Location { - row: 1, - column: 1, + ), + custom: (), + node: Attribute( + ExprAttribute { + value: Located { + location: Location { + row: 1, + column: 0, + }, + end_location: Some( + Location { + row: 1, + column: 1, + }, + ), + custom: (), + node: Name( + ExprName { + id: "x", + ctx: Load, + }, + ), }, - ), - custom: (), - node: Name { - id: "x", - ctx: Load, + attr: "y", + ctx: Store, }, - }, - attr: "y", - ctx: Store, + ), }, - }, - ], - value: Located { - location: Location { - row: 1, - column: 6, - }, - end_location: Some( - Location { + ], + value: Located { + location: Location { row: 1, - column: 15, + column: 6, }, - ), - custom: (), - node: Tuple { - elts: [ - Located { - location: Location { - row: 1, - column: 7, - }, - end_location: Some( - Location { - row: 1, - column: 8, - }, - ), - custom: (), - node: Constant { - value: Int( - 1, - ), - kind: None, - }, + end_location: Some( + Location { + row: 1, + column: 15, }, - Located { - location: Location { - row: 1, - column: 10, - }, - end_location: Some( - Location { - row: 1, - column: 11, + ), + custom: (), + node: Tuple( + ExprTuple { + elts: [ + Located { + location: Location { + row: 1, + column: 7, + }, + end_location: Some( + Location { + row: 1, + column: 8, + }, + ), + custom: (), + node: Constant( + ExprConstant { + value: Int( + 1, + ), + kind: None, + }, + ), }, - ), - custom: (), - node: Constant { - value: Int( - 2, - ), - kind: None, - }, - }, - Located { - location: Location { - row: 1, - column: 13, - }, - end_location: Some( - Location { - row: 1, - column: 14, + Located { + location: Location { + row: 1, + column: 10, + }, + end_location: Some( + Location { + row: 1, + column: 11, + }, + ), + custom: (), + node: Constant( + ExprConstant { + value: Int( + 2, + ), + kind: None, + }, + ), }, - ), - custom: (), - node: Constant { - value: Int( - 3, - ), - kind: None, - }, + Located { + location: Location { + row: 1, + column: 13, + }, + end_location: Some( + Location { + row: 1, + column: 14, + }, + ), + custom: (), + node: Constant( + ExprConstant { + value: Int( + 3, + ), + kind: None, + }, + ), + }, + ], + ctx: Load, }, - ], - ctx: Load, + ), }, + type_comment: None, }, - type_comment: None, - }, + ), }, ] diff --git a/parser/src/snapshots/rustpython_parser__context__tests__assign_for.snap b/parser/src/snapshots/rustpython_parser__context__tests__assign_for.snap index 9dd28020..a3eecf2d 100644 --- a/parser/src/snapshots/rustpython_parser__context__tests__assign_for.snap +++ b/parser/src/snapshots/rustpython_parser__context__tests__assign_for.snap @@ -1,5 +1,5 @@ --- -source: compiler/parser/src/context.rs +source: parser/src/context.rs expression: parse_ast --- [ @@ -15,117 +15,129 @@ expression: parse_ast }, ), custom: (), - node: For { - target: Located { - location: Location { - row: 1, - column: 4, - }, - end_location: Some( - Location { - row: 1, - column: 5, - }, - ), - custom: (), - node: Name { - id: "x", - ctx: Store, - }, - }, - iter: Located { - location: Location { - row: 1, - column: 9, - }, - end_location: Some( - Location { + node: For( + StmtFor { + target: Located { + location: Location { row: 1, - column: 18, + column: 4, }, - ), - custom: (), - node: Tuple { - elts: [ - Located { - location: Location { - row: 1, - column: 10, - }, - end_location: Some( - Location { - row: 1, - column: 11, - }, - ), - custom: (), - node: Constant { - value: Int( - 1, - ), - kind: None, - }, - }, - Located { - location: Location { - row: 1, - column: 13, - }, - end_location: Some( - Location { - row: 1, - column: 14, - }, - ), - custom: (), - node: Constant { - value: Int( - 2, - ), - kind: None, - }, + end_location: Some( + Location { + row: 1, + column: 5, }, - Located { - location: Location { - row: 1, - column: 16, - }, - end_location: Some( - Location { - row: 1, - column: 17, - }, - ), - custom: (), - node: Constant { - value: Int( - 3, - ), - kind: None, - }, + ), + custom: (), + node: Name( + ExprName { + id: "x", + ctx: Store, }, - ], - ctx: Load, + ), }, - }, - body: [ - Located { + iter: Located { location: Location { row: 1, - column: 20, + column: 9, }, end_location: Some( Location { row: 1, - column: 24, + column: 18, }, ), custom: (), - node: Pass, + node: Tuple( + ExprTuple { + elts: [ + Located { + location: Location { + row: 1, + column: 10, + }, + end_location: Some( + Location { + row: 1, + column: 11, + }, + ), + custom: (), + node: Constant( + ExprConstant { + value: Int( + 1, + ), + kind: None, + }, + ), + }, + Located { + location: Location { + row: 1, + column: 13, + }, + end_location: Some( + Location { + row: 1, + column: 14, + }, + ), + custom: (), + node: Constant( + ExprConstant { + value: Int( + 2, + ), + kind: None, + }, + ), + }, + Located { + location: Location { + row: 1, + column: 16, + }, + end_location: Some( + Location { + row: 1, + column: 17, + }, + ), + custom: (), + node: Constant( + ExprConstant { + value: Int( + 3, + ), + kind: None, + }, + ), + }, + ], + ctx: Load, + }, + ), }, - ], - orelse: [], - type_comment: None, - }, + body: [ + Located { + location: Location { + row: 1, + column: 20, + }, + end_location: Some( + Location { + row: 1, + column: 24, + }, + ), + custom: (), + node: Pass, + }, + ], + orelse: [], + type_comment: None, + }, + ), }, ] diff --git a/parser/src/snapshots/rustpython_parser__context__tests__assign_list.snap b/parser/src/snapshots/rustpython_parser__context__tests__assign_list.snap index ea59293b..1c9285b4 100644 --- a/parser/src/snapshots/rustpython_parser__context__tests__assign_list.snap +++ b/parser/src/snapshots/rustpython_parser__context__tests__assign_list.snap @@ -1,5 +1,5 @@ --- -source: compiler/parser/src/context.rs +source: parser/src/context.rs expression: parse_ast --- [ @@ -15,137 +15,153 @@ expression: parse_ast }, ), custom: (), - node: Assign { - targets: [ - Located { + node: Assign( + StmtAssign { + targets: [ + Located { + location: Location { + row: 1, + column: 0, + }, + end_location: Some( + Location { + row: 1, + column: 6, + }, + ), + custom: (), + node: List( + ExprList { + elts: [ + Located { + location: Location { + row: 1, + column: 1, + }, + end_location: Some( + Location { + row: 1, + column: 2, + }, + ), + custom: (), + node: Name( + ExprName { + id: "x", + ctx: Store, + }, + ), + }, + Located { + location: Location { + row: 1, + column: 4, + }, + end_location: Some( + Location { + row: 1, + column: 5, + }, + ), + custom: (), + node: Name( + ExprName { + id: "y", + ctx: Store, + }, + ), + }, + ], + ctx: Store, + }, + ), + }, + ], + value: Located { location: Location { row: 1, - column: 0, + column: 9, }, end_location: Some( Location { row: 1, - column: 6, + column: 18, }, ), custom: (), - node: List { - elts: [ - Located { - location: Location { - row: 1, - column: 1, - }, - end_location: Some( - Location { + node: Tuple( + ExprTuple { + elts: [ + Located { + location: Location { row: 1, - column: 2, + column: 10, }, - ), - custom: (), - node: Name { - id: "x", - ctx: Store, + end_location: Some( + Location { + row: 1, + column: 11, + }, + ), + custom: (), + node: Constant( + ExprConstant { + value: Int( + 1, + ), + kind: None, + }, + ), }, - }, - Located { - location: Location { - row: 1, - column: 4, - }, - end_location: Some( - Location { + Located { + location: Location { row: 1, - column: 5, + column: 13, }, - ), - custom: (), - node: Name { - id: "y", - ctx: Store, + end_location: Some( + Location { + row: 1, + column: 14, + }, + ), + custom: (), + node: Constant( + ExprConstant { + value: Int( + 2, + ), + kind: None, + }, + ), }, - }, - ], - ctx: Store, - }, - }, - ], - value: Located { - location: Location { - row: 1, - column: 9, - }, - end_location: Some( - Location { - row: 1, - column: 18, - }, - ), - custom: (), - node: Tuple { - elts: [ - Located { - location: Location { - row: 1, - column: 10, - }, - end_location: Some( - Location { - row: 1, - column: 11, - }, - ), - custom: (), - node: Constant { - value: Int( - 1, - ), - kind: None, - }, - }, - Located { - location: Location { - row: 1, - column: 13, - }, - end_location: Some( - Location { - row: 1, - column: 14, - }, - ), - custom: (), - node: Constant { - value: Int( - 2, - ), - kind: None, - }, - }, - Located { - location: Location { - row: 1, - column: 16, - }, - end_location: Some( - Location { - row: 1, - column: 17, + Located { + location: Location { + row: 1, + column: 16, + }, + end_location: Some( + Location { + row: 1, + column: 17, + }, + ), + custom: (), + node: Constant( + ExprConstant { + value: Int( + 3, + ), + kind: None, + }, + ), }, - ), - custom: (), - node: Constant { - value: Int( - 3, - ), - kind: None, - }, + ], + ctx: Load, }, - ], - ctx: Load, + ), }, + type_comment: None, }, - type_comment: None, - }, + ), }, ] diff --git a/parser/src/snapshots/rustpython_parser__context__tests__assign_list_comp.snap b/parser/src/snapshots/rustpython_parser__context__tests__assign_list_comp.snap index 367f09a4..8ce58518 100644 --- a/parser/src/snapshots/rustpython_parser__context__tests__assign_list_comp.snap +++ b/parser/src/snapshots/rustpython_parser__context__tests__assign_list_comp.snap @@ -1,5 +1,5 @@ --- -source: compiler/parser/src/context.rs +source: parser/src/context.rs expression: parse_ast --- [ @@ -15,157 +15,175 @@ expression: parse_ast }, ), custom: (), - node: Assign { - targets: [ - Located { - location: Location { - row: 1, - column: 0, - }, - end_location: Some( - Location { - row: 1, - column: 1, - }, - ), - custom: (), - node: Name { - id: "x", - ctx: Store, - }, - }, - ], - value: Located { - location: Location { - row: 1, - column: 4, - }, - end_location: Some( - Location { - row: 1, - column: 26, - }, - ), - custom: (), - node: ListComp { - elt: Located { + node: Assign( + StmtAssign { + targets: [ + Located { location: Location { row: 1, - column: 5, + column: 0, }, end_location: Some( Location { row: 1, - column: 6, + column: 1, }, ), custom: (), - node: Name { - id: "y", - ctx: Load, - }, + node: Name( + ExprName { + id: "x", + ctx: Store, + }, + ), }, - generators: [ - Comprehension { - target: Located { + ], + value: Located { + location: Location { + row: 1, + column: 4, + }, + end_location: Some( + Location { + row: 1, + column: 26, + }, + ), + custom: (), + node: ListComp( + ExprListComp { + elt: Located { location: Location { row: 1, - column: 11, + column: 5, }, end_location: Some( Location { row: 1, - column: 12, + column: 6, }, ), custom: (), - node: Name { - id: "y", - ctx: Store, - }, - }, - iter: Located { - location: Location { - row: 1, - column: 16, - }, - end_location: Some( - Location { - row: 1, - column: 25, + node: Name( + ExprName { + id: "y", + ctx: Load, }, ), - custom: (), - node: Tuple { - elts: [ - Located { - location: Location { - row: 1, - column: 17, - }, - end_location: Some( - Location { - row: 1, - column: 18, - }, - ), - custom: (), - node: Constant { - value: Int( - 1, - ), - kind: None, - }, + }, + generators: [ + Comprehension { + target: Located { + location: Location { + row: 1, + column: 11, }, - Located { - location: Location { + end_location: Some( + Location { row: 1, - column: 20, + column: 12, }, - end_location: Some( - Location { - row: 1, - column: 21, - }, - ), - custom: (), - node: Constant { - value: Int( - 2, - ), - kind: None, + ), + custom: (), + node: Name( + ExprName { + id: "y", + ctx: Store, }, + ), + }, + iter: Located { + location: Location { + row: 1, + column: 16, }, - Located { - location: Location { + end_location: Some( + Location { row: 1, - column: 23, + column: 25, }, - end_location: Some( - Location { - row: 1, - column: 24, - }, - ), - custom: (), - node: Constant { - value: Int( - 3, - ), - kind: None, + ), + custom: (), + node: Tuple( + ExprTuple { + elts: [ + Located { + location: Location { + row: 1, + column: 17, + }, + end_location: Some( + Location { + row: 1, + column: 18, + }, + ), + custom: (), + node: Constant( + ExprConstant { + value: Int( + 1, + ), + kind: None, + }, + ), + }, + Located { + location: Location { + row: 1, + column: 20, + }, + end_location: Some( + Location { + row: 1, + column: 21, + }, + ), + custom: (), + node: Constant( + ExprConstant { + value: Int( + 2, + ), + kind: None, + }, + ), + }, + Located { + location: Location { + row: 1, + column: 23, + }, + end_location: Some( + Location { + row: 1, + column: 24, + }, + ), + custom: (), + node: Constant( + ExprConstant { + value: Int( + 3, + ), + kind: None, + }, + ), + }, + ], + ctx: Load, }, - }, - ], - ctx: Load, + ), + }, + ifs: [], + is_async: 0, }, - }, - ifs: [], - is_async: 0, + ], }, - ], + ), }, + type_comment: None, }, - type_comment: None, - }, + ), }, ] diff --git a/parser/src/snapshots/rustpython_parser__context__tests__assign_name.snap b/parser/src/snapshots/rustpython_parser__context__tests__assign_name.snap index 55d4e70d..370db7c2 100644 --- a/parser/src/snapshots/rustpython_parser__context__tests__assign_name.snap +++ b/parser/src/snapshots/rustpython_parser__context__tests__assign_name.snap @@ -1,5 +1,5 @@ --- -source: compiler/parser/src/context.rs +source: parser/src/context.rs expression: parse_ast --- [ @@ -15,102 +15,114 @@ expression: parse_ast }, ), custom: (), - node: Assign { - targets: [ - Located { + node: Assign( + StmtAssign { + targets: [ + Located { + location: Location { + row: 1, + column: 0, + }, + end_location: Some( + Location { + row: 1, + column: 1, + }, + ), + custom: (), + node: Name( + ExprName { + id: "x", + ctx: Store, + }, + ), + }, + ], + value: Located { location: Location { row: 1, - column: 0, + column: 4, }, end_location: Some( Location { row: 1, - column: 1, + column: 13, }, ), custom: (), - node: Name { - id: "x", - ctx: Store, - }, - }, - ], - value: Located { - location: Location { - row: 1, - column: 4, - }, - end_location: Some( - Location { - row: 1, - column: 13, - }, - ), - custom: (), - node: Tuple { - elts: [ - Located { - location: Location { - row: 1, - column: 5, - }, - end_location: Some( - Location { - row: 1, - column: 6, + node: Tuple( + ExprTuple { + elts: [ + Located { + location: Location { + row: 1, + column: 5, + }, + end_location: Some( + Location { + row: 1, + column: 6, + }, + ), + custom: (), + node: Constant( + ExprConstant { + value: Int( + 1, + ), + kind: None, + }, + ), }, - ), - custom: (), - node: Constant { - value: Int( - 1, - ), - kind: None, - }, - }, - Located { - location: Location { - row: 1, - column: 8, - }, - end_location: Some( - Location { - row: 1, - column: 9, + Located { + location: Location { + row: 1, + column: 8, + }, + end_location: Some( + Location { + row: 1, + column: 9, + }, + ), + custom: (), + node: Constant( + ExprConstant { + value: Int( + 2, + ), + kind: None, + }, + ), }, - ), - custom: (), - node: Constant { - value: Int( - 2, - ), - kind: None, - }, - }, - Located { - location: Location { - row: 1, - column: 11, - }, - end_location: Some( - Location { - row: 1, - column: 12, + Located { + location: Location { + row: 1, + column: 11, + }, + end_location: Some( + Location { + row: 1, + column: 12, + }, + ), + custom: (), + node: Constant( + ExprConstant { + value: Int( + 3, + ), + kind: None, + }, + ), }, - ), - custom: (), - node: Constant { - value: Int( - 3, - ), - kind: None, - }, + ], + ctx: Load, }, - ], - ctx: Load, + ), }, + type_comment: None, }, - type_comment: None, - }, + ), }, ] diff --git a/parser/src/snapshots/rustpython_parser__context__tests__assign_named_expr.snap b/parser/src/snapshots/rustpython_parser__context__tests__assign_named_expr.snap index 64ddb632..530a3e29 100644 --- a/parser/src/snapshots/rustpython_parser__context__tests__assign_named_expr.snap +++ b/parser/src/snapshots/rustpython_parser__context__tests__assign_named_expr.snap @@ -1,5 +1,5 @@ --- -source: compiler/parser/src/context.rs +source: parser/src/context.rs expression: parse_ast --- [ @@ -15,75 +15,83 @@ expression: parse_ast }, ), custom: (), - node: If { - test: Located { - location: Location { - row: 1, - column: 3, - }, - end_location: Some( - Location { + node: If( + StmtIf { + test: Located { + location: Location { row: 1, - column: 8, + column: 3, }, - ), - custom: (), - node: NamedExpr { - target: Located { - location: Location { + end_location: Some( + Location { row: 1, - column: 3, + column: 8, }, - end_location: Some( - Location { - row: 1, - column: 4, + ), + custom: (), + node: NamedExpr( + ExprNamedExpr { + target: Located { + location: Location { + row: 1, + column: 3, + }, + end_location: Some( + Location { + row: 1, + column: 4, + }, + ), + custom: (), + node: Name( + ExprName { + id: "x", + ctx: Store, + }, + ), + }, + value: Located { + location: Location { + row: 1, + column: 7, + }, + end_location: Some( + Location { + row: 1, + column: 8, + }, + ), + custom: (), + node: Constant( + ExprConstant { + value: Int( + 1, + ), + kind: None, + }, + ), }, - ), - custom: (), - node: Name { - id: "x", - ctx: Store, }, - }, - value: Located { + ), + }, + body: [ + Located { location: Location { row: 1, - column: 7, + column: 10, }, end_location: Some( Location { row: 1, - column: 8, + column: 14, }, ), custom: (), - node: Constant { - value: Int( - 1, - ), - kind: None, - }, + node: Pass, }, - }, + ], + orelse: [], }, - body: [ - Located { - location: Location { - row: 1, - column: 10, - }, - end_location: Some( - Location { - row: 1, - column: 14, - }, - ), - custom: (), - node: Pass, - }, - ], - orelse: [], - }, + ), }, ] diff --git a/parser/src/snapshots/rustpython_parser__context__tests__assign_set_comp.snap b/parser/src/snapshots/rustpython_parser__context__tests__assign_set_comp.snap index 97ecaa08..8249ba44 100644 --- a/parser/src/snapshots/rustpython_parser__context__tests__assign_set_comp.snap +++ b/parser/src/snapshots/rustpython_parser__context__tests__assign_set_comp.snap @@ -1,5 +1,5 @@ --- -source: compiler/parser/src/context.rs +source: parser/src/context.rs expression: parse_ast --- [ @@ -15,157 +15,175 @@ expression: parse_ast }, ), custom: (), - node: Assign { - targets: [ - Located { - location: Location { - row: 1, - column: 0, - }, - end_location: Some( - Location { - row: 1, - column: 1, - }, - ), - custom: (), - node: Name { - id: "x", - ctx: Store, - }, - }, - ], - value: Located { - location: Location { - row: 1, - column: 4, - }, - end_location: Some( - Location { - row: 1, - column: 26, - }, - ), - custom: (), - node: SetComp { - elt: Located { + node: Assign( + StmtAssign { + targets: [ + Located { location: Location { row: 1, - column: 5, + column: 0, }, end_location: Some( Location { row: 1, - column: 6, + column: 1, }, ), custom: (), - node: Name { - id: "y", - ctx: Load, - }, + node: Name( + ExprName { + id: "x", + ctx: Store, + }, + ), }, - generators: [ - Comprehension { - target: Located { + ], + value: Located { + location: Location { + row: 1, + column: 4, + }, + end_location: Some( + Location { + row: 1, + column: 26, + }, + ), + custom: (), + node: SetComp( + ExprSetComp { + elt: Located { location: Location { row: 1, - column: 11, + column: 5, }, end_location: Some( Location { row: 1, - column: 12, + column: 6, }, ), custom: (), - node: Name { - id: "y", - ctx: Store, - }, - }, - iter: Located { - location: Location { - row: 1, - column: 16, - }, - end_location: Some( - Location { - row: 1, - column: 25, + node: Name( + ExprName { + id: "y", + ctx: Load, }, ), - custom: (), - node: Tuple { - elts: [ - Located { - location: Location { - row: 1, - column: 17, - }, - end_location: Some( - Location { - row: 1, - column: 18, - }, - ), - custom: (), - node: Constant { - value: Int( - 1, - ), - kind: None, - }, + }, + generators: [ + Comprehension { + target: Located { + location: Location { + row: 1, + column: 11, }, - Located { - location: Location { + end_location: Some( + Location { row: 1, - column: 20, + column: 12, }, - end_location: Some( - Location { - row: 1, - column: 21, - }, - ), - custom: (), - node: Constant { - value: Int( - 2, - ), - kind: None, + ), + custom: (), + node: Name( + ExprName { + id: "y", + ctx: Store, }, + ), + }, + iter: Located { + location: Location { + row: 1, + column: 16, }, - Located { - location: Location { + end_location: Some( + Location { row: 1, - column: 23, + column: 25, }, - end_location: Some( - Location { - row: 1, - column: 24, - }, - ), - custom: (), - node: Constant { - value: Int( - 3, - ), - kind: None, + ), + custom: (), + node: Tuple( + ExprTuple { + elts: [ + Located { + location: Location { + row: 1, + column: 17, + }, + end_location: Some( + Location { + row: 1, + column: 18, + }, + ), + custom: (), + node: Constant( + ExprConstant { + value: Int( + 1, + ), + kind: None, + }, + ), + }, + Located { + location: Location { + row: 1, + column: 20, + }, + end_location: Some( + Location { + row: 1, + column: 21, + }, + ), + custom: (), + node: Constant( + ExprConstant { + value: Int( + 2, + ), + kind: None, + }, + ), + }, + Located { + location: Location { + row: 1, + column: 23, + }, + end_location: Some( + Location { + row: 1, + column: 24, + }, + ), + custom: (), + node: Constant( + ExprConstant { + value: Int( + 3, + ), + kind: None, + }, + ), + }, + ], + ctx: Load, }, - }, - ], - ctx: Load, + ), + }, + ifs: [], + is_async: 0, }, - }, - ifs: [], - is_async: 0, + ], }, - ], + ), }, + type_comment: None, }, - type_comment: None, - }, + ), }, ] diff --git a/parser/src/snapshots/rustpython_parser__context__tests__assign_starred.snap b/parser/src/snapshots/rustpython_parser__context__tests__assign_starred.snap index 015f9bdd..18804c99 100644 --- a/parser/src/snapshots/rustpython_parser__context__tests__assign_starred.snap +++ b/parser/src/snapshots/rustpython_parser__context__tests__assign_starred.snap @@ -1,5 +1,5 @@ --- -source: compiler/parser/src/context.rs +source: parser/src/context.rs expression: parse_ast --- [ @@ -15,56 +15,47 @@ expression: parse_ast }, ), custom: (), - node: Assign { - targets: [ - Located { - location: Location { - row: 1, - column: 0, - }, - end_location: Some( - Location { + node: Assign( + StmtAssign { + targets: [ + Located { + location: Location { row: 1, - column: 7, + column: 0, }, - ), - custom: (), - node: Tuple { - elts: [ - Located { - location: Location { - row: 1, - column: 1, - }, - end_location: Some( - Location { - row: 1, - column: 2, - }, - ), - custom: (), - node: Name { - id: "x", - ctx: Store, - }, + end_location: Some( + Location { + row: 1, + column: 7, }, - Located { - location: Location { - row: 1, - column: 4, - }, - end_location: Some( - Location { - row: 1, - column: 6, + ), + custom: (), + node: Tuple( + ExprTuple { + elts: [ + Located { + location: Location { + row: 1, + column: 1, + }, + end_location: Some( + Location { + row: 1, + column: 2, + }, + ), + custom: (), + node: Name( + ExprName { + id: "x", + ctx: Store, + }, + ), }, - ), - custom: (), - node: Starred { - value: Located { + Located { location: Location { row: 1, - column: 5, + column: 4, }, end_location: Some( Location { @@ -73,95 +64,122 @@ expression: parse_ast }, ), custom: (), - node: Name { - id: "y", - ctx: Store, - }, + node: Starred( + ExprStarred { + value: Located { + location: Location { + row: 1, + column: 5, + }, + end_location: Some( + Location { + row: 1, + column: 6, + }, + ), + custom: (), + node: Name( + ExprName { + id: "y", + ctx: Store, + }, + ), + }, + ctx: Store, + }, + ), }, - ctx: Store, - }, + ], + ctx: Store, }, - ], - ctx: Store, + ), }, - }, - ], - value: Located { - location: Location { - row: 1, - column: 10, - }, - end_location: Some( - Location { + ], + value: Located { + location: Location { row: 1, - column: 19, + column: 10, }, - ), - custom: (), - node: Tuple { - elts: [ - Located { - location: Location { - row: 1, - column: 11, - }, - end_location: Some( - Location { - row: 1, - column: 12, - }, - ), - custom: (), - node: Constant { - value: Int( - 1, - ), - kind: None, - }, + end_location: Some( + Location { + row: 1, + column: 19, }, - Located { - location: Location { - row: 1, - column: 14, - }, - end_location: Some( - Location { - row: 1, - column: 15, + ), + custom: (), + node: Tuple( + ExprTuple { + elts: [ + Located { + location: Location { + row: 1, + column: 11, + }, + end_location: Some( + Location { + row: 1, + column: 12, + }, + ), + custom: (), + node: Constant( + ExprConstant { + value: Int( + 1, + ), + kind: None, + }, + ), }, - ), - custom: (), - node: Constant { - value: Int( - 2, - ), - kind: None, - }, - }, - Located { - location: Location { - row: 1, - column: 17, - }, - end_location: Some( - Location { - row: 1, - column: 18, + Located { + location: Location { + row: 1, + column: 14, + }, + end_location: Some( + Location { + row: 1, + column: 15, + }, + ), + custom: (), + node: Constant( + ExprConstant { + value: Int( + 2, + ), + kind: None, + }, + ), }, - ), - custom: (), - node: Constant { - value: Int( - 3, - ), - kind: None, - }, + Located { + location: Location { + row: 1, + column: 17, + }, + end_location: Some( + Location { + row: 1, + column: 18, + }, + ), + custom: (), + node: Constant( + ExprConstant { + value: Int( + 3, + ), + kind: None, + }, + ), + }, + ], + ctx: Load, }, - ], - ctx: Load, + ), }, + type_comment: None, }, - type_comment: None, - }, + ), }, ] diff --git a/parser/src/snapshots/rustpython_parser__context__tests__assign_subscript.snap b/parser/src/snapshots/rustpython_parser__context__tests__assign_subscript.snap index 756867c3..a81d7b06 100644 --- a/parser/src/snapshots/rustpython_parser__context__tests__assign_subscript.snap +++ b/parser/src/snapshots/rustpython_parser__context__tests__assign_subscript.snap @@ -1,5 +1,5 @@ --- -source: compiler/parser/src/context.rs +source: parser/src/context.rs expression: parse_ast --- [ @@ -15,135 +15,151 @@ expression: parse_ast }, ), custom: (), - node: Assign { - targets: [ - Located { - location: Location { - row: 1, - column: 0, - }, - end_location: Some( - Location { + node: Assign( + StmtAssign { + targets: [ + Located { + location: Location { row: 1, - column: 4, + column: 0, }, - ), - custom: (), - node: Subscript { - value: Located { - location: Location { + end_location: Some( + Location { row: 1, - column: 0, + column: 4, }, - end_location: Some( - Location { - row: 1, - column: 1, + ), + custom: (), + node: Subscript( + ExprSubscript { + value: Located { + location: Location { + row: 1, + column: 0, + }, + end_location: Some( + Location { + row: 1, + column: 1, + }, + ), + custom: (), + node: Name( + ExprName { + id: "x", + ctx: Load, + }, + ), }, - ), - custom: (), - node: Name { - id: "x", - ctx: Load, - }, - }, - slice: Located { - location: Location { - row: 1, - column: 2, - }, - end_location: Some( - Location { - row: 1, - column: 3, + slice: Located { + location: Location { + row: 1, + column: 2, + }, + end_location: Some( + Location { + row: 1, + column: 3, + }, + ), + custom: (), + node: Name( + ExprName { + id: "y", + ctx: Load, + }, + ), }, - ), - custom: (), - node: Name { - id: "y", - ctx: Load, + ctx: Store, }, - }, - ctx: Store, + ), }, - }, - ], - value: Located { - location: Location { - row: 1, - column: 7, - }, - end_location: Some( - Location { + ], + value: Located { + location: Location { row: 1, - column: 16, + column: 7, }, - ), - custom: (), - node: Tuple { - elts: [ - Located { - location: Location { - row: 1, - column: 8, - }, - end_location: Some( - Location { - row: 1, - column: 9, - }, - ), - custom: (), - node: Constant { - value: Int( - 1, - ), - kind: None, - }, + end_location: Some( + Location { + row: 1, + column: 16, }, - Located { - location: Location { - row: 1, - column: 11, - }, - end_location: Some( - Location { - row: 1, - column: 12, + ), + custom: (), + node: Tuple( + ExprTuple { + elts: [ + Located { + location: Location { + row: 1, + column: 8, + }, + end_location: Some( + Location { + row: 1, + column: 9, + }, + ), + custom: (), + node: Constant( + ExprConstant { + value: Int( + 1, + ), + kind: None, + }, + ), }, - ), - custom: (), - node: Constant { - value: Int( - 2, - ), - kind: None, - }, - }, - Located { - location: Location { - row: 1, - column: 14, - }, - end_location: Some( - Location { - row: 1, - column: 15, + Located { + location: Location { + row: 1, + column: 11, + }, + end_location: Some( + Location { + row: 1, + column: 12, + }, + ), + custom: (), + node: Constant( + ExprConstant { + value: Int( + 2, + ), + kind: None, + }, + ), }, - ), - custom: (), - node: Constant { - value: Int( - 3, - ), - kind: None, - }, + Located { + location: Location { + row: 1, + column: 14, + }, + end_location: Some( + Location { + row: 1, + column: 15, + }, + ), + custom: (), + node: Constant( + ExprConstant { + value: Int( + 3, + ), + kind: None, + }, + ), + }, + ], + ctx: Load, }, - ], - ctx: Load, + ), }, + type_comment: None, }, - type_comment: None, - }, + ), }, ] diff --git a/parser/src/snapshots/rustpython_parser__context__tests__assign_tuple.snap b/parser/src/snapshots/rustpython_parser__context__tests__assign_tuple.snap index c520427d..bab294e0 100644 --- a/parser/src/snapshots/rustpython_parser__context__tests__assign_tuple.snap +++ b/parser/src/snapshots/rustpython_parser__context__tests__assign_tuple.snap @@ -1,5 +1,5 @@ --- -source: compiler/parser/src/context.rs +source: parser/src/context.rs expression: parse_ast --- [ @@ -15,137 +15,153 @@ expression: parse_ast }, ), custom: (), - node: Assign { - targets: [ - Located { + node: Assign( + StmtAssign { + targets: [ + Located { + location: Location { + row: 1, + column: 0, + }, + end_location: Some( + Location { + row: 1, + column: 6, + }, + ), + custom: (), + node: Tuple( + ExprTuple { + elts: [ + Located { + location: Location { + row: 1, + column: 1, + }, + end_location: Some( + Location { + row: 1, + column: 2, + }, + ), + custom: (), + node: Name( + ExprName { + id: "x", + ctx: Store, + }, + ), + }, + Located { + location: Location { + row: 1, + column: 4, + }, + end_location: Some( + Location { + row: 1, + column: 5, + }, + ), + custom: (), + node: Name( + ExprName { + id: "y", + ctx: Store, + }, + ), + }, + ], + ctx: Store, + }, + ), + }, + ], + value: Located { location: Location { row: 1, - column: 0, + column: 9, }, end_location: Some( Location { row: 1, - column: 6, + column: 18, }, ), custom: (), - node: Tuple { - elts: [ - Located { - location: Location { - row: 1, - column: 1, - }, - end_location: Some( - Location { + node: Tuple( + ExprTuple { + elts: [ + Located { + location: Location { row: 1, - column: 2, + column: 10, }, - ), - custom: (), - node: Name { - id: "x", - ctx: Store, + end_location: Some( + Location { + row: 1, + column: 11, + }, + ), + custom: (), + node: Constant( + ExprConstant { + value: Int( + 1, + ), + kind: None, + }, + ), }, - }, - Located { - location: Location { - row: 1, - column: 4, - }, - end_location: Some( - Location { + Located { + location: Location { row: 1, - column: 5, + column: 13, }, - ), - custom: (), - node: Name { - id: "y", - ctx: Store, + end_location: Some( + Location { + row: 1, + column: 14, + }, + ), + custom: (), + node: Constant( + ExprConstant { + value: Int( + 2, + ), + kind: None, + }, + ), }, - }, - ], - ctx: Store, - }, - }, - ], - value: Located { - location: Location { - row: 1, - column: 9, - }, - end_location: Some( - Location { - row: 1, - column: 18, - }, - ), - custom: (), - node: Tuple { - elts: [ - Located { - location: Location { - row: 1, - column: 10, - }, - end_location: Some( - Location { - row: 1, - column: 11, - }, - ), - custom: (), - node: Constant { - value: Int( - 1, - ), - kind: None, - }, - }, - Located { - location: Location { - row: 1, - column: 13, - }, - end_location: Some( - Location { - row: 1, - column: 14, - }, - ), - custom: (), - node: Constant { - value: Int( - 2, - ), - kind: None, - }, - }, - Located { - location: Location { - row: 1, - column: 16, - }, - end_location: Some( - Location { - row: 1, - column: 17, + Located { + location: Location { + row: 1, + column: 16, + }, + end_location: Some( + Location { + row: 1, + column: 17, + }, + ), + custom: (), + node: Constant( + ExprConstant { + value: Int( + 3, + ), + kind: None, + }, + ), }, - ), - custom: (), - node: Constant { - value: Int( - 3, - ), - kind: None, - }, + ], + ctx: Load, }, - ], - ctx: Load, + ), }, + type_comment: None, }, - type_comment: None, - }, + ), }, ] diff --git a/parser/src/snapshots/rustpython_parser__context__tests__assign_with.snap b/parser/src/snapshots/rustpython_parser__context__tests__assign_with.snap index 100b6728..12fcda82 100644 --- a/parser/src/snapshots/rustpython_parser__context__tests__assign_with.snap +++ b/parser/src/snapshots/rustpython_parser__context__tests__assign_with.snap @@ -1,5 +1,5 @@ --- -source: compiler/parser/src/context.rs +source: parser/src/context.rs expression: parse_ast --- [ @@ -15,66 +15,72 @@ expression: parse_ast }, ), custom: (), - node: With { - items: [ - Withitem { - context_expr: Located { - location: Location { - row: 1, - column: 5, - }, - end_location: Some( - Location { - row: 1, - column: 6, - }, - ), - custom: (), - node: Constant { - value: Int( - 1, - ), - kind: None, - }, - }, - optional_vars: Some( - Located { + node: With( + StmtWith { + items: [ + Withitem { + context_expr: Located { location: Location { row: 1, - column: 10, + column: 5, }, end_location: Some( Location { row: 1, - column: 11, + column: 6, }, ), custom: (), - node: Name { - id: "x", - ctx: Store, - }, + node: Constant( + ExprConstant { + value: Int( + 1, + ), + kind: None, + }, + ), }, - ), - }, - ], - body: [ - Located { - location: Location { - row: 1, - column: 13, + optional_vars: Some( + Located { + location: Location { + row: 1, + column: 10, + }, + end_location: Some( + Location { + row: 1, + column: 11, + }, + ), + custom: (), + node: Name( + ExprName { + id: "x", + ctx: Store, + }, + ), + }, + ), }, - end_location: Some( - Location { + ], + body: [ + Located { + location: Location { row: 1, - column: 17, + column: 13, }, - ), - custom: (), - node: Pass, - }, - ], - type_comment: None, - }, + end_location: Some( + Location { + row: 1, + column: 17, + }, + ), + custom: (), + node: Pass, + }, + ], + type_comment: None, + }, + ), }, ] diff --git a/parser/src/snapshots/rustpython_parser__context__tests__aug_assign_attribute.snap b/parser/src/snapshots/rustpython_parser__context__tests__aug_assign_attribute.snap index 3e6e4b79..006a9571 100644 --- a/parser/src/snapshots/rustpython_parser__context__tests__aug_assign_attribute.snap +++ b/parser/src/snapshots/rustpython_parser__context__tests__aug_assign_attribute.snap @@ -1,5 +1,5 @@ --- -source: compiler/parser/src/context.rs +source: parser/src/context.rs expression: parse_ast --- [ @@ -15,117 +15,131 @@ expression: parse_ast }, ), custom: (), - node: AugAssign { - target: Located { - location: Location { - row: 1, - column: 0, - }, - end_location: Some( - Location { + node: AugAssign( + StmtAugAssign { + target: Located { + location: Location { row: 1, - column: 3, + column: 0, }, - ), - custom: (), - node: Attribute { - value: Located { - location: Location { + end_location: Some( + Location { row: 1, - column: 0, + column: 3, }, - end_location: Some( - Location { - row: 1, - column: 1, + ), + custom: (), + node: Attribute( + ExprAttribute { + value: Located { + location: Location { + row: 1, + column: 0, + }, + end_location: Some( + Location { + row: 1, + column: 1, + }, + ), + custom: (), + node: Name( + ExprName { + id: "x", + ctx: Load, + }, + ), }, - ), - custom: (), - node: Name { - id: "x", - ctx: Load, + attr: "y", + ctx: Store, }, - }, - attr: "y", - ctx: Store, + ), }, - }, - op: Add, - value: Located { - location: Location { - row: 1, - column: 7, - }, - end_location: Some( - Location { + op: Add, + value: Located { + location: Location { row: 1, - column: 16, + column: 7, }, - ), - custom: (), - node: Tuple { - elts: [ - Located { - location: Location { - row: 1, - column: 8, - }, - end_location: Some( - Location { - row: 1, - column: 9, - }, - ), - custom: (), - node: Constant { - value: Int( - 1, - ), - kind: None, - }, + end_location: Some( + Location { + row: 1, + column: 16, }, - Located { - location: Location { - row: 1, - column: 11, - }, - end_location: Some( - Location { - row: 1, - column: 12, + ), + custom: (), + node: Tuple( + ExprTuple { + elts: [ + Located { + location: Location { + row: 1, + column: 8, + }, + end_location: Some( + Location { + row: 1, + column: 9, + }, + ), + custom: (), + node: Constant( + ExprConstant { + value: Int( + 1, + ), + kind: None, + }, + ), }, - ), - custom: (), - node: Constant { - value: Int( - 2, - ), - kind: None, - }, - }, - Located { - location: Location { - row: 1, - column: 14, - }, - end_location: Some( - Location { - row: 1, - column: 15, + Located { + location: Location { + row: 1, + column: 11, + }, + end_location: Some( + Location { + row: 1, + column: 12, + }, + ), + custom: (), + node: Constant( + ExprConstant { + value: Int( + 2, + ), + kind: None, + }, + ), }, - ), - custom: (), - node: Constant { - value: Int( - 3, - ), - kind: None, - }, + Located { + location: Location { + row: 1, + column: 14, + }, + end_location: Some( + Location { + row: 1, + column: 15, + }, + ), + custom: (), + node: Constant( + ExprConstant { + value: Int( + 3, + ), + kind: None, + }, + ), + }, + ], + ctx: Load, }, - ], - ctx: Load, + ), }, }, - }, + ), }, ] diff --git a/parser/src/snapshots/rustpython_parser__context__tests__aug_assign_name.snap b/parser/src/snapshots/rustpython_parser__context__tests__aug_assign_name.snap index 0035310f..6b82083a 100644 --- a/parser/src/snapshots/rustpython_parser__context__tests__aug_assign_name.snap +++ b/parser/src/snapshots/rustpython_parser__context__tests__aug_assign_name.snap @@ -1,5 +1,5 @@ --- -source: compiler/parser/src/context.rs +source: parser/src/context.rs expression: parse_ast --- [ @@ -15,44 +15,50 @@ expression: parse_ast }, ), custom: (), - node: AugAssign { - target: Located { - location: Location { - row: 1, - column: 0, - }, - end_location: Some( - Location { + node: AugAssign( + StmtAugAssign { + target: Located { + location: Location { row: 1, - column: 1, + column: 0, }, - ), - custom: (), - node: Name { - id: "x", - ctx: Store, - }, - }, - op: Add, - value: Located { - location: Location { - row: 1, - column: 5, + end_location: Some( + Location { + row: 1, + column: 1, + }, + ), + custom: (), + node: Name( + ExprName { + id: "x", + ctx: Store, + }, + ), }, - end_location: Some( - Location { + op: Add, + value: Located { + location: Location { row: 1, - column: 6, + column: 5, }, - ), - custom: (), - node: Constant { - value: Int( - 1, + end_location: Some( + Location { + row: 1, + column: 6, + }, + ), + custom: (), + node: Constant( + ExprConstant { + value: Int( + 1, + ), + kind: None, + }, ), - kind: None, }, }, - }, + ), }, ] diff --git a/parser/src/snapshots/rustpython_parser__context__tests__aug_assign_subscript.snap b/parser/src/snapshots/rustpython_parser__context__tests__aug_assign_subscript.snap index 72fe61db..61e89e78 100644 --- a/parser/src/snapshots/rustpython_parser__context__tests__aug_assign_subscript.snap +++ b/parser/src/snapshots/rustpython_parser__context__tests__aug_assign_subscript.snap @@ -1,5 +1,5 @@ --- -source: compiler/parser/src/context.rs +source: parser/src/context.rs expression: parse_ast --- [ @@ -15,133 +15,149 @@ expression: parse_ast }, ), custom: (), - node: AugAssign { - target: Located { - location: Location { - row: 1, - column: 0, - }, - end_location: Some( - Location { + node: AugAssign( + StmtAugAssign { + target: Located { + location: Location { row: 1, - column: 4, + column: 0, }, - ), - custom: (), - node: Subscript { - value: Located { - location: Location { + end_location: Some( + Location { row: 1, - column: 0, - }, - end_location: Some( - Location { - row: 1, - column: 1, - }, - ), - custom: (), - node: Name { - id: "x", - ctx: Load, - }, - }, - slice: Located { - location: Location { - row: 1, - column: 2, - }, - end_location: Some( - Location { - row: 1, - column: 3, - }, - ), - custom: (), - node: Name { - id: "y", - ctx: Load, + column: 4, }, - }, - ctx: Store, - }, - }, - op: Add, - value: Located { - location: Location { - row: 1, - column: 8, - }, - end_location: Some( - Location { - row: 1, - column: 17, - }, - ), - custom: (), - node: Tuple { - elts: [ - Located { - location: Location { - row: 1, - column: 9, - }, - end_location: Some( - Location { + ), + custom: (), + node: Subscript( + ExprSubscript { + value: Located { + location: Location { row: 1, - column: 10, + column: 0, }, - ), - custom: (), - node: Constant { - value: Int( - 1, + end_location: Some( + Location { + row: 1, + column: 1, + }, + ), + custom: (), + node: Name( + ExprName { + id: "x", + ctx: Load, + }, ), - kind: None, - }, - }, - Located { - location: Location { - row: 1, - column: 12, }, - end_location: Some( - Location { + slice: Located { + location: Location { row: 1, - column: 13, + column: 2, }, - ), - custom: (), - node: Constant { - value: Int( - 2, + end_location: Some( + Location { + row: 1, + column: 3, + }, + ), + custom: (), + node: Name( + ExprName { + id: "y", + ctx: Load, + }, ), - kind: None, }, + ctx: Store, }, - Located { - location: Location { - row: 1, - column: 15, - }, - end_location: Some( - Location { - row: 1, - column: 16, + ), + }, + op: Add, + value: Located { + location: Location { + row: 1, + column: 8, + }, + end_location: Some( + Location { + row: 1, + column: 17, + }, + ), + custom: (), + node: Tuple( + ExprTuple { + elts: [ + Located { + location: Location { + row: 1, + column: 9, + }, + end_location: Some( + Location { + row: 1, + column: 10, + }, + ), + custom: (), + node: Constant( + ExprConstant { + value: Int( + 1, + ), + kind: None, + }, + ), }, - ), - custom: (), - node: Constant { - value: Int( - 3, - ), - kind: None, - }, + Located { + location: Location { + row: 1, + column: 12, + }, + end_location: Some( + Location { + row: 1, + column: 13, + }, + ), + custom: (), + node: Constant( + ExprConstant { + value: Int( + 2, + ), + kind: None, + }, + ), + }, + Located { + location: Location { + row: 1, + column: 15, + }, + end_location: Some( + Location { + row: 1, + column: 16, + }, + ), + custom: (), + node: Constant( + ExprConstant { + value: Int( + 3, + ), + kind: None, + }, + ), + }, + ], + ctx: Load, }, - ], - ctx: Load, + ), }, }, - }, + ), }, ] diff --git a/parser/src/snapshots/rustpython_parser__context__tests__del_attribute.snap b/parser/src/snapshots/rustpython_parser__context__tests__del_attribute.snap index f44c23b5..1ba62fe1 100644 --- a/parser/src/snapshots/rustpython_parser__context__tests__del_attribute.snap +++ b/parser/src/snapshots/rustpython_parser__context__tests__del_attribute.snap @@ -1,5 +1,5 @@ --- -source: compiler/parser/src/context.rs +source: parser/src/context.rs expression: parse_ast --- [ @@ -15,43 +15,49 @@ expression: parse_ast }, ), custom: (), - node: Delete { - targets: [ - Located { - location: Location { - row: 1, - column: 4, - }, - end_location: Some( - Location { + node: Delete( + StmtDelete { + targets: [ + Located { + location: Location { row: 1, - column: 7, + column: 4, }, - ), - custom: (), - node: Attribute { - value: Located { - location: Location { + end_location: Some( + Location { row: 1, - column: 4, + column: 7, }, - end_location: Some( - Location { - row: 1, - column: 5, + ), + custom: (), + node: Attribute( + ExprAttribute { + value: Located { + location: Location { + row: 1, + column: 4, + }, + end_location: Some( + Location { + row: 1, + column: 5, + }, + ), + custom: (), + node: Name( + ExprName { + id: "x", + ctx: Load, + }, + ), }, - ), - custom: (), - node: Name { - id: "x", - ctx: Load, + attr: "y", + ctx: Del, }, - }, - attr: "y", - ctx: Del, + ), }, - }, - ], - }, + ], + }, + ), }, ] diff --git a/parser/src/snapshots/rustpython_parser__context__tests__del_name.snap b/parser/src/snapshots/rustpython_parser__context__tests__del_name.snap index 56208d20..fa8019c2 100644 --- a/parser/src/snapshots/rustpython_parser__context__tests__del_name.snap +++ b/parser/src/snapshots/rustpython_parser__context__tests__del_name.snap @@ -1,5 +1,5 @@ --- -source: compiler/parser/src/context.rs +source: parser/src/context.rs expression: parse_ast --- [ @@ -15,26 +15,30 @@ expression: parse_ast }, ), custom: (), - node: Delete { - targets: [ - Located { - location: Location { - row: 1, - column: 4, - }, - end_location: Some( - Location { + node: Delete( + StmtDelete { + targets: [ + Located { + location: Location { row: 1, - column: 5, + column: 4, }, - ), - custom: (), - node: Name { - id: "x", - ctx: Del, + end_location: Some( + Location { + row: 1, + column: 5, + }, + ), + custom: (), + node: Name( + ExprName { + id: "x", + ctx: Del, + }, + ), }, - }, - ], - }, + ], + }, + ), }, ] diff --git a/parser/src/snapshots/rustpython_parser__context__tests__del_subscript.snap b/parser/src/snapshots/rustpython_parser__context__tests__del_subscript.snap index dca2e7ce..720c9af7 100644 --- a/parser/src/snapshots/rustpython_parser__context__tests__del_subscript.snap +++ b/parser/src/snapshots/rustpython_parser__context__tests__del_subscript.snap @@ -1,5 +1,5 @@ --- -source: compiler/parser/src/context.rs +source: parser/src/context.rs expression: parse_ast --- [ @@ -15,59 +15,67 @@ expression: parse_ast }, ), custom: (), - node: Delete { - targets: [ - Located { - location: Location { - row: 1, - column: 4, - }, - end_location: Some( - Location { + node: Delete( + StmtDelete { + targets: [ + Located { + location: Location { row: 1, - column: 8, + column: 4, }, - ), - custom: (), - node: Subscript { - value: Located { - location: Location { + end_location: Some( + Location { row: 1, - column: 4, + column: 8, }, - end_location: Some( - Location { - row: 1, - column: 5, + ), + custom: (), + node: Subscript( + ExprSubscript { + value: Located { + location: Location { + row: 1, + column: 4, + }, + end_location: Some( + Location { + row: 1, + column: 5, + }, + ), + custom: (), + node: Name( + ExprName { + id: "x", + ctx: Load, + }, + ), }, - ), - custom: (), - node: Name { - id: "x", - ctx: Load, - }, - }, - slice: Located { - location: Location { - row: 1, - column: 6, - }, - end_location: Some( - Location { - row: 1, - column: 7, + slice: Located { + location: Location { + row: 1, + column: 6, + }, + end_location: Some( + Location { + row: 1, + column: 7, + }, + ), + custom: (), + node: Name( + ExprName { + id: "y", + ctx: Load, + }, + ), }, - ), - custom: (), - node: Name { - id: "y", - ctx: Load, + ctx: Del, }, - }, - ctx: Del, + ), }, - }, - ], - }, + ], + }, + ), }, ] diff --git a/parser/src/snapshots/rustpython_parser__function__tests__function_kw_only_args.snap b/parser/src/snapshots/rustpython_parser__function__tests__function_kw_only_args.snap index 2b990fa8..cc74a915 100644 --- a/parser/src/snapshots/rustpython_parser__function__tests__function_kw_only_args.snap +++ b/parser/src/snapshots/rustpython_parser__function__tests__function_kw_only_args.snap @@ -1,5 +1,5 @@ --- -source: compiler/parser/src/function.rs +source: parser/src/function.rs expression: parse_ast --- Ok( @@ -16,92 +16,94 @@ Ok( }, ), custom: (), - node: FunctionDef { - name: "f", - args: Arguments { - posonlyargs: [], - args: [], - vararg: None, - kwonlyargs: [ - Located { - location: Location { - row: 1, - column: 9, - }, - end_location: Some( - Location { + node: FunctionDef( + StmtFunctionDef { + name: "f", + args: Arguments { + posonlyargs: [], + args: [], + vararg: None, + kwonlyargs: [ + Located { + location: Location { row: 1, - column: 10, + column: 9, + }, + end_location: Some( + Location { + row: 1, + column: 10, + }, + ), + custom: (), + node: ArgData { + arg: "a", + annotation: None, + type_comment: None, }, - ), - custom: (), - node: ArgData { - arg: "a", - annotation: None, - type_comment: None, }, - }, - Located { - location: Location { - row: 1, - column: 12, + Located { + location: Location { + row: 1, + column: 12, + }, + end_location: Some( + Location { + row: 1, + column: 13, + }, + ), + custom: (), + node: ArgData { + arg: "b", + annotation: None, + type_comment: None, + }, }, - end_location: Some( - Location { + Located { + location: Location { row: 1, - column: 13, + column: 15, + }, + end_location: Some( + Location { + row: 1, + column: 16, + }, + ), + custom: (), + node: ArgData { + arg: "c", + annotation: None, + type_comment: None, }, - ), - custom: (), - node: ArgData { - arg: "b", - annotation: None, - type_comment: None, }, - }, + ], + kw_defaults: [], + kwarg: None, + defaults: [], + }, + body: [ Located { location: Location { row: 1, - column: 15, + column: 19, }, end_location: Some( Location { row: 1, - column: 16, + column: 23, }, ), custom: (), - node: ArgData { - arg: "c", - annotation: None, - type_comment: None, - }, + node: Pass, }, ], - kw_defaults: [], - kwarg: None, - defaults: [], + decorator_list: [], + returns: None, + type_comment: None, }, - body: [ - Located { - location: Location { - row: 1, - column: 19, - }, - end_location: Some( - Location { - row: 1, - column: 23, - }, - ), - custom: (), - node: Pass, - }, - ], - decorator_list: [], - returns: None, - type_comment: None, - }, + ), }, ], ) diff --git a/parser/src/snapshots/rustpython_parser__function__tests__function_kw_only_args_with_defaults.snap b/parser/src/snapshots/rustpython_parser__function__tests__function_kw_only_args_with_defaults.snap index 08fa27e4..27d6672e 100644 --- a/parser/src/snapshots/rustpython_parser__function__tests__function_kw_only_args_with_defaults.snap +++ b/parser/src/snapshots/rustpython_parser__function__tests__function_kw_only_args_with_defaults.snap @@ -1,5 +1,5 @@ --- -source: compiler/parser/src/function.rs +source: parser/src/function.rs expression: parse_ast --- Ok( @@ -16,131 +16,137 @@ Ok( }, ), custom: (), - node: FunctionDef { - name: "f", - args: Arguments { - posonlyargs: [], - args: [], - vararg: None, - kwonlyargs: [ - Located { - location: Location { - row: 1, - column: 9, - }, - end_location: Some( - Location { + node: FunctionDef( + StmtFunctionDef { + name: "f", + args: Arguments { + posonlyargs: [], + args: [], + vararg: None, + kwonlyargs: [ + Located { + location: Location { row: 1, - column: 10, + column: 9, + }, + end_location: Some( + Location { + row: 1, + column: 10, + }, + ), + custom: (), + node: ArgData { + arg: "a", + annotation: None, + type_comment: None, }, - ), - custom: (), - node: ArgData { - arg: "a", - annotation: None, - type_comment: None, - }, - }, - Located { - location: Location { - row: 1, - column: 12, }, - end_location: Some( - Location { + Located { + location: Location { row: 1, - column: 13, + column: 12, + }, + end_location: Some( + Location { + row: 1, + column: 13, + }, + ), + custom: (), + node: ArgData { + arg: "b", + annotation: None, + type_comment: None, }, - ), - custom: (), - node: ArgData { - arg: "b", - annotation: None, - type_comment: None, - }, - }, - Located { - location: Location { - row: 1, - column: 18, }, - end_location: Some( - Location { + Located { + location: Location { row: 1, - column: 19, + column: 18, + }, + end_location: Some( + Location { + row: 1, + column: 19, + }, + ), + custom: (), + node: ArgData { + arg: "c", + annotation: None, + type_comment: None, }, - ), - custom: (), - node: ArgData { - arg: "c", - annotation: None, - type_comment: None, }, - }, - ], - kw_defaults: [ - Located { - location: Location { - row: 1, - column: 14, + ], + kw_defaults: [ + Located { + location: Location { + row: 1, + column: 14, + }, + end_location: Some( + Location { + row: 1, + column: 16, + }, + ), + custom: (), + node: Constant( + ExprConstant { + value: Int( + 20, + ), + kind: None, + }, + ), }, - end_location: Some( - Location { + Located { + location: Location { row: 1, - column: 16, + column: 20, }, - ), - custom: (), - node: Constant { - value: Int( - 20, + end_location: Some( + Location { + row: 1, + column: 22, + }, + ), + custom: (), + node: Constant( + ExprConstant { + value: Int( + 30, + ), + kind: None, + }, ), - kind: None, }, - }, + ], + kwarg: None, + defaults: [], + }, + body: [ Located { location: Location { row: 1, - column: 20, + column: 25, }, end_location: Some( Location { row: 1, - column: 22, + column: 29, }, ), custom: (), - node: Constant { - value: Int( - 30, - ), - kind: None, - }, + node: Pass, }, ], - kwarg: None, - defaults: [], + decorator_list: [], + returns: None, + type_comment: None, }, - body: [ - Located { - location: Location { - row: 1, - column: 25, - }, - end_location: Some( - Location { - row: 1, - column: 29, - }, - ), - custom: (), - node: Pass, - }, - ], - decorator_list: [], - returns: None, - type_comment: None, - }, + ), }, ], ) diff --git a/parser/src/snapshots/rustpython_parser__function__tests__function_no_args.snap b/parser/src/snapshots/rustpython_parser__function__tests__function_no_args.snap index a8d08b9a..d4c413e6 100644 --- a/parser/src/snapshots/rustpython_parser__function__tests__function_no_args.snap +++ b/parser/src/snapshots/rustpython_parser__function__tests__function_no_args.snap @@ -1,5 +1,5 @@ --- -source: compiler/parser/src/function.rs +source: parser/src/function.rs expression: parse_ast --- Ok( @@ -16,37 +16,39 @@ Ok( }, ), custom: (), - node: FunctionDef { - name: "f", - args: Arguments { - posonlyargs: [], - args: [], - vararg: None, - kwonlyargs: [], - kw_defaults: [], - kwarg: None, - defaults: [], - }, - body: [ - Located { - location: Location { - row: 1, - column: 9, - }, - end_location: Some( - Location { + node: FunctionDef( + StmtFunctionDef { + name: "f", + args: Arguments { + posonlyargs: [], + args: [], + vararg: None, + kwonlyargs: [], + kw_defaults: [], + kwarg: None, + defaults: [], + }, + body: [ + Located { + location: Location { row: 1, - column: 13, + column: 9, }, - ), - custom: (), - node: Pass, - }, - ], - decorator_list: [], - returns: None, - type_comment: None, - }, + end_location: Some( + Location { + row: 1, + column: 13, + }, + ), + custom: (), + node: Pass, + }, + ], + decorator_list: [], + returns: None, + type_comment: None, + }, + ), }, ], ) diff --git a/parser/src/snapshots/rustpython_parser__function__tests__function_pos_and_kw_only_args.snap b/parser/src/snapshots/rustpython_parser__function__tests__function_pos_and_kw_only_args.snap index 766a36b1..37e3b173 100644 --- a/parser/src/snapshots/rustpython_parser__function__tests__function_pos_and_kw_only_args.snap +++ b/parser/src/snapshots/rustpython_parser__function__tests__function_pos_and_kw_only_args.snap @@ -1,5 +1,5 @@ --- -source: compiler/parser/src/function.rs +source: parser/src/function.rs expression: parse_ast --- Ok( @@ -16,147 +16,149 @@ Ok( }, ), custom: (), - node: FunctionDef { - name: "f", - args: Arguments { - posonlyargs: [], - args: [ - Located { - location: Location { - row: 1, - column: 6, - }, - end_location: Some( - Location { + node: FunctionDef( + StmtFunctionDef { + name: "f", + args: Arguments { + posonlyargs: [], + args: [ + Located { + location: Location { row: 1, - column: 7, + column: 6, + }, + end_location: Some( + Location { + row: 1, + column: 7, + }, + ), + custom: (), + node: ArgData { + arg: "a", + annotation: None, + type_comment: None, }, - ), - custom: (), - node: ArgData { - arg: "a", - annotation: None, - type_comment: None, - }, - }, - Located { - location: Location { - row: 1, - column: 9, }, - end_location: Some( - Location { + Located { + location: Location { row: 1, - column: 10, + column: 9, + }, + end_location: Some( + Location { + row: 1, + column: 10, + }, + ), + custom: (), + node: ArgData { + arg: "b", + annotation: None, + type_comment: None, }, - ), - custom: (), - node: ArgData { - arg: "b", - annotation: None, - type_comment: None, - }, - }, - Located { - location: Location { - row: 1, - column: 12, }, - end_location: Some( - Location { + Located { + location: Location { row: 1, - column: 13, + column: 12, + }, + end_location: Some( + Location { + row: 1, + column: 13, + }, + ), + custom: (), + node: ArgData { + arg: "c", + annotation: None, + type_comment: None, }, - ), - custom: (), - node: ArgData { - arg: "c", - annotation: None, - type_comment: None, - }, - }, - ], - vararg: None, - kwonlyargs: [ - Located { - location: Location { - row: 1, - column: 18, }, - end_location: Some( - Location { + ], + vararg: None, + kwonlyargs: [ + Located { + location: Location { row: 1, - column: 19, + column: 18, + }, + end_location: Some( + Location { + row: 1, + column: 19, + }, + ), + custom: (), + node: ArgData { + arg: "d", + annotation: None, + type_comment: None, }, - ), - custom: (), - node: ArgData { - arg: "d", - annotation: None, - type_comment: None, }, - }, - Located { - location: Location { - row: 1, - column: 21, + Located { + location: Location { + row: 1, + column: 21, + }, + end_location: Some( + Location { + row: 1, + column: 22, + }, + ), + custom: (), + node: ArgData { + arg: "e", + annotation: None, + type_comment: None, + }, }, - end_location: Some( - Location { + Located { + location: Location { row: 1, - column: 22, + column: 24, + }, + end_location: Some( + Location { + row: 1, + column: 25, + }, + ), + custom: (), + node: ArgData { + arg: "f", + annotation: None, + type_comment: None, }, - ), - custom: (), - node: ArgData { - arg: "e", - annotation: None, - type_comment: None, }, - }, + ], + kw_defaults: [], + kwarg: None, + defaults: [], + }, + body: [ Located { location: Location { row: 1, - column: 24, + column: 28, }, end_location: Some( Location { row: 1, - column: 25, + column: 32, }, ), custom: (), - node: ArgData { - arg: "f", - annotation: None, - type_comment: None, - }, + node: Pass, }, ], - kw_defaults: [], - kwarg: None, - defaults: [], + decorator_list: [], + returns: None, + type_comment: None, }, - body: [ - Located { - location: Location { - row: 1, - column: 28, - }, - end_location: Some( - Location { - row: 1, - column: 32, - }, - ), - custom: (), - node: Pass, - }, - ], - decorator_list: [], - returns: None, - type_comment: None, - }, + ), }, ], ) diff --git a/parser/src/snapshots/rustpython_parser__function__tests__function_pos_and_kw_only_args_with_defaults.snap b/parser/src/snapshots/rustpython_parser__function__tests__function_pos_and_kw_only_args_with_defaults.snap index c6ff5e5d..af3fa128 100644 --- a/parser/src/snapshots/rustpython_parser__function__tests__function_pos_and_kw_only_args_with_defaults.snap +++ b/parser/src/snapshots/rustpython_parser__function__tests__function_pos_and_kw_only_args_with_defaults.snap @@ -1,5 +1,5 @@ --- -source: compiler/parser/src/function.rs +source: parser/src/function.rs expression: parse_ast --- Ok( @@ -16,186 +16,192 @@ Ok( }, ), custom: (), - node: FunctionDef { - name: "f", - args: Arguments { - posonlyargs: [], - args: [ - Located { - location: Location { - row: 1, - column: 6, - }, - end_location: Some( - Location { + node: FunctionDef( + StmtFunctionDef { + name: "f", + args: Arguments { + posonlyargs: [], + args: [ + Located { + location: Location { row: 1, - column: 7, + column: 6, + }, + end_location: Some( + Location { + row: 1, + column: 7, + }, + ), + custom: (), + node: ArgData { + arg: "a", + annotation: None, + type_comment: None, }, - ), - custom: (), - node: ArgData { - arg: "a", - annotation: None, - type_comment: None, - }, - }, - Located { - location: Location { - row: 1, - column: 9, }, - end_location: Some( - Location { + Located { + location: Location { row: 1, - column: 10, + column: 9, + }, + end_location: Some( + Location { + row: 1, + column: 10, + }, + ), + custom: (), + node: ArgData { + arg: "b", + annotation: None, + type_comment: None, }, - ), - custom: (), - node: ArgData { - arg: "b", - annotation: None, - type_comment: None, - }, - }, - Located { - location: Location { - row: 1, - column: 12, }, - end_location: Some( - Location { + Located { + location: Location { row: 1, - column: 13, + column: 12, + }, + end_location: Some( + Location { + row: 1, + column: 13, + }, + ), + custom: (), + node: ArgData { + arg: "c", + annotation: None, + type_comment: None, }, - ), - custom: (), - node: ArgData { - arg: "c", - annotation: None, - type_comment: None, - }, - }, - ], - vararg: None, - kwonlyargs: [ - Located { - location: Location { - row: 1, - column: 18, }, - end_location: Some( - Location { + ], + vararg: None, + kwonlyargs: [ + Located { + location: Location { row: 1, - column: 19, + column: 18, + }, + end_location: Some( + Location { + row: 1, + column: 19, + }, + ), + custom: (), + node: ArgData { + arg: "d", + annotation: None, + type_comment: None, }, - ), - custom: (), - node: ArgData { - arg: "d", - annotation: None, - type_comment: None, - }, - }, - Located { - location: Location { - row: 1, - column: 21, }, - end_location: Some( - Location { + Located { + location: Location { row: 1, - column: 22, + column: 21, + }, + end_location: Some( + Location { + row: 1, + column: 22, + }, + ), + custom: (), + node: ArgData { + arg: "e", + annotation: None, + type_comment: None, }, - ), - custom: (), - node: ArgData { - arg: "e", - annotation: None, - type_comment: None, - }, - }, - Located { - location: Location { - row: 1, - column: 27, }, - end_location: Some( - Location { + Located { + location: Location { row: 1, - column: 28, + column: 27, + }, + end_location: Some( + Location { + row: 1, + column: 28, + }, + ), + custom: (), + node: ArgData { + arg: "f", + annotation: None, + type_comment: None, }, - ), - custom: (), - node: ArgData { - arg: "f", - annotation: None, - type_comment: None, }, - }, - ], - kw_defaults: [ - Located { - location: Location { - row: 1, - column: 23, + ], + kw_defaults: [ + Located { + location: Location { + row: 1, + column: 23, + }, + end_location: Some( + Location { + row: 1, + column: 25, + }, + ), + custom: (), + node: Constant( + ExprConstant { + value: Int( + 20, + ), + kind: None, + }, + ), }, - end_location: Some( - Location { + Located { + location: Location { row: 1, - column: 25, + column: 29, }, - ), - custom: (), - node: Constant { - value: Int( - 20, + end_location: Some( + Location { + row: 1, + column: 31, + }, + ), + custom: (), + node: Constant( + ExprConstant { + value: Int( + 30, + ), + kind: None, + }, ), - kind: None, }, - }, + ], + kwarg: None, + defaults: [], + }, + body: [ Located { location: Location { row: 1, - column: 29, + column: 34, }, end_location: Some( Location { row: 1, - column: 31, + column: 38, }, ), custom: (), - node: Constant { - value: Int( - 30, - ), - kind: None, - }, + node: Pass, }, ], - kwarg: None, - defaults: [], + decorator_list: [], + returns: None, + type_comment: None, }, - body: [ - Located { - location: Location { - row: 1, - column: 34, - }, - end_location: Some( - Location { - row: 1, - column: 38, - }, - ), - custom: (), - node: Pass, - }, - ], - decorator_list: [], - returns: None, - type_comment: None, - }, + ), }, ], ) diff --git a/parser/src/snapshots/rustpython_parser__function__tests__function_pos_and_kw_only_args_with_defaults_and_varargs.snap b/parser/src/snapshots/rustpython_parser__function__tests__function_pos_and_kw_only_args_with_defaults_and_varargs.snap index 830a9c52..348c4231 100644 --- a/parser/src/snapshots/rustpython_parser__function__tests__function_pos_and_kw_only_args_with_defaults_and_varargs.snap +++ b/parser/src/snapshots/rustpython_parser__function__tests__function_pos_and_kw_only_args_with_defaults_and_varargs.snap @@ -1,5 +1,5 @@ --- -source: compiler/parser/src/function.rs +source: parser/src/function.rs expression: parse_ast --- Ok( @@ -16,205 +16,211 @@ Ok( }, ), custom: (), - node: FunctionDef { - name: "f", - args: Arguments { - posonlyargs: [], - args: [ - Located { - location: Location { - row: 1, - column: 6, - }, - end_location: Some( - Location { + node: FunctionDef( + StmtFunctionDef { + name: "f", + args: Arguments { + posonlyargs: [], + args: [ + Located { + location: Location { row: 1, - column: 7, + column: 6, + }, + end_location: Some( + Location { + row: 1, + column: 7, + }, + ), + custom: (), + node: ArgData { + arg: "a", + annotation: None, + type_comment: None, }, - ), - custom: (), - node: ArgData { - arg: "a", - annotation: None, - type_comment: None, - }, - }, - Located { - location: Location { - row: 1, - column: 9, }, - end_location: Some( - Location { + Located { + location: Location { row: 1, - column: 10, + column: 9, + }, + end_location: Some( + Location { + row: 1, + column: 10, + }, + ), + custom: (), + node: ArgData { + arg: "b", + annotation: None, + type_comment: None, }, - ), - custom: (), - node: ArgData { - arg: "b", - annotation: None, - type_comment: None, - }, - }, - Located { - location: Location { - row: 1, - column: 12, }, - end_location: Some( - Location { + Located { + location: Location { row: 1, - column: 13, + column: 12, + }, + end_location: Some( + Location { + row: 1, + column: 13, + }, + ), + custom: (), + node: ArgData { + arg: "c", + annotation: None, + type_comment: None, }, - ), - custom: (), - node: ArgData { - arg: "c", - annotation: None, - type_comment: None, - }, - }, - ], - vararg: Some( - Located { - location: Location { - row: 1, - column: 16, }, - end_location: Some( - Location { + ], + vararg: Some( + Located { + location: Location { row: 1, - column: 20, + column: 16, + }, + end_location: Some( + Location { + row: 1, + column: 20, + }, + ), + custom: (), + node: ArgData { + arg: "args", + annotation: None, + type_comment: None, }, - ), - custom: (), - node: ArgData { - arg: "args", - annotation: None, - type_comment: None, - }, - }, - ), - kwonlyargs: [ - Located { - location: Location { - row: 1, - column: 22, }, - end_location: Some( - Location { + ), + kwonlyargs: [ + Located { + location: Location { row: 1, - column: 23, + column: 22, + }, + end_location: Some( + Location { + row: 1, + column: 23, + }, + ), + custom: (), + node: ArgData { + arg: "d", + annotation: None, + type_comment: None, }, - ), - custom: (), - node: ArgData { - arg: "d", - annotation: None, - type_comment: None, - }, - }, - Located { - location: Location { - row: 1, - column: 25, }, - end_location: Some( - Location { + Located { + location: Location { row: 1, - column: 26, + column: 25, + }, + end_location: Some( + Location { + row: 1, + column: 26, + }, + ), + custom: (), + node: ArgData { + arg: "e", + annotation: None, + type_comment: None, }, - ), - custom: (), - node: ArgData { - arg: "e", - annotation: None, - type_comment: None, - }, - }, - Located { - location: Location { - row: 1, - column: 31, }, - end_location: Some( - Location { + Located { + location: Location { row: 1, - column: 32, + column: 31, + }, + end_location: Some( + Location { + row: 1, + column: 32, + }, + ), + custom: (), + node: ArgData { + arg: "f", + annotation: None, + type_comment: None, }, - ), - custom: (), - node: ArgData { - arg: "f", - annotation: None, - type_comment: None, }, - }, - ], - kw_defaults: [ - Located { - location: Location { - row: 1, - column: 27, + ], + kw_defaults: [ + Located { + location: Location { + row: 1, + column: 27, + }, + end_location: Some( + Location { + row: 1, + column: 29, + }, + ), + custom: (), + node: Constant( + ExprConstant { + value: Int( + 20, + ), + kind: None, + }, + ), }, - end_location: Some( - Location { + Located { + location: Location { row: 1, - column: 29, + column: 33, }, - ), - custom: (), - node: Constant { - value: Int( - 20, + end_location: Some( + Location { + row: 1, + column: 35, + }, + ), + custom: (), + node: Constant( + ExprConstant { + value: Int( + 30, + ), + kind: None, + }, ), - kind: None, }, - }, + ], + kwarg: None, + defaults: [], + }, + body: [ Located { location: Location { row: 1, - column: 33, + column: 38, }, end_location: Some( Location { row: 1, - column: 35, + column: 42, }, ), custom: (), - node: Constant { - value: Int( - 30, - ), - kind: None, - }, + node: Pass, }, ], - kwarg: None, - defaults: [], + decorator_list: [], + returns: None, + type_comment: None, }, - body: [ - Located { - location: Location { - row: 1, - column: 38, - }, - end_location: Some( - Location { - row: 1, - column: 42, - }, - ), - custom: (), - node: Pass, - }, - ], - decorator_list: [], - returns: None, - type_comment: None, - }, + ), }, ], ) diff --git a/parser/src/snapshots/rustpython_parser__function__tests__function_pos_and_kw_only_args_with_defaults_and_varargs_and_kwargs.snap b/parser/src/snapshots/rustpython_parser__function__tests__function_pos_and_kw_only_args_with_defaults_and_varargs_and_kwargs.snap index fde81e98..3076f771 100644 --- a/parser/src/snapshots/rustpython_parser__function__tests__function_pos_and_kw_only_args_with_defaults_and_varargs_and_kwargs.snap +++ b/parser/src/snapshots/rustpython_parser__function__tests__function_pos_and_kw_only_args_with_defaults_and_varargs_and_kwargs.snap @@ -1,5 +1,5 @@ --- -source: compiler/parser/src/function.rs +source: parser/src/function.rs expression: parse_ast --- Ok( @@ -16,224 +16,230 @@ Ok( }, ), custom: (), - node: FunctionDef { - name: "f", - args: Arguments { - posonlyargs: [], - args: [ - Located { - location: Location { - row: 1, - column: 6, - }, - end_location: Some( - Location { + node: FunctionDef( + StmtFunctionDef { + name: "f", + args: Arguments { + posonlyargs: [], + args: [ + Located { + location: Location { row: 1, - column: 7, + column: 6, + }, + end_location: Some( + Location { + row: 1, + column: 7, + }, + ), + custom: (), + node: ArgData { + arg: "a", + annotation: None, + type_comment: None, }, - ), - custom: (), - node: ArgData { - arg: "a", - annotation: None, - type_comment: None, - }, - }, - Located { - location: Location { - row: 1, - column: 9, }, - end_location: Some( - Location { + Located { + location: Location { row: 1, - column: 10, + column: 9, + }, + end_location: Some( + Location { + row: 1, + column: 10, + }, + ), + custom: (), + node: ArgData { + arg: "b", + annotation: None, + type_comment: None, }, - ), - custom: (), - node: ArgData { - arg: "b", - annotation: None, - type_comment: None, - }, - }, - Located { - location: Location { - row: 1, - column: 12, }, - end_location: Some( - Location { + Located { + location: Location { row: 1, - column: 13, + column: 12, + }, + end_location: Some( + Location { + row: 1, + column: 13, + }, + ), + custom: (), + node: ArgData { + arg: "c", + annotation: None, + type_comment: None, }, - ), - custom: (), - node: ArgData { - arg: "c", - annotation: None, - type_comment: None, - }, - }, - ], - vararg: Some( - Located { - location: Location { - row: 1, - column: 16, }, - end_location: Some( - Location { + ], + vararg: Some( + Located { + location: Location { row: 1, - column: 20, + column: 16, + }, + end_location: Some( + Location { + row: 1, + column: 20, + }, + ), + custom: (), + node: ArgData { + arg: "args", + annotation: None, + type_comment: None, }, - ), - custom: (), - node: ArgData { - arg: "args", - annotation: None, - type_comment: None, - }, - }, - ), - kwonlyargs: [ - Located { - location: Location { - row: 1, - column: 22, }, - end_location: Some( - Location { + ), + kwonlyargs: [ + Located { + location: Location { row: 1, - column: 23, + column: 22, + }, + end_location: Some( + Location { + row: 1, + column: 23, + }, + ), + custom: (), + node: ArgData { + arg: "d", + annotation: None, + type_comment: None, }, - ), - custom: (), - node: ArgData { - arg: "d", - annotation: None, - type_comment: None, - }, - }, - Located { - location: Location { - row: 1, - column: 25, }, - end_location: Some( - Location { + Located { + location: Location { row: 1, - column: 26, + column: 25, + }, + end_location: Some( + Location { + row: 1, + column: 26, + }, + ), + custom: (), + node: ArgData { + arg: "e", + annotation: None, + type_comment: None, }, - ), - custom: (), - node: ArgData { - arg: "e", - annotation: None, - type_comment: None, - }, - }, - Located { - location: Location { - row: 1, - column: 31, }, - end_location: Some( - Location { + Located { + location: Location { row: 1, - column: 32, + column: 31, + }, + end_location: Some( + Location { + row: 1, + column: 32, + }, + ), + custom: (), + node: ArgData { + arg: "f", + annotation: None, + type_comment: None, }, - ), - custom: (), - node: ArgData { - arg: "f", - annotation: None, - type_comment: None, - }, - }, - ], - kw_defaults: [ - Located { - location: Location { - row: 1, - column: 27, }, - end_location: Some( - Location { + ], + kw_defaults: [ + Located { + location: Location { row: 1, - column: 29, + column: 27, }, - ), - custom: (), - node: Constant { - value: Int( - 20, + end_location: Some( + Location { + row: 1, + column: 29, + }, + ), + custom: (), + node: Constant( + ExprConstant { + value: Int( + 20, + ), + kind: None, + }, ), - kind: None, }, - }, - Located { - location: Location { - row: 1, - column: 33, + Located { + location: Location { + row: 1, + column: 33, + }, + end_location: Some( + Location { + row: 1, + column: 35, + }, + ), + custom: (), + node: Constant( + ExprConstant { + value: Int( + 30, + ), + kind: None, + }, + ), }, - end_location: Some( - Location { + ], + kwarg: Some( + Located { + location: Location { row: 1, - column: 35, + column: 39, }, - ), - custom: (), - node: Constant { - value: Int( - 30, + end_location: Some( + Location { + row: 1, + column: 45, + }, ), - kind: None, + custom: (), + node: ArgData { + arg: "kwargs", + annotation: None, + type_comment: None, + }, }, - }, - ], - kwarg: Some( + ), + defaults: [], + }, + body: [ Located { location: Location { row: 1, - column: 39, + column: 48, }, end_location: Some( Location { row: 1, - column: 45, + column: 52, }, ), custom: (), - node: ArgData { - arg: "kwargs", - annotation: None, - type_comment: None, - }, + node: Pass, }, - ), - defaults: [], + ], + decorator_list: [], + returns: None, + type_comment: None, }, - body: [ - Located { - location: Location { - row: 1, - column: 48, - }, - end_location: Some( - Location { - row: 1, - column: 52, - }, - ), - custom: (), - node: Pass, - }, - ], - decorator_list: [], - returns: None, - type_comment: None, - }, + ), }, ], ) diff --git a/parser/src/snapshots/rustpython_parser__function__tests__function_pos_args.snap b/parser/src/snapshots/rustpython_parser__function__tests__function_pos_args.snap index 251bba87..1a23ad24 100644 --- a/parser/src/snapshots/rustpython_parser__function__tests__function_pos_args.snap +++ b/parser/src/snapshots/rustpython_parser__function__tests__function_pos_args.snap @@ -1,5 +1,5 @@ --- -source: compiler/parser/src/function.rs +source: parser/src/function.rs expression: parse_ast --- Ok( @@ -16,92 +16,94 @@ Ok( }, ), custom: (), - node: FunctionDef { - name: "f", - args: Arguments { - posonlyargs: [], - args: [ - Located { - location: Location { - row: 1, - column: 6, - }, - end_location: Some( - Location { + node: FunctionDef( + StmtFunctionDef { + name: "f", + args: Arguments { + posonlyargs: [], + args: [ + Located { + location: Location { row: 1, - column: 7, + column: 6, + }, + end_location: Some( + Location { + row: 1, + column: 7, + }, + ), + custom: (), + node: ArgData { + arg: "a", + annotation: None, + type_comment: None, }, - ), - custom: (), - node: ArgData { - arg: "a", - annotation: None, - type_comment: None, }, - }, - Located { - location: Location { - row: 1, - column: 9, + Located { + location: Location { + row: 1, + column: 9, + }, + end_location: Some( + Location { + row: 1, + column: 10, + }, + ), + custom: (), + node: ArgData { + arg: "b", + annotation: None, + type_comment: None, + }, }, - end_location: Some( - Location { + Located { + location: Location { row: 1, - column: 10, + column: 12, + }, + end_location: Some( + Location { + row: 1, + column: 13, + }, + ), + custom: (), + node: ArgData { + arg: "c", + annotation: None, + type_comment: None, }, - ), - custom: (), - node: ArgData { - arg: "b", - annotation: None, - type_comment: None, }, - }, + ], + vararg: None, + kwonlyargs: [], + kw_defaults: [], + kwarg: None, + defaults: [], + }, + body: [ Located { location: Location { row: 1, - column: 12, + column: 16, }, end_location: Some( Location { row: 1, - column: 13, + column: 20, }, ), custom: (), - node: ArgData { - arg: "c", - annotation: None, - type_comment: None, - }, + node: Pass, }, ], - vararg: None, - kwonlyargs: [], - kw_defaults: [], - kwarg: None, - defaults: [], + decorator_list: [], + returns: None, + type_comment: None, }, - body: [ - Located { - location: Location { - row: 1, - column: 16, - }, - end_location: Some( - Location { - row: 1, - column: 20, - }, - ), - custom: (), - node: Pass, - }, - ], - decorator_list: [], - returns: None, - type_comment: None, - }, + ), }, ], ) diff --git a/parser/src/snapshots/rustpython_parser__function__tests__function_pos_args_with_defaults.snap b/parser/src/snapshots/rustpython_parser__function__tests__function_pos_args_with_defaults.snap index 71b4bb86..af6ba70f 100644 --- a/parser/src/snapshots/rustpython_parser__function__tests__function_pos_args_with_defaults.snap +++ b/parser/src/snapshots/rustpython_parser__function__tests__function_pos_args_with_defaults.snap @@ -1,5 +1,5 @@ --- -source: compiler/parser/src/function.rs +source: parser/src/function.rs expression: parse_ast --- Ok( @@ -16,131 +16,137 @@ Ok( }, ), custom: (), - node: FunctionDef { - name: "f", - args: Arguments { - posonlyargs: [], - args: [ - Located { - location: Location { - row: 1, - column: 6, - }, - end_location: Some( - Location { + node: FunctionDef( + StmtFunctionDef { + name: "f", + args: Arguments { + posonlyargs: [], + args: [ + Located { + location: Location { row: 1, - column: 7, + column: 6, + }, + end_location: Some( + Location { + row: 1, + column: 7, + }, + ), + custom: (), + node: ArgData { + arg: "a", + annotation: None, + type_comment: None, }, - ), - custom: (), - node: ArgData { - arg: "a", - annotation: None, - type_comment: None, - }, - }, - Located { - location: Location { - row: 1, - column: 9, }, - end_location: Some( - Location { + Located { + location: Location { row: 1, - column: 10, + column: 9, + }, + end_location: Some( + Location { + row: 1, + column: 10, + }, + ), + custom: (), + node: ArgData { + arg: "b", + annotation: None, + type_comment: None, }, - ), - custom: (), - node: ArgData { - arg: "b", - annotation: None, - type_comment: None, - }, - }, - Located { - location: Location { - row: 1, - column: 15, }, - end_location: Some( - Location { + Located { + location: Location { row: 1, - column: 16, + column: 15, + }, + end_location: Some( + Location { + row: 1, + column: 16, + }, + ), + custom: (), + node: ArgData { + arg: "c", + annotation: None, + type_comment: None, }, - ), - custom: (), - node: ArgData { - arg: "c", - annotation: None, - type_comment: None, }, - }, - ], - vararg: None, - kwonlyargs: [], - kw_defaults: [], - kwarg: None, - defaults: [ - Located { - location: Location { - row: 1, - column: 11, + ], + vararg: None, + kwonlyargs: [], + kw_defaults: [], + kwarg: None, + defaults: [ + Located { + location: Location { + row: 1, + column: 11, + }, + end_location: Some( + Location { + row: 1, + column: 13, + }, + ), + custom: (), + node: Constant( + ExprConstant { + value: Int( + 20, + ), + kind: None, + }, + ), }, - end_location: Some( - Location { + Located { + location: Location { row: 1, - column: 13, + column: 17, }, - ), - custom: (), - node: Constant { - value: Int( - 20, + end_location: Some( + Location { + row: 1, + column: 19, + }, + ), + custom: (), + node: Constant( + ExprConstant { + value: Int( + 30, + ), + kind: None, + }, ), - kind: None, }, - }, + ], + }, + body: [ Located { location: Location { row: 1, - column: 17, + column: 22, }, end_location: Some( Location { row: 1, - column: 19, + column: 26, }, ), custom: (), - node: Constant { - value: Int( - 30, - ), - kind: None, - }, + node: Pass, }, ], + decorator_list: [], + returns: None, + type_comment: None, }, - body: [ - Located { - location: Location { - row: 1, - column: 22, - }, - end_location: Some( - Location { - row: 1, - column: 26, - }, - ), - custom: (), - node: Pass, - }, - ], - decorator_list: [], - returns: None, - type_comment: None, - }, + ), }, ], ) diff --git a/parser/src/snapshots/rustpython_parser__function__tests__lambda_kw_only_args.snap b/parser/src/snapshots/rustpython_parser__function__tests__lambda_kw_only_args.snap index 59987372..f766b17d 100644 --- a/parser/src/snapshots/rustpython_parser__function__tests__lambda_kw_only_args.snap +++ b/parser/src/snapshots/rustpython_parser__function__tests__lambda_kw_only_args.snap @@ -1,5 +1,5 @@ --- -source: compiler/parser/src/function.rs +source: parser/src/function.rs expression: parse_ast --- Ok( @@ -16,106 +16,112 @@ Ok( }, ), custom: (), - node: Expr { - value: Located { - location: Location { - row: 1, - column: 0, - }, - end_location: Some( - Location { + node: Expr( + StmtExpr { + value: Located { + location: Location { row: 1, - column: 20, + column: 0, }, - ), - custom: (), - node: Lambda { - args: Arguments { - posonlyargs: [], - args: [], - vararg: None, - kwonlyargs: [ - Located { - location: Location { - row: 1, - column: 10, - }, - end_location: Some( - Location { - row: 1, - column: 11, + end_location: Some( + Location { + row: 1, + column: 20, + }, + ), + custom: (), + node: Lambda( + ExprLambda { + args: Arguments { + posonlyargs: [], + args: [], + vararg: None, + kwonlyargs: [ + Located { + location: Location { + row: 1, + column: 10, + }, + end_location: Some( + Location { + row: 1, + column: 11, + }, + ), + custom: (), + node: ArgData { + arg: "a", + annotation: None, + type_comment: None, + }, }, - ), - custom: (), - node: ArgData { - arg: "a", - annotation: None, - type_comment: None, - }, + Located { + location: Location { + row: 1, + column: 13, + }, + end_location: Some( + Location { + row: 1, + column: 14, + }, + ), + custom: (), + node: ArgData { + arg: "b", + annotation: None, + type_comment: None, + }, + }, + Located { + location: Location { + row: 1, + column: 16, + }, + end_location: Some( + Location { + row: 1, + column: 17, + }, + ), + custom: (), + node: ArgData { + arg: "c", + annotation: None, + type_comment: None, + }, + }, + ], + kw_defaults: [], + kwarg: None, + defaults: [], }, - Located { + body: Located { location: Location { row: 1, - column: 13, + column: 19, }, end_location: Some( Location { row: 1, - column: 14, + column: 20, }, ), custom: (), - node: ArgData { - arg: "b", - annotation: None, - type_comment: None, - }, - }, - Located { - location: Location { - row: 1, - column: 16, - }, - end_location: Some( - Location { - row: 1, - column: 17, + node: Constant( + ExprConstant { + value: Int( + 1, + ), + kind: None, }, ), - custom: (), - node: ArgData { - arg: "c", - annotation: None, - type_comment: None, - }, }, - ], - kw_defaults: [], - kwarg: None, - defaults: [], - }, - body: Located { - location: Location { - row: 1, - column: 19, - }, - end_location: Some( - Location { - row: 1, - column: 20, - }, - ), - custom: (), - node: Constant { - value: Int( - 1, - ), - kind: None, }, - }, + ), }, }, - }, + ), }, ], ) diff --git a/parser/src/snapshots/rustpython_parser__function__tests__lambda_kw_only_args_with_defaults.snap b/parser/src/snapshots/rustpython_parser__function__tests__lambda_kw_only_args_with_defaults.snap index d48792dc..586eb499 100644 --- a/parser/src/snapshots/rustpython_parser__function__tests__lambda_kw_only_args_with_defaults.snap +++ b/parser/src/snapshots/rustpython_parser__function__tests__lambda_kw_only_args_with_defaults.snap @@ -1,5 +1,5 @@ --- -source: compiler/parser/src/function.rs +source: parser/src/function.rs expression: parse_ast --- Ok( @@ -16,145 +16,155 @@ Ok( }, ), custom: (), - node: Expr { - value: Located { - location: Location { - row: 1, - column: 0, - }, - end_location: Some( - Location { + node: Expr( + StmtExpr { + value: Located { + location: Location { row: 1, - column: 26, + column: 0, }, - ), - custom: (), - node: Lambda { - args: Arguments { - posonlyargs: [], - args: [], - vararg: None, - kwonlyargs: [ - Located { - location: Location { - row: 1, - column: 10, - }, - end_location: Some( - Location { - row: 1, - column: 11, + end_location: Some( + Location { + row: 1, + column: 26, + }, + ), + custom: (), + node: Lambda( + ExprLambda { + args: Arguments { + posonlyargs: [], + args: [], + vararg: None, + kwonlyargs: [ + Located { + location: Location { + row: 1, + column: 10, + }, + end_location: Some( + Location { + row: 1, + column: 11, + }, + ), + custom: (), + node: ArgData { + arg: "a", + annotation: None, + type_comment: None, + }, }, - ), - custom: (), - node: ArgData { - arg: "a", - annotation: None, - type_comment: None, - }, - }, - Located { - location: Location { - row: 1, - column: 13, - }, - end_location: Some( - Location { - row: 1, - column: 14, + Located { + location: Location { + row: 1, + column: 13, + }, + end_location: Some( + Location { + row: 1, + column: 14, + }, + ), + custom: (), + node: ArgData { + arg: "b", + annotation: None, + type_comment: None, + }, }, - ), - custom: (), - node: ArgData { - arg: "b", - annotation: None, - type_comment: None, - }, - }, - Located { - location: Location { - row: 1, - column: 19, - }, - end_location: Some( - Location { - row: 1, - column: 20, + Located { + location: Location { + row: 1, + column: 19, + }, + end_location: Some( + Location { + row: 1, + column: 20, + }, + ), + custom: (), + node: ArgData { + arg: "c", + annotation: None, + type_comment: None, + }, }, - ), - custom: (), - node: ArgData { - arg: "c", - annotation: None, - type_comment: None, - }, + ], + kw_defaults: [ + Located { + location: Location { + row: 1, + column: 15, + }, + end_location: Some( + Location { + row: 1, + column: 17, + }, + ), + custom: (), + node: Constant( + ExprConstant { + value: Int( + 20, + ), + kind: None, + }, + ), + }, + Located { + location: Location { + row: 1, + column: 21, + }, + end_location: Some( + Location { + row: 1, + column: 23, + }, + ), + custom: (), + node: Constant( + ExprConstant { + value: Int( + 30, + ), + kind: None, + }, + ), + }, + ], + kwarg: None, + defaults: [], }, - ], - kw_defaults: [ - Located { + body: Located { location: Location { row: 1, - column: 15, + column: 25, }, end_location: Some( Location { row: 1, - column: 17, + column: 26, }, ), custom: (), - node: Constant { - value: Int( - 20, - ), - kind: None, - }, - }, - Located { - location: Location { - row: 1, - column: 21, - }, - end_location: Some( - Location { - row: 1, - column: 23, + node: Constant( + ExprConstant { + value: Int( + 1, + ), + kind: None, }, ), - custom: (), - node: Constant { - value: Int( - 30, - ), - kind: None, - }, - }, - ], - kwarg: None, - defaults: [], - }, - body: Located { - location: Location { - row: 1, - column: 25, - }, - end_location: Some( - Location { - row: 1, - column: 26, }, - ), - custom: (), - node: Constant { - value: Int( - 1, - ), - kind: None, }, - }, + ), }, }, - }, + ), }, ], ) diff --git a/parser/src/snapshots/rustpython_parser__function__tests__lambda_no_args.snap b/parser/src/snapshots/rustpython_parser__function__tests__lambda_no_args.snap index aab5ec4d..f6cbdf41 100644 --- a/parser/src/snapshots/rustpython_parser__function__tests__lambda_no_args.snap +++ b/parser/src/snapshots/rustpython_parser__function__tests__lambda_no_args.snap @@ -1,5 +1,5 @@ --- -source: compiler/parser/src/function.rs +source: parser/src/function.rs expression: parse_ast --- Ok( @@ -16,51 +16,57 @@ Ok( }, ), custom: (), - node: Expr { - value: Located { - location: Location { - row: 1, - column: 0, - }, - end_location: Some( - Location { + node: Expr( + StmtExpr { + value: Located { + location: Location { row: 1, - column: 9, - }, - ), - custom: (), - node: Lambda { - args: Arguments { - posonlyargs: [], - args: [], - vararg: None, - kwonlyargs: [], - kw_defaults: [], - kwarg: None, - defaults: [], + column: 0, }, - body: Located { - location: Location { + end_location: Some( + Location { row: 1, - column: 8, + column: 9, }, - end_location: Some( - Location { - row: 1, - column: 9, + ), + custom: (), + node: Lambda( + ExprLambda { + args: Arguments { + posonlyargs: [], + args: [], + vararg: None, + kwonlyargs: [], + kw_defaults: [], + kwarg: None, + defaults: [], + }, + body: Located { + location: Location { + row: 1, + column: 8, + }, + end_location: Some( + Location { + row: 1, + column: 9, + }, + ), + custom: (), + node: Constant( + ExprConstant { + value: Int( + 1, + ), + kind: None, + }, + ), }, - ), - custom: (), - node: Constant { - value: Int( - 1, - ), - kind: None, }, - }, + ), }, }, - }, + ), }, ], ) diff --git a/parser/src/snapshots/rustpython_parser__function__tests__lambda_pos_and_kw_only_args.snap b/parser/src/snapshots/rustpython_parser__function__tests__lambda_pos_and_kw_only_args.snap index 22f695b3..85b0d0d0 100644 --- a/parser/src/snapshots/rustpython_parser__function__tests__lambda_pos_and_kw_only_args.snap +++ b/parser/src/snapshots/rustpython_parser__function__tests__lambda_pos_and_kw_only_args.snap @@ -1,5 +1,5 @@ --- -source: compiler/parser/src/function.rs +source: parser/src/function.rs expression: parse_ast --- Ok( @@ -16,143 +16,149 @@ Ok( }, ), custom: (), - node: Expr { - value: Located { - location: Location { - row: 1, - column: 0, - }, - end_location: Some( - Location { + node: Expr( + StmtExpr { + value: Located { + location: Location { row: 1, - column: 26, + column: 0, }, - ), - custom: (), - node: Lambda { - args: Arguments { - posonlyargs: [], - args: [ - Located { - location: Location { - row: 1, - column: 7, - }, - end_location: Some( - Location { - row: 1, - column: 8, + end_location: Some( + Location { + row: 1, + column: 26, + }, + ), + custom: (), + node: Lambda( + ExprLambda { + args: Arguments { + posonlyargs: [], + args: [ + Located { + location: Location { + row: 1, + column: 7, + }, + end_location: Some( + Location { + row: 1, + column: 8, + }, + ), + custom: (), + node: ArgData { + arg: "a", + annotation: None, + type_comment: None, + }, }, - ), - custom: (), - node: ArgData { - arg: "a", - annotation: None, - type_comment: None, - }, - }, - Located { - location: Location { - row: 1, - column: 10, - }, - end_location: Some( - Location { - row: 1, - column: 11, + Located { + location: Location { + row: 1, + column: 10, + }, + end_location: Some( + Location { + row: 1, + column: 11, + }, + ), + custom: (), + node: ArgData { + arg: "b", + annotation: None, + type_comment: None, + }, }, - ), - custom: (), - node: ArgData { - arg: "b", - annotation: None, - type_comment: None, - }, - }, - Located { - location: Location { - row: 1, - column: 13, - }, - end_location: Some( - Location { - row: 1, - column: 14, + Located { + location: Location { + row: 1, + column: 13, + }, + end_location: Some( + Location { + row: 1, + column: 14, + }, + ), + custom: (), + node: ArgData { + arg: "c", + annotation: None, + type_comment: None, + }, }, - ), - custom: (), - node: ArgData { - arg: "c", - annotation: None, - type_comment: None, - }, + ], + vararg: None, + kwonlyargs: [ + Located { + location: Location { + row: 1, + column: 19, + }, + end_location: Some( + Location { + row: 1, + column: 20, + }, + ), + custom: (), + node: ArgData { + arg: "d", + annotation: None, + type_comment: None, + }, + }, + Located { + location: Location { + row: 1, + column: 22, + }, + end_location: Some( + Location { + row: 1, + column: 23, + }, + ), + custom: (), + node: ArgData { + arg: "e", + annotation: None, + type_comment: None, + }, + }, + ], + kw_defaults: [], + kwarg: None, + defaults: [], }, - ], - vararg: None, - kwonlyargs: [ - Located { + body: Located { location: Location { row: 1, - column: 19, + column: 25, }, end_location: Some( Location { row: 1, - column: 20, + column: 26, }, ), custom: (), - node: ArgData { - arg: "d", - annotation: None, - type_comment: None, - }, - }, - Located { - location: Location { - row: 1, - column: 22, - }, - end_location: Some( - Location { - row: 1, - column: 23, + node: Constant( + ExprConstant { + value: Int( + 0, + ), + kind: None, }, ), - custom: (), - node: ArgData { - arg: "e", - annotation: None, - type_comment: None, - }, - }, - ], - kw_defaults: [], - kwarg: None, - defaults: [], - }, - body: Located { - location: Location { - row: 1, - column: 25, - }, - end_location: Some( - Location { - row: 1, - column: 26, }, - ), - custom: (), - node: Constant { - value: Int( - 0, - ), - kind: None, }, - }, + ), }, }, - }, + ), }, ], ) diff --git a/parser/src/snapshots/rustpython_parser__function__tests__lambda_pos_args.snap b/parser/src/snapshots/rustpython_parser__function__tests__lambda_pos_args.snap index f4ce79f9..bd52002b 100644 --- a/parser/src/snapshots/rustpython_parser__function__tests__lambda_pos_args.snap +++ b/parser/src/snapshots/rustpython_parser__function__tests__lambda_pos_args.snap @@ -1,5 +1,5 @@ --- -source: compiler/parser/src/function.rs +source: parser/src/function.rs expression: parse_ast --- Ok( @@ -16,106 +16,112 @@ Ok( }, ), custom: (), - node: Expr { - value: Located { - location: Location { - row: 1, - column: 0, - }, - end_location: Some( - Location { + node: Expr( + StmtExpr { + value: Located { + location: Location { row: 1, - column: 17, + column: 0, }, - ), - custom: (), - node: Lambda { - args: Arguments { - posonlyargs: [], - args: [ - Located { - location: Location { - row: 1, - column: 7, - }, - end_location: Some( - Location { - row: 1, - column: 8, + end_location: Some( + Location { + row: 1, + column: 17, + }, + ), + custom: (), + node: Lambda( + ExprLambda { + args: Arguments { + posonlyargs: [], + args: [ + Located { + location: Location { + row: 1, + column: 7, + }, + end_location: Some( + Location { + row: 1, + column: 8, + }, + ), + custom: (), + node: ArgData { + arg: "a", + annotation: None, + type_comment: None, + }, }, - ), - custom: (), - node: ArgData { - arg: "a", - annotation: None, - type_comment: None, - }, + Located { + location: Location { + row: 1, + column: 10, + }, + end_location: Some( + Location { + row: 1, + column: 11, + }, + ), + custom: (), + node: ArgData { + arg: "b", + annotation: None, + type_comment: None, + }, + }, + Located { + location: Location { + row: 1, + column: 13, + }, + end_location: Some( + Location { + row: 1, + column: 14, + }, + ), + custom: (), + node: ArgData { + arg: "c", + annotation: None, + type_comment: None, + }, + }, + ], + vararg: None, + kwonlyargs: [], + kw_defaults: [], + kwarg: None, + defaults: [], }, - Located { + body: Located { location: Location { row: 1, - column: 10, + column: 16, }, end_location: Some( Location { row: 1, - column: 11, + column: 17, }, ), custom: (), - node: ArgData { - arg: "b", - annotation: None, - type_comment: None, - }, - }, - Located { - location: Location { - row: 1, - column: 13, - }, - end_location: Some( - Location { - row: 1, - column: 14, + node: Constant( + ExprConstant { + value: Int( + 1, + ), + kind: None, }, ), - custom: (), - node: ArgData { - arg: "c", - annotation: None, - type_comment: None, - }, }, - ], - vararg: None, - kwonlyargs: [], - kw_defaults: [], - kwarg: None, - defaults: [], - }, - body: Located { - location: Location { - row: 1, - column: 16, - }, - end_location: Some( - Location { - row: 1, - column: 17, - }, - ), - custom: (), - node: Constant { - value: Int( - 1, - ), - kind: None, }, - }, + ), }, }, - }, + ), }, ], ) diff --git a/parser/src/snapshots/rustpython_parser__function__tests__lambda_pos_args_with_defaults.snap b/parser/src/snapshots/rustpython_parser__function__tests__lambda_pos_args_with_defaults.snap index 01691aa7..3578d760 100644 --- a/parser/src/snapshots/rustpython_parser__function__tests__lambda_pos_args_with_defaults.snap +++ b/parser/src/snapshots/rustpython_parser__function__tests__lambda_pos_args_with_defaults.snap @@ -1,5 +1,5 @@ --- -source: compiler/parser/src/function.rs +source: parser/src/function.rs expression: parse_ast --- Ok( @@ -16,145 +16,155 @@ Ok( }, ), custom: (), - node: Expr { - value: Located { - location: Location { - row: 1, - column: 0, - }, - end_location: Some( - Location { + node: Expr( + StmtExpr { + value: Located { + location: Location { row: 1, - column: 23, + column: 0, }, - ), - custom: (), - node: Lambda { - args: Arguments { - posonlyargs: [], - args: [ - Located { - location: Location { - row: 1, - column: 7, - }, - end_location: Some( - Location { - row: 1, - column: 8, + end_location: Some( + Location { + row: 1, + column: 23, + }, + ), + custom: (), + node: Lambda( + ExprLambda { + args: Arguments { + posonlyargs: [], + args: [ + Located { + location: Location { + row: 1, + column: 7, + }, + end_location: Some( + Location { + row: 1, + column: 8, + }, + ), + custom: (), + node: ArgData { + arg: "a", + annotation: None, + type_comment: None, + }, }, - ), - custom: (), - node: ArgData { - arg: "a", - annotation: None, - type_comment: None, - }, - }, - Located { - location: Location { - row: 1, - column: 10, - }, - end_location: Some( - Location { - row: 1, - column: 11, + Located { + location: Location { + row: 1, + column: 10, + }, + end_location: Some( + Location { + row: 1, + column: 11, + }, + ), + custom: (), + node: ArgData { + arg: "b", + annotation: None, + type_comment: None, + }, }, - ), - custom: (), - node: ArgData { - arg: "b", - annotation: None, - type_comment: None, - }, - }, - Located { - location: Location { - row: 1, - column: 16, - }, - end_location: Some( - Location { - row: 1, - column: 17, + Located { + location: Location { + row: 1, + column: 16, + }, + end_location: Some( + Location { + row: 1, + column: 17, + }, + ), + custom: (), + node: ArgData { + arg: "c", + annotation: None, + type_comment: None, + }, }, - ), - custom: (), - node: ArgData { - arg: "c", - annotation: None, - type_comment: None, - }, + ], + vararg: None, + kwonlyargs: [], + kw_defaults: [], + kwarg: None, + defaults: [ + Located { + location: Location { + row: 1, + column: 12, + }, + end_location: Some( + Location { + row: 1, + column: 14, + }, + ), + custom: (), + node: Constant( + ExprConstant { + value: Int( + 20, + ), + kind: None, + }, + ), + }, + Located { + location: Location { + row: 1, + column: 18, + }, + end_location: Some( + Location { + row: 1, + column: 20, + }, + ), + custom: (), + node: Constant( + ExprConstant { + value: Int( + 30, + ), + kind: None, + }, + ), + }, + ], }, - ], - vararg: None, - kwonlyargs: [], - kw_defaults: [], - kwarg: None, - defaults: [ - Located { + body: Located { location: Location { row: 1, - column: 12, + column: 22, }, end_location: Some( Location { row: 1, - column: 14, + column: 23, }, ), custom: (), - node: Constant { - value: Int( - 20, - ), - kind: None, - }, - }, - Located { - location: Location { - row: 1, - column: 18, - }, - end_location: Some( - Location { - row: 1, - column: 20, + node: Constant( + ExprConstant { + value: Int( + 1, + ), + kind: None, }, ), - custom: (), - node: Constant { - value: Int( - 30, - ), - kind: None, - }, - }, - ], - }, - body: Located { - location: Location { - row: 1, - column: 22, - }, - end_location: Some( - Location { - row: 1, - column: 23, }, - ), - custom: (), - node: Constant { - value: Int( - 1, - ), - kind: None, }, - }, + ), }, }, - }, + ), }, ], ) diff --git a/parser/src/snapshots/rustpython_parser__parser__tests__dict_unpacking.snap b/parser/src/snapshots/rustpython_parser__parser__tests__dict_unpacking.snap index 212f737e..302a9854 100644 --- a/parser/src/snapshots/rustpython_parser__parser__tests__dict_unpacking.snap +++ b/parser/src/snapshots/rustpython_parser__parser__tests__dict_unpacking.snap @@ -1,5 +1,5 @@ --- -source: compiler/parser/src/parser.rs +source: parser/src/parser.rs expression: parse_ast --- Located { @@ -14,108 +14,120 @@ Located { }, ), custom: (), - node: Dict { - keys: [ - Some( + node: Dict( + ExprDict { + keys: [ + Some( + Located { + location: Location { + row: 1, + column: 1, + }, + end_location: Some( + Location { + row: 1, + column: 4, + }, + ), + custom: (), + node: Constant( + ExprConstant { + value: Str( + "a", + ), + kind: None, + }, + ), + }, + ), + None, + Some( + Located { + location: Location { + row: 1, + column: 16, + }, + end_location: Some( + Location { + row: 1, + column: 19, + }, + ), + custom: (), + node: Constant( + ExprConstant { + value: Str( + "d", + ), + kind: None, + }, + ), + }, + ), + ], + values: [ Located { location: Location { row: 1, - column: 1, + column: 6, }, end_location: Some( Location { row: 1, - column: 4, + column: 9, }, ), custom: (), - node: Constant { - value: Str( - "a", - ), - kind: None, - }, + node: Constant( + ExprConstant { + value: Str( + "b", + ), + kind: None, + }, + ), }, - ), - None, - Some( Located { location: Location { row: 1, - column: 16, + column: 13, }, end_location: Some( Location { row: 1, - column: 19, + column: 14, }, ), custom: (), - node: Constant { - value: Str( - "d", - ), - kind: None, - }, - }, - ), - ], - values: [ - Located { - location: Location { - row: 1, - column: 6, - }, - end_location: Some( - Location { - row: 1, - column: 9, - }, - ), - custom: (), - node: Constant { - value: Str( - "b", + node: Name( + ExprName { + id: "c", + ctx: Load, + }, ), - kind: None, - }, - }, - Located { - location: Location { - row: 1, - column: 13, }, - end_location: Some( - Location { - row: 1, - column: 14, - }, - ), - custom: (), - node: Name { - id: "c", - ctx: Load, - }, - }, - Located { - location: Location { - row: 1, - column: 21, - }, - end_location: Some( - Location { + Located { + location: Location { row: 1, - column: 24, + column: 21, }, - ), - custom: (), - node: Constant { - value: Str( - "e", + end_location: Some( + Location { + row: 1, + column: 24, + }, + ), + custom: (), + node: Constant( + ExprConstant { + value: Str( + "e", + ), + kind: None, + }, ), - kind: None, }, - }, - ], - }, + ], + }, + ), } diff --git a/parser/src/snapshots/rustpython_parser__parser__tests__generator_expression_argument.snap b/parser/src/snapshots/rustpython_parser__parser__tests__generator_expression_argument.snap index 863ece46..79b5540d 100644 --- a/parser/src/snapshots/rustpython_parser__parser__tests__generator_expression_argument.snap +++ b/parser/src/snapshots/rustpython_parser__parser__tests__generator_expression_argument.snap @@ -1,5 +1,5 @@ --- -source: compiler/parser/src/parser.rs +source: parser/src/parser.rs expression: parse_ast --- Located { @@ -14,320 +14,358 @@ Located { }, ), custom: (), - node: Call { - func: Located { - location: Location { - row: 1, - column: 0, - }, - end_location: Some( - Location { - row: 1, - column: 8, - }, - ), - custom: (), - node: Attribute { - value: Located { - location: Location { - row: 1, - column: 0, - }, - end_location: Some( - Location { - row: 1, - column: 3, - }, - ), - custom: (), - node: Constant { - value: Str( - " ", - ), - kind: None, - }, - }, - attr: "join", - ctx: Load, - }, - }, - args: [ - Located { + node: Call( + ExprCall { + func: Located { location: Location { - row: 2, - column: 4, + row: 1, + column: 0, }, end_location: Some( Location { - row: 6, - column: 5, + row: 1, + column: 8, }, ), custom: (), - node: GeneratorExp { - elt: Located { - location: Location { - row: 2, - column: 4, - }, - end_location: Some( - Location { - row: 2, - column: 7, + node: Attribute( + ExprAttribute { + value: Located { + location: Location { + row: 1, + column: 0, }, - ), - custom: (), - node: Name { - id: "sql", - ctx: Load, + end_location: Some( + Location { + row: 1, + column: 3, + }, + ), + custom: (), + node: Constant( + ExprConstant { + value: Str( + " ", + ), + kind: None, + }, + ), }, + attr: "join", + ctx: Load, + }, + ), + }, + args: [ + Located { + location: Location { + row: 2, + column: 4, }, - generators: [ - Comprehension { - target: Located { + end_location: Some( + Location { + row: 6, + column: 5, + }, + ), + custom: (), + node: GeneratorExp( + ExprGeneratorExp { + elt: Located { location: Location { - row: 3, - column: 8, + row: 2, + column: 4, }, end_location: Some( Location { - row: 3, - column: 11, + row: 2, + column: 7, }, ), custom: (), - node: Name { - id: "sql", - ctx: Store, - }, - }, - iter: Located { - location: Location { - row: 3, - column: 15, - }, - end_location: Some( - Location { - row: 6, - column: 5, + node: Name( + ExprName { + id: "sql", + ctx: Load, }, ), - custom: (), - node: Tuple { - elts: [ - Located { - location: Location { - row: 4, - column: 8, + }, + generators: [ + Comprehension { + target: Located { + location: Location { + row: 3, + column: 8, + }, + end_location: Some( + Location { + row: 3, + column: 11, }, - end_location: Some( - Location { - row: 4, - column: 45, - }, - ), - custom: (), - node: IfExp { - test: Located { - location: Location { - row: 4, - column: 30, - }, - end_location: Some( - Location { - row: 4, - column: 35, - }, - ), - custom: (), - node: Name { - id: "limit", - ctx: Load, - }, - }, - body: Located { - location: Location { - row: 4, - column: 8, - }, - end_location: Some( - Location { + ), + custom: (), + node: Name( + ExprName { + id: "sql", + ctx: Store, + }, + ), + }, + iter: Located { + location: Location { + row: 3, + column: 15, + }, + end_location: Some( + Location { + row: 6, + column: 5, + }, + ), + custom: (), + node: Tuple( + ExprTuple { + elts: [ + Located { + location: Location { row: 4, - column: 26, + column: 8, }, - ), - custom: (), - node: BinOp { - left: Located { - location: Location { + end_location: Some( + Location { row: 4, - column: 8, + column: 45, }, - end_location: Some( - Location { - row: 4, - column: 18, + ), + custom: (), + node: IfExp( + ExprIfExp { + test: Located { + location: Location { + row: 4, + column: 30, + }, + end_location: Some( + Location { + row: 4, + column: 35, + }, + ), + custom: (), + node: Name( + ExprName { + id: "limit", + ctx: Load, + }, + ), }, - ), - custom: (), - node: Constant { - value: Str( - "LIMIT %d", - ), - kind: None, - }, - }, - op: Mod, - right: Located { - location: Location { - row: 4, - column: 21, - }, - end_location: Some( - Location { - row: 4, - column: 26, + body: Located { + location: Location { + row: 4, + column: 8, + }, + end_location: Some( + Location { + row: 4, + column: 26, + }, + ), + custom: (), + node: BinOp( + ExprBinOp { + left: Located { + location: Location { + row: 4, + column: 8, + }, + end_location: Some( + Location { + row: 4, + column: 18, + }, + ), + custom: (), + node: Constant( + ExprConstant { + value: Str( + "LIMIT %d", + ), + kind: None, + }, + ), + }, + op: Mod, + right: Located { + location: Location { + row: 4, + column: 21, + }, + end_location: Some( + Location { + row: 4, + column: 26, + }, + ), + custom: (), + node: Name( + ExprName { + id: "limit", + ctx: Load, + }, + ), + }, + }, + ), + }, + orelse: Located { + location: Location { + row: 4, + column: 41, + }, + end_location: Some( + Location { + row: 4, + column: 45, + }, + ), + custom: (), + node: Constant( + ExprConstant { + value: None, + kind: None, + }, + ), }, - ), - custom: (), - node: Name { - id: "limit", - ctx: Load, }, - }, + ), }, - }, - orelse: Located { - location: Location { - row: 4, - column: 41, - }, - end_location: Some( - Location { - row: 4, - column: 45, - }, - ), - custom: (), - node: Constant { - value: None, - kind: None, - }, - }, - }, - }, - Located { - location: Location { - row: 5, - column: 8, - }, - end_location: Some( - Location { - row: 5, - column: 50, - }, - ), - custom: (), - node: IfExp { - test: Located { - location: Location { - row: 5, - column: 34, - }, - end_location: Some( - Location { + Located { + location: Location { row: 5, - column: 40, + column: 8, }, - ), - custom: (), - node: Name { - id: "offset", - ctx: Load, - }, - }, - body: Located { - location: Location { - row: 5, - column: 9, - }, - end_location: Some( - Location { - row: 5, - column: 29, - }, - ), - custom: (), - node: BinOp { - left: Located { - location: Location { + end_location: Some( + Location { row: 5, - column: 9, + column: 50, }, - end_location: Some( - Location { - row: 5, - column: 20, + ), + custom: (), + node: IfExp( + ExprIfExp { + test: Located { + location: Location { + row: 5, + column: 34, + }, + end_location: Some( + Location { + row: 5, + column: 40, + }, + ), + custom: (), + node: Name( + ExprName { + id: "offset", + ctx: Load, + }, + ), }, - ), - custom: (), - node: Constant { - value: Str( - "OFFSET %d", - ), - kind: None, - }, - }, - op: Mod, - right: Located { - location: Location { - row: 5, - column: 23, - }, - end_location: Some( - Location { - row: 5, - column: 29, + body: Located { + location: Location { + row: 5, + column: 9, + }, + end_location: Some( + Location { + row: 5, + column: 29, + }, + ), + custom: (), + node: BinOp( + ExprBinOp { + left: Located { + location: Location { + row: 5, + column: 9, + }, + end_location: Some( + Location { + row: 5, + column: 20, + }, + ), + custom: (), + node: Constant( + ExprConstant { + value: Str( + "OFFSET %d", + ), + kind: None, + }, + ), + }, + op: Mod, + right: Located { + location: Location { + row: 5, + column: 23, + }, + end_location: Some( + Location { + row: 5, + column: 29, + }, + ), + custom: (), + node: Name( + ExprName { + id: "offset", + ctx: Load, + }, + ), + }, + }, + ), + }, + orelse: Located { + location: Location { + row: 5, + column: 46, + }, + end_location: Some( + Location { + row: 5, + column: 50, + }, + ), + custom: (), + node: Constant( + ExprConstant { + value: None, + kind: None, + }, + ), }, - ), - custom: (), - node: Name { - id: "offset", - ctx: Load, }, - }, - }, - }, - orelse: Located { - location: Location { - row: 5, - column: 46, - }, - end_location: Some( - Location { - row: 5, - column: 50, - }, - ), - custom: (), - node: Constant { - value: None, - kind: None, + ), }, - }, + ], + ctx: Load, }, - }, - ], - ctx: Load, + ), + }, + ifs: [], + is_async: 0, }, - }, - ifs: [], - is_async: 0, + ], }, - ], + ), }, - }, - ], - keywords: [], - }, + ], + keywords: [], + }, + ), } diff --git a/parser/src/snapshots/rustpython_parser__parser__tests__match.snap b/parser/src/snapshots/rustpython_parser__parser__tests__match.snap index 6bc9c16a..893462f2 100644 --- a/parser/src/snapshots/rustpython_parser__parser__tests__match.snap +++ b/parser/src/snapshots/rustpython_parser__parser__tests__match.snap @@ -1,5 +1,5 @@ --- -source: compiler/parser/src/parser.rs +source: parser/src/parser.rs expression: parse_ast --- [ @@ -15,117 +15,114 @@ expression: parse_ast }, ), custom: (), - node: Match { - subject: Located { - location: Location { - row: 2, - column: 6, - }, - end_location: Some( - Location { + node: Match( + StmtMatch { + subject: Located { + location: Location { row: 2, - column: 17, + column: 6, }, - ), - custom: (), - node: Dict { - keys: [ - Some( - Located { - location: Location { - row: 2, - column: 7, - }, - end_location: Some( - Location { - row: 2, - column: 13, + end_location: Some( + Location { + row: 2, + column: 17, + }, + ), + custom: (), + node: Dict( + ExprDict { + keys: [ + Some( + Located { + location: Location { + row: 2, + column: 7, + }, + end_location: Some( + Location { + row: 2, + column: 13, + }, + ), + custom: (), + node: Constant( + ExprConstant { + value: Str( + "test", + ), + kind: None, + }, + ), }, ), - custom: (), - node: Constant { - value: Str( - "test", + ], + values: [ + Located { + location: Location { + row: 2, + column: 15, + }, + end_location: Some( + Location { + row: 2, + column: 16, + }, + ), + custom: (), + node: Constant( + ExprConstant { + value: Int( + 1, + ), + kind: None, + }, ), - kind: None, }, - }, - ), - ], - values: [ - Located { + ], + }, + ), + }, + cases: [ + MatchCase { + pattern: Located { location: Location { - row: 2, - column: 15, + row: 3, + column: 9, }, end_location: Some( Location { - row: 2, - column: 16, + row: 5, + column: 5, }, ), custom: (), - node: Constant { - value: Int( - 1, - ), - kind: None, - }, - }, - ], - }, - }, - cases: [ - MatchCase { - pattern: Located { - location: Location { - row: 3, - column: 9, - }, - end_location: Some( - Location { - row: 5, - column: 5, - }, - ), - custom: (), - node: MatchMapping { - keys: [], - patterns: [], - rest: Some( - "rest", + node: MatchMapping( + PatternMatchMapping { + keys: [], + patterns: [], + rest: Some( + "rest", + ), + }, ), }, - }, - guard: None, - body: [ - Located { - location: Location { - row: 6, - column: 8, - }, - end_location: Some( - Location { + guard: None, + body: [ + Located { + location: Location { row: 6, - column: 19, + column: 8, }, - ), - custom: (), - node: Expr { - value: Located { - location: Location { + end_location: Some( + Location { row: 6, - column: 8, + column: 19, }, - end_location: Some( - Location { - row: 6, - column: 19, - }, - ), - custom: (), - node: Call { - func: Located { + ), + custom: (), + node: Expr( + StmtExpr { + value: Located { location: Location { row: 6, column: 8, @@ -133,43 +130,64 @@ expression: parse_ast end_location: Some( Location { row: 6, - column: 13, + column: 19, }, ), custom: (), - node: Name { - id: "print", - ctx: Load, - }, - }, - args: [ - Located { - location: Location { - row: 6, - column: 14, - }, - end_location: Some( - Location { - row: 6, - column: 18, + node: Call( + ExprCall { + func: Located { + location: Location { + row: 6, + column: 8, + }, + end_location: Some( + Location { + row: 6, + column: 13, + }, + ), + custom: (), + node: Name( + ExprName { + id: "print", + ctx: Load, + }, + ), }, - ), - custom: (), - node: Name { - id: "rest", - ctx: Load, + args: [ + Located { + location: Location { + row: 6, + column: 14, + }, + end_location: Some( + Location { + row: 6, + column: 18, + }, + ), + custom: (), + node: Name( + ExprName { + id: "rest", + ctx: Load, + }, + ), + }, + ], + keywords: [], }, - }, - ], - keywords: [], + ), + }, }, - }, + ), }, - }, - ], - }, - ], - }, + ], + }, + ], + }, + ), }, Located { location: Location { @@ -183,131 +201,128 @@ expression: parse_ast }, ), custom: (), - node: Match { - subject: Located { - location: Location { - row: 7, - column: 6, - }, - end_location: Some( - Location { + node: Match( + StmtMatch { + subject: Located { + location: Location { row: 7, - column: 23, + column: 6, }, - ), - custom: (), - node: Dict { - keys: [ - Some( - Located { - location: Location { - row: 7, - column: 7, - }, - end_location: Some( - Location { - row: 7, - column: 14, - }, - ), - custom: (), - node: Constant { - value: Str( - "label", - ), - kind: None, - }, - }, - ), - ], - values: [ - Located { - location: Location { - row: 7, - column: 16, - }, - end_location: Some( - Location { - row: 7, - column: 22, - }, - ), - custom: (), - node: Constant { - value: Str( - "test", - ), - kind: None, - }, - }, - ], - }, - }, - cases: [ - MatchCase { - pattern: Located { - location: Location { - row: 8, - column: 9, + end_location: Some( + Location { + row: 7, + column: 23, }, - end_location: Some( - Location { - row: 10, - column: 5, - }, - ), - custom: (), - node: MatchMapping { + ), + custom: (), + node: Dict( + ExprDict { keys: [ - Located { - location: Location { - row: 9, - column: 8, - }, - end_location: Some( - Location { - row: 9, - column: 15, + Some( + Located { + location: Location { + row: 7, + column: 7, }, - ), - custom: (), - node: Constant { - value: Str( - "label", + end_location: Some( + Location { + row: 7, + column: 14, + }, + ), + custom: (), + node: Constant( + ExprConstant { + value: Str( + "label", + ), + kind: None, + }, ), - kind: None, }, - }, + ), ], - patterns: [ + values: [ Located { location: Location { - row: 9, - column: 17, + row: 7, + column: 16, }, end_location: Some( Location { - row: 9, - column: 38, + row: 7, + column: 22, }, ), custom: (), - node: MatchAs { - pattern: Some( - Located { - location: Location { + node: Constant( + ExprConstant { + value: Str( + "test", + ), + kind: None, + }, + ), + }, + ], + }, + ), + }, + cases: [ + MatchCase { + pattern: Located { + location: Location { + row: 8, + column: 9, + }, + end_location: Some( + Location { + row: 10, + column: 5, + }, + ), + custom: (), + node: MatchMapping( + PatternMatchMapping { + keys: [ + Located { + location: Location { + row: 9, + column: 8, + }, + end_location: Some( + Location { row: 9, - column: 17, + column: 15, }, - end_location: Some( - Location { - row: 9, - column: 29, - }, - ), - custom: (), - node: MatchOr { - patterns: [ + ), + custom: (), + node: Constant( + ExprConstant { + value: Str( + "label", + ), + kind: None, + }, + ), + }, + ], + patterns: [ + Located { + location: Location { + row: 9, + column: 17, + }, + end_location: Some( + Location { + row: 9, + column: 38, + }, + ), + custom: (), + node: MatchAs( + PatternMatchAs { + pattern: Some( Located { location: Location { row: 9, @@ -316,91 +331,103 @@ expression: parse_ast end_location: Some( Location { row: 9, - column: 22, + column: 29, }, ), custom: (), - node: MatchClass { - cls: Located { - location: Location { - row: 9, - column: 17, - }, - end_location: Some( - Location { - row: 9, - column: 20, + node: MatchOr( + PatternMatchOr { + patterns: [ + Located { + location: Location { + row: 9, + column: 17, + }, + end_location: Some( + Location { + row: 9, + column: 22, + }, + ), + custom: (), + node: MatchClass( + PatternMatchClass { + cls: Located { + location: Location { + row: 9, + column: 17, + }, + end_location: Some( + Location { + row: 9, + column: 20, + }, + ), + custom: (), + node: Name( + ExprName { + id: "str", + ctx: Load, + }, + ), + }, + patterns: [], + kwd_attrs: [], + kwd_patterns: [], + }, + ), }, - ), - custom: (), - node: Name { - id: "str", - ctx: Load, - }, - }, - patterns: [], - kwd_attrs: [], - kwd_patterns: [], - }, - }, - Located { - location: Location { - row: 9, - column: 25, - }, - end_location: Some( - Location { - row: 9, - column: 29, + Located { + location: Location { + row: 9, + column: 25, + }, + end_location: Some( + Location { + row: 9, + column: 29, + }, + ), + custom: (), + node: MatchSingleton( + PatternMatchSingleton { + value: None, + }, + ), + }, + ], }, ), - custom: (), - node: MatchSingleton { - value: None, - }, }, - ], + ), + name: Some( + "label", + ), }, - }, - ), - name: Some( - "label", - ), - }, + ), + }, + ], + rest: None, }, - ], - rest: None, + ), }, - }, - guard: None, - body: [ - Located { - location: Location { - row: 11, - column: 8, - }, - end_location: Some( - Location { + guard: None, + body: [ + Located { + location: Location { row: 11, - column: 20, + column: 8, }, - ), - custom: (), - node: Expr { - value: Located { - location: Location { + end_location: Some( + Location { row: 11, - column: 8, + column: 20, }, - end_location: Some( - Location { - row: 11, - column: 20, - }, - ), - custom: (), - node: Call { - func: Located { + ), + custom: (), + node: Expr( + StmtExpr { + value: Located { location: Location { row: 11, column: 8, @@ -408,43 +435,64 @@ expression: parse_ast end_location: Some( Location { row: 11, - column: 13, + column: 20, }, ), custom: (), - node: Name { - id: "print", - ctx: Load, - }, - }, - args: [ - Located { - location: Location { - row: 11, - column: 14, - }, - end_location: Some( - Location { - row: 11, - column: 19, + node: Call( + ExprCall { + func: Located { + location: Location { + row: 11, + column: 8, + }, + end_location: Some( + Location { + row: 11, + column: 13, + }, + ), + custom: (), + node: Name( + ExprName { + id: "print", + ctx: Load, + }, + ), }, - ), - custom: (), - node: Name { - id: "label", - ctx: Load, - }, - }, - ], - keywords: [], + args: [ + Located { + location: Location { + row: 11, + column: 14, + }, + end_location: Some( + Location { + row: 11, + column: 19, + }, + ), + custom: (), + node: Name( + ExprName { + id: "label", + ctx: Load, + }, + ), + }, + ], + keywords: [], + }, + ), + }, }, - }, + ), }, - }, - ], - }, - ], - }, + ], + }, + ], + }, + ), }, Located { location: Location { @@ -458,54 +506,45 @@ expression: parse_ast }, ), custom: (), - node: Match { - subject: Located { - location: Location { - row: 12, - column: 6, - }, - end_location: Some( - Location { + node: Match( + StmtMatch { + subject: Located { + location: Location { row: 12, - column: 7, + column: 6, }, - ), - custom: (), - node: Name { - id: "x", - ctx: Load, - }, - }, - cases: [ - MatchCase { - pattern: Located { - location: Location { - row: 13, - column: 9, + end_location: Some( + Location { + row: 12, + column: 7, }, - end_location: Some( - Location { + ), + custom: (), + node: Name( + ExprName { + id: "x", + ctx: Load, + }, + ), + }, + cases: [ + MatchCase { + pattern: Located { + location: Location { row: 13, - column: 16, + column: 9, }, - ), - custom: (), - node: MatchSequence { - patterns: [ - Located { - location: Location { - row: 13, - column: 10, - }, - end_location: Some( - Location { - row: 13, - column: 11, - }, - ), - custom: (), - node: MatchValue { - value: Located { + end_location: Some( + Location { + row: 13, + column: 16, + }, + ), + custom: (), + node: MatchSequence( + PatternMatchSequence { + patterns: [ + Located { location: Location { row: 13, column: 10, @@ -517,29 +556,33 @@ expression: parse_ast }, ), custom: (), - node: Constant { - value: Int( - 0, - ), - kind: None, - }, - }, - }, - }, - Located { - location: Location { - row: 13, - column: 13, - }, - end_location: Some( - Location { - row: 13, - column: 14, + node: MatchValue( + PatternMatchValue { + value: Located { + location: Location { + row: 13, + column: 10, + }, + end_location: Some( + Location { + row: 13, + column: 11, + }, + ), + custom: (), + node: Constant( + ExprConstant { + value: Int( + 0, + ), + kind: None, + }, + ), + }, + }, + ), }, - ), - custom: (), - node: MatchValue { - value: Located { + Located { location: Location { row: 13, column: 13, @@ -551,78 +594,103 @@ expression: parse_ast }, ), custom: (), - node: Constant { - value: Int( - 1, - ), - kind: None, - }, + node: MatchValue( + PatternMatchValue { + value: Located { + location: Location { + row: 13, + column: 13, + }, + end_location: Some( + Location { + row: 13, + column: 14, + }, + ), + custom: (), + node: Constant( + ExprConstant { + value: Int( + 1, + ), + kind: None, + }, + ), + }, + }, + ), }, - }, + ], }, - ], + ), }, - }, - guard: None, - body: [ - Located { - location: Location { - row: 14, - column: 8, - }, - end_location: Some( - Location { + guard: None, + body: [ + Located { + location: Location { row: 14, - column: 13, + column: 8, }, - ), - custom: (), - node: Assign { - targets: [ - Located { - location: Location { - row: 14, - column: 8, - }, - end_location: Some( - Location { - row: 14, - column: 9, - }, - ), - custom: (), - node: Name { - id: "y", - ctx: Store, - }, - }, - ], - value: Located { - location: Location { + end_location: Some( + Location { row: 14, - column: 12, + column: 13, }, - end_location: Some( - Location { - row: 14, - column: 13, + ), + custom: (), + node: Assign( + StmtAssign { + targets: [ + Located { + location: Location { + row: 14, + column: 8, + }, + end_location: Some( + Location { + row: 14, + column: 9, + }, + ), + custom: (), + node: Name( + ExprName { + id: "y", + ctx: Store, + }, + ), + }, + ], + value: Located { + location: Location { + row: 14, + column: 12, + }, + end_location: Some( + Location { + row: 14, + column: 13, + }, + ), + custom: (), + node: Constant( + ExprConstant { + value: Int( + 0, + ), + kind: None, + }, + ), }, - ), - custom: (), - node: Constant { - value: Int( - 0, - ), - kind: None, + type_comment: None, }, - }, - type_comment: None, + ), }, - }, - ], - }, - ], - }, + ], + }, + ], + }, + ), }, Located { location: Location { @@ -636,54 +704,45 @@ expression: parse_ast }, ), custom: (), - node: Match { - subject: Located { - location: Location { - row: 15, - column: 6, - }, - end_location: Some( - Location { + node: Match( + StmtMatch { + subject: Located { + location: Location { row: 15, - column: 7, + column: 6, }, - ), - custom: (), - node: Name { - id: "x", - ctx: Load, - }, - }, - cases: [ - MatchCase { - pattern: Located { - location: Location { - row: 16, - column: 9, + end_location: Some( + Location { + row: 15, + column: 7, + }, + ), + custom: (), + node: Name( + ExprName { + id: "x", + ctx: Load, }, - end_location: Some( - Location { + ), + }, + cases: [ + MatchCase { + pattern: Located { + location: Location { row: 16, - column: 16, + column: 9, }, - ), - custom: (), - node: MatchSequence { - patterns: [ - Located { - location: Location { - row: 16, - column: 10, - }, - end_location: Some( - Location { - row: 16, - column: 11, - }, - ), - custom: (), - node: MatchValue { - value: Located { + end_location: Some( + Location { + row: 16, + column: 16, + }, + ), + custom: (), + node: MatchSequence( + PatternMatchSequence { + patterns: [ + Located { location: Location { row: 16, column: 10, @@ -695,29 +754,33 @@ expression: parse_ast }, ), custom: (), - node: Constant { - value: Int( - 0, - ), - kind: None, - }, - }, - }, - }, - Located { - location: Location { - row: 16, - column: 13, - }, - end_location: Some( - Location { - row: 16, - column: 14, + node: MatchValue( + PatternMatchValue { + value: Located { + location: Location { + row: 16, + column: 10, + }, + end_location: Some( + Location { + row: 16, + column: 11, + }, + ), + custom: (), + node: Constant( + ExprConstant { + value: Int( + 0, + ), + kind: None, + }, + ), + }, + }, + ), }, - ), - custom: (), - node: MatchValue { - value: Located { + Located { location: Location { row: 16, column: 13, @@ -729,78 +792,103 @@ expression: parse_ast }, ), custom: (), - node: Constant { - value: Int( - 1, - ), - kind: None, - }, + node: MatchValue( + PatternMatchValue { + value: Located { + location: Location { + row: 16, + column: 13, + }, + end_location: Some( + Location { + row: 16, + column: 14, + }, + ), + custom: (), + node: Constant( + ExprConstant { + value: Int( + 1, + ), + kind: None, + }, + ), + }, + }, + ), }, - }, + ], }, - ], + ), }, - }, - guard: None, - body: [ - Located { - location: Location { - row: 17, - column: 8, - }, - end_location: Some( - Location { + guard: None, + body: [ + Located { + location: Location { row: 17, - column: 13, + column: 8, }, - ), - custom: (), - node: Assign { - targets: [ - Located { - location: Location { - row: 17, - column: 8, - }, - end_location: Some( - Location { - row: 17, - column: 9, - }, - ), - custom: (), - node: Name { - id: "y", - ctx: Store, - }, - }, - ], - value: Located { - location: Location { + end_location: Some( + Location { row: 17, - column: 12, + column: 13, }, - end_location: Some( - Location { - row: 17, - column: 13, + ), + custom: (), + node: Assign( + StmtAssign { + targets: [ + Located { + location: Location { + row: 17, + column: 8, + }, + end_location: Some( + Location { + row: 17, + column: 9, + }, + ), + custom: (), + node: Name( + ExprName { + id: "y", + ctx: Store, + }, + ), + }, + ], + value: Located { + location: Location { + row: 17, + column: 12, + }, + end_location: Some( + Location { + row: 17, + column: 13, + }, + ), + custom: (), + node: Constant( + ExprConstant { + value: Int( + 0, + ), + kind: None, + }, + ), }, - ), - custom: (), - node: Constant { - value: Int( - 0, - ), - kind: None, + type_comment: None, }, - }, - type_comment: None, + ), }, - }, - ], - }, - ], - }, + ], + }, + ], + }, + ), }, Located { location: Location { @@ -814,54 +902,45 @@ expression: parse_ast }, ), custom: (), - node: Match { - subject: Located { - location: Location { - row: 18, - column: 6, - }, - end_location: Some( - Location { + node: Match( + StmtMatch { + subject: Located { + location: Location { row: 18, - column: 7, + column: 6, }, - ), - custom: (), - node: Name { - id: "x", - ctx: Load, - }, - }, - cases: [ - MatchCase { - pattern: Located { - location: Location { - row: 19, - column: 9, + end_location: Some( + Location { + row: 18, + column: 7, }, - end_location: Some( - Location { + ), + custom: (), + node: Name( + ExprName { + id: "x", + ctx: Load, + }, + ), + }, + cases: [ + MatchCase { + pattern: Located { + location: Location { row: 19, - column: 13, + column: 9, }, - ), - custom: (), - node: MatchSequence { - patterns: [ - Located { - location: Location { - row: 19, - column: 10, - }, - end_location: Some( - Location { - row: 19, - column: 11, - }, - ), - custom: (), - node: MatchValue { - value: Located { + end_location: Some( + Location { + row: 19, + column: 13, + }, + ), + custom: (), + node: MatchSequence( + PatternMatchSequence { + patterns: [ + Located { location: Location { row: 19, column: 10, @@ -873,77 +952,102 @@ expression: parse_ast }, ), custom: (), - node: Constant { - value: Int( - 0, - ), - kind: None, - }, + node: MatchValue( + PatternMatchValue { + value: Located { + location: Location { + row: 19, + column: 10, + }, + end_location: Some( + Location { + row: 19, + column: 11, + }, + ), + custom: (), + node: Constant( + ExprConstant { + value: Int( + 0, + ), + kind: None, + }, + ), + }, + }, + ), }, - }, + ], }, - ], + ), }, - }, - guard: None, - body: [ - Located { - location: Location { - row: 20, - column: 8, - }, - end_location: Some( - Location { + guard: None, + body: [ + Located { + location: Location { row: 20, - column: 13, + column: 8, }, - ), - custom: (), - node: Assign { - targets: [ - Located { - location: Location { - row: 20, - column: 8, - }, - end_location: Some( - Location { - row: 20, - column: 9, - }, - ), - custom: (), - node: Name { - id: "y", - ctx: Store, - }, - }, - ], - value: Located { - location: Location { + end_location: Some( + Location { row: 20, - column: 12, + column: 13, }, - end_location: Some( - Location { - row: 20, - column: 13, + ), + custom: (), + node: Assign( + StmtAssign { + targets: [ + Located { + location: Location { + row: 20, + column: 8, + }, + end_location: Some( + Location { + row: 20, + column: 9, + }, + ), + custom: (), + node: Name( + ExprName { + id: "y", + ctx: Store, + }, + ), + }, + ], + value: Located { + location: Location { + row: 20, + column: 12, + }, + end_location: Some( + Location { + row: 20, + column: 13, + }, + ), + custom: (), + node: Constant( + ExprConstant { + value: Int( + 0, + ), + kind: None, + }, + ), }, - ), - custom: (), - node: Constant { - value: Int( - 0, - ), - kind: None, + type_comment: None, }, - }, - type_comment: None, + ), }, - }, - ], - }, - ], - }, + ], + }, + ], + }, + ), }, ] diff --git a/parser/src/snapshots/rustpython_parser__parser__tests__match_as_identifier.snap b/parser/src/snapshots/rustpython_parser__parser__tests__match_as_identifier.snap index 2fb15a7f..ab62b796 100644 --- a/parser/src/snapshots/rustpython_parser__parser__tests__match_as_identifier.snap +++ b/parser/src/snapshots/rustpython_parser__parser__tests__match_as_identifier.snap @@ -1,5 +1,5 @@ --- -source: compiler/parser/src/parser.rs +source: parser/src/parser.rs expression: parse_ast --- [ @@ -15,35 +15,24 @@ expression: parse_ast }, ), custom: (), - node: Expr { - value: Located { - location: Location { - row: 2, - column: 0, - }, - end_location: Some( - Location { + node: Expr( + StmtExpr { + value: Located { + location: Location { row: 2, - column: 15, + column: 0, }, - ), - custom: (), - node: Tuple { - elts: [ - Located { - location: Location { - row: 2, - column: 0, - }, - end_location: Some( - Location { - row: 2, - column: 12, - }, - ), - custom: (), - node: BinOp { - left: Located { + end_location: Some( + Location { + row: 2, + column: 15, + }, + ), + custom: (), + node: Tuple( + ExprTuple { + elts: [ + Located { location: Location { row: 2, column: 0, @@ -51,90 +40,117 @@ expression: parse_ast end_location: Some( Location { row: 2, - column: 8, + column: 12, }, ), custom: (), - node: BinOp { - left: Located { - location: Location { - row: 2, - column: 0, - }, - end_location: Some( - Location { + node: BinOp( + ExprBinOp { + left: Located { + location: Location { row: 2, - column: 5, + column: 0, }, - ), - custom: (), - node: Name { - id: "match", - ctx: Load, - }, - }, - op: Mult, - right: Located { - location: Location { - row: 2, - column: 7, + end_location: Some( + Location { + row: 2, + column: 8, + }, + ), + custom: (), + node: BinOp( + ExprBinOp { + left: Located { + location: Location { + row: 2, + column: 0, + }, + end_location: Some( + Location { + row: 2, + column: 5, + }, + ), + custom: (), + node: Name( + ExprName { + id: "match", + ctx: Load, + }, + ), + }, + op: Mult, + right: Located { + location: Location { + row: 2, + column: 7, + }, + end_location: Some( + Location { + row: 2, + column: 8, + }, + ), + custom: (), + node: Name( + ExprName { + id: "a", + ctx: Load, + }, + ), + }, + }, + ), }, - end_location: Some( - Location { + op: Add, + right: Located { + location: Location { row: 2, - column: 8, + column: 11, }, - ), - custom: (), - node: Name { - id: "a", - ctx: Load, + end_location: Some( + Location { + row: 2, + column: 12, + }, + ), + custom: (), + node: Name( + ExprName { + id: "b", + ctx: Load, + }, + ), }, }, - }, + ), }, - op: Add, - right: Located { + Located { location: Location { row: 2, - column: 11, + column: 14, }, end_location: Some( Location { row: 2, - column: 12, + column: 15, }, ), custom: (), - node: Name { - id: "b", - ctx: Load, - }, - }, - }, - }, - Located { - location: Location { - row: 2, - column: 14, - }, - end_location: Some( - Location { - row: 2, - column: 15, + node: Name( + ExprName { + id: "c", + ctx: Load, + }, + ), }, - ), - custom: (), - node: Name { - id: "c", - ctx: Load, - }, + ], + ctx: Load, }, - ], - ctx: Load, + ), }, }, - }, + ), }, Located { location: Location { @@ -148,35 +164,24 @@ expression: parse_ast }, ), custom: (), - node: Expr { - value: Located { - location: Location { - row: 3, - column: 0, - }, - end_location: Some( - Location { + node: Expr( + StmtExpr { + value: Located { + location: Location { row: 3, - column: 17, + column: 0, }, - ), - custom: (), - node: Tuple { - elts: [ - Located { - location: Location { - row: 3, - column: 0, - }, - end_location: Some( - Location { - row: 3, - column: 14, - }, - ), - custom: (), - node: BinOp { - left: Located { + end_location: Some( + Location { + row: 3, + column: 17, + }, + ), + custom: (), + node: Tuple( + ExprTuple { + elts: [ + Located { location: Location { row: 3, column: 0, @@ -184,90 +189,117 @@ expression: parse_ast end_location: Some( Location { row: 3, - column: 5, + column: 14, }, ), custom: (), - node: Name { - id: "match", - ctx: Load, - }, + node: BinOp( + ExprBinOp { + left: Located { + location: Location { + row: 3, + column: 0, + }, + end_location: Some( + Location { + row: 3, + column: 5, + }, + ), + custom: (), + node: Name( + ExprName { + id: "match", + ctx: Load, + }, + ), + }, + op: Mult, + right: Located { + location: Location { + row: 3, + column: 8, + }, + end_location: Some( + Location { + row: 3, + column: 13, + }, + ), + custom: (), + node: BinOp( + ExprBinOp { + left: Located { + location: Location { + row: 3, + column: 8, + }, + end_location: Some( + Location { + row: 3, + column: 9, + }, + ), + custom: (), + node: Name( + ExprName { + id: "a", + ctx: Load, + }, + ), + }, + op: Add, + right: Located { + location: Location { + row: 3, + column: 12, + }, + end_location: Some( + Location { + row: 3, + column: 13, + }, + ), + custom: (), + node: Name( + ExprName { + id: "b", + ctx: Load, + }, + ), + }, + }, + ), + }, + }, + ), }, - op: Mult, - right: Located { + Located { location: Location { row: 3, - column: 8, + column: 16, }, end_location: Some( Location { row: 3, - column: 13, + column: 17, }, ), custom: (), - node: BinOp { - left: Located { - location: Location { - row: 3, - column: 8, - }, - end_location: Some( - Location { - row: 3, - column: 9, - }, - ), - custom: (), - node: Name { - id: "a", - ctx: Load, - }, - }, - op: Add, - right: Located { - location: Location { - row: 3, - column: 12, - }, - end_location: Some( - Location { - row: 3, - column: 13, - }, - ), - custom: (), - node: Name { - id: "b", - ctx: Load, - }, + node: Name( + ExprName { + id: "c", + ctx: Load, }, - }, - }, - }, - }, - Located { - location: Location { - row: 3, - column: 16, - }, - end_location: Some( - Location { - row: 3, - column: 17, + ), }, - ), - custom: (), - node: Name { - id: "c", - ctx: Load, - }, + ], + ctx: Load, }, - ], - ctx: Load, + ), }, }, - }, + ), }, Located { location: Location { @@ -281,55 +313,46 @@ expression: parse_ast }, ), custom: (), - node: Expr { - value: Located { - location: Location { - row: 4, - column: 0, - }, - end_location: Some( - Location { + node: Expr( + StmtExpr { + value: Located { + location: Location { row: 4, - column: 17, + column: 0, }, - ), - custom: (), - node: Call { - func: Located { - location: Location { + end_location: Some( + Location { row: 4, - column: 0, - }, - end_location: Some( - Location { - row: 4, - column: 5, - }, - ), - custom: (), - node: Name { - id: "match", - ctx: Load, + column: 17, }, - }, - args: [ - Located { - location: Location { - row: 4, - column: 7, - }, - end_location: Some( - Location { + ), + custom: (), + node: Call( + ExprCall { + func: Located { + location: Location { row: 4, - column: 13, + column: 0, }, - ), - custom: (), - node: Starred { - value: Located { + end_location: Some( + Location { + row: 4, + column: 5, + }, + ), + custom: (), + node: Name( + ExprName { + id: "match", + ctx: Load, + }, + ), + }, + args: [ + Located { location: Location { row: 4, - column: 8, + column: 7, }, end_location: Some( Location { @@ -338,69 +361,94 @@ expression: parse_ast }, ), custom: (), - node: BinOp { - left: Located { - location: Location { - row: 4, - column: 8, - }, - end_location: Some( - Location { - row: 4, - column: 9, - }, - ), - custom: (), - node: Name { - id: "a", - ctx: Load, - }, - }, - op: Add, - right: Located { - location: Location { - row: 4, - column: 12, - }, - end_location: Some( - Location { + node: Starred( + ExprStarred { + value: Located { + location: Location { row: 4, - column: 13, + column: 8, }, - ), - custom: (), - node: Name { - id: "b", - ctx: Load, + end_location: Some( + Location { + row: 4, + column: 13, + }, + ), + custom: (), + node: BinOp( + ExprBinOp { + left: Located { + location: Location { + row: 4, + column: 8, + }, + end_location: Some( + Location { + row: 4, + column: 9, + }, + ), + custom: (), + node: Name( + ExprName { + id: "a", + ctx: Load, + }, + ), + }, + op: Add, + right: Located { + location: Location { + row: 4, + column: 12, + }, + end_location: Some( + Location { + row: 4, + column: 13, + }, + ), + custom: (), + node: Name( + ExprName { + id: "b", + ctx: Load, + }, + ), + }, + }, + ), }, + ctx: Load, }, - }, + ), }, - ctx: Load, - }, - }, - Located { - location: Location { - row: 4, - column: 15, - }, - end_location: Some( - Location { - row: 4, - column: 16, + Located { + location: Location { + row: 4, + column: 15, + }, + end_location: Some( + Location { + row: 4, + column: 16, + }, + ), + custom: (), + node: Name( + ExprName { + id: "c", + ctx: Load, + }, + ), }, - ), - custom: (), - node: Name { - id: "c", - ctx: Load, - }, + ], + keywords: [], }, - ], - keywords: [], + ), }, }, - }, + ), }, Located { location: Location { @@ -414,33 +462,22 @@ expression: parse_ast }, ), custom: (), - node: Expr { - value: Located { - location: Location { - row: 5, - column: 0, - }, - end_location: Some( - Location { + node: Expr( + StmtExpr { + value: Located { + location: Location { row: 5, - column: 16, + column: 0, }, - ), - custom: (), - node: BinOp { - left: Located { - location: Location { + end_location: Some( + Location { row: 5, - column: 0, + column: 16, }, - end_location: Some( - Location { - row: 5, - column: 12, - }, - ), - custom: (), - node: BinOp { + ), + custom: (), + node: BinOp( + ExprBinOp { left: Located { location: Location { row: 5, @@ -449,89 +486,116 @@ expression: parse_ast end_location: Some( Location { row: 5, - column: 5, + column: 12, }, ), custom: (), - node: Name { - id: "match", - ctx: Load, - }, + node: BinOp( + ExprBinOp { + left: Located { + location: Location { + row: 5, + column: 0, + }, + end_location: Some( + Location { + row: 5, + column: 5, + }, + ), + custom: (), + node: Name( + ExprName { + id: "match", + ctx: Load, + }, + ), + }, + op: Sub, + right: Located { + location: Location { + row: 5, + column: 7, + }, + end_location: Some( + Location { + row: 5, + column: 12, + }, + ), + custom: (), + node: BinOp( + ExprBinOp { + left: Located { + location: Location { + row: 5, + column: 7, + }, + end_location: Some( + Location { + row: 5, + column: 8, + }, + ), + custom: (), + node: Name( + ExprName { + id: "a", + ctx: Load, + }, + ), + }, + op: Mult, + right: Located { + location: Location { + row: 5, + column: 11, + }, + end_location: Some( + Location { + row: 5, + column: 12, + }, + ), + custom: (), + node: Name( + ExprName { + id: "b", + ctx: Load, + }, + ), + }, + }, + ), + }, + }, + ), }, - op: Sub, + op: Add, right: Located { location: Location { row: 5, - column: 7, + column: 15, }, end_location: Some( Location { row: 5, - column: 12, + column: 16, }, ), custom: (), - node: BinOp { - left: Located { - location: Location { - row: 5, - column: 7, - }, - end_location: Some( - Location { - row: 5, - column: 8, - }, - ), - custom: (), - node: Name { - id: "a", - ctx: Load, - }, - }, - op: Mult, - right: Located { - location: Location { - row: 5, - column: 11, - }, - end_location: Some( - Location { - row: 5, - column: 12, - }, - ), - custom: (), - node: Name { - id: "b", - ctx: Load, - }, + node: Name( + ExprName { + id: "c", + ctx: Load, }, - }, - }, - }, - }, - op: Add, - right: Located { - location: Location { - row: 5, - column: 15, - }, - end_location: Some( - Location { - row: 5, - column: 16, + ), }, - ), - custom: (), - node: Name { - id: "c", - ctx: Load, }, - }, + ), }, }, - }, + ), }, Located { location: Location { @@ -545,33 +609,22 @@ expression: parse_ast }, ), custom: (), - node: Expr { - value: Located { - location: Location { - row: 6, - column: 0, - }, - end_location: Some( - Location { + node: Expr( + StmtExpr { + value: Located { + location: Location { row: 6, - column: 18, + column: 0, }, - ), - custom: (), - node: BinOp { - left: Located { - location: Location { + end_location: Some( + Location { row: 6, - column: 0, + column: 18, }, - end_location: Some( - Location { - row: 6, - column: 14, - }, - ), - custom: (), - node: BinOp { + ), + custom: (), + node: BinOp( + ExprBinOp { left: Located { location: Location { row: 6, @@ -580,89 +633,116 @@ expression: parse_ast end_location: Some( Location { row: 6, - column: 5, + column: 14, }, ), custom: (), - node: Name { - id: "match", - ctx: Load, - }, + node: BinOp( + ExprBinOp { + left: Located { + location: Location { + row: 6, + column: 0, + }, + end_location: Some( + Location { + row: 6, + column: 5, + }, + ), + custom: (), + node: Name( + ExprName { + id: "match", + ctx: Load, + }, + ), + }, + op: Sub, + right: Located { + location: Location { + row: 6, + column: 8, + }, + end_location: Some( + Location { + row: 6, + column: 13, + }, + ), + custom: (), + node: BinOp( + ExprBinOp { + left: Located { + location: Location { + row: 6, + column: 8, + }, + end_location: Some( + Location { + row: 6, + column: 9, + }, + ), + custom: (), + node: Name( + ExprName { + id: "a", + ctx: Load, + }, + ), + }, + op: Mult, + right: Located { + location: Location { + row: 6, + column: 12, + }, + end_location: Some( + Location { + row: 6, + column: 13, + }, + ), + custom: (), + node: Name( + ExprName { + id: "b", + ctx: Load, + }, + ), + }, + }, + ), + }, + }, + ), }, - op: Sub, + op: Add, right: Located { location: Location { row: 6, - column: 8, + column: 17, }, end_location: Some( Location { row: 6, - column: 13, + column: 18, }, ), custom: (), - node: BinOp { - left: Located { - location: Location { - row: 6, - column: 8, - }, - end_location: Some( - Location { - row: 6, - column: 9, - }, - ), - custom: (), - node: Name { - id: "a", - ctx: Load, - }, - }, - op: Mult, - right: Located { - location: Location { - row: 6, - column: 12, - }, - end_location: Some( - Location { - row: 6, - column: 13, - }, - ), - custom: (), - node: Name { - id: "b", - ctx: Load, - }, + node: Name( + ExprName { + id: "c", + ctx: Load, }, - }, - }, - }, - }, - op: Add, - right: Located { - location: Location { - row: 6, - column: 17, - }, - end_location: Some( - Location { - row: 6, - column: 18, + ), }, - ), - custom: (), - node: Name { - id: "c", - ctx: Load, }, - }, + ), }, }, - }, + ), }, Located { location: Location { @@ -676,33 +756,22 @@ expression: parse_ast }, ), custom: (), - node: Expr { - value: Located { - location: Location { - row: 7, - column: 0, - }, - end_location: Some( - Location { + node: Expr( + StmtExpr { + value: Located { + location: Location { row: 7, - column: 18, + column: 0, }, - ), - custom: (), - node: BinOp { - left: Located { - location: Location { + end_location: Some( + Location { row: 7, - column: 0, + column: 18, }, - end_location: Some( - Location { - row: 7, - column: 14, - }, - ), - custom: (), - node: BinOp { + ), + custom: (), + node: BinOp( + ExprBinOp { left: Located { location: Location { row: 7, @@ -711,107 +780,136 @@ expression: parse_ast end_location: Some( Location { row: 7, - column: 10, + column: 14, }, ), custom: (), - node: Call { - func: Located { - location: Location { - row: 7, - column: 0, - }, - end_location: Some( - Location { - row: 7, - column: 5, - }, - ), - custom: (), - node: Name { - id: "match", - ctx: Load, - }, - }, - args: [ - Located { + node: BinOp( + ExprBinOp { + left: Located { location: Location { row: 7, - column: 7, + column: 0, }, end_location: Some( Location { row: 7, - column: 9, + column: 10, }, ), custom: (), - node: UnaryOp { - op: USub, - operand: Located { - location: Location { - row: 7, - column: 8, - }, - end_location: Some( - Location { + node: Call( + ExprCall { + func: Located { + location: Location { row: 7, - column: 9, + column: 0, }, - ), - custom: (), - node: Name { - id: "a", - ctx: Load, + end_location: Some( + Location { + row: 7, + column: 5, + }, + ), + custom: (), + node: Name( + ExprName { + id: "match", + ctx: Load, + }, + ), }, + args: [ + Located { + location: Location { + row: 7, + column: 7, + }, + end_location: Some( + Location { + row: 7, + column: 9, + }, + ), + custom: (), + node: UnaryOp( + ExprUnaryOp { + op: USub, + operand: Located { + location: Location { + row: 7, + column: 8, + }, + end_location: Some( + Location { + row: 7, + column: 9, + }, + ), + custom: (), + node: Name( + ExprName { + id: "a", + ctx: Load, + }, + ), + }, + }, + ), + }, + ], + keywords: [], }, + ), + }, + op: Mult, + right: Located { + location: Location { + row: 7, + column: 13, }, + end_location: Some( + Location { + row: 7, + column: 14, + }, + ), + custom: (), + node: Name( + ExprName { + id: "b", + ctx: Load, + }, + ), }, - ], - keywords: [], - }, + }, + ), }, - op: Mult, + op: Add, right: Located { location: Location { row: 7, - column: 13, + column: 17, }, end_location: Some( Location { row: 7, - column: 14, + column: 18, }, ), custom: (), - node: Name { - id: "b", - ctx: Load, - }, + node: Name( + ExprName { + id: "c", + ctx: Load, + }, + ), }, }, - }, - op: Add, - right: Located { - location: Location { - row: 7, - column: 17, - }, - end_location: Some( - Location { - row: 7, - column: 18, - }, - ), - custom: (), - node: Name { - id: "c", - ctx: Load, - }, - }, + ), }, }, - }, + ), }, Located { location: Location { @@ -825,34 +923,23 @@ expression: parse_ast }, ), custom: (), - node: Expr { - value: Located { - location: Location { - row: 8, - column: 0, - }, - end_location: Some( - Location { + node: Expr( + StmtExpr { + value: Located { + location: Location { row: 8, - column: 10, + column: 0, }, - ), - custom: (), - node: Attribute { - value: Located { - location: Location { + end_location: Some( + Location { row: 8, - column: 0, + column: 10, }, - end_location: Some( - Location { - row: 8, - column: 8, - }, - ), - custom: (), - node: Call { - func: Located { + ), + custom: (), + node: Attribute( + ExprAttribute { + value: Located { location: Location { row: 8, column: 0, @@ -860,24 +947,43 @@ expression: parse_ast end_location: Some( Location { row: 8, - column: 5, + column: 8, }, ), custom: (), - node: Name { - id: "match", - ctx: Load, - }, + node: Call( + ExprCall { + func: Located { + location: Location { + row: 8, + column: 0, + }, + end_location: Some( + Location { + row: 8, + column: 5, + }, + ), + custom: (), + node: Name( + ExprName { + id: "match", + ctx: Load, + }, + ), + }, + args: [], + keywords: [], + }, + ), }, - args: [], - keywords: [], + attr: "a", + ctx: Load, }, - }, - attr: "a", - ctx: Load, + ), }, }, - }, + ), }, Located { location: Location { @@ -891,34 +997,23 @@ expression: parse_ast }, ), custom: (), - node: Expr { - value: Located { - location: Location { - row: 9, - column: 0, - }, - end_location: Some( - Location { + node: Expr( + StmtExpr { + value: Located { + location: Location { row: 9, - column: 12, + column: 0, }, - ), - custom: (), - node: Attribute { - value: Located { - location: Location { + end_location: Some( + Location { row: 9, - column: 0, + column: 12, }, - end_location: Some( - Location { - row: 9, - column: 10, - }, - ), - custom: (), - node: Call { - func: Located { + ), + custom: (), + node: Attribute( + ExprAttribute { + value: Located { location: Location { row: 9, column: 0, @@ -926,42 +1021,63 @@ expression: parse_ast end_location: Some( Location { row: 9, - column: 5, + column: 10, }, ), custom: (), - node: Name { - id: "match", - ctx: Load, - }, - }, - args: [ - Located { - location: Location { - row: 9, - column: 7, - }, - end_location: Some( - Location { - row: 9, - column: 9, + node: Call( + ExprCall { + func: Located { + location: Location { + row: 9, + column: 0, + }, + end_location: Some( + Location { + row: 9, + column: 5, + }, + ), + custom: (), + node: Name( + ExprName { + id: "match", + ctx: Load, + }, + ), }, - ), - custom: (), - node: Tuple { - elts: [], - ctx: Load, + args: [ + Located { + location: Location { + row: 9, + column: 7, + }, + end_location: Some( + Location { + row: 9, + column: 9, + }, + ), + custom: (), + node: Tuple( + ExprTuple { + elts: [], + ctx: Load, + }, + ), + }, + ], + keywords: [], }, - }, - ], - keywords: [], + ), + }, + attr: "a", + ctx: Load, }, - }, - attr: "a", - ctx: Load, + ), }, }, - }, + ), }, Located { location: Location { @@ -975,34 +1091,23 @@ expression: parse_ast }, ), custom: (), - node: Expr { - value: Located { - location: Location { - row: 10, - column: 0, - }, - end_location: Some( - Location { + node: Expr( + StmtExpr { + value: Located { + location: Location { row: 10, - column: 13, + column: 0, }, - ), - custom: (), - node: Attribute { - value: Located { - location: Location { + end_location: Some( + Location { row: 10, - column: 0, + column: 13, }, - end_location: Some( - Location { - row: 10, - column: 11, - }, - ), - custom: (), - node: Call { - func: Located { + ), + custom: (), + node: Attribute( + ExprAttribute { + value: Located { location: Location { row: 10, column: 0, @@ -1010,42 +1115,63 @@ expression: parse_ast end_location: Some( Location { row: 10, - column: 5, + column: 11, }, ), custom: (), - node: Name { - id: "match", - ctx: Load, - }, - }, - args: [ - Located { - location: Location { - row: 10, - column: 7, - }, - end_location: Some( - Location { - row: 10, - column: 9, + node: Call( + ExprCall { + func: Located { + location: Location { + row: 10, + column: 0, + }, + end_location: Some( + Location { + row: 10, + column: 5, + }, + ), + custom: (), + node: Name( + ExprName { + id: "match", + ctx: Load, + }, + ), }, - ), - custom: (), - node: Tuple { - elts: [], - ctx: Load, + args: [ + Located { + location: Location { + row: 10, + column: 7, + }, + end_location: Some( + Location { + row: 10, + column: 9, + }, + ), + custom: (), + node: Tuple( + ExprTuple { + elts: [], + ctx: Load, + }, + ), + }, + ], + keywords: [], }, - }, - ], - keywords: [], + ), + }, + attr: "a", + ctx: Load, }, - }, - attr: "a", - ctx: Load, + ), }, }, - }, + ), }, Located { location: Location { @@ -1059,33 +1185,22 @@ expression: parse_ast }, ), custom: (), - node: Expr { - value: Located { - location: Location { - row: 11, - column: 0, - }, - end_location: Some( - Location { + node: Expr( + StmtExpr { + value: Located { + location: Location { row: 11, - column: 11, + column: 0, }, - ), - custom: (), - node: Attribute { - value: Located { - location: Location { + end_location: Some( + Location { row: 11, - column: 0, + column: 11, }, - end_location: Some( - Location { - row: 11, - column: 9, - }, - ), - custom: (), - node: Subscript { + ), + custom: (), + node: Attribute( + ExprAttribute { value: Located { location: Location { row: 11, @@ -1094,40 +1209,61 @@ expression: parse_ast end_location: Some( Location { row: 11, - column: 5, + column: 9, }, ), custom: (), - node: Name { - id: "match", - ctx: Load, - }, - }, - slice: Located { - location: Location { - row: 11, - column: 7, - }, - end_location: Some( - Location { - row: 11, - column: 8, + node: Subscript( + ExprSubscript { + value: Located { + location: Location { + row: 11, + column: 0, + }, + end_location: Some( + Location { + row: 11, + column: 5, + }, + ), + custom: (), + node: Name( + ExprName { + id: "match", + ctx: Load, + }, + ), + }, + slice: Located { + location: Location { + row: 11, + column: 7, + }, + end_location: Some( + Location { + row: 11, + column: 8, + }, + ), + custom: (), + node: Name( + ExprName { + id: "a", + ctx: Load, + }, + ), + }, + ctx: Load, }, ), - custom: (), - node: Name { - id: "a", - ctx: Load, - }, }, + attr: "b", ctx: Load, }, - }, - attr: "b", - ctx: Load, + ), }, }, - }, + ), }, Located { location: Location { @@ -1141,33 +1277,22 @@ expression: parse_ast }, ), custom: (), - node: Expr { - value: Located { - location: Location { - row: 12, - column: 0, - }, - end_location: Some( - Location { + node: Expr( + StmtExpr { + value: Located { + location: Location { row: 12, - column: 12, + column: 0, }, - ), - custom: (), - node: Attribute { - value: Located { - location: Location { + end_location: Some( + Location { row: 12, - column: 0, + column: 12, }, - end_location: Some( - Location { - row: 12, - column: 10, - }, - ), - custom: (), - node: Subscript { + ), + custom: (), + node: Attribute( + ExprAttribute { value: Located { location: Location { row: 12, @@ -1176,58 +1301,81 @@ expression: parse_ast end_location: Some( Location { row: 12, - column: 5, + column: 10, }, ), custom: (), - node: Name { - id: "match", - ctx: Load, - }, - }, - slice: Located { - location: Location { - row: 12, - column: 7, - }, - end_location: Some( - Location { - row: 12, - column: 9, - }, - ), - custom: (), - node: Tuple { - elts: [ - Located { + node: Subscript( + ExprSubscript { + value: Located { location: Location { row: 12, - column: 7, + column: 0, }, end_location: Some( Location { row: 12, - column: 8, + column: 5, }, ), custom: (), - node: Name { - id: "a", - ctx: Load, + node: Name( + ExprName { + id: "match", + ctx: Load, + }, + ), + }, + slice: Located { + location: Location { + row: 12, + column: 7, }, + end_location: Some( + Location { + row: 12, + column: 9, + }, + ), + custom: (), + node: Tuple( + ExprTuple { + elts: [ + Located { + location: Location { + row: 12, + column: 7, + }, + end_location: Some( + Location { + row: 12, + column: 8, + }, + ), + custom: (), + node: Name( + ExprName { + id: "a", + ctx: Load, + }, + ), + }, + ], + ctx: Load, + }, + ), }, - ], - ctx: Load, - }, + ctx: Load, + }, + ), }, + attr: "b", ctx: Load, }, - }, - attr: "b", - ctx: Load, + ), }, }, - }, + ), }, Located { location: Location { @@ -1241,33 +1389,22 @@ expression: parse_ast }, ), custom: (), - node: Expr { - value: Located { - location: Location { - row: 13, - column: 0, - }, - end_location: Some( - Location { + node: Expr( + StmtExpr { + value: Located { + location: Location { row: 13, - column: 14, + column: 0, }, - ), - custom: (), - node: Attribute { - value: Located { - location: Location { + end_location: Some( + Location { row: 13, - column: 0, + column: 14, }, - end_location: Some( - Location { - row: 13, - column: 12, - }, - ), - custom: (), - node: Subscript { + ), + custom: (), + node: Attribute( + ExprAttribute { value: Located { location: Location { row: 13, @@ -1276,58 +1413,81 @@ expression: parse_ast end_location: Some( Location { row: 13, - column: 5, - }, - ), - custom: (), - node: Name { - id: "match", - ctx: Load, - }, - }, - slice: Located { - location: Location { - row: 13, - column: 7, - }, - end_location: Some( - Location { - row: 13, - column: 11, + column: 12, }, ), custom: (), - node: Tuple { - elts: [ - Located { + node: Subscript( + ExprSubscript { + value: Located { location: Location { row: 13, - column: 8, + column: 0, }, end_location: Some( Location { row: 13, - column: 9, + column: 5, }, ), custom: (), - node: Name { - id: "a", - ctx: Load, + node: Name( + ExprName { + id: "match", + ctx: Load, + }, + ), + }, + slice: Located { + location: Location { + row: 13, + column: 7, }, + end_location: Some( + Location { + row: 13, + column: 11, + }, + ), + custom: (), + node: Tuple( + ExprTuple { + elts: [ + Located { + location: Location { + row: 13, + column: 8, + }, + end_location: Some( + Location { + row: 13, + column: 9, + }, + ), + custom: (), + node: Name( + ExprName { + id: "a", + ctx: Load, + }, + ), + }, + ], + ctx: Load, + }, + ), }, - ], - ctx: Load, - }, + ctx: Load, + }, + ), }, + attr: "b", ctx: Load, }, - }, - attr: "b", - ctx: Load, + ), }, }, - }, + ), }, Located { location: Location { @@ -1341,34 +1501,23 @@ expression: parse_ast }, ), custom: (), - node: Expr { - value: Located { - location: Location { - row: 14, - column: 0, - }, - end_location: Some( - Location { - row: 15, - column: 6, + node: Expr( + StmtExpr { + value: Located { + location: Location { + row: 14, + column: 0, }, - ), - custom: (), - node: Subscript { - value: Located { - location: Location { - row: 14, - column: 0, + end_location: Some( + Location { + row: 15, + column: 6, }, - end_location: Some( - Location { - row: 14, - column: 7, - }, - ), - custom: (), - node: Call { - func: Located { + ), + custom: (), + node: Subscript( + ExprSubscript { + value: Located { location: Location { row: 14, column: 0, @@ -1376,77 +1525,102 @@ expression: parse_ast end_location: Some( Location { row: 14, - column: 5, + column: 7, }, ), custom: (), - node: Name { - id: "match", - ctx: Load, - }, - }, - args: [], - keywords: [], - }, - }, - slice: Located { - location: Location { - row: 14, - column: 8, - }, - end_location: Some( - Location { - row: 15, - column: 5, - }, - ), - custom: (), - node: Slice { - lower: Some( - Located { - location: Location { - row: 14, - column: 8, - }, - end_location: Some( - Location { - row: 14, - column: 9, + node: Call( + ExprCall { + func: Located { + location: Location { + row: 14, + column: 0, + }, + end_location: Some( + Location { + row: 14, + column: 5, + }, + ), + custom: (), + node: Name( + ExprName { + id: "match", + ctx: Load, + }, + ), }, - ), - custom: (), - node: Name { - id: "a", - ctx: Load, + args: [], + keywords: [], }, + ), + }, + slice: Located { + location: Location { + row: 14, + column: 8, }, - ), - upper: Some( - Located { - location: Location { + end_location: Some( + Location { row: 15, - column: 4, + column: 5, }, - end_location: Some( - Location { - row: 15, - column: 5, - }, - ), - custom: (), - node: Name { - id: "b", - ctx: Load, + ), + custom: (), + node: Slice( + ExprSlice { + lower: Some( + Located { + location: Location { + row: 14, + column: 8, + }, + end_location: Some( + Location { + row: 14, + column: 9, + }, + ), + custom: (), + node: Name( + ExprName { + id: "a", + ctx: Load, + }, + ), + }, + ), + upper: Some( + Located { + location: Location { + row: 15, + column: 4, + }, + end_location: Some( + Location { + row: 15, + column: 5, + }, + ), + custom: (), + node: Name( + ExprName { + id: "b", + ctx: Load, + }, + ), + }, + ), + step: None, }, - }, - ), - step: None, + ), + }, + ctx: Load, }, - }, - ctx: Load, + ), }, }, - }, + ), }, Located { location: Location { @@ -1460,76 +1634,84 @@ expression: parse_ast }, ), custom: (), - node: If { - test: Located { - location: Location { - row: 16, - column: 3, - }, - end_location: Some( - Location { + node: If( + StmtIf { + test: Located { + location: Location { row: 16, - column: 13, + column: 3, }, - ), - custom: (), - node: NamedExpr { - target: Located { - location: Location { + end_location: Some( + Location { row: 16, - column: 3, + column: 13, }, - end_location: Some( - Location { - row: 16, - column: 8, + ), + custom: (), + node: NamedExpr( + ExprNamedExpr { + target: Located { + location: Location { + row: 16, + column: 3, + }, + end_location: Some( + Location { + row: 16, + column: 8, + }, + ), + custom: (), + node: Name( + ExprName { + id: "match", + ctx: Store, + }, + ), + }, + value: Located { + location: Location { + row: 16, + column: 12, + }, + end_location: Some( + Location { + row: 16, + column: 13, + }, + ), + custom: (), + node: Constant( + ExprConstant { + value: Int( + 1, + ), + kind: None, + }, + ), }, - ), - custom: (), - node: Name { - id: "match", - ctx: Store, }, - }, - value: Located { + ), + }, + body: [ + Located { location: Location { row: 16, - column: 12, + column: 15, }, end_location: Some( Location { row: 16, - column: 13, + column: 19, }, ), custom: (), - node: Constant { - value: Int( - 1, - ), - kind: None, - }, + node: Pass, }, - }, + ], + orelse: [], }, - body: [ - Located { - location: Location { - row: 16, - column: 15, - }, - end_location: Some( - Location { - row: 16, - column: 19, - }, - ), - custom: (), - node: Pass, - }, - ], - orelse: [], - }, + ), }, Located { location: Location { @@ -1543,133 +1725,145 @@ expression: parse_ast }, ), custom: (), - node: Match { - subject: Located { - location: Location { - row: 17, - column: 6, - }, - end_location: Some( - Location { + node: Match( + StmtMatch { + subject: Located { + location: Location { row: 17, - column: 11, + column: 6, }, - ), - custom: (), - node: Name { - id: "match", - ctx: Load, - }, - }, - cases: [ - MatchCase { - pattern: Located { - location: Location { - row: 18, - column: 9, + end_location: Some( + Location { + row: 17, + column: 11, }, - end_location: Some( - Location { - row: 18, - column: 10, - }, - ), - custom: (), - node: MatchValue { - value: Located { - location: Location { - row: 18, - column: 9, - }, - end_location: Some( - Location { - row: 18, - column: 10, - }, - ), - custom: (), - node: Constant { - value: Int( - 1, - ), - kind: None, - }, - }, + ), + custom: (), + node: Name( + ExprName { + id: "match", + ctx: Load, }, - }, - guard: None, - body: [ - Located { + ), + }, + cases: [ + MatchCase { + pattern: Located { location: Location { row: 18, - column: 12, + column: 9, }, end_location: Some( Location { row: 18, - column: 16, + column: 10, }, ), custom: (), - node: Pass, - }, - ], - }, - MatchCase { - pattern: Located { - location: Location { - row: 19, - column: 9, + node: MatchValue( + PatternMatchValue { + value: Located { + location: Location { + row: 18, + column: 9, + }, + end_location: Some( + Location { + row: 18, + column: 10, + }, + ), + custom: (), + node: Constant( + ExprConstant { + value: Int( + 1, + ), + kind: None, + }, + ), + }, + }, + ), }, - end_location: Some( - Location { - row: 19, - column: 10, - }, - ), - custom: (), - node: MatchValue { - value: Located { + guard: None, + body: [ + Located { location: Location { - row: 19, - column: 9, + row: 18, + column: 12, }, end_location: Some( Location { - row: 19, - column: 10, + row: 18, + column: 16, }, ), custom: (), - node: Constant { - value: Int( - 2, - ), - kind: None, - }, + node: Pass, }, - }, + ], }, - guard: None, - body: [ - Located { + MatchCase { + pattern: Located { location: Location { - row: 20, - column: 8, + row: 19, + column: 9, }, end_location: Some( Location { - row: 20, - column: 12, + row: 19, + column: 10, }, ), custom: (), - node: Pass, + node: MatchValue( + PatternMatchValue { + value: Located { + location: Location { + row: 19, + column: 9, + }, + end_location: Some( + Location { + row: 19, + column: 10, + }, + ), + custom: (), + node: Constant( + ExprConstant { + value: Int( + 2, + ), + kind: None, + }, + ), + }, + }, + ), }, - ], - }, - ], - }, + guard: None, + body: [ + Located { + location: Location { + row: 20, + column: 8, + }, + end_location: Some( + Location { + row: 20, + column: 12, + }, + ), + custom: (), + node: Pass, + }, + ], + }, + ], + }, + ), }, Located { location: Location { @@ -1683,81 +1877,72 @@ expression: parse_ast }, ), custom: (), - node: Assign { - targets: [ - Located { + node: Assign( + StmtAssign { + targets: [ + Located { + location: Location { + row: 21, + column: 0, + }, + end_location: Some( + Location { + row: 21, + column: 5, + }, + ), + custom: (), + node: Name( + ExprName { + id: "match", + ctx: Store, + }, + ), + }, + ], + value: Located { location: Location { row: 21, - column: 0, + column: 8, }, end_location: Some( Location { row: 21, - column: 5, + column: 36, }, ), custom: (), - node: Name { - id: "match", - ctx: Store, - }, - }, - ], - value: Located { - location: Location { - row: 21, - column: 8, - }, - end_location: Some( - Location { - row: 21, - column: 36, - }, - ), - custom: (), - node: Lambda { - args: Arguments { - posonlyargs: [], - args: [ - Located { - location: Location { - row: 21, - column: 15, - }, - end_location: Some( - Location { - row: 21, - column: 20, + node: Lambda( + ExprLambda { + args: Arguments { + posonlyargs: [], + args: [ + Located { + location: Location { + row: 21, + column: 15, + }, + end_location: Some( + Location { + row: 21, + column: 20, + }, + ), + custom: (), + node: ArgData { + arg: "query", + annotation: None, + type_comment: None, + }, }, - ), - custom: (), - node: ArgData { - arg: "query", - annotation: None, - type_comment: None, - }, - }, - ], - vararg: None, - kwonlyargs: [], - kw_defaults: [], - kwarg: None, - defaults: [], - }, - body: Located { - location: Location { - row: 21, - column: 22, - }, - end_location: Some( - Location { - row: 21, - column: 36, + ], + vararg: None, + kwonlyargs: [], + kw_defaults: [], + kwarg: None, + defaults: [], }, - ), - custom: (), - node: Compare { - left: Located { + body: Located { location: Location { row: 21, column: 22, @@ -1765,43 +1950,64 @@ expression: parse_ast end_location: Some( Location { row: 21, - column: 27, + column: 36, }, ), custom: (), - node: Name { - id: "query", - ctx: Load, - }, - }, - ops: [ - Eq, - ], - comparators: [ - Located { - location: Location { - row: 21, - column: 31, - }, - end_location: Some( - Location { - row: 21, - column: 36, + node: Compare( + ExprCompare { + left: Located { + location: Location { + row: 21, + column: 22, + }, + end_location: Some( + Location { + row: 21, + column: 27, + }, + ), + custom: (), + node: Name( + ExprName { + id: "query", + ctx: Load, + }, + ), }, - ), - custom: (), - node: Name { - id: "event", - ctx: Load, + ops: [ + Eq, + ], + comparators: [ + Located { + location: Location { + row: 21, + column: 31, + }, + end_location: Some( + Location { + row: 21, + column: 36, + }, + ), + custom: (), + node: Name( + ExprName { + id: "event", + ctx: Load, + }, + ), + }, + ], }, - }, - ], + ), + }, }, - }, + ), }, + type_comment: None, }, - type_comment: None, - }, + ), }, Located { location: Location { @@ -1815,52 +2021,43 @@ expression: parse_ast }, ), custom: (), - node: Expr { - value: Located { - location: Location { - row: 22, - column: 0, - }, - end_location: Some( - Location { + node: Expr( + StmtExpr { + value: Located { + location: Location { row: 22, - column: 16, + column: 0, }, - ), - custom: (), - node: Call { - func: Located { - location: Location { + end_location: Some( + Location { row: 22, - column: 0, - }, - end_location: Some( - Location { - row: 22, - column: 5, - }, - ), - custom: (), - node: Name { - id: "print", - ctx: Load, + column: 16, }, - }, - args: [ - Located { - location: Location { - row: 22, - column: 6, - }, - end_location: Some( - Location { + ), + custom: (), + node: Call( + ExprCall { + func: Located { + location: Location { row: 22, - column: 15, + column: 0, }, - ), - custom: (), - node: Call { - func: Located { + end_location: Some( + Location { + row: 22, + column: 5, + }, + ), + custom: (), + node: Name( + ExprName { + id: "print", + ctx: Load, + }, + ), + }, + args: [ + Located { location: Location { row: 22, column: 6, @@ -1868,43 +2065,64 @@ expression: parse_ast end_location: Some( Location { row: 22, - column: 11, + column: 15, }, ), custom: (), - node: Name { - id: "match", - ctx: Load, - }, - }, - args: [ - Located { - location: Location { - row: 22, - column: 12, - }, - end_location: Some( - Location { - row: 22, - column: 14, + node: Call( + ExprCall { + func: Located { + location: Location { + row: 22, + column: 6, + }, + end_location: Some( + Location { + row: 22, + column: 11, + }, + ), + custom: (), + node: Name( + ExprName { + id: "match", + ctx: Load, + }, + ), }, - ), - custom: (), - node: Constant { - value: Int( - 12, - ), - kind: None, + args: [ + Located { + location: Location { + row: 22, + column: 12, + }, + end_location: Some( + Location { + row: 22, + column: 14, + }, + ), + custom: (), + node: Constant( + ExprConstant { + value: Int( + 12, + ), + kind: None, + }, + ), + }, + ], + keywords: [], }, - }, - ], - keywords: [], - }, + ), + }, + ], + keywords: [], }, - ], - keywords: [], + ), }, }, - }, + ), }, ] diff --git a/parser/src/snapshots/rustpython_parser__parser__tests__parse_bool_op_and.snap b/parser/src/snapshots/rustpython_parser__parser__tests__parse_bool_op_and.snap index f0e85620..12afcdde 100644 --- a/parser/src/snapshots/rustpython_parser__parser__tests__parse_bool_op_and.snap +++ b/parser/src/snapshots/rustpython_parser__parser__tests__parse_bool_op_and.snap @@ -1,5 +1,5 @@ --- -source: compiler/parser/src/parser.rs +source: parser/src/parser.rs expression: parse_ast --- Located { @@ -14,43 +14,49 @@ Located { }, ), custom: (), - node: BoolOp { - op: And, - values: [ - Located { - location: Location { - row: 1, - column: 0, - }, - end_location: Some( - Location { + node: BoolOp( + ExprBoolOp { + op: And, + values: [ + Located { + location: Location { row: 1, - column: 1, + column: 0, }, - ), - custom: (), - node: Name { - id: "x", - ctx: Load, - }, - }, - Located { - location: Location { - row: 1, - column: 6, + end_location: Some( + Location { + row: 1, + column: 1, + }, + ), + custom: (), + node: Name( + ExprName { + id: "x", + ctx: Load, + }, + ), }, - end_location: Some( - Location { + Located { + location: Location { row: 1, - column: 7, + column: 6, }, - ), - custom: (), - node: Name { - id: "y", - ctx: Load, + end_location: Some( + Location { + row: 1, + column: 7, + }, + ), + custom: (), + node: Name( + ExprName { + id: "y", + ctx: Load, + }, + ), }, - }, - ], - }, + ], + }, + ), } diff --git a/parser/src/snapshots/rustpython_parser__parser__tests__parse_bool_op_or.snap b/parser/src/snapshots/rustpython_parser__parser__tests__parse_bool_op_or.snap index 5d5abad3..891088c7 100644 --- a/parser/src/snapshots/rustpython_parser__parser__tests__parse_bool_op_or.snap +++ b/parser/src/snapshots/rustpython_parser__parser__tests__parse_bool_op_or.snap @@ -1,5 +1,5 @@ --- -source: compiler/parser/src/parser.rs +source: parser/src/parser.rs expression: parse_ast --- Located { @@ -14,43 +14,49 @@ Located { }, ), custom: (), - node: BoolOp { - op: Or, - values: [ - Located { - location: Location { - row: 1, - column: 0, - }, - end_location: Some( - Location { + node: BoolOp( + ExprBoolOp { + op: Or, + values: [ + Located { + location: Location { row: 1, - column: 1, + column: 0, }, - ), - custom: (), - node: Name { - id: "x", - ctx: Load, - }, - }, - Located { - location: Location { - row: 1, - column: 5, + end_location: Some( + Location { + row: 1, + column: 1, + }, + ), + custom: (), + node: Name( + ExprName { + id: "x", + ctx: Load, + }, + ), }, - end_location: Some( - Location { + Located { + location: Location { row: 1, - column: 6, + column: 5, }, - ), - custom: (), - node: Name { - id: "y", - ctx: Load, + end_location: Some( + Location { + row: 1, + column: 6, + }, + ), + custom: (), + node: Name( + ExprName { + id: "y", + ctx: Load, + }, + ), }, - }, - ], - }, + ], + }, + ), } diff --git a/parser/src/snapshots/rustpython_parser__parser__tests__parse_class.snap b/parser/src/snapshots/rustpython_parser__parser__tests__parse_class.snap index 22b15410..caff1dda 100644 --- a/parser/src/snapshots/rustpython_parser__parser__tests__parse_class.snap +++ b/parser/src/snapshots/rustpython_parser__parser__tests__parse_class.snap @@ -1,5 +1,5 @@ --- -source: compiler/parser/src/parser.rs +source: parser/src/parser.rs expression: "parse_program(source, \"\").unwrap()" --- [ @@ -15,212 +15,224 @@ expression: "parse_program(source, \"\").unwrap()" }, ), custom: (), - node: ClassDef { - name: "Foo", - bases: [ - Located { - location: Location { - row: 1, - column: 10, - }, - end_location: Some( - Location { + node: ClassDef( + StmtClassDef { + name: "Foo", + bases: [ + Located { + location: Location { row: 1, - column: 11, + column: 10, }, - ), - custom: (), - node: Name { - id: "A", - ctx: Load, - }, - }, - Located { - location: Location { - row: 1, - column: 13, + end_location: Some( + Location { + row: 1, + column: 11, + }, + ), + custom: (), + node: Name( + ExprName { + id: "A", + ctx: Load, + }, + ), }, - end_location: Some( - Location { + Located { + location: Location { row: 1, - column: 14, + column: 13, }, - ), - custom: (), - node: Name { - id: "B", - ctx: Load, - }, - }, - ], - keywords: [], - body: [ - Located { - location: Location { - row: 2, - column: 1, + end_location: Some( + Location { + row: 1, + column: 14, + }, + ), + custom: (), + node: Name( + ExprName { + id: "B", + ctx: Load, + }, + ), }, - end_location: Some( - Location { - row: 3, - column: 6, + ], + keywords: [], + body: [ + Located { + location: Location { + row: 2, + column: 1, }, - ), - custom: (), - node: FunctionDef { - name: "__init__", - args: Arguments { - posonlyargs: [], - args: [ - Located { - location: Location { - row: 2, - column: 14, - }, - end_location: Some( - Location { - row: 2, - column: 18, + end_location: Some( + Location { + row: 3, + column: 6, + }, + ), + custom: (), + node: FunctionDef( + StmtFunctionDef { + name: "__init__", + args: Arguments { + posonlyargs: [], + args: [ + Located { + location: Location { + row: 2, + column: 14, + }, + end_location: Some( + Location { + row: 2, + column: 18, + }, + ), + custom: (), + node: ArgData { + arg: "self", + annotation: None, + type_comment: None, + }, }, - ), - custom: (), - node: ArgData { - arg: "self", - annotation: None, - type_comment: None, - }, - }, - ], - vararg: None, - kwonlyargs: [], - kw_defaults: [], - kwarg: None, - defaults: [], - }, - body: [ - Located { - location: Location { - row: 3, - column: 2, + ], + vararg: None, + kwonlyargs: [], + kw_defaults: [], + kwarg: None, + defaults: [], }, - end_location: Some( - Location { - row: 3, - column: 6, + body: [ + Located { + location: Location { + row: 3, + column: 2, + }, + end_location: Some( + Location { + row: 3, + column: 6, + }, + ), + custom: (), + node: Pass, }, - ), - custom: (), - node: Pass, + ], + decorator_list: [], + returns: None, + type_comment: None, }, - ], - decorator_list: [], - returns: None, - type_comment: None, - }, - }, - Located { - location: Location { - row: 4, - column: 1, + ), }, - end_location: Some( - Location { - row: 5, - column: 6, + Located { + location: Location { + row: 4, + column: 1, }, - ), - custom: (), - node: FunctionDef { - name: "method_with_default", - args: Arguments { - posonlyargs: [], - args: [ - Located { - location: Location { - row: 4, - column: 25, - }, - end_location: Some( - Location { - row: 4, - column: 29, + end_location: Some( + Location { + row: 5, + column: 6, + }, + ), + custom: (), + node: FunctionDef( + StmtFunctionDef { + name: "method_with_default", + args: Arguments { + posonlyargs: [], + args: [ + Located { + location: Location { + row: 4, + column: 25, + }, + end_location: Some( + Location { + row: 4, + column: 29, + }, + ), + custom: (), + node: ArgData { + arg: "self", + annotation: None, + type_comment: None, + }, }, - ), - custom: (), - node: ArgData { - arg: "self", - annotation: None, - type_comment: None, - }, - }, - Located { - location: Location { - row: 4, - column: 31, - }, - end_location: Some( - Location { - row: 4, - column: 34, + Located { + location: Location { + row: 4, + column: 31, + }, + end_location: Some( + Location { + row: 4, + column: 34, + }, + ), + custom: (), + node: ArgData { + arg: "arg", + annotation: None, + type_comment: None, + }, }, - ), - custom: (), - node: ArgData { - arg: "arg", - annotation: None, - type_comment: None, - }, + ], + vararg: None, + kwonlyargs: [], + kw_defaults: [], + kwarg: None, + defaults: [ + Located { + location: Location { + row: 4, + column: 35, + }, + end_location: Some( + Location { + row: 4, + column: 44, + }, + ), + custom: (), + node: Constant( + ExprConstant { + value: Str( + "default", + ), + kind: None, + }, + ), + }, + ], }, - ], - vararg: None, - kwonlyargs: [], - kw_defaults: [], - kwarg: None, - defaults: [ - Located { - location: Location { - row: 4, - column: 35, - }, - end_location: Some( - Location { - row: 4, - column: 44, + body: [ + Located { + location: Location { + row: 5, + column: 2, }, - ), - custom: (), - node: Constant { - value: Str( - "default", + end_location: Some( + Location { + row: 5, + column: 6, + }, ), - kind: None, + custom: (), + node: Pass, }, - }, - ], - }, - body: [ - Located { - location: Location { - row: 5, - column: 2, - }, - end_location: Some( - Location { - row: 5, - column: 6, - }, - ), - custom: (), - node: Pass, + ], + decorator_list: [], + returns: None, + type_comment: None, }, - ], - decorator_list: [], - returns: None, - type_comment: None, + ), }, - }, - ], - decorator_list: [], - }, + ], + decorator_list: [], + }, + ), }, ] diff --git a/parser/src/snapshots/rustpython_parser__parser__tests__parse_dict_comprehension.snap b/parser/src/snapshots/rustpython_parser__parser__tests__parse_dict_comprehension.snap index 2c0bc513..07d1d698 100644 --- a/parser/src/snapshots/rustpython_parser__parser__tests__parse_dict_comprehension.snap +++ b/parser/src/snapshots/rustpython_parser__parser__tests__parse_dict_comprehension.snap @@ -1,5 +1,5 @@ --- -source: compiler/parser/src/parser.rs +source: parser/src/parser.rs expression: parse_ast --- Located { @@ -14,80 +14,90 @@ Located { }, ), custom: (), - node: DictComp { - key: Located { - location: Location { - row: 1, - column: 1, - }, - end_location: Some( - Location { + node: DictComp( + ExprDictComp { + key: Located { + location: Location { row: 1, - column: 3, + column: 1, }, - ), - custom: (), - node: Name { - id: "x1", - ctx: Load, - }, - }, - value: Located { - location: Location { - row: 1, - column: 5, + end_location: Some( + Location { + row: 1, + column: 3, + }, + ), + custom: (), + node: Name( + ExprName { + id: "x1", + ctx: Load, + }, + ), }, - end_location: Some( - Location { + value: Located { + location: Location { row: 1, - column: 7, + column: 5, }, - ), - custom: (), - node: Name { - id: "x2", - ctx: Load, - }, - }, - generators: [ - Comprehension { - target: Located { - location: Location { + end_location: Some( + Location { row: 1, - column: 12, + column: 7, + }, + ), + custom: (), + node: Name( + ExprName { + id: "x2", + ctx: Load, }, - end_location: Some( - Location { + ), + }, + generators: [ + Comprehension { + target: Located { + location: Location { row: 1, - column: 13, + column: 12, }, - ), - custom: (), - node: Name { - id: "y", - ctx: Store, - }, - }, - iter: Located { - location: Location { - row: 1, - column: 17, + end_location: Some( + Location { + row: 1, + column: 13, + }, + ), + custom: (), + node: Name( + ExprName { + id: "y", + ctx: Store, + }, + ), }, - end_location: Some( - Location { + iter: Located { + location: Location { row: 1, - column: 18, + column: 17, }, - ), - custom: (), - node: Name { - id: "z", - ctx: Load, + end_location: Some( + Location { + row: 1, + column: 18, + }, + ), + custom: (), + node: Name( + ExprName { + id: "z", + ctx: Load, + }, + ), }, + ifs: [], + is_async: 0, }, - ifs: [], - is_async: 0, - }, - ], - }, + ], + }, + ), } diff --git a/parser/src/snapshots/rustpython_parser__parser__tests__parse_double_list_comprehension.snap b/parser/src/snapshots/rustpython_parser__parser__tests__parse_double_list_comprehension.snap index f8346b5c..681c80fd 100644 --- a/parser/src/snapshots/rustpython_parser__parser__tests__parse_double_list_comprehension.snap +++ b/parser/src/snapshots/rustpython_parser__parser__tests__parse_double_list_comprehension.snap @@ -1,5 +1,5 @@ --- -source: compiler/parser/src/parser.rs +source: parser/src/parser.rs expression: parse_ast --- Located { @@ -14,249 +14,277 @@ Located { }, ), custom: (), - node: ListComp { - elt: Located { - location: Location { - row: 1, - column: 1, - }, - end_location: Some( - Location { + node: ListComp( + ExprListComp { + elt: Located { + location: Location { row: 1, - column: 2, + column: 1, }, - ), - custom: (), - node: Name { - id: "x", - ctx: Load, - }, - }, - generators: [ - Comprehension { - target: Located { - location: Location { + end_location: Some( + Location { row: 1, - column: 7, + column: 2, }, - end_location: Some( - Location { - row: 1, - column: 12, - }, - ), - custom: (), - node: Tuple { - elts: [ - Located { - location: Location { - row: 1, - column: 7, - }, - end_location: Some( - Location { - row: 1, - column: 8, - }, - ), - custom: (), - node: Name { - id: "y", - ctx: Store, - }, - }, - Located { - location: Location { - row: 1, - column: 10, - }, - end_location: Some( - Location { - row: 1, - column: 12, - }, - ), - custom: (), - node: Name { - id: "y2", - ctx: Store, - }, - }, - ], - ctx: Store, - }, - }, - iter: Located { - location: Location { - row: 1, - column: 16, - }, - end_location: Some( - Location { - row: 1, - column: 17, - }, - ), - custom: (), - node: Name { - id: "z", + ), + custom: (), + node: Name( + ExprName { + id: "x", ctx: Load, }, - }, - ifs: [], - is_async: 0, + ), }, - Comprehension { - target: Located { - location: Location { - row: 1, - column: 22, - }, - end_location: Some( - Location { + generators: [ + Comprehension { + target: Located { + location: Location { row: 1, - column: 23, + column: 7, }, - ), - custom: (), - node: Name { - id: "a", - ctx: Store, - }, - }, - iter: Located { - location: Location { - row: 1, - column: 27, + end_location: Some( + Location { + row: 1, + column: 12, + }, + ), + custom: (), + node: Tuple( + ExprTuple { + elts: [ + Located { + location: Location { + row: 1, + column: 7, + }, + end_location: Some( + Location { + row: 1, + column: 8, + }, + ), + custom: (), + node: Name( + ExprName { + id: "y", + ctx: Store, + }, + ), + }, + Located { + location: Location { + row: 1, + column: 10, + }, + end_location: Some( + Location { + row: 1, + column: 12, + }, + ), + custom: (), + node: Name( + ExprName { + id: "y2", + ctx: Store, + }, + ), + }, + ], + ctx: Store, + }, + ), }, - end_location: Some( - Location { + iter: Located { + location: Location { row: 1, - column: 28, + column: 16, }, - ), - custom: (), - node: Name { - id: "b", - ctx: Load, + end_location: Some( + Location { + row: 1, + column: 17, + }, + ), + custom: (), + node: Name( + ExprName { + id: "z", + ctx: Load, + }, + ), }, + ifs: [], + is_async: 0, }, - ifs: [ - Located { + Comprehension { + target: Located { location: Location { row: 1, - column: 32, + column: 22, }, end_location: Some( Location { row: 1, - column: 37, + column: 23, }, ), custom: (), - node: Compare { - left: Located { - location: Location { - row: 1, - column: 32, - }, - end_location: Some( - Location { - row: 1, - column: 33, - }, - ), - custom: (), - node: Name { - id: "a", - ctx: Load, - }, + node: Name( + ExprName { + id: "a", + ctx: Store, }, - ops: [ - Lt, - ], - comparators: [ - Located { - location: Location { - row: 1, - column: 36, - }, - end_location: Some( - Location { - row: 1, - column: 37, - }, - ), - custom: (), - node: Constant { - value: Int( - 5, - ), - kind: None, - }, - }, - ], - }, + ), }, - Located { + iter: Located { location: Location { row: 1, - column: 41, + column: 27, }, end_location: Some( Location { row: 1, - column: 47, + column: 28, }, ), custom: (), - node: Compare { - left: Located { - location: Location { + node: Name( + ExprName { + id: "b", + ctx: Load, + }, + ), + }, + ifs: [ + Located { + location: Location { + row: 1, + column: 32, + }, + end_location: Some( + Location { row: 1, - column: 41, + column: 37, }, - end_location: Some( - Location { - row: 1, - column: 42, + ), + custom: (), + node: Compare( + ExprCompare { + left: Located { + location: Location { + row: 1, + column: 32, + }, + end_location: Some( + Location { + row: 1, + column: 33, + }, + ), + custom: (), + node: Name( + ExprName { + id: "a", + ctx: Load, + }, + ), }, - ), - custom: (), - node: Name { - id: "a", - ctx: Load, + ops: [ + Lt, + ], + comparators: [ + Located { + location: Location { + row: 1, + column: 36, + }, + end_location: Some( + Location { + row: 1, + column: 37, + }, + ), + custom: (), + node: Constant( + ExprConstant { + value: Int( + 5, + ), + kind: None, + }, + ), + }, + ], }, + ), + }, + Located { + location: Location { + row: 1, + column: 41, }, - ops: [ - Gt, - ], - comparators: [ - Located { - location: Location { - row: 1, - column: 45, - }, - end_location: Some( - Location { + end_location: Some( + Location { + row: 1, + column: 47, + }, + ), + custom: (), + node: Compare( + ExprCompare { + left: Located { + location: Location { row: 1, - column: 47, + column: 41, }, - ), - custom: (), - node: Constant { - value: Int( - 10, + end_location: Some( + Location { + row: 1, + column: 42, + }, + ), + custom: (), + node: Name( + ExprName { + id: "a", + ctx: Load, + }, ), - kind: None, }, + ops: [ + Gt, + ], + comparators: [ + Located { + location: Location { + row: 1, + column: 45, + }, + end_location: Some( + Location { + row: 1, + column: 47, + }, + ), + custom: (), + node: Constant( + ExprConstant { + value: Int( + 10, + ), + kind: None, + }, + ), + }, + ], }, - ], + ), }, - }, - ], - is_async: 0, - }, - ], - }, + ], + is_async: 0, + }, + ], + }, + ), } diff --git a/parser/src/snapshots/rustpython_parser__parser__tests__parse_f_string.snap b/parser/src/snapshots/rustpython_parser__parser__tests__parse_f_string.snap index 14009d32..4546ff4b 100644 --- a/parser/src/snapshots/rustpython_parser__parser__tests__parse_f_string.snap +++ b/parser/src/snapshots/rustpython_parser__parser__tests__parse_f_string.snap @@ -1,5 +1,5 @@ --- -source: compiler/parser/src/parser.rs +source: parser/src/parser.rs expression: parse_ast --- [ @@ -15,43 +15,49 @@ expression: parse_ast }, ), custom: (), - node: Expr { - value: Located { - location: Location { - row: 1, - column: 0, - }, - end_location: Some( - Location { + node: Expr( + StmtExpr { + value: Located { + location: Location { row: 1, - column: 14, + column: 0, }, - ), - custom: (), - node: JoinedStr { - values: [ - Located { - location: Location { - row: 1, - column: 0, - }, - end_location: Some( - Location { - row: 1, - column: 14, + end_location: Some( + Location { + row: 1, + column: 14, + }, + ), + custom: (), + node: JoinedStr( + ExprJoinedStr { + values: [ + Located { + location: Location { + row: 1, + column: 0, + }, + end_location: Some( + Location { + row: 1, + column: 14, + }, + ), + custom: (), + node: Constant( + ExprConstant { + value: Str( + "Hello world", + ), + kind: None, + }, + ), }, - ), - custom: (), - node: Constant { - value: Str( - "Hello world", - ), - kind: None, - }, + ], }, - ], + ), }, }, - }, + ), }, ] diff --git a/parser/src/snapshots/rustpython_parser__parser__tests__parse_generator_comprehension.snap b/parser/src/snapshots/rustpython_parser__parser__tests__parse_generator_comprehension.snap index 89e05b28..3756cc8b 100644 --- a/parser/src/snapshots/rustpython_parser__parser__tests__parse_generator_comprehension.snap +++ b/parser/src/snapshots/rustpython_parser__parser__tests__parse_generator_comprehension.snap @@ -1,5 +1,5 @@ --- -source: compiler/parser/src/parser.rs +source: parser/src/parser.rs expression: parse_ast --- Located { @@ -14,63 +14,71 @@ Located { }, ), custom: (), - node: GeneratorExp { - elt: Located { - location: Location { - row: 1, - column: 1, - }, - end_location: Some( - Location { + node: GeneratorExp( + ExprGeneratorExp { + elt: Located { + location: Location { row: 1, - column: 2, + column: 1, }, - ), - custom: (), - node: Name { - id: "x", - ctx: Load, - }, - }, - generators: [ - Comprehension { - target: Located { - location: Location { + end_location: Some( + Location { row: 1, - column: 7, + column: 2, }, - end_location: Some( - Location { + ), + custom: (), + node: Name( + ExprName { + id: "x", + ctx: Load, + }, + ), + }, + generators: [ + Comprehension { + target: Located { + location: Location { row: 1, - column: 8, + column: 7, }, - ), - custom: (), - node: Name { - id: "y", - ctx: Store, - }, - }, - iter: Located { - location: Location { - row: 1, - column: 12, + end_location: Some( + Location { + row: 1, + column: 8, + }, + ), + custom: (), + node: Name( + ExprName { + id: "y", + ctx: Store, + }, + ), }, - end_location: Some( - Location { + iter: Located { + location: Location { row: 1, - column: 13, + column: 12, }, - ), - custom: (), - node: Name { - id: "z", - ctx: Load, + end_location: Some( + Location { + row: 1, + column: 13, + }, + ), + custom: (), + node: Name( + ExprName { + id: "z", + ctx: Load, + }, + ), }, + ifs: [], + is_async: 0, }, - ifs: [], - is_async: 0, - }, - ], - }, + ], + }, + ), } diff --git a/parser/src/snapshots/rustpython_parser__parser__tests__parse_if_elif_else.snap b/parser/src/snapshots/rustpython_parser__parser__tests__parse_if_elif_else.snap index 26bd492b..ca8fea36 100644 --- a/parser/src/snapshots/rustpython_parser__parser__tests__parse_if_elif_else.snap +++ b/parser/src/snapshots/rustpython_parser__parser__tests__parse_if_elif_else.snap @@ -1,5 +1,5 @@ --- -source: compiler/parser/src/parser.rs +source: parser/src/parser.rs expression: parse_ast --- [ @@ -15,110 +15,107 @@ expression: parse_ast }, ), custom: (), - node: If { - test: Located { - location: Location { - row: 1, - column: 3, - }, - end_location: Some( - Location { - row: 1, - column: 4, - }, - ), - custom: (), - node: Constant { - value: Int( - 1, - ), - kind: None, - }, - }, - body: [ - Located { + node: If( + StmtIf { + test: Located { location: Location { row: 1, - column: 6, + column: 3, }, end_location: Some( Location { row: 1, - column: 8, + column: 4, }, ), custom: (), - node: Expr { - value: Located { - location: Location { - row: 1, - column: 6, - }, - end_location: Some( - Location { - row: 1, - column: 8, - }, + node: Constant( + ExprConstant { + value: Int( + 1, ), - custom: (), - node: Constant { - value: Int( - 10, - ), - kind: None, - }, + kind: None, }, - }, + ), }, - ], - orelse: [ - Located { - location: Location { - row: 2, - column: 0, - }, - end_location: Some( - Location { - row: 3, - column: 8, + body: [ + Located { + location: Location { + row: 1, + column: 6, }, - ), - custom: (), - node: If { - test: Located { - location: Location { - row: 2, - column: 5, + end_location: Some( + Location { + row: 1, + column: 8, }, - end_location: Some( - Location { - row: 2, - column: 6, + ), + custom: (), + node: Expr( + StmtExpr { + value: Located { + location: Location { + row: 1, + column: 6, + }, + end_location: Some( + Location { + row: 1, + column: 8, + }, + ), + custom: (), + node: Constant( + ExprConstant { + value: Int( + 10, + ), + kind: None, + }, + ), }, - ), - custom: (), - node: Constant { - value: Int( - 2, - ), - kind: None, }, + ), + }, + ], + orelse: [ + Located { + location: Location { + row: 2, + column: 0, }, - body: [ - Located { - location: Location { - row: 2, - column: 8, - }, - end_location: Some( - Location { + end_location: Some( + Location { + row: 3, + column: 8, + }, + ), + custom: (), + node: If( + StmtIf { + test: Located { + location: Location { row: 2, - column: 10, + column: 5, }, - ), - custom: (), - node: Expr { - value: Located { + end_location: Some( + Location { + row: 2, + column: 6, + }, + ), + custom: (), + node: Constant( + ExprConstant { + value: Int( + 2, + ), + kind: None, + }, + ), + }, + body: [ + Located { location: Location { row: 2, column: 8, @@ -130,31 +127,35 @@ expression: parse_ast }, ), custom: (), - node: Constant { - value: Int( - 20, - ), - kind: None, - }, - }, - }, - }, - ], - orelse: [ - Located { - location: Location { - row: 3, - column: 6, - }, - end_location: Some( - Location { - row: 3, - column: 8, + node: Expr( + StmtExpr { + value: Located { + location: Location { + row: 2, + column: 8, + }, + end_location: Some( + Location { + row: 2, + column: 10, + }, + ), + custom: (), + node: Constant( + ExprConstant { + value: Int( + 20, + ), + kind: None, + }, + ), + }, + }, + ), }, - ), - custom: (), - node: Expr { - value: Located { + ], + orelse: [ + Located { location: Location { row: 3, column: 6, @@ -166,19 +167,38 @@ expression: parse_ast }, ), custom: (), - node: Constant { - value: Int( - 30, - ), - kind: None, - }, + node: Expr( + StmtExpr { + value: Located { + location: Location { + row: 3, + column: 6, + }, + end_location: Some( + Location { + row: 3, + column: 8, + }, + ), + custom: (), + node: Constant( + ExprConstant { + value: Int( + 30, + ), + kind: None, + }, + ), + }, + }, + ), }, - }, + ], }, - ], + ), }, - }, - ], - }, + ], + }, + ), }, ] diff --git a/parser/src/snapshots/rustpython_parser__parser__tests__parse_if_else_generator_comprehension.snap b/parser/src/snapshots/rustpython_parser__parser__tests__parse_if_else_generator_comprehension.snap index 92b85877..34c9e9eb 100644 --- a/parser/src/snapshots/rustpython_parser__parser__tests__parse_if_else_generator_comprehension.snap +++ b/parser/src/snapshots/rustpython_parser__parser__tests__parse_if_else_generator_comprehension.snap @@ -1,5 +1,5 @@ --- -source: compiler/parser/src/parser.rs +source: parser/src/parser.rs expression: parse_ast --- Located { @@ -14,112 +14,126 @@ Located { }, ), custom: (), - node: GeneratorExp { - elt: Located { - location: Location { - row: 1, - column: 1, - }, - end_location: Some( - Location { + node: GeneratorExp( + ExprGeneratorExp { + elt: Located { + location: Location { row: 1, - column: 14, + column: 1, }, - ), - custom: (), - node: IfExp { - test: Located { - location: Location { + end_location: Some( + Location { row: 1, - column: 6, + column: 14, }, - end_location: Some( - Location { - row: 1, - column: 7, + ), + custom: (), + node: IfExp( + ExprIfExp { + test: Located { + location: Location { + row: 1, + column: 6, + }, + end_location: Some( + Location { + row: 1, + column: 7, + }, + ), + custom: (), + node: Name( + ExprName { + id: "y", + ctx: Load, + }, + ), }, - ), - custom: (), - node: Name { - id: "y", - ctx: Load, - }, - }, - body: Located { - location: Location { - row: 1, - column: 1, - }, - end_location: Some( - Location { - row: 1, - column: 2, + body: Located { + location: Location { + row: 1, + column: 1, + }, + end_location: Some( + Location { + row: 1, + column: 2, + }, + ), + custom: (), + node: Name( + ExprName { + id: "x", + ctx: Load, + }, + ), }, - ), - custom: (), - node: Name { - id: "x", - ctx: Load, - }, - }, - orelse: Located { - location: Location { - row: 1, - column: 13, - }, - end_location: Some( - Location { - row: 1, - column: 14, + orelse: Located { + location: Location { + row: 1, + column: 13, + }, + end_location: Some( + Location { + row: 1, + column: 14, + }, + ), + custom: (), + node: Name( + ExprName { + id: "y", + ctx: Load, + }, + ), }, - ), - custom: (), - node: Name { - id: "y", - ctx: Load, }, - }, + ), }, - }, - generators: [ - Comprehension { - target: Located { - location: Location { - row: 1, - column: 19, - }, - end_location: Some( - Location { + generators: [ + Comprehension { + target: Located { + location: Location { row: 1, - column: 20, + column: 19, }, - ), - custom: (), - node: Name { - id: "y", - ctx: Store, + end_location: Some( + Location { + row: 1, + column: 20, + }, + ), + custom: (), + node: Name( + ExprName { + id: "y", + ctx: Store, + }, + ), }, - }, - iter: Located { - location: Location { - row: 1, - column: 24, - }, - end_location: Some( - Location { + iter: Located { + location: Location { row: 1, - column: 25, + column: 24, }, - ), - custom: (), - node: Name { - id: "z", - ctx: Load, + end_location: Some( + Location { + row: 1, + column: 25, + }, + ), + custom: (), + node: Name( + ExprName { + id: "z", + ctx: Load, + }, + ), }, + ifs: [], + is_async: 0, }, - ifs: [], - is_async: 0, - }, - ], - }, + ], + }, + ), } diff --git a/parser/src/snapshots/rustpython_parser__parser__tests__parse_kwargs.snap b/parser/src/snapshots/rustpython_parser__parser__tests__parse_kwargs.snap index dfe98597..fbf09ebc 100644 --- a/parser/src/snapshots/rustpython_parser__parser__tests__parse_kwargs.snap +++ b/parser/src/snapshots/rustpython_parser__parser__tests__parse_kwargs.snap @@ -1,5 +1,5 @@ --- -source: compiler/parser/src/parser.rs +source: parser/src/parser.rs expression: parse_ast --- [ @@ -15,79 +15,69 @@ expression: parse_ast }, ), custom: (), - node: Expr { - value: Located { - location: Location { - row: 1, - column: 0, - }, - end_location: Some( - Location { + node: Expr( + StmtExpr { + value: Located { + location: Location { row: 1, - column: 32, + column: 0, }, - ), - custom: (), - node: Call { - func: Located { - location: Location { + end_location: Some( + Location { row: 1, - column: 0, - }, - end_location: Some( - Location { - row: 1, - column: 7, - }, - ), - custom: (), - node: Name { - id: "my_func", - ctx: Load, + column: 32, }, - }, - args: [ - Located { - location: Location { - row: 1, - column: 8, - }, - end_location: Some( - Location { + ), + custom: (), + node: Call( + ExprCall { + func: Located { + location: Location { row: 1, - column: 20, + column: 0, }, - ), - custom: (), - node: Constant { - value: Str( - "positional", + end_location: Some( + Location { + row: 1, + column: 7, + }, + ), + custom: (), + node: Name( + ExprName { + id: "my_func", + ctx: Load, + }, ), - kind: None, - }, - }, - ], - keywords: [ - Located { - location: Location { - row: 1, - column: 22, }, - end_location: Some( - Location { - row: 1, - column: 31, + args: [ + Located { + location: Location { + row: 1, + column: 8, + }, + end_location: Some( + Location { + row: 1, + column: 20, + }, + ), + custom: (), + node: Constant( + ExprConstant { + value: Str( + "positional", + ), + kind: None, + }, + ), }, - ), - custom: (), - node: KeywordData { - arg: Some( - "keyword", - ), - value: Located { + ], + keywords: [ + Located { location: Location { row: 1, - column: 30, + column: 22, }, end_location: Some( Location { @@ -96,18 +86,38 @@ expression: parse_ast }, ), custom: (), - node: Constant { - value: Int( - 2, + node: KeywordData { + arg: Some( + "keyword", ), - kind: None, + value: Located { + location: Location { + row: 1, + column: 30, + }, + end_location: Some( + Location { + row: 1, + column: 31, + }, + ), + custom: (), + node: Constant( + ExprConstant { + value: Int( + 2, + ), + kind: None, + }, + ), + }, }, }, - }, + ], }, - ], + ), }, }, - }, + ), }, ] diff --git a/parser/src/snapshots/rustpython_parser__parser__tests__parse_lambda.snap b/parser/src/snapshots/rustpython_parser__parser__tests__parse_lambda.snap index df154a37..3603fe31 100644 --- a/parser/src/snapshots/rustpython_parser__parser__tests__parse_lambda.snap +++ b/parser/src/snapshots/rustpython_parser__parser__tests__parse_lambda.snap @@ -1,5 +1,5 @@ --- -source: compiler/parser/src/parser.rs +source: parser/src/parser.rs expression: parse_ast --- [ @@ -15,80 +15,69 @@ expression: parse_ast }, ), custom: (), - node: Expr { - value: Located { - location: Location { - row: 1, - column: 0, - }, - end_location: Some( - Location { + node: Expr( + StmtExpr { + value: Located { + location: Location { row: 1, - column: 18, + column: 0, }, - ), - custom: (), - node: Lambda { - args: Arguments { - posonlyargs: [], - args: [ - Located { - location: Location { - row: 1, - column: 7, - }, - end_location: Some( - Location { - row: 1, - column: 8, - }, - ), - custom: (), - node: ArgData { - arg: "x", - annotation: None, - type_comment: None, - }, - }, - Located { - location: Location { - row: 1, - column: 10, - }, - end_location: Some( - Location { - row: 1, - column: 11, - }, - ), - custom: (), - node: ArgData { - arg: "y", - annotation: None, - type_comment: None, - }, - }, - ], - vararg: None, - kwonlyargs: [], - kw_defaults: [], - kwarg: None, - defaults: [], - }, - body: Located { - location: Location { + end_location: Some( + Location { row: 1, - column: 13, + column: 18, }, - end_location: Some( - Location { - row: 1, - column: 18, + ), + custom: (), + node: Lambda( + ExprLambda { + args: Arguments { + posonlyargs: [], + args: [ + Located { + location: Location { + row: 1, + column: 7, + }, + end_location: Some( + Location { + row: 1, + column: 8, + }, + ), + custom: (), + node: ArgData { + arg: "x", + annotation: None, + type_comment: None, + }, + }, + Located { + location: Location { + row: 1, + column: 10, + }, + end_location: Some( + Location { + row: 1, + column: 11, + }, + ), + custom: (), + node: ArgData { + arg: "y", + annotation: None, + type_comment: None, + }, + }, + ], + vararg: None, + kwonlyargs: [], + kw_defaults: [], + kwarg: None, + defaults: [], }, - ), - custom: (), - node: BinOp { - left: Located { + body: Located { location: Location { row: 1, column: 13, @@ -96,37 +85,58 @@ expression: parse_ast end_location: Some( Location { row: 1, - column: 14, + column: 18, }, ), custom: (), - node: Name { - id: "x", - ctx: Load, - }, - }, - op: Mult, - right: Located { - location: Location { - row: 1, - column: 17, - }, - end_location: Some( - Location { - row: 1, - column: 18, + node: BinOp( + ExprBinOp { + left: Located { + location: Location { + row: 1, + column: 13, + }, + end_location: Some( + Location { + row: 1, + column: 14, + }, + ), + custom: (), + node: Name( + ExprName { + id: "x", + ctx: Load, + }, + ), + }, + op: Mult, + right: Located { + location: Location { + row: 1, + column: 17, + }, + end_location: Some( + Location { + row: 1, + column: 18, + }, + ), + custom: (), + node: Name( + ExprName { + id: "y", + ctx: Load, + }, + ), + }, }, ), - custom: (), - node: Name { - id: "y", - ctx: Load, - }, }, }, - }, + ), }, }, - }, + ), }, ] diff --git a/parser/src/snapshots/rustpython_parser__parser__tests__parse_list_comprehension.snap b/parser/src/snapshots/rustpython_parser__parser__tests__parse_list_comprehension.snap index 9af8e55e..4a74317f 100644 --- a/parser/src/snapshots/rustpython_parser__parser__tests__parse_list_comprehension.snap +++ b/parser/src/snapshots/rustpython_parser__parser__tests__parse_list_comprehension.snap @@ -1,5 +1,5 @@ --- -source: compiler/parser/src/parser.rs +source: parser/src/parser.rs expression: parse_ast --- Located { @@ -14,63 +14,71 @@ Located { }, ), custom: (), - node: ListComp { - elt: Located { - location: Location { - row: 1, - column: 1, - }, - end_location: Some( - Location { + node: ListComp( + ExprListComp { + elt: Located { + location: Location { row: 1, - column: 2, + column: 1, }, - ), - custom: (), - node: Name { - id: "x", - ctx: Load, - }, - }, - generators: [ - Comprehension { - target: Located { - location: Location { + end_location: Some( + Location { row: 1, - column: 7, + column: 2, }, - end_location: Some( - Location { + ), + custom: (), + node: Name( + ExprName { + id: "x", + ctx: Load, + }, + ), + }, + generators: [ + Comprehension { + target: Located { + location: Location { row: 1, - column: 8, + column: 7, }, - ), - custom: (), - node: Name { - id: "y", - ctx: Store, - }, - }, - iter: Located { - location: Location { - row: 1, - column: 12, + end_location: Some( + Location { + row: 1, + column: 8, + }, + ), + custom: (), + node: Name( + ExprName { + id: "y", + ctx: Store, + }, + ), }, - end_location: Some( - Location { + iter: Located { + location: Location { row: 1, - column: 13, + column: 12, }, - ), - custom: (), - node: Name { - id: "z", - ctx: Load, + end_location: Some( + Location { + row: 1, + column: 13, + }, + ), + custom: (), + node: Name( + ExprName { + id: "z", + ctx: Load, + }, + ), }, + ifs: [], + is_async: 0, }, - ifs: [], - is_async: 0, - }, - ], - }, + ], + }, + ), } diff --git a/parser/src/snapshots/rustpython_parser__parser__tests__parse_named_expression_generator_comprehension.snap b/parser/src/snapshots/rustpython_parser__parser__tests__parse_named_expression_generator_comprehension.snap index 639bf21f..9375e6f2 100644 --- a/parser/src/snapshots/rustpython_parser__parser__tests__parse_named_expression_generator_comprehension.snap +++ b/parser/src/snapshots/rustpython_parser__parser__tests__parse_named_expression_generator_comprehension.snap @@ -1,5 +1,5 @@ --- -source: compiler/parser/src/parser.rs +source: parser/src/parser.rs expression: parse_ast --- Located { @@ -14,72 +14,45 @@ Located { }, ), custom: (), - node: GeneratorExp { - elt: Located { - location: Location { - row: 1, - column: 1, - }, - end_location: Some( - Location { + node: GeneratorExp( + ExprGeneratorExp { + elt: Located { + location: Location { row: 1, - column: 11, - }, - ), - custom: (), - node: NamedExpr { - target: Located { - location: Location { - row: 1, - column: 1, - }, - end_location: Some( - Location { - row: 1, - column: 2, - }, - ), - custom: (), - node: Name { - id: "x", - ctx: Store, - }, + column: 1, }, - value: Located { - location: Location { + end_location: Some( + Location { row: 1, - column: 6, + column: 11, }, - end_location: Some( - Location { - row: 1, - column: 11, - }, - ), - custom: (), - node: BinOp { - left: Located { + ), + custom: (), + node: NamedExpr( + ExprNamedExpr { + target: Located { location: Location { row: 1, - column: 6, + column: 1, }, end_location: Some( Location { row: 1, - column: 7, + column: 2, }, ), custom: (), - node: Name { - id: "y", - ctx: Load, - }, + node: Name( + ExprName { + id: "x", + ctx: Store, + }, + ), }, - op: Add, - right: Located { + value: Located { location: Location { row: 1, - column: 10, + column: 6, }, end_location: Some( Location { @@ -88,56 +61,99 @@ Located { }, ), custom: (), - node: Constant { - value: Int( - 1, - ), - kind: None, - }, + node: BinOp( + ExprBinOp { + left: Located { + location: Location { + row: 1, + column: 6, + }, + end_location: Some( + Location { + row: 1, + column: 7, + }, + ), + custom: (), + node: Name( + ExprName { + id: "y", + ctx: Load, + }, + ), + }, + op: Add, + right: Located { + location: Location { + row: 1, + column: 10, + }, + end_location: Some( + Location { + row: 1, + column: 11, + }, + ), + custom: (), + node: Constant( + ExprConstant { + value: Int( + 1, + ), + kind: None, + }, + ), + }, + }, + ), }, }, - }, + ), }, - }, - generators: [ - Comprehension { - target: Located { - location: Location { - row: 1, - column: 16, - }, - end_location: Some( - Location { + generators: [ + Comprehension { + target: Located { + location: Location { row: 1, - column: 17, + column: 16, }, - ), - custom: (), - node: Name { - id: "y", - ctx: Store, - }, - }, - iter: Located { - location: Location { - row: 1, - column: 21, + end_location: Some( + Location { + row: 1, + column: 17, + }, + ), + custom: (), + node: Name( + ExprName { + id: "y", + ctx: Store, + }, + ), }, - end_location: Some( - Location { + iter: Located { + location: Location { row: 1, - column: 22, + column: 21, }, - ), - custom: (), - node: Name { - id: "z", - ctx: Load, + end_location: Some( + Location { + row: 1, + column: 22, + }, + ), + custom: (), + node: Name( + ExprName { + id: "z", + ctx: Load, + }, + ), }, + ifs: [], + is_async: 0, }, - ifs: [], - is_async: 0, - }, - ], - }, + ], + }, + ), } diff --git a/parser/src/snapshots/rustpython_parser__parser__tests__parse_print_2.snap b/parser/src/snapshots/rustpython_parser__parser__tests__parse_print_2.snap index c782b8a8..c3f910b1 100644 --- a/parser/src/snapshots/rustpython_parser__parser__tests__parse_print_2.snap +++ b/parser/src/snapshots/rustpython_parser__parser__tests__parse_print_2.snap @@ -1,5 +1,5 @@ --- -source: compiler/parser/src/parser.rs +source: parser/src/parser.rs expression: parse_ast --- [ @@ -15,80 +15,90 @@ expression: parse_ast }, ), custom: (), - node: Expr { - value: Located { - location: Location { - row: 1, - column: 0, - }, - end_location: Some( - Location { + node: Expr( + StmtExpr { + value: Located { + location: Location { row: 1, - column: 23, + column: 0, }, - ), - custom: (), - node: Call { - func: Located { - location: Location { + end_location: Some( + Location { row: 1, - column: 0, - }, - end_location: Some( - Location { - row: 1, - column: 5, - }, - ), - custom: (), - node: Name { - id: "print", - ctx: Load, + column: 23, }, - }, - args: [ - Located { - location: Location { - row: 1, - column: 6, - }, - end_location: Some( - Location { + ), + custom: (), + node: Call( + ExprCall { + func: Located { + location: Location { row: 1, - column: 19, + column: 0, }, - ), - custom: (), - node: Constant { - value: Str( - "Hello world", + end_location: Some( + Location { + row: 1, + column: 5, + }, ), - kind: None, - }, - }, - Located { - location: Location { - row: 1, - column: 21, - }, - end_location: Some( - Location { - row: 1, - column: 22, - }, - ), - custom: (), - node: Constant { - value: Int( - 2, + custom: (), + node: Name( + ExprName { + id: "print", + ctx: Load, + }, ), - kind: None, }, + args: [ + Located { + location: Location { + row: 1, + column: 6, + }, + end_location: Some( + Location { + row: 1, + column: 19, + }, + ), + custom: (), + node: Constant( + ExprConstant { + value: Str( + "Hello world", + ), + kind: None, + }, + ), + }, + Located { + location: Location { + row: 1, + column: 21, + }, + end_location: Some( + Location { + row: 1, + column: 22, + }, + ), + custom: (), + node: Constant( + ExprConstant { + value: Int( + 2, + ), + kind: None, + }, + ), + }, + ], + keywords: [], }, - ], - keywords: [], + ), }, }, - }, + ), }, ] diff --git a/parser/src/snapshots/rustpython_parser__parser__tests__parse_print_hello.snap b/parser/src/snapshots/rustpython_parser__parser__tests__parse_print_hello.snap index 34f6ed85..92d6394a 100644 --- a/parser/src/snapshots/rustpython_parser__parser__tests__parse_print_hello.snap +++ b/parser/src/snapshots/rustpython_parser__parser__tests__parse_print_hello.snap @@ -1,5 +1,5 @@ --- -source: compiler/parser/src/parser.rs +source: parser/src/parser.rs expression: parse_ast --- [ @@ -15,61 +15,69 @@ expression: parse_ast }, ), custom: (), - node: Expr { - value: Located { - location: Location { - row: 1, - column: 0, - }, - end_location: Some( - Location { + node: Expr( + StmtExpr { + value: Located { + location: Location { row: 1, - column: 20, + column: 0, }, - ), - custom: (), - node: Call { - func: Located { - location: Location { + end_location: Some( + Location { row: 1, - column: 0, - }, - end_location: Some( - Location { - row: 1, - column: 5, - }, - ), - custom: (), - node: Name { - id: "print", - ctx: Load, + column: 20, }, - }, - args: [ - Located { - location: Location { - row: 1, - column: 6, - }, - end_location: Some( - Location { + ), + custom: (), + node: Call( + ExprCall { + func: Located { + location: Location { row: 1, - column: 19, + column: 0, }, - ), - custom: (), - node: Constant { - value: Str( - "Hello world", + end_location: Some( + Location { + row: 1, + column: 5, + }, + ), + custom: (), + node: Name( + ExprName { + id: "print", + ctx: Load, + }, ), - kind: None, }, + args: [ + Located { + location: Location { + row: 1, + column: 6, + }, + end_location: Some( + Location { + row: 1, + column: 19, + }, + ), + custom: (), + node: Constant( + ExprConstant { + value: Str( + "Hello world", + ), + kind: None, + }, + ), + }, + ], + keywords: [], }, - ], - keywords: [], + ), }, }, - }, + ), }, ] diff --git a/parser/src/snapshots/rustpython_parser__parser__tests__parse_string.snap b/parser/src/snapshots/rustpython_parser__parser__tests__parse_string.snap index d58f9e3a..2b1d1ff3 100644 --- a/parser/src/snapshots/rustpython_parser__parser__tests__parse_string.snap +++ b/parser/src/snapshots/rustpython_parser__parser__tests__parse_string.snap @@ -1,5 +1,5 @@ --- -source: compiler/parser/src/parser.rs +source: parser/src/parser.rs expression: parse_ast --- [ @@ -15,26 +15,30 @@ expression: parse_ast }, ), custom: (), - node: Expr { - value: Located { - location: Location { - row: 1, - column: 0, - }, - end_location: Some( - Location { + node: Expr( + StmtExpr { + value: Located { + location: Location { row: 1, - column: 13, + column: 0, }, - ), - custom: (), - node: Constant { - value: Str( - "Hello world", + end_location: Some( + Location { + row: 1, + column: 13, + }, + ), + custom: (), + node: Constant( + ExprConstant { + value: Str( + "Hello world", + ), + kind: None, + }, ), - kind: None, }, }, - }, + ), }, ] diff --git a/parser/src/snapshots/rustpython_parser__parser__tests__parse_tuples.snap b/parser/src/snapshots/rustpython_parser__parser__tests__parse_tuples.snap index 7be86281..1fc21d80 100644 --- a/parser/src/snapshots/rustpython_parser__parser__tests__parse_tuples.snap +++ b/parser/src/snapshots/rustpython_parser__parser__tests__parse_tuples.snap @@ -1,5 +1,5 @@ --- -source: compiler/parser/src/parser.rs +source: parser/src/parser.rs expression: "parse_program(source, \"\").unwrap()" --- [ @@ -15,118 +15,132 @@ expression: "parse_program(source, \"\").unwrap()" }, ), custom: (), - node: Assign { - targets: [ - Located { + node: Assign( + StmtAssign { + targets: [ + Located { + location: Location { + row: 1, + column: 0, + }, + end_location: Some( + Location { + row: 1, + column: 4, + }, + ), + custom: (), + node: Tuple( + ExprTuple { + elts: [ + Located { + location: Location { + row: 1, + column: 0, + }, + end_location: Some( + Location { + row: 1, + column: 1, + }, + ), + custom: (), + node: Name( + ExprName { + id: "a", + ctx: Store, + }, + ), + }, + Located { + location: Location { + row: 1, + column: 3, + }, + end_location: Some( + Location { + row: 1, + column: 4, + }, + ), + custom: (), + node: Name( + ExprName { + id: "b", + ctx: Store, + }, + ), + }, + ], + ctx: Store, + }, + ), + }, + ], + value: Located { location: Location { row: 1, - column: 0, + column: 7, }, end_location: Some( Location { row: 1, - column: 4, + column: 11, }, ), custom: (), - node: Tuple { - elts: [ - Located { - location: Location { - row: 1, - column: 0, - }, - end_location: Some( - Location { + node: Tuple( + ExprTuple { + elts: [ + Located { + location: Location { row: 1, - column: 1, + column: 7, }, - ), - custom: (), - node: Name { - id: "a", - ctx: Store, - }, - }, - Located { - location: Location { - row: 1, - column: 3, + end_location: Some( + Location { + row: 1, + column: 8, + }, + ), + custom: (), + node: Constant( + ExprConstant { + value: Int( + 4, + ), + kind: None, + }, + ), }, - end_location: Some( - Location { + Located { + location: Location { row: 1, - column: 4, + column: 10, }, - ), - custom: (), - node: Name { - id: "b", - ctx: Store, + end_location: Some( + Location { + row: 1, + column: 11, + }, + ), + custom: (), + node: Constant( + ExprConstant { + value: Int( + 5, + ), + kind: None, + }, + ), }, - }, - ], - ctx: Store, - }, - }, - ], - value: Located { - location: Location { - row: 1, - column: 7, - }, - end_location: Some( - Location { - row: 1, - column: 11, - }, - ), - custom: (), - node: Tuple { - elts: [ - Located { - location: Location { - row: 1, - column: 7, - }, - end_location: Some( - Location { - row: 1, - column: 8, - }, - ), - custom: (), - node: Constant { - value: Int( - 4, - ), - kind: None, - }, - }, - Located { - location: Location { - row: 1, - column: 10, - }, - end_location: Some( - Location { - row: 1, - column: 11, - }, - ), - custom: (), - node: Constant { - value: Int( - 5, - ), - kind: None, - }, + ], + ctx: Load, }, - ], - ctx: Load, + ), }, + type_comment: None, }, - type_comment: None, - }, + ), }, ] diff --git a/parser/src/snapshots/rustpython_parser__parser__tests__patma.snap b/parser/src/snapshots/rustpython_parser__parser__tests__patma.snap index 147ba242..91e59dd7 100644 --- a/parser/src/snapshots/rustpython_parser__parser__tests__patma.snap +++ b/parser/src/snapshots/rustpython_parser__parser__tests__patma.snap @@ -1,5 +1,5 @@ --- -source: compiler/parser/src/parser.rs +source: parser/src/parser.rs expression: parse_ast --- [ @@ -15,57 +15,47 @@ expression: parse_ast }, ), custom: (), - node: Match { - subject: Located { - location: Location { - row: 4, - column: 6, - }, - end_location: Some( - Location { + node: Match( + StmtMatch { + subject: Located { + location: Location { row: 4, - column: 7, + column: 6, }, - ), - custom: (), - node: Name { - id: "x", - ctx: Load, - }, - }, - cases: [ - MatchCase { - pattern: Located { - location: Location { - row: 5, - column: 9, + end_location: Some( + Location { + row: 4, + column: 7, + }, + ), + custom: (), + node: Name( + ExprName { + id: "x", + ctx: Load, }, - end_location: Some( - Location { + ), + }, + cases: [ + MatchCase { + pattern: Located { + location: Location { row: 5, - column: 12, + column: 9, }, - ), - custom: (), - node: MatchValue { - value: Located { - location: Location { + end_location: Some( + Location { row: 5, - column: 9, + column: 12, }, - end_location: Some( - Location { - row: 5, - column: 12, - }, - ), - custom: (), - node: UnaryOp { - op: USub, - operand: Located { + ), + custom: (), + node: MatchValue( + PatternMatchValue { + value: Located { location: Location { row: 5, - column: 10, + column: 9, }, end_location: Some( Location { @@ -74,78 +64,104 @@ expression: parse_ast }, ), custom: (), - node: Constant { - value: Complex { - real: 0.0, - imag: 0.0, + node: UnaryOp( + ExprUnaryOp { + op: USub, + operand: Located { + location: Location { + row: 5, + column: 10, + }, + end_location: Some( + Location { + row: 5, + column: 12, + }, + ), + custom: (), + node: Constant( + ExprConstant { + value: Complex { + real: 0.0, + imag: 0.0, + }, + kind: None, + }, + ), + }, }, - kind: None, - }, + ), }, }, - }, + ), }, - }, - guard: None, - body: [ - Located { - location: Location { - row: 6, - column: 8, - }, - end_location: Some( - Location { + guard: None, + body: [ + Located { + location: Location { row: 6, - column: 13, + column: 8, }, - ), - custom: (), - node: Assign { - targets: [ - Located { - location: Location { - row: 6, - column: 8, - }, - end_location: Some( - Location { - row: 6, - column: 9, - }, - ), - custom: (), - node: Name { - id: "y", - ctx: Store, - }, - }, - ], - value: Located { - location: Location { + end_location: Some( + Location { row: 6, - column: 12, + column: 13, }, - end_location: Some( - Location { - row: 6, - column: 13, + ), + custom: (), + node: Assign( + StmtAssign { + targets: [ + Located { + location: Location { + row: 6, + column: 8, + }, + end_location: Some( + Location { + row: 6, + column: 9, + }, + ), + custom: (), + node: Name( + ExprName { + id: "y", + ctx: Store, + }, + ), + }, + ], + value: Located { + location: Location { + row: 6, + column: 12, + }, + end_location: Some( + Location { + row: 6, + column: 13, + }, + ), + custom: (), + node: Constant( + ExprConstant { + value: Int( + 0, + ), + kind: None, + }, + ), }, - ), - custom: (), - node: Constant { - value: Int( - 0, - ), - kind: None, + type_comment: None, }, - }, - type_comment: None, + ), }, - }, - ], - }, - ], - }, + ], + }, + ], + }, + ), }, Located { location: Location { @@ -159,141 +175,157 @@ expression: parse_ast }, ), custom: (), - node: Match { - subject: Located { - location: Location { - row: 8, - column: 6, - }, - end_location: Some( - Location { + node: Match( + StmtMatch { + subject: Located { + location: Location { row: 8, - column: 7, + column: 6, }, - ), - custom: (), - node: Name { - id: "x", - ctx: Load, - }, - }, - cases: [ - MatchCase { - pattern: Located { - location: Location { - row: 9, - column: 9, + end_location: Some( + Location { + row: 8, + column: 7, }, - end_location: Some( - Location { - row: 9, - column: 17, - }, - ), - custom: (), - node: MatchClass { - cls: Located { - location: Location { - row: 9, - column: 9, - }, - end_location: Some( - Location { - row: 9, - column: 14, - }, - ), - custom: (), - node: Name { - id: "bytes", - ctx: Load, - }, - }, - patterns: [ - Located { - location: Location { - row: 9, - column: 15, - }, - end_location: Some( - Location { - row: 9, - column: 16, - }, - ), - custom: (), - node: MatchAs { - pattern: None, - name: Some( - "z", - ), - }, - }, - ], - kwd_attrs: [], - kwd_patterns: [], + ), + custom: (), + node: Name( + ExprName { + id: "x", + ctx: Load, }, - }, - guard: None, - body: [ - Located { + ), + }, + cases: [ + MatchCase { + pattern: Located { location: Location { - row: 10, - column: 8, + row: 9, + column: 9, }, end_location: Some( Location { - row: 10, - column: 13, + row: 9, + column: 17, }, ), custom: (), - node: Assign { - targets: [ - Located { + node: MatchClass( + PatternMatchClass { + cls: Located { location: Location { - row: 10, - column: 8, + row: 9, + column: 9, }, end_location: Some( Location { - row: 10, - column: 9, + row: 9, + column: 14, }, ), custom: (), - node: Name { - id: "y", - ctx: Store, - }, + node: Name( + ExprName { + id: "bytes", + ctx: Load, + }, + ), }, - ], - value: Located { - location: Location { + patterns: [ + Located { + location: Location { + row: 9, + column: 15, + }, + end_location: Some( + Location { + row: 9, + column: 16, + }, + ), + custom: (), + node: MatchAs( + PatternMatchAs { + pattern: None, + name: Some( + "z", + ), + }, + ), + }, + ], + kwd_attrs: [], + kwd_patterns: [], + }, + ), + }, + guard: None, + body: [ + Located { + location: Location { + row: 10, + column: 8, + }, + end_location: Some( + Location { row: 10, - column: 12, + column: 13, }, - end_location: Some( - Location { - row: 10, - column: 13, + ), + custom: (), + node: Assign( + StmtAssign { + targets: [ + Located { + location: Location { + row: 10, + column: 8, + }, + end_location: Some( + Location { + row: 10, + column: 9, + }, + ), + custom: (), + node: Name( + ExprName { + id: "y", + ctx: Store, + }, + ), + }, + ], + value: Located { + location: Location { + row: 10, + column: 12, + }, + end_location: Some( + Location { + row: 10, + column: 13, + }, + ), + custom: (), + node: Constant( + ExprConstant { + value: Int( + 0, + ), + kind: None, + }, + ), }, - ), - custom: (), - node: Constant { - value: Int( - 0, - ), - kind: None, + type_comment: None, }, - }, - type_comment: None, + ), }, - }, - ], - }, - ], - }, + ], + }, + ], + }, + ), }, Located { location: Location { @@ -307,253 +339,281 @@ expression: parse_ast }, ), custom: (), - node: Match { - subject: Located { - location: Location { - row: 12, - column: 6, - }, - end_location: Some( - Location { + node: Match( + StmtMatch { + subject: Located { + location: Location { row: 12, - column: 7, + column: 6, }, - ), - custom: (), - node: Name { - id: "x", - ctx: Load, - }, - }, - cases: [ - MatchCase { - pattern: Located { - location: Location { - row: 13, - column: 9, + end_location: Some( + Location { + row: 12, + column: 7, + }, + ), + custom: (), + node: Name( + ExprName { + id: "x", + ctx: Load, }, - end_location: Some( - Location { + ), + }, + cases: [ + MatchCase { + pattern: Located { + location: Location { row: 13, - column: 10, + column: 9, }, - ), - custom: (), - node: MatchValue { - value: Located { - location: Location { + end_location: Some( + Location { row: 13, - column: 9, - }, - end_location: Some( - Location { - row: 13, - column: 10, - }, - ), - custom: (), - node: Constant { - value: Int( - 0, - ), - kind: None, - }, - }, - }, - }, - guard: Some( - Located { - location: Location { - row: 13, - column: 14, - }, - end_location: Some( - Location { - row: 13, - column: 15, - }, - ), - custom: (), - node: Constant { - value: Int( - 0, - ), - kind: None, - }, - }, - ), - body: [ - Located { - location: Location { - row: 14, - column: 8, - }, - end_location: Some( - Location { - row: 14, - column: 13, + column: 10, }, ), custom: (), - node: Assign { - targets: [ - Located { + node: MatchValue( + PatternMatchValue { + value: Located { location: Location { - row: 14, - column: 8, + row: 13, + column: 9, }, end_location: Some( Location { - row: 14, - column: 9, + row: 13, + column: 10, }, ), custom: (), - node: Name { - id: "y", - ctx: Store, - }, + node: Constant( + ExprConstant { + value: Int( + 0, + ), + kind: None, + }, + ), }, - ], - value: Located { - location: Location { - row: 14, - column: 12, + }, + ), + }, + guard: Some( + Located { + location: Location { + row: 13, + column: 14, + }, + end_location: Some( + Location { + row: 13, + column: 15, }, - end_location: Some( - Location { - row: 14, - column: 13, - }, - ), - custom: (), - node: Constant { + ), + custom: (), + node: Constant( + ExprConstant { value: Int( 0, ), kind: None, }, - }, - type_comment: None, - }, - }, - ], - }, - MatchCase { - pattern: Located { - location: Location { - row: 15, - column: 9, - }, - end_location: Some( - Location { - row: 15, - column: 10, + ), }, ), - custom: (), - node: MatchValue { - value: Located { + body: [ + Located { location: Location { - row: 15, - column: 9, + row: 14, + column: 8, }, end_location: Some( Location { - row: 15, - column: 10, + row: 14, + column: 13, }, ), custom: (), - node: Constant { - value: Int( - 0, - ), - kind: None, - }, + node: Assign( + StmtAssign { + targets: [ + Located { + location: Location { + row: 14, + column: 8, + }, + end_location: Some( + Location { + row: 14, + column: 9, + }, + ), + custom: (), + node: Name( + ExprName { + id: "y", + ctx: Store, + }, + ), + }, + ], + value: Located { + location: Location { + row: 14, + column: 12, + }, + end_location: Some( + Location { + row: 14, + column: 13, + }, + ), + custom: (), + node: Constant( + ExprConstant { + value: Int( + 0, + ), + kind: None, + }, + ), + }, + type_comment: None, + }, + ), }, - }, + ], }, - guard: Some( - Located { + MatchCase { + pattern: Located { location: Location { row: 15, - column: 14, + column: 9, }, end_location: Some( Location { row: 15, - column: 15, - }, - ), - custom: (), - node: Constant { - value: Int( - 1, - ), - kind: None, - }, - }, - ), - body: [ - Located { - location: Location { - row: 16, - column: 8, - }, - end_location: Some( - Location { - row: 16, - column: 13, + column: 10, }, ), custom: (), - node: Assign { - targets: [ - Located { + node: MatchValue( + PatternMatchValue { + value: Located { location: Location { - row: 16, - column: 8, + row: 15, + column: 9, }, end_location: Some( Location { - row: 16, - column: 9, + row: 15, + column: 10, }, ), custom: (), - node: Name { - id: "y", - ctx: Store, - }, + node: Constant( + ExprConstant { + value: Int( + 0, + ), + kind: None, + }, + ), }, - ], - value: Located { - location: Location { - row: 16, - column: 12, + }, + ), + }, + guard: Some( + Located { + location: Location { + row: 15, + column: 14, + }, + end_location: Some( + Location { + row: 15, + column: 15, }, - end_location: Some( - Location { - row: 16, - column: 13, - }, - ), - custom: (), - node: Constant { + ), + custom: (), + node: Constant( + ExprConstant { value: Int( 1, ), kind: None, }, + ), + }, + ), + body: [ + Located { + location: Location { + row: 16, + column: 8, }, - type_comment: None, + end_location: Some( + Location { + row: 16, + column: 13, + }, + ), + custom: (), + node: Assign( + StmtAssign { + targets: [ + Located { + location: Location { + row: 16, + column: 8, + }, + end_location: Some( + Location { + row: 16, + column: 9, + }, + ), + custom: (), + node: Name( + ExprName { + id: "y", + ctx: Store, + }, + ), + }, + ], + value: Located { + location: Location { + row: 16, + column: 12, + }, + end_location: Some( + Location { + row: 16, + column: 13, + }, + ), + custom: (), + node: Constant( + ExprConstant { + value: Int( + 1, + ), + kind: None, + }, + ), + }, + type_comment: None, + }, + ), }, - }, - ], - }, - ], - }, + ], + }, + ], + }, + ), }, Located { location: Location { @@ -567,56 +627,47 @@ expression: parse_ast }, ), custom: (), - node: Match { - subject: Located { - location: Location { - row: 18, - column: 6, - }, - end_location: Some( - Location { + node: Match( + StmtMatch { + subject: Located { + location: Location { row: 18, - column: 7, + column: 6, }, - ), - custom: (), - node: Constant { - value: Int( - 3, + end_location: Some( + Location { + row: 18, + column: 7, + }, ), - kind: None, - }, - }, - cases: [ - MatchCase { - pattern: Located { - location: Location { - row: 19, - column: 9, + custom: (), + node: Constant( + ExprConstant { + value: Int( + 3, + ), + kind: None, }, - end_location: Some( - Location { + ), + }, + cases: [ + MatchCase { + pattern: Located { + location: Location { row: 19, - column: 22, + column: 9, }, - ), - custom: (), - node: MatchOr { - patterns: [ - Located { - location: Location { - row: 19, - column: 9, - }, - end_location: Some( - Location { - row: 19, - column: 10, - }, - ), - custom: (), - node: MatchValue { - value: Located { + end_location: Some( + Location { + row: 19, + column: 22, + }, + ), + custom: (), + node: MatchOr( + PatternMatchOr { + patterns: [ + Located { location: Location { row: 19, column: 9, @@ -628,29 +679,33 @@ expression: parse_ast }, ), custom: (), - node: Constant { - value: Int( - 0, - ), - kind: None, - }, - }, - }, - }, - Located { - location: Location { - row: 19, - column: 13, - }, - end_location: Some( - Location { - row: 19, - column: 14, + node: MatchValue( + PatternMatchValue { + value: Located { + location: Location { + row: 19, + column: 9, + }, + end_location: Some( + Location { + row: 19, + column: 10, + }, + ), + custom: (), + node: Constant( + ExprConstant { + value: Int( + 0, + ), + kind: None, + }, + ), + }, + }, + ), }, - ), - custom: (), - node: MatchValue { - value: Located { + Located { location: Location { row: 19, column: 13, @@ -662,29 +717,33 @@ expression: parse_ast }, ), custom: (), - node: Constant { - value: Int( - 1, - ), - kind: None, - }, - }, - }, - }, - Located { - location: Location { - row: 19, - column: 17, - }, - end_location: Some( - Location { - row: 19, - column: 18, + node: MatchValue( + PatternMatchValue { + value: Located { + location: Location { + row: 19, + column: 13, + }, + end_location: Some( + Location { + row: 19, + column: 14, + }, + ), + custom: (), + node: Constant( + ExprConstant { + value: Int( + 1, + ), + kind: None, + }, + ), + }, + }, + ), }, - ), - custom: (), - node: MatchValue { - value: Located { + Located { location: Location { row: 19, column: 17, @@ -696,29 +755,33 @@ expression: parse_ast }, ), custom: (), - node: Constant { - value: Int( - 2, - ), - kind: None, - }, - }, - }, - }, - Located { - location: Location { - row: 19, - column: 21, - }, - end_location: Some( - Location { - row: 19, - column: 22, + node: MatchValue( + PatternMatchValue { + value: Located { + location: Location { + row: 19, + column: 17, + }, + end_location: Some( + Location { + row: 19, + column: 18, + }, + ), + custom: (), + node: Constant( + ExprConstant { + value: Int( + 2, + ), + kind: None, + }, + ), + }, + }, + ), }, - ), - custom: (), - node: MatchValue { - value: Located { + Located { location: Location { row: 19, column: 21, @@ -730,78 +793,103 @@ expression: parse_ast }, ), custom: (), - node: Constant { - value: Int( - 3, - ), - kind: None, - }, + node: MatchValue( + PatternMatchValue { + value: Located { + location: Location { + row: 19, + column: 21, + }, + end_location: Some( + Location { + row: 19, + column: 22, + }, + ), + custom: (), + node: Constant( + ExprConstant { + value: Int( + 3, + ), + kind: None, + }, + ), + }, + }, + ), }, - }, + ], }, - ], + ), }, - }, - guard: None, - body: [ - Located { - location: Location { - row: 20, - column: 8, - }, - end_location: Some( - Location { + guard: None, + body: [ + Located { + location: Location { row: 20, - column: 16, + column: 8, }, - ), - custom: (), - node: Assign { - targets: [ - Located { - location: Location { - row: 20, - column: 8, - }, - end_location: Some( - Location { - row: 20, - column: 9, - }, - ), - custom: (), - node: Name { - id: "x", - ctx: Store, - }, - }, - ], - value: Located { - location: Location { + end_location: Some( + Location { row: 20, - column: 12, + column: 16, }, - end_location: Some( - Location { - row: 20, - column: 16, + ), + custom: (), + node: Assign( + StmtAssign { + targets: [ + Located { + location: Location { + row: 20, + column: 8, + }, + end_location: Some( + Location { + row: 20, + column: 9, + }, + ), + custom: (), + node: Name( + ExprName { + id: "x", + ctx: Store, + }, + ), + }, + ], + value: Located { + location: Location { + row: 20, + column: 12, + }, + end_location: Some( + Location { + row: 20, + column: 16, + }, + ), + custom: (), + node: Constant( + ExprConstant { + value: Bool( + true, + ), + kind: None, + }, + ), }, - ), - custom: (), - node: Constant { - value: Bool( - true, - ), - kind: None, + type_comment: None, }, - }, - type_comment: None, + ), }, - }, - ], - }, - ], - }, + ], + }, + ], + }, + ), }, Located { location: Location { @@ -815,273 +903,305 @@ expression: parse_ast }, ), custom: (), - node: Match { - subject: Located { - location: Location { - row: 22, - column: 6, - }, - end_location: Some( - Location { + node: Match( + StmtMatch { + subject: Located { + location: Location { row: 22, - column: 7, + column: 6, }, - ), - custom: (), - node: Name { - id: "x", - ctx: Load, - }, - }, - cases: [ - MatchCase { - pattern: Located { - location: Location { - row: 23, - column: 9, + end_location: Some( + Location { + row: 22, + column: 7, + }, + ), + custom: (), + node: Name( + ExprName { + id: "x", + ctx: Load, }, - end_location: Some( - Location { + ), + }, + cases: [ + MatchCase { + pattern: Located { + location: Location { row: 23, - column: 24, + column: 9, }, - ), - custom: (), - node: MatchOr { - patterns: [ - Located { - location: Location { - row: 23, - column: 9, - }, - end_location: Some( - Location { - row: 23, - column: 15, - }, - ), - custom: (), - node: MatchSequence { - patterns: [ - Located { - location: Location { + end_location: Some( + Location { + row: 23, + column: 24, + }, + ), + custom: (), + node: MatchOr( + PatternMatchOr { + patterns: [ + Located { + location: Location { + row: 23, + column: 9, + }, + end_location: Some( + Location { row: 23, - column: 10, + column: 15, }, - end_location: Some( - Location { - row: 23, - column: 11, - }, - ), - custom: (), - node: MatchValue { - value: Located { - location: Location { - row: 23, - column: 10, - }, - end_location: Some( - Location { + ), + custom: (), + node: MatchSequence( + PatternMatchSequence { + patterns: [ + Located { + location: Location { row: 23, - column: 11, + column: 10, }, - ), - custom: (), - node: Constant { - value: Int( - 0, + end_location: Some( + Location { + row: 23, + column: 11, + }, + ), + custom: (), + node: MatchValue( + PatternMatchValue { + value: Located { + location: Location { + row: 23, + column: 10, + }, + end_location: Some( + Location { + row: 23, + column: 11, + }, + ), + custom: (), + node: Constant( + ExprConstant { + value: Int( + 0, + ), + kind: None, + }, + ), + }, + }, ), - kind: None, }, - }, - }, - }, - Located { - location: Location { - row: 23, - column: 13, - }, - end_location: Some( - Location { - row: 23, - column: 14, - }, - ), - custom: (), - node: MatchValue { - value: Located { - location: Location { - row: 23, - column: 13, - }, - end_location: Some( - Location { + Located { + location: Location { row: 23, - column: 14, + column: 13, }, - ), - custom: (), - node: Constant { - value: Int( - 1, + end_location: Some( + Location { + row: 23, + column: 14, + }, + ), + custom: (), + node: MatchValue( + PatternMatchValue { + value: Located { + location: Location { + row: 23, + column: 13, + }, + end_location: Some( + Location { + row: 23, + column: 14, + }, + ), + custom: (), + node: Constant( + ExprConstant { + value: Int( + 1, + ), + kind: None, + }, + ), + }, + }, ), - kind: None, }, - }, + ], }, - }, - ], - }, - }, - Located { - location: Location { - row: 23, - column: 18, - }, - end_location: Some( - Location { - row: 23, - column: 24, + ), }, - ), - custom: (), - node: MatchSequence { - patterns: [ - Located { - location: Location { + Located { + location: Location { + row: 23, + column: 18, + }, + end_location: Some( + Location { row: 23, - column: 19, + column: 24, }, - end_location: Some( - Location { - row: 23, - column: 20, - }, - ), - custom: (), - node: MatchValue { - value: Located { - location: Location { - row: 23, - column: 19, + ), + custom: (), + node: MatchSequence( + PatternMatchSequence { + patterns: [ + Located { + location: Location { + row: 23, + column: 19, + }, + end_location: Some( + Location { + row: 23, + column: 20, + }, + ), + custom: (), + node: MatchValue( + PatternMatchValue { + value: Located { + location: Location { + row: 23, + column: 19, + }, + end_location: Some( + Location { + row: 23, + column: 20, + }, + ), + custom: (), + node: Constant( + ExprConstant { + value: Int( + 1, + ), + kind: None, + }, + ), + }, + }, + ), }, - end_location: Some( - Location { + Located { + location: Location { row: 23, - column: 20, + column: 22, }, - ), - custom: (), - node: Constant { - value: Int( - 1, + end_location: Some( + Location { + row: 23, + column: 23, + }, + ), + custom: (), + node: MatchValue( + PatternMatchValue { + value: Located { + location: Location { + row: 23, + column: 22, + }, + end_location: Some( + Location { + row: 23, + column: 23, + }, + ), + custom: (), + node: Constant( + ExprConstant { + value: Int( + 0, + ), + kind: None, + }, + ), + }, + }, ), - kind: None, }, - }, + ], }, - }, + ), + }, + ], + }, + ), + }, + guard: None, + body: [ + Located { + location: Location { + row: 24, + column: 8, + }, + end_location: Some( + Location { + row: 24, + column: 13, + }, + ), + custom: (), + node: Assign( + StmtAssign { + targets: [ Located { location: Location { - row: 23, - column: 22, + row: 24, + column: 8, }, end_location: Some( Location { - row: 23, - column: 23, + row: 24, + column: 9, }, ), custom: (), - node: MatchValue { - value: Located { - location: Location { - row: 23, - column: 22, - }, - end_location: Some( - Location { - row: 23, - column: 23, - }, - ), - custom: (), - node: Constant { - value: Int( - 0, - ), - kind: None, - }, + node: Name( + ExprName { + id: "y", + ctx: Store, }, - }, + ), }, ], - }, - }, - ], - }, - }, - guard: None, - body: [ - Located { - location: Location { - row: 24, - column: 8, - }, - end_location: Some( - Location { - row: 24, - column: 13, - }, - ), - custom: (), - node: Assign { - targets: [ - Located { - location: Location { - row: 24, - column: 8, - }, - end_location: Some( - Location { + value: Located { + location: Location { row: 24, - column: 9, + column: 12, }, - ), - custom: (), - node: Name { - id: "y", - ctx: Store, - }, - }, - ], - value: Located { - location: Location { - row: 24, - column: 12, - }, - end_location: Some( - Location { - row: 24, - column: 13, + end_location: Some( + Location { + row: 24, + column: 13, + }, + ), + custom: (), + node: Constant( + ExprConstant { + value: Int( + 0, + ), + kind: None, + }, + ), }, - ), - custom: (), - node: Constant { - value: Int( - 0, - ), - kind: None, + type_comment: None, }, - }, - type_comment: None, + ), }, - }, - ], - }, - ], - }, + ], + }, + ], + }, + ), }, Located { location: Location { @@ -1095,160 +1215,178 @@ expression: parse_ast }, ), custom: (), - node: Match { - subject: Located { - location: Location { - row: 26, - column: 6, - }, - end_location: Some( - Location { + node: Match( + StmtMatch { + subject: Located { + location: Location { row: 26, - column: 7, + column: 6, }, - ), - custom: (), - node: Name { - id: "x", - ctx: Load, - }, - }, - cases: [ - MatchCase { - pattern: Located { - location: Location { - row: 27, - column: 9, + end_location: Some( + Location { + row: 26, + column: 7, }, - end_location: Some( - Location { - row: 27, - column: 13, - }, - ), - custom: (), - node: MatchSequence { - patterns: [ - Located { - location: Location { - row: 27, - column: 10, - }, - end_location: Some( - Location { - row: 27, - column: 12, - }, - ), - custom: (), - node: MatchStar { - name: None, - }, - }, - ], + ), + custom: (), + node: Name( + ExprName { + id: "x", + ctx: Load, }, - }, - guard: None, - body: [ - Located { + ), + }, + cases: [ + MatchCase { + pattern: Located { location: Location { - row: 28, - column: 8, + row: 27, + column: 9, }, end_location: Some( Location { - row: 28, - column: 20, + row: 27, + column: 13, }, ), custom: (), - node: Return { - value: Some( - Located { - location: Location { - row: 28, - column: 15, - }, - end_location: Some( - Location { - row: 28, - column: 20, + node: MatchSequence( + PatternMatchSequence { + patterns: [ + Located { + location: Location { + row: 27, + column: 10, }, - ), - custom: (), - node: Constant { - value: Str( - "seq", + end_location: Some( + Location { + row: 27, + column: 12, + }, ), - kind: None, - }, - }, - ), - }, - }, - ], - }, - MatchCase { - pattern: Located { - location: Location { - row: 29, - column: 9, + custom: (), + node: MatchStar( + PatternMatchStar { + name: None, + }, + ), + }, + ], + }, + ), }, - end_location: Some( - Location { - row: 29, - column: 11, + guard: None, + body: [ + Located { + location: Location { + row: 28, + column: 8, + }, + end_location: Some( + Location { + row: 28, + column: 20, + }, + ), + custom: (), + node: Return( + StmtReturn { + value: Some( + Located { + location: Location { + row: 28, + column: 15, + }, + end_location: Some( + Location { + row: 28, + column: 20, + }, + ), + custom: (), + node: Constant( + ExprConstant { + value: Str( + "seq", + ), + kind: None, + }, + ), + }, + ), + }, + ), }, - ), - custom: (), - node: MatchMapping { - keys: [], - patterns: [], - rest: None, - }, + ], }, - guard: None, - body: [ - Located { + MatchCase { + pattern: Located { location: Location { - row: 30, - column: 8, + row: 29, + column: 9, }, end_location: Some( Location { - row: 30, - column: 20, + row: 29, + column: 11, }, ), custom: (), - node: Return { - value: Some( - Located { - location: Location { - row: 30, - column: 15, - }, - end_location: Some( - Location { - row: 30, - column: 20, + node: MatchMapping( + PatternMatchMapping { + keys: [], + patterns: [], + rest: None, + }, + ), + }, + guard: None, + body: [ + Located { + location: Location { + row: 30, + column: 8, + }, + end_location: Some( + Location { + row: 30, + column: 20, + }, + ), + custom: (), + node: Return( + StmtReturn { + value: Some( + Located { + location: Location { + row: 30, + column: 15, + }, + end_location: Some( + Location { + row: 30, + column: 20, + }, + ), + custom: (), + node: Constant( + ExprConstant { + value: Str( + "map", + ), + kind: None, + }, + ), }, ), - custom: (), - node: Constant { - value: Str( - "map", - ), - kind: None, - }, }, ), }, - }, - ], - }, - ], - }, + ], + }, + ], + }, + ), }, Located { location: Location { @@ -1262,289 +1400,304 @@ expression: parse_ast }, ), custom: (), - node: Match { - subject: Located { - location: Location { - row: 32, - column: 6, - }, - end_location: Some( - Location { + node: Match( + StmtMatch { + subject: Located { + location: Location { row: 32, - column: 7, + column: 6, }, - ), - custom: (), - node: Name { - id: "x", - ctx: Load, - }, - }, - cases: [ - MatchCase { - pattern: Located { - location: Location { - row: 33, - column: 9, + end_location: Some( + Location { + row: 32, + column: 7, + }, + ), + custom: (), + node: Name( + ExprName { + id: "x", + ctx: Load, }, - end_location: Some( - Location { + ), + }, + cases: [ + MatchCase { + pattern: Located { + location: Location { row: 33, - column: 24, + column: 9, }, - ), - custom: (), - node: MatchMapping { - keys: [ - Located { - location: Location { - row: 33, - column: 10, - }, - end_location: Some( - Location { - row: 33, - column: 11, - }, - ), - custom: (), - node: Constant { - value: Int( - 0, - ), - kind: None, - }, + end_location: Some( + Location { + row: 33, + column: 24, }, - ], - patterns: [ - Located { - location: Location { - row: 33, - column: 13, - }, - end_location: Some( - Location { - row: 33, - column: 23, + ), + custom: (), + node: MatchMapping( + PatternMatchMapping { + keys: [ + Located { + location: Location { + row: 33, + column: 10, + }, + end_location: Some( + Location { + row: 33, + column: 11, + }, + ), + custom: (), + node: Constant( + ExprConstant { + value: Int( + 0, + ), + kind: None, + }, + ), }, - ), - custom: (), - node: MatchSequence { - patterns: [ - Located { - location: Location { + ], + patterns: [ + Located { + location: Location { + row: 33, + column: 13, + }, + end_location: Some( + Location { row: 33, - column: 14, + column: 23, }, - end_location: Some( - Location { - row: 33, - column: 15, - }, - ), - custom: (), - node: MatchValue { - value: Located { - location: Location { - row: 33, - column: 14, + ), + custom: (), + node: MatchSequence( + PatternMatchSequence { + patterns: [ + Located { + location: Location { + row: 33, + column: 14, + }, + end_location: Some( + Location { + row: 33, + column: 15, + }, + ), + custom: (), + node: MatchValue( + PatternMatchValue { + value: Located { + location: Location { + row: 33, + column: 14, + }, + end_location: Some( + Location { + row: 33, + column: 15, + }, + ), + custom: (), + node: Constant( + ExprConstant { + value: Int( + 1, + ), + kind: None, + }, + ), + }, + }, + ), }, - end_location: Some( - Location { + Located { + location: Location { row: 33, - column: 15, + column: 17, }, - ), - custom: (), - node: Constant { - value: Int( - 1, + end_location: Some( + Location { + row: 33, + column: 18, + }, + ), + custom: (), + node: MatchValue( + PatternMatchValue { + value: Located { + location: Location { + row: 33, + column: 17, + }, + end_location: Some( + Location { + row: 33, + column: 18, + }, + ), + custom: (), + node: Constant( + ExprConstant { + value: Int( + 2, + ), + kind: None, + }, + ), + }, + }, ), - kind: None, }, - }, + Located { + location: Location { + row: 33, + column: 20, + }, + end_location: Some( + Location { + row: 33, + column: 22, + }, + ), + custom: (), + node: MatchMapping( + PatternMatchMapping { + keys: [], + patterns: [], + rest: None, + }, + ), + }, + ], }, - }, + ), + }, + ], + rest: None, + }, + ), + }, + guard: None, + body: [ + Located { + location: Location { + row: 34, + column: 8, + }, + end_location: Some( + Location { + row: 34, + column: 13, + }, + ), + custom: (), + node: Assign( + StmtAssign { + targets: [ Located { location: Location { - row: 33, - column: 17, + row: 34, + column: 8, }, end_location: Some( Location { - row: 33, - column: 18, + row: 34, + column: 9, }, ), custom: (), - node: MatchValue { - value: Located { - location: Location { - row: 33, - column: 17, - }, - end_location: Some( - Location { - row: 33, - column: 18, - }, - ), - custom: (), - node: Constant { - value: Int( - 2, - ), - kind: None, - }, - }, - }, - }, - Located { - location: Location { - row: 33, - column: 20, - }, - end_location: Some( - Location { - row: 33, - column: 22, + node: Name( + ExprName { + id: "y", + ctx: Store, }, ), - custom: (), - node: MatchMapping { - keys: [], - patterns: [], - rest: None, - }, }, ], + value: Located { + location: Location { + row: 34, + column: 12, + }, + end_location: Some( + Location { + row: 34, + column: 13, + }, + ), + custom: (), + node: Constant( + ExprConstant { + value: Int( + 0, + ), + kind: None, + }, + ), + }, + type_comment: None, }, - }, - ], - rest: None, - }, + ), + }, + ], }, - guard: None, - body: [ - Located { + MatchCase { + pattern: Located { location: Location { - row: 34, - column: 8, + row: 35, + column: 9, }, end_location: Some( Location { - row: 34, - column: 13, + row: 35, + column: 77, }, ), custom: (), - node: Assign { - targets: [ - Located { - location: Location { - row: 34, - column: 8, - }, - end_location: Some( - Location { - row: 34, + node: MatchOr( + PatternMatchOr { + patterns: [ + Located { + location: Location { + row: 35, column: 9, }, - ), - custom: (), - node: Name { - id: "y", - ctx: Store, - }, - }, - ], - value: Located { - location: Location { - row: 34, - column: 12, - }, - end_location: Some( - Location { - row: 34, - column: 13, - }, - ), - custom: (), - node: Constant { - value: Int( - 0, - ), - kind: None, - }, - }, - type_comment: None, - }, - }, - ], - }, - MatchCase { - pattern: Located { - location: Location { - row: 35, - column: 9, - }, - end_location: Some( - Location { - row: 35, - column: 77, - }, - ), - custom: (), - node: MatchOr { - patterns: [ - Located { - location: Location { - row: 35, - column: 9, - }, - end_location: Some( - Location { - row: 35, - column: 31, - }, - ), - custom: (), - node: MatchMapping { - keys: [ - Located { - location: Location { - row: 35, - column: 10, - }, - end_location: Some( - Location { - row: 35, - column: 11, - }, - ), - custom: (), - node: Constant { - value: Int( - 0, - ), - kind: None, - }, - }, - ], - patterns: [ - Located { - location: Location { + end_location: Some( + Location { row: 35, - column: 13, + column: 31, }, - end_location: Some( - Location { - row: 35, - column: 30, - }, - ), - custom: (), - node: MatchOr { + ), + custom: (), + node: MatchMapping( + PatternMatchMapping { + keys: [ + Located { + location: Location { + row: 35, + column: 10, + }, + end_location: Some( + Location { + row: 35, + column: 11, + }, + ), + custom: (), + node: Constant( + ExprConstant { + value: Int( + 0, + ), + kind: None, + }, + ), + }, + ], patterns: [ Located { location: Location { @@ -1554,370 +1707,414 @@ expression: parse_ast end_location: Some( Location { row: 35, - column: 23, + column: 30, }, ), custom: (), - node: MatchSequence { - patterns: [ - Located { - location: Location { - row: 35, - column: 14, - }, - end_location: Some( - Location { + node: MatchOr( + PatternMatchOr { + patterns: [ + Located { + location: Location { row: 35, - column: 15, + column: 13, }, - ), - custom: (), - node: MatchValue { - value: Located { - location: Location { + end_location: Some( + Location { row: 35, - column: 14, + column: 23, }, - end_location: Some( - Location { - row: 35, - column: 15, - }, - ), - custom: (), - node: Constant { - value: Int( - 1, - ), - kind: None, + ), + custom: (), + node: MatchSequence( + PatternMatchSequence { + patterns: [ + Located { + location: Location { + row: 35, + column: 14, + }, + end_location: Some( + Location { + row: 35, + column: 15, + }, + ), + custom: (), + node: MatchValue( + PatternMatchValue { + value: Located { + location: Location { + row: 35, + column: 14, + }, + end_location: Some( + Location { + row: 35, + column: 15, + }, + ), + custom: (), + node: Constant( + ExprConstant { + value: Int( + 1, + ), + kind: None, + }, + ), + }, + }, + ), + }, + Located { + location: Location { + row: 35, + column: 17, + }, + end_location: Some( + Location { + row: 35, + column: 18, + }, + ), + custom: (), + node: MatchValue( + PatternMatchValue { + value: Located { + location: Location { + row: 35, + column: 17, + }, + end_location: Some( + Location { + row: 35, + column: 18, + }, + ), + custom: (), + node: Constant( + ExprConstant { + value: Int( + 2, + ), + kind: None, + }, + ), + }, + }, + ), + }, + Located { + location: Location { + row: 35, + column: 20, + }, + end_location: Some( + Location { + row: 35, + column: 22, + }, + ), + custom: (), + node: MatchMapping( + PatternMatchMapping { + keys: [], + patterns: [], + rest: None, + }, + ), + }, + ], }, - }, - }, - }, - Located { - location: Location { - row: 35, - column: 17, + ), }, - end_location: Some( - Location { + Located { + location: Location { row: 35, - column: 18, + column: 26, }, - ), - custom: (), - node: MatchValue { - value: Located { - location: Location { + end_location: Some( + Location { row: 35, - column: 17, + column: 30, }, - end_location: Some( - Location { - row: 35, - column: 18, - }, - ), - custom: (), - node: Constant { - value: Int( - 2, + ), + custom: (), + node: MatchSingleton( + PatternMatchSingleton { + value: Bool( + true, ), - kind: None, }, - }, + ), }, - }, - Located { - location: Location { - row: 35, - column: 20, - }, - end_location: Some( - Location { - row: 35, - column: 22, - }, - ), - custom: (), - node: MatchMapping { - keys: [], - patterns: [], - rest: None, - }, - }, - ], - }, + ], + }, + ), }, + ], + rest: None, + }, + ), + }, + Located { + location: Location { + row: 35, + column: 34, + }, + end_location: Some( + Location { + row: 35, + column: 43, + }, + ), + custom: (), + node: MatchMapping( + PatternMatchMapping { + keys: [ Located { location: Location { row: 35, - column: 26, + column: 35, }, end_location: Some( Location { row: 35, - column: 30, + column: 36, }, ), custom: (), - node: MatchSingleton { - value: Bool( - true, - ), - }, + node: Constant( + ExprConstant { + value: Int( + 1, + ), + kind: None, + }, + ), }, ], - }, - }, - ], - rest: None, - }, - }, - Located { - location: Location { - row: 35, - column: 34, - }, - end_location: Some( - Location { - row: 35, - column: 43, - }, - ), - custom: (), - node: MatchMapping { - keys: [ - Located { - location: Location { - row: 35, - column: 35, - }, - end_location: Some( - Location { - row: 35, - column: 36, - }, - ), - custom: (), - node: Constant { - value: Int( - 1, - ), - kind: None, - }, - }, - ], - patterns: [ - Located { - location: Location { - row: 35, - column: 38, - }, - end_location: Some( - Location { - row: 35, - column: 42, - }, - ), - custom: (), - node: MatchSequence { patterns: [ Located { location: Location { row: 35, - column: 39, + column: 38, }, end_location: Some( Location { row: 35, - column: 41, + column: 42, }, ), custom: (), - node: MatchSequence { - patterns: [], - }, + node: MatchSequence( + PatternMatchSequence { + patterns: [ + Located { + location: Location { + row: 35, + column: 39, + }, + end_location: Some( + Location { + row: 35, + column: 41, + }, + ), + custom: (), + node: MatchSequence( + PatternMatchSequence { + patterns: [], + }, + ), + }, + ], + }, + ), }, ], + rest: None, }, + ), + }, + Located { + location: Location { + row: 35, + column: 46, }, - ], - rest: None, - }, - }, - Located { - location: Location { - row: 35, - column: 46, - }, - end_location: Some( - Location { - row: 35, - column: 61, - }, - ), - custom: (), - node: MatchMapping { - keys: [ - Located { - location: Location { - row: 35, - column: 47, - }, - end_location: Some( - Location { - row: 35, - column: 48, - }, - ), - custom: (), - node: Constant { - value: Int( - 0, - ), - kind: None, - }, - }, - ], - patterns: [ - Located { - location: Location { + end_location: Some( + Location { row: 35, - column: 50, + column: 61, }, - end_location: Some( - Location { - row: 35, - column: 60, - }, - ), - custom: (), - node: MatchSequence { - patterns: [ + ), + custom: (), + node: MatchMapping( + PatternMatchMapping { + keys: [ Located { location: Location { row: 35, - column: 51, + column: 47, }, end_location: Some( Location { row: 35, - column: 52, + column: 48, }, ), custom: (), - node: MatchValue { - value: Located { - location: Location { - row: 35, - column: 51, - }, - end_location: Some( - Location { - row: 35, - column: 52, - }, + node: Constant( + ExprConstant { + value: Int( + 0, ), - custom: (), - node: Constant { - value: Int( - 1, - ), - kind: None, - }, + kind: None, }, - }, + ), }, + ], + patterns: [ Located { location: Location { row: 35, - column: 54, + column: 50, }, end_location: Some( Location { row: 35, - column: 55, + column: 60, }, ), custom: (), - node: MatchValue { - value: Located { - location: Location { - row: 35, - column: 54, - }, - end_location: Some( - Location { - row: 35, - column: 55, + node: MatchSequence( + PatternMatchSequence { + patterns: [ + Located { + location: Location { + row: 35, + column: 51, + }, + end_location: Some( + Location { + row: 35, + column: 52, + }, + ), + custom: (), + node: MatchValue( + PatternMatchValue { + value: Located { + location: Location { + row: 35, + column: 51, + }, + end_location: Some( + Location { + row: 35, + column: 52, + }, + ), + custom: (), + node: Constant( + ExprConstant { + value: Int( + 1, + ), + kind: None, + }, + ), + }, + }, + ), }, - ), - custom: (), - node: Constant { - value: Int( - 2, - ), - kind: None, - }, - }, - }, - }, - Located { - location: Location { - row: 35, - column: 57, - }, - end_location: Some( - Location { - row: 35, - column: 59, + Located { + location: Location { + row: 35, + column: 54, + }, + end_location: Some( + Location { + row: 35, + column: 55, + }, + ), + custom: (), + node: MatchValue( + PatternMatchValue { + value: Located { + location: Location { + row: 35, + column: 54, + }, + end_location: Some( + Location { + row: 35, + column: 55, + }, + ), + custom: (), + node: Constant( + ExprConstant { + value: Int( + 2, + ), + kind: None, + }, + ), + }, + }, + ), + }, + Located { + location: Location { + row: 35, + column: 57, + }, + end_location: Some( + Location { + row: 35, + column: 59, + }, + ), + custom: (), + node: MatchMapping( + PatternMatchMapping { + keys: [], + patterns: [], + rest: None, + }, + ), + }, + ], }, ), - custom: (), - node: MatchMapping { - keys: [], - patterns: [], - rest: None, - }, }, ], + rest: None, }, - }, - ], - rest: None, - }, - }, - Located { - location: Location { - row: 35, - column: 64, - }, - end_location: Some( - Location { - row: 35, - column: 66, + ), }, - ), - custom: (), - node: MatchSequence { - patterns: [], - }, - }, - Located { - location: Location { - row: 35, - column: 69, - }, - end_location: Some( - Location { - row: 35, - column: 72, + Located { + location: Location { + row: 35, + column: 64, + }, + end_location: Some( + Location { + row: 35, + column: 66, + }, + ), + custom: (), + node: MatchSequence( + PatternMatchSequence { + patterns: [], + }, + ), }, - ), - custom: (), - node: MatchValue { - value: Located { + Located { location: Location { row: 35, column: 69, @@ -1929,171 +2126,206 @@ expression: parse_ast }, ), custom: (), - node: Constant { - value: Str( - "X", - ), - kind: None, - }, + node: MatchValue( + PatternMatchValue { + value: Located { + location: Location { + row: 35, + column: 69, + }, + end_location: Some( + Location { + row: 35, + column: 72, + }, + ), + custom: (), + node: Constant( + ExprConstant { + value: Str( + "X", + ), + kind: None, + }, + ), + }, + }, + ), }, - }, - }, - Located { - location: Location { - row: 35, - column: 75, - }, - end_location: Some( - Location { - row: 35, - column: 77, + Located { + location: Location { + row: 35, + column: 75, + }, + end_location: Some( + Location { + row: 35, + column: 77, + }, + ), + custom: (), + node: MatchMapping( + PatternMatchMapping { + keys: [], + patterns: [], + rest: None, + }, + ), }, - ), - custom: (), - node: MatchMapping { - keys: [], - patterns: [], - rest: None, - }, + ], }, - ], + ), }, - }, - guard: None, - body: [ - Located { - location: Location { - row: 36, - column: 8, - }, - end_location: Some( - Location { + guard: None, + body: [ + Located { + location: Location { row: 36, - column: 13, + column: 8, }, - ), - custom: (), - node: Assign { - targets: [ - Located { - location: Location { - row: 36, - column: 8, - }, - end_location: Some( - Location { - row: 36, - column: 9, - }, - ), - custom: (), - node: Name { - id: "y", - ctx: Store, - }, - }, - ], - value: Located { - location: Location { + end_location: Some( + Location { row: 36, - column: 12, + column: 13, }, - end_location: Some( - Location { - row: 36, - column: 13, + ), + custom: (), + node: Assign( + StmtAssign { + targets: [ + Located { + location: Location { + row: 36, + column: 8, + }, + end_location: Some( + Location { + row: 36, + column: 9, + }, + ), + custom: (), + node: Name( + ExprName { + id: "y", + ctx: Store, + }, + ), + }, + ], + value: Located { + location: Location { + row: 36, + column: 12, + }, + end_location: Some( + Location { + row: 36, + column: 13, + }, + ), + custom: (), + node: Constant( + ExprConstant { + value: Int( + 1, + ), + kind: None, + }, + ), }, - ), - custom: (), - node: Constant { - value: Int( - 1, - ), - kind: None, + type_comment: None, }, - }, - type_comment: None, - }, - }, - ], - }, - MatchCase { - pattern: Located { - location: Location { - row: 37, - column: 9, - }, - end_location: Some( - Location { - row: 37, - column: 11, + ), }, - ), - custom: (), - node: MatchSequence { - patterns: [], - }, + ], }, - guard: None, - body: [ - Located { + MatchCase { + pattern: Located { location: Location { - row: 38, - column: 8, + row: 37, + column: 9, }, end_location: Some( Location { - row: 38, - column: 13, + row: 37, + column: 11, }, ), custom: (), - node: Assign { - targets: [ - Located { - location: Location { - row: 38, - column: 8, - }, - end_location: Some( - Location { - row: 38, - column: 9, - }, - ), - custom: (), - node: Name { - id: "y", - ctx: Store, - }, - }, - ], - value: Located { - location: Location { - row: 38, - column: 12, + node: MatchSequence( + PatternMatchSequence { + patterns: [], + }, + ), + }, + guard: None, + body: [ + Located { + location: Location { + row: 38, + column: 8, + }, + end_location: Some( + Location { + row: 38, + column: 13, }, - end_location: Some( - Location { - row: 38, - column: 13, + ), + custom: (), + node: Assign( + StmtAssign { + targets: [ + Located { + location: Location { + row: 38, + column: 8, + }, + end_location: Some( + Location { + row: 38, + column: 9, + }, + ), + custom: (), + node: Name( + ExprName { + id: "y", + ctx: Store, + }, + ), + }, + ], + value: Located { + location: Location { + row: 38, + column: 12, + }, + end_location: Some( + Location { + row: 38, + column: 13, + }, + ), + custom: (), + node: Constant( + ExprConstant { + value: Int( + 2, + ), + kind: None, + }, + ), }, - ), - custom: (), - node: Constant { - value: Int( - 2, - ), - kind: None, + type_comment: None, }, - }, - type_comment: None, + ), }, - }, - ], - }, - ], - }, + ], + }, + ], + }, + ), }, Located { location: Location { @@ -2107,77 +2339,48 @@ expression: parse_ast }, ), custom: (), - node: Match { - subject: Located { - location: Location { - row: 40, - column: 6, - }, - end_location: Some( - Location { + node: Match( + StmtMatch { + subject: Located { + location: Location { row: 40, - column: 7, + column: 6, }, - ), - custom: (), - node: Name { - id: "x", - ctx: Load, - }, - }, - cases: [ - MatchCase { - pattern: Located { - location: Location { - row: 41, - column: 9, + end_location: Some( + Location { + row: 40, + column: 7, + }, + ), + custom: (), + node: Name( + ExprName { + id: "x", + ctx: Load, }, - end_location: Some( - Location { + ), + }, + cases: [ + MatchCase { + pattern: Located { + location: Location { row: 41, - column: 21, + column: 9, }, - ), - custom: (), - node: MatchValue { - value: Located { - location: Location { + end_location: Some( + Location { row: 41, - column: 9, + column: 21, }, - end_location: Some( - Location { - row: 41, - column: 21, - }, - ), - custom: (), - node: BinOp { - left: Located { + ), + custom: (), + node: MatchValue( + PatternMatchValue { + value: Located { location: Location { row: 41, column: 9, }, - end_location: Some( - Location { - row: 41, - column: 13, - }, - ), - custom: (), - node: Constant { - value: Float( - 0.25, - ), - kind: None, - }, - }, - op: Add, - right: Located { - location: Location { - row: 41, - column: 16, - }, end_location: Some( Location { row: 41, @@ -2185,78 +2388,125 @@ expression: parse_ast }, ), custom: (), - node: Constant { - value: Complex { - real: 0.0, - imag: 1.75, + node: BinOp( + ExprBinOp { + left: Located { + location: Location { + row: 41, + column: 9, + }, + end_location: Some( + Location { + row: 41, + column: 13, + }, + ), + custom: (), + node: Constant( + ExprConstant { + value: Float( + 0.25, + ), + kind: None, + }, + ), + }, + op: Add, + right: Located { + location: Location { + row: 41, + column: 16, + }, + end_location: Some( + Location { + row: 41, + column: 21, + }, + ), + custom: (), + node: Constant( + ExprConstant { + value: Complex { + real: 0.0, + imag: 1.75, + }, + kind: None, + }, + ), + }, }, - kind: None, - }, + ), }, }, - }, + ), }, - }, - guard: None, - body: [ - Located { - location: Location { - row: 42, - column: 8, - }, - end_location: Some( - Location { + guard: None, + body: [ + Located { + location: Location { row: 42, - column: 13, + column: 8, }, - ), - custom: (), - node: Assign { - targets: [ - Located { - location: Location { - row: 42, - column: 8, - }, - end_location: Some( - Location { - row: 42, - column: 9, - }, - ), - custom: (), - node: Name { - id: "y", - ctx: Store, - }, - }, - ], - value: Located { - location: Location { + end_location: Some( + Location { row: 42, - column: 12, + column: 13, }, - end_location: Some( - Location { - row: 42, - column: 13, + ), + custom: (), + node: Assign( + StmtAssign { + targets: [ + Located { + location: Location { + row: 42, + column: 8, + }, + end_location: Some( + Location { + row: 42, + column: 9, + }, + ), + custom: (), + node: Name( + ExprName { + id: "y", + ctx: Store, + }, + ), + }, + ], + value: Located { + location: Location { + row: 42, + column: 12, + }, + end_location: Some( + Location { + row: 42, + column: 13, + }, + ), + custom: (), + node: Constant( + ExprConstant { + value: Int( + 0, + ), + kind: None, + }, + ), }, - ), - custom: (), - node: Constant { - value: Int( - 0, - ), - kind: None, + type_comment: None, }, - }, - type_comment: None, + ), }, - }, - ], - }, - ], - }, + ], + }, + ], + }, + ), }, Located { location: Location { @@ -2270,57 +2520,47 @@ expression: parse_ast }, ), custom: (), - node: Match { - subject: Located { - location: Location { - row: 44, - column: 6, - }, - end_location: Some( - Location { + node: Match( + StmtMatch { + subject: Located { + location: Location { row: 44, - column: 7, + column: 6, }, - ), - custom: (), - node: Name { - id: "x", - ctx: Load, - }, - }, - cases: [ - MatchCase { - pattern: Located { - location: Location { - row: 45, - column: 9, + end_location: Some( + Location { + row: 44, + column: 7, + }, + ), + custom: (), + node: Name( + ExprName { + id: "x", + ctx: Load, }, - end_location: Some( - Location { + ), + }, + cases: [ + MatchCase { + pattern: Located { + location: Location { row: 45, - column: 12, + column: 9, }, - ), - custom: (), - node: MatchValue { - value: Located { - location: Location { + end_location: Some( + Location { row: 45, - column: 9, + column: 12, }, - end_location: Some( - Location { - row: 45, - column: 12, - }, - ), - custom: (), - node: UnaryOp { - op: USub, - operand: Located { + ), + custom: (), + node: MatchValue( + PatternMatchValue { + value: Located { location: Location { row: 45, - column: 10, + column: 9, }, end_location: Some( Location { @@ -2329,78 +2569,104 @@ expression: parse_ast }, ), custom: (), - node: Constant { - value: Complex { - real: 0.0, - imag: 0.0, + node: UnaryOp( + ExprUnaryOp { + op: USub, + operand: Located { + location: Location { + row: 45, + column: 10, + }, + end_location: Some( + Location { + row: 45, + column: 12, + }, + ), + custom: (), + node: Constant( + ExprConstant { + value: Complex { + real: 0.0, + imag: 0.0, + }, + kind: None, + }, + ), + }, }, - kind: None, - }, + ), }, }, - }, + ), }, - }, - guard: None, - body: [ - Located { - location: Location { - row: 46, - column: 8, - }, - end_location: Some( - Location { + guard: None, + body: [ + Located { + location: Location { row: 46, - column: 13, + column: 8, }, - ), - custom: (), - node: Assign { - targets: [ - Located { - location: Location { - row: 46, - column: 8, - }, - end_location: Some( - Location { - row: 46, - column: 9, - }, - ), - custom: (), - node: Name { - id: "y", - ctx: Store, - }, - }, - ], - value: Located { - location: Location { + end_location: Some( + Location { row: 46, - column: 12, + column: 13, }, - end_location: Some( - Location { - row: 46, - column: 13, + ), + custom: (), + node: Assign( + StmtAssign { + targets: [ + Located { + location: Location { + row: 46, + column: 8, + }, + end_location: Some( + Location { + row: 46, + column: 9, + }, + ), + custom: (), + node: Name( + ExprName { + id: "y", + ctx: Store, + }, + ), + }, + ], + value: Located { + location: Location { + row: 46, + column: 12, + }, + end_location: Some( + Location { + row: 46, + column: 13, + }, + ), + custom: (), + node: Constant( + ExprConstant { + value: Int( + 0, + ), + kind: None, + }, + ), }, - ), - custom: (), - node: Constant { - value: Int( - 0, - ), - kind: None, + type_comment: None, }, - }, - type_comment: None, + ), }, - }, - ], - }, - ], - }, + ], + }, + ], + }, + ), }, Located { location: Location { @@ -2414,56 +2680,47 @@ expression: parse_ast }, ), custom: (), - node: Match { - subject: Located { - location: Location { - row: 48, - column: 6, - }, - end_location: Some( - Location { + node: Match( + StmtMatch { + subject: Located { + location: Location { row: 48, - column: 7, + column: 6, }, - ), - custom: (), - node: Constant { - value: Int( - 4, + end_location: Some( + Location { + row: 48, + column: 7, + }, ), - kind: None, - }, - }, - cases: [ - MatchCase { - pattern: Located { - location: Location { - row: 49, - column: 9, + custom: (), + node: Constant( + ExprConstant { + value: Int( + 4, + ), + kind: None, }, - end_location: Some( - Location { + ), + }, + cases: [ + MatchCase { + pattern: Located { + location: Location { row: 49, - column: 22, + column: 9, }, - ), - custom: (), - node: MatchOr { - patterns: [ - Located { - location: Location { - row: 49, - column: 9, - }, - end_location: Some( - Location { - row: 49, - column: 10, - }, - ), - custom: (), - node: MatchValue { - value: Located { + end_location: Some( + Location { + row: 49, + column: 22, + }, + ), + custom: (), + node: MatchOr( + PatternMatchOr { + patterns: [ + Located { location: Location { row: 49, column: 9, @@ -2475,29 +2732,33 @@ expression: parse_ast }, ), custom: (), - node: Constant { - value: Int( - 0, - ), - kind: None, - }, - }, - }, - }, - Located { - location: Location { - row: 49, - column: 13, - }, - end_location: Some( - Location { - row: 49, - column: 14, + node: MatchValue( + PatternMatchValue { + value: Located { + location: Location { + row: 49, + column: 9, + }, + end_location: Some( + Location { + row: 49, + column: 10, + }, + ), + custom: (), + node: Constant( + ExprConstant { + value: Int( + 0, + ), + kind: None, + }, + ), + }, + }, + ), }, - ), - custom: (), - node: MatchValue { - value: Located { + Located { location: Location { row: 49, column: 13, @@ -2509,29 +2770,33 @@ expression: parse_ast }, ), custom: (), - node: Constant { - value: Int( - 1, - ), - kind: None, - }, - }, - }, - }, - Located { - location: Location { - row: 49, - column: 17, - }, - end_location: Some( - Location { - row: 49, - column: 18, + node: MatchValue( + PatternMatchValue { + value: Located { + location: Location { + row: 49, + column: 13, + }, + end_location: Some( + Location { + row: 49, + column: 14, + }, + ), + custom: (), + node: Constant( + ExprConstant { + value: Int( + 1, + ), + kind: None, + }, + ), + }, + }, + ), }, - ), - custom: (), - node: MatchValue { - value: Located { + Located { location: Location { row: 49, column: 17, @@ -2543,29 +2808,33 @@ expression: parse_ast }, ), custom: (), - node: Constant { - value: Int( - 2, - ), - kind: None, - }, - }, - }, - }, - Located { - location: Location { - row: 49, - column: 21, - }, - end_location: Some( - Location { - row: 49, - column: 22, + node: MatchValue( + PatternMatchValue { + value: Located { + location: Location { + row: 49, + column: 17, + }, + end_location: Some( + Location { + row: 49, + column: 18, + }, + ), + custom: (), + node: Constant( + ExprConstant { + value: Int( + 2, + ), + kind: None, + }, + ), + }, + }, + ), }, - ), - custom: (), - node: MatchValue { - value: Located { + Located { location: Location { row: 49, column: 21, @@ -2577,78 +2846,103 @@ expression: parse_ast }, ), custom: (), - node: Constant { - value: Int( - 3, - ), - kind: None, - }, + node: MatchValue( + PatternMatchValue { + value: Located { + location: Location { + row: 49, + column: 21, + }, + end_location: Some( + Location { + row: 49, + column: 22, + }, + ), + custom: (), + node: Constant( + ExprConstant { + value: Int( + 3, + ), + kind: None, + }, + ), + }, + }, + ), }, - }, + ], }, - ], + ), }, - }, - guard: None, - body: [ - Located { - location: Location { - row: 50, - column: 8, - }, - end_location: Some( - Location { + guard: None, + body: [ + Located { + location: Location { row: 50, - column: 16, + column: 8, }, - ), - custom: (), - node: Assign { - targets: [ - Located { - location: Location { - row: 50, - column: 8, - }, - end_location: Some( - Location { + end_location: Some( + Location { + row: 50, + column: 16, + }, + ), + custom: (), + node: Assign( + StmtAssign { + targets: [ + Located { + location: Location { + row: 50, + column: 8, + }, + end_location: Some( + Location { + row: 50, + column: 9, + }, + ), + custom: (), + node: Name( + ExprName { + id: "x", + ctx: Store, + }, + ), + }, + ], + value: Located { + location: Location { row: 50, - column: 9, + column: 12, }, - ), - custom: (), - node: Name { - id: "x", - ctx: Store, + end_location: Some( + Location { + row: 50, + column: 16, + }, + ), + custom: (), + node: Constant( + ExprConstant { + value: Bool( + true, + ), + kind: None, + }, + ), }, + type_comment: None, }, - ], - value: Located { - location: Location { - row: 50, - column: 12, - }, - end_location: Some( - Location { - row: 50, - column: 16, - }, - ), - custom: (), - node: Constant { - value: Bool( - true, - ), - kind: None, - }, - }, - type_comment: None, + ), }, - }, - ], - }, - ], - }, + ], + }, + ], + }, + ), }, Located { location: Location { @@ -2662,138 +2956,154 @@ expression: parse_ast }, ), custom: (), - node: Match { - subject: Located { - location: Location { - row: 52, - column: 6, - }, - end_location: Some( - Location { + node: Match( + StmtMatch { + subject: Located { + location: Location { row: 52, - column: 7, + column: 6, }, - ), - custom: (), - node: Name { - id: "x", - ctx: Load, - }, - }, - cases: [ - MatchCase { - pattern: Located { - location: Location { - row: 53, - column: 9, + end_location: Some( + Location { + row: 52, + column: 7, }, - end_location: Some( - Location { - row: 53, - column: 10, - }, - ), - custom: (), - node: MatchValue { - value: Located { - location: Location { - row: 53, - column: 9, - }, - end_location: Some( - Location { - row: 53, - column: 10, - }, - ), - custom: (), - node: Constant { - value: Int( - 0, - ), - kind: None, - }, - }, + ), + custom: (), + node: Name( + ExprName { + id: "x", + ctx: Load, }, - }, - guard: Some( - Located { + ), + }, + cases: [ + MatchCase { + pattern: Located { location: Location { row: 53, - column: 14, + column: 9, }, end_location: Some( Location { row: 53, - column: 15, - }, - ), - custom: (), - node: Name { - id: "x", - ctx: Load, - }, - }, - ), - body: [ - Located { - location: Location { - row: 54, - column: 8, - }, - end_location: Some( - Location { - row: 54, - column: 13, + column: 10, }, ), custom: (), - node: Assign { - targets: [ - Located { + node: MatchValue( + PatternMatchValue { + value: Located { location: Location { - row: 54, - column: 8, + row: 53, + column: 9, }, end_location: Some( Location { - row: 54, - column: 9, + row: 53, + column: 10, }, ), custom: (), - node: Name { - id: "y", - ctx: Store, - }, + node: Constant( + ExprConstant { + value: Int( + 0, + ), + kind: None, + }, + ), }, - ], - value: Located { - location: Location { + }, + ), + }, + guard: Some( + Located { + location: Location { + row: 53, + column: 14, + }, + end_location: Some( + Location { + row: 53, + column: 15, + }, + ), + custom: (), + node: Name( + ExprName { + id: "x", + ctx: Load, + }, + ), + }, + ), + body: [ + Located { + location: Location { + row: 54, + column: 8, + }, + end_location: Some( + Location { row: 54, - column: 12, + column: 13, }, - end_location: Some( - Location { - row: 54, - column: 13, + ), + custom: (), + node: Assign( + StmtAssign { + targets: [ + Located { + location: Location { + row: 54, + column: 8, + }, + end_location: Some( + Location { + row: 54, + column: 9, + }, + ), + custom: (), + node: Name( + ExprName { + id: "y", + ctx: Store, + }, + ), + }, + ], + value: Located { + location: Location { + row: 54, + column: 12, + }, + end_location: Some( + Location { + row: 54, + column: 13, + }, + ), + custom: (), + node: Constant( + ExprConstant { + value: Int( + 0, + ), + kind: None, + }, + ), }, - ), - custom: (), - node: Constant { - value: Int( - 0, - ), - kind: None, + type_comment: None, }, - }, - type_comment: None, + ), }, - }, - ], - }, - ], - }, + ], + }, + ], + }, + ), }, Located { location: Location { @@ -2807,75 +3117,68 @@ expression: parse_ast }, ), custom: (), - node: Match { - subject: Located { - location: Location { - row: 56, - column: 6, - }, - end_location: Some( - Location { + node: Match( + StmtMatch { + subject: Located { + location: Location { row: 56, - column: 7, + column: 6, }, - ), - custom: (), - node: Name { - id: "x", - ctx: Load, - }, - }, - cases: [ - MatchCase { - pattern: Located { - location: Location { - row: 57, - column: 9, + end_location: Some( + Location { + row: 56, + column: 7, }, - end_location: Some( - Location { + ), + custom: (), + node: Name( + ExprName { + id: "x", + ctx: Load, + }, + ), + }, + cases: [ + MatchCase { + pattern: Located { + location: Location { row: 57, - column: 15, + column: 9, }, - ), - custom: (), - node: MatchMapping { - keys: [ - Located { - location: Location { - row: 57, - column: 10, - }, - end_location: Some( - Location { - row: 57, - column: 11, - }, - ), - custom: (), - node: Constant { - value: Int( - 1, - ), - kind: None, - }, + end_location: Some( + Location { + row: 57, + column: 15, }, - ], - patterns: [ - Located { - location: Location { - row: 57, - column: 13, - }, - end_location: Some( - Location { - row: 57, - column: 14, + ), + custom: (), + node: MatchMapping( + PatternMatchMapping { + keys: [ + Located { + location: Location { + row: 57, + column: 10, + }, + end_location: Some( + Location { + row: 57, + column: 11, + }, + ), + custom: (), + node: Constant( + ExprConstant { + value: Int( + 1, + ), + kind: None, + }, + ), }, - ), - custom: (), - node: MatchValue { - value: Located { + ], + patterns: [ + Located { location: Location { row: 57, column: 13, @@ -2887,127 +3190,141 @@ expression: parse_ast }, ), custom: (), - node: Constant { - value: Int( - 0, - ), - kind: None, - }, + node: MatchValue( + PatternMatchValue { + value: Located { + location: Location { + row: 57, + column: 13, + }, + end_location: Some( + Location { + row: 57, + column: 14, + }, + ), + custom: (), + node: Constant( + ExprConstant { + value: Int( + 0, + ), + kind: None, + }, + ), + }, + }, + ), }, - }, + ], + rest: None, }, - ], - rest: None, + ), }, - }, - guard: None, - body: [ - Located { - location: Location { - row: 58, - column: 8, - }, - end_location: Some( - Location { + guard: None, + body: [ + Located { + location: Location { row: 58, - column: 13, + column: 8, }, - ), - custom: (), - node: Assign { - targets: [ - Located { - location: Location { - row: 58, - column: 8, - }, - end_location: Some( - Location { - row: 58, - column: 9, - }, - ), - custom: (), - node: Name { - id: "y", - ctx: Store, - }, - }, - ], - value: Located { - location: Location { + end_location: Some( + Location { row: 58, - column: 12, + column: 13, }, - end_location: Some( - Location { - row: 58, - column: 13, - }, - ), - custom: (), - node: Constant { - value: Int( - 0, - ), - kind: None, + ), + custom: (), + node: Assign( + StmtAssign { + targets: [ + Located { + location: Location { + row: 58, + column: 8, + }, + end_location: Some( + Location { + row: 58, + column: 9, + }, + ), + custom: (), + node: Name( + ExprName { + id: "y", + ctx: Store, + }, + ), + }, + ], + value: Located { + location: Location { + row: 58, + column: 12, + }, + end_location: Some( + Location { + row: 58, + column: 13, + }, + ), + custom: (), + node: Constant( + ExprConstant { + value: Int( + 0, + ), + kind: None, + }, + ), + }, + type_comment: None, }, - }, - type_comment: None, + ), }, - }, - ], - }, - MatchCase { - pattern: Located { - location: Location { - row: 59, - column: 9, - }, - end_location: Some( - Location { + ], + }, + MatchCase { + pattern: Located { + location: Location { row: 59, - column: 15, + column: 9, }, - ), - custom: (), - node: MatchMapping { - keys: [ - Located { - location: Location { - row: 59, - column: 10, - }, - end_location: Some( - Location { - row: 59, - column: 11, - }, - ), - custom: (), - node: Constant { - value: Int( - 0, - ), - kind: None, - }, + end_location: Some( + Location { + row: 59, + column: 15, }, - ], - patterns: [ - Located { - location: Location { - row: 59, - column: 13, - }, - end_location: Some( - Location { - row: 59, - column: 14, + ), + custom: (), + node: MatchMapping( + PatternMatchMapping { + keys: [ + Located { + location: Location { + row: 59, + column: 10, + }, + end_location: Some( + Location { + row: 59, + column: 11, + }, + ), + custom: (), + node: Constant( + ExprConstant { + value: Int( + 0, + ), + kind: None, + }, + ), }, - ), - custom: (), - node: MatchValue { - value: Located { + ], + patterns: [ + Located { location: Location { row: 59, column: 13, @@ -3019,158 +3336,191 @@ expression: parse_ast }, ), custom: (), - node: Constant { - value: Int( - 0, - ), - kind: None, - }, + node: MatchValue( + PatternMatchValue { + value: Located { + location: Location { + row: 59, + column: 13, + }, + end_location: Some( + Location { + row: 59, + column: 14, + }, + ), + custom: (), + node: Constant( + ExprConstant { + value: Int( + 0, + ), + kind: None, + }, + ), + }, + }, + ), }, - }, + ], + rest: None, }, - ], - rest: None, + ), }, - }, - guard: None, - body: [ - Located { - location: Location { - row: 60, - column: 8, - }, - end_location: Some( - Location { + guard: None, + body: [ + Located { + location: Location { row: 60, - column: 13, + column: 8, }, - ), - custom: (), - node: Assign { - targets: [ - Located { - location: Location { - row: 60, - column: 8, - }, - end_location: Some( - Location { - row: 60, - column: 9, - }, - ), - custom: (), - node: Name { - id: "y", - ctx: Store, - }, - }, - ], - value: Located { - location: Location { + end_location: Some( + Location { row: 60, - column: 12, + column: 13, }, - end_location: Some( - Location { - row: 60, - column: 13, + ), + custom: (), + node: Assign( + StmtAssign { + targets: [ + Located { + location: Location { + row: 60, + column: 8, + }, + end_location: Some( + Location { + row: 60, + column: 9, + }, + ), + custom: (), + node: Name( + ExprName { + id: "y", + ctx: Store, + }, + ), + }, + ], + value: Located { + location: Location { + row: 60, + column: 12, + }, + end_location: Some( + Location { + row: 60, + column: 13, + }, + ), + custom: (), + node: Constant( + ExprConstant { + value: Int( + 1, + ), + kind: None, + }, + ), }, - ), - custom: (), - node: Constant { - value: Int( - 1, - ), - kind: None, + type_comment: None, }, - }, - type_comment: None, - }, - }, - ], - }, - MatchCase { - pattern: Located { - location: Location { - row: 61, - column: 9, - }, - end_location: Some( - Location { - row: 61, - column: 14, + ), }, - ), - custom: (), - node: MatchMapping { - keys: [], - patterns: [], - rest: Some( - "z", - ), - }, + ], }, - guard: None, - body: [ - Located { + MatchCase { + pattern: Located { location: Location { - row: 62, - column: 8, + row: 61, + column: 9, }, end_location: Some( Location { - row: 62, - column: 13, + row: 61, + column: 14, }, ), custom: (), - node: Assign { - targets: [ - Located { - location: Location { - row: 62, - column: 8, - }, - end_location: Some( - Location { - row: 62, - column: 9, - }, - ), - custom: (), - node: Name { - id: "y", - ctx: Store, - }, - }, - ], - value: Located { - location: Location { + node: MatchMapping( + PatternMatchMapping { + keys: [], + patterns: [], + rest: Some( + "z", + ), + }, + ), + }, + guard: None, + body: [ + Located { + location: Location { + row: 62, + column: 8, + }, + end_location: Some( + Location { row: 62, - column: 12, + column: 13, }, - end_location: Some( - Location { - row: 62, - column: 13, + ), + custom: (), + node: Assign( + StmtAssign { + targets: [ + Located { + location: Location { + row: 62, + column: 8, + }, + end_location: Some( + Location { + row: 62, + column: 9, + }, + ), + custom: (), + node: Name( + ExprName { + id: "y", + ctx: Store, + }, + ), + }, + ], + value: Located { + location: Location { + row: 62, + column: 12, + }, + end_location: Some( + Location { + row: 62, + column: 13, + }, + ), + custom: (), + node: Constant( + ExprConstant { + value: Int( + 2, + ), + kind: None, + }, + ), }, - ), - custom: (), - node: Constant { - value: Int( - 2, - ), - kind: None, + type_comment: None, }, - }, - type_comment: None, + ), }, - }, - ], - }, - ], - }, + ], + }, + ], + }, + ), }, Located { location: Location { @@ -3184,136 +3534,152 @@ expression: parse_ast }, ), custom: (), - node: Match { - subject: Located { - location: Location { - row: 64, - column: 6, - }, - end_location: Some( - Location { + node: Match( + StmtMatch { + subject: Located { + location: Location { row: 64, - column: 11, + column: 6, }, - ), - custom: (), - node: Call { - func: Located { - location: Location { + end_location: Some( + Location { row: 64, - column: 6, - }, - end_location: Some( - Location { - row: 64, - column: 9, - }, - ), - custom: (), - node: Name { - id: "Seq", - ctx: Load, - }, - }, - args: [], - keywords: [], - }, - }, - cases: [ - MatchCase { - pattern: Located { - location: Location { - row: 65, - column: 9, + column: 11, }, - end_location: Some( - Location { - row: 65, - column: 13, - }, - ), - custom: (), - node: MatchSequence { - patterns: [ - Located { - location: Location { - row: 65, - column: 10, + ), + custom: (), + node: Call( + ExprCall { + func: Located { + location: Location { + row: 64, + column: 6, + }, + end_location: Some( + Location { + row: 64, + column: 9, }, - end_location: Some( - Location { - row: 65, - column: 12, - }, - ), - custom: (), - node: MatchStar { - name: None, + ), + custom: (), + node: Name( + ExprName { + id: "Seq", + ctx: Load, }, - }, - ], + ), + }, + args: [], + keywords: [], }, - }, - guard: None, - body: [ - Located { + ), + }, + cases: [ + MatchCase { + pattern: Located { location: Location { - row: 66, - column: 8, + row: 65, + column: 9, }, end_location: Some( Location { - row: 66, + row: 65, column: 13, }, ), custom: (), - node: Assign { - targets: [ - Located { - location: Location { - row: 66, - column: 8, - }, - end_location: Some( - Location { - row: 66, - column: 9, + node: MatchSequence( + PatternMatchSequence { + patterns: [ + Located { + location: Location { + row: 65, + column: 10, }, - ), - custom: (), - node: Name { - id: "y", - ctx: Store, + end_location: Some( + Location { + row: 65, + column: 12, + }, + ), + custom: (), + node: MatchStar( + PatternMatchStar { + name: None, + }, + ), }, - }, - ], - value: Located { - location: Location { + ], + }, + ), + }, + guard: None, + body: [ + Located { + location: Location { + row: 66, + column: 8, + }, + end_location: Some( + Location { row: 66, - column: 12, + column: 13, }, - end_location: Some( - Location { - row: 66, - column: 13, - }, - ), - custom: (), - node: Constant { - value: Int( - 0, - ), - kind: None, + ), + custom: (), + node: Assign( + StmtAssign { + targets: [ + Located { + location: Location { + row: 66, + column: 8, + }, + end_location: Some( + Location { + row: 66, + column: 9, + }, + ), + custom: (), + node: Name( + ExprName { + id: "y", + ctx: Store, + }, + ), + }, + ], + value: Located { + location: Location { + row: 66, + column: 12, + }, + end_location: Some( + Location { + row: 66, + column: 13, + }, + ), + custom: (), + node: Constant( + ExprConstant { + value: Int( + 0, + ), + kind: None, + }, + ), + }, + type_comment: None, }, - }, - type_comment: None, + ), }, - }, - ], - }, - ], - }, + ], + }, + ], + }, + ), }, Located { location: Location { @@ -3327,481 +3693,518 @@ expression: parse_ast }, ), custom: (), - node: Match { - subject: Located { - location: Location { - row: 68, - column: 6, - }, - end_location: Some( - Location { + node: Match( + StmtMatch { + subject: Located { + location: Location { row: 68, - column: 7, + column: 6, }, - ), - custom: (), - node: Name { - id: "x", - ctx: Load, - }, - }, - cases: [ - MatchCase { - pattern: Located { - location: Location { - row: 69, - column: 9, + end_location: Some( + Location { + row: 68, + column: 7, + }, + ), + custom: (), + node: Name( + ExprName { + id: "x", + ctx: Load, }, - end_location: Some( - Location { + ), + }, + cases: [ + MatchCase { + pattern: Located { + location: Location { row: 69, - column: 10, + column: 9, }, - ), - custom: (), - node: MatchValue { - value: Located { - location: Location { + end_location: Some( + Location { row: 69, - column: 9, + column: 10, + }, + ), + custom: (), + node: MatchValue( + PatternMatchValue { + value: Located { + location: Location { + row: 69, + column: 9, + }, + end_location: Some( + Location { + row: 69, + column: 10, + }, + ), + custom: (), + node: Constant( + ExprConstant { + value: Int( + 1, + ), + kind: None, + }, + ), + }, + }, + ), + }, + guard: None, + body: [ + Located { + location: Location { + row: 70, + column: 8, }, end_location: Some( Location { - row: 69, - column: 10, + row: 70, + column: 13, }, ), custom: (), - node: Constant { - value: Int( - 1, - ), - kind: None, - }, + node: Assign( + StmtAssign { + targets: [ + Located { + location: Location { + row: 70, + column: 8, + }, + end_location: Some( + Location { + row: 70, + column: 9, + }, + ), + custom: (), + node: Name( + ExprName { + id: "y", + ctx: Store, + }, + ), + }, + ], + value: Located { + location: Location { + row: 70, + column: 12, + }, + end_location: Some( + Location { + row: 70, + column: 13, + }, + ), + custom: (), + node: Constant( + ExprConstant { + value: Int( + 0, + ), + kind: None, + }, + ), + }, + type_comment: None, + }, + ), }, - }, + ], }, - guard: None, - body: [ - Located { + MatchCase { + pattern: Located { location: Location { - row: 70, - column: 8, + row: 71, + column: 9, }, end_location: Some( Location { - row: 70, - column: 13, + row: 71, + column: 10, }, ), custom: (), - node: Assign { - targets: [ - Located { + node: MatchValue( + PatternMatchValue { + value: Located { location: Location { - row: 70, - column: 8, + row: 71, + column: 9, }, end_location: Some( Location { - row: 70, - column: 9, + row: 71, + column: 10, }, ), custom: (), - node: Name { - id: "y", - ctx: Store, - }, - }, - ], - value: Located { - location: Location { - row: 70, - column: 12, - }, - end_location: Some( - Location { - row: 70, - column: 13, - }, - ), - custom: (), - node: Constant { - value: Int( - 0, + node: Constant( + ExprConstant { + value: Int( + 1, + ), + kind: None, + }, ), - kind: None, }, }, - type_comment: None, - }, - }, - ], - }, - MatchCase { - pattern: Located { - location: Location { - row: 71, - column: 9, + ), }, - end_location: Some( - Location { - row: 71, - column: 10, - }, - ), - custom: (), - node: MatchValue { - value: Located { + guard: None, + body: [ + Located { location: Location { - row: 71, - column: 9, + row: 72, + column: 8, }, end_location: Some( Location { - row: 71, - column: 10, + row: 72, + column: 13, }, ), custom: (), - node: Constant { - value: Int( - 1, - ), - kind: None, - }, + node: Assign( + StmtAssign { + targets: [ + Located { + location: Location { + row: 72, + column: 8, + }, + end_location: Some( + Location { + row: 72, + column: 9, + }, + ), + custom: (), + node: Name( + ExprName { + id: "y", + ctx: Store, + }, + ), + }, + ], + value: Located { + location: Location { + row: 72, + column: 12, + }, + end_location: Some( + Location { + row: 72, + column: 13, + }, + ), + custom: (), + node: Constant( + ExprConstant { + value: Int( + 1, + ), + kind: None, + }, + ), + }, + type_comment: None, + }, + ), }, - }, + ], + }, + ], + }, + ), + }, + Located { + location: Location { + row: 74, + column: 0, + }, + end_location: Some( + Location { + row: 76, + column: 15, + }, + ), + custom: (), + node: Match( + StmtMatch { + subject: Located { + location: Location { + row: 74, + column: 6, }, - guard: None, - body: [ - Located { + end_location: Some( + Location { + row: 74, + column: 7, + }, + ), + custom: (), + node: Name( + ExprName { + id: "x", + ctx: Load, + }, + ), + }, + cases: [ + MatchCase { + pattern: Located { location: Location { - row: 72, - column: 8, + row: 75, + column: 9, }, end_location: Some( Location { - row: 72, - column: 13, + row: 75, + column: 21, }, ), custom: (), - node: Assign { - targets: [ - Located { - location: Location { - row: 72, - column: 8, + node: MatchMapping( + PatternMatchMapping { + keys: [ + Located { + location: Location { + row: 75, + column: 10, + }, + end_location: Some( + Location { + row: 75, + column: 15, + }, + ), + custom: (), + node: Constant( + ExprConstant { + value: Str( + "foo", + ), + kind: None, + }, + ), }, - end_location: Some( - Location { - row: 72, - column: 9, + ], + patterns: [ + Located { + location: Location { + row: 75, + column: 17, + }, + end_location: Some( + Location { + row: 75, + column: 20, + }, + ), + custom: (), + node: MatchAs( + PatternMatchAs { + pattern: None, + name: Some( + "bar", + ), + }, + ), + }, + ], + rest: None, + }, + ), + }, + guard: None, + body: [ + Located { + location: Location { + row: 76, + column: 8, + }, + end_location: Some( + Location { + row: 76, + column: 15, + }, + ), + custom: (), + node: Assign( + StmtAssign { + targets: [ + Located { + location: Location { + row: 76, + column: 8, + }, + end_location: Some( + Location { + row: 76, + column: 9, + }, + ), + custom: (), + node: Name( + ExprName { + id: "y", + ctx: Store, + }, + ), }, - ), - custom: (), - node: Name { - id: "y", - ctx: Store, - }, - }, - ], - value: Located { - location: Location { - row: 72, - column: 12, - }, - end_location: Some( - Location { - row: 72, - column: 13, + ], + value: Located { + location: Location { + row: 76, + column: 12, + }, + end_location: Some( + Location { + row: 76, + column: 15, + }, + ), + custom: (), + node: Name( + ExprName { + id: "bar", + ctx: Load, + }, + ), }, - ), - custom: (), - node: Constant { - value: Int( - 1, - ), - kind: None, + type_comment: None, }, - }, - type_comment: None, + ), }, - }, - ], - }, - ], - }, + ], + }, + ], + }, + ), }, Located { location: Location { - row: 74, + row: 78, column: 0, }, end_location: Some( Location { - row: 76, - column: 15, + row: 80, + column: 13, }, ), custom: (), - node: Match { - subject: Located { - location: Location { - row: 74, - column: 6, - }, - end_location: Some( - Location { - row: 74, - column: 7, + node: Match( + StmtMatch { + subject: Located { + location: Location { + row: 78, + column: 6, }, - ), - custom: (), - node: Name { - id: "x", - ctx: Load, - }, - }, - cases: [ - MatchCase { - pattern: Located { - location: Location { - row: 75, - column: 9, + end_location: Some( + Location { + row: 78, + column: 15, }, - end_location: Some( - Location { - row: 75, - column: 21, - }, - ), - custom: (), - node: MatchMapping { - keys: [ + ), + custom: (), + node: Tuple( + ExprTuple { + elts: [ Located { location: Location { - row: 75, - column: 10, + row: 78, + column: 7, }, end_location: Some( Location { - row: 75, - column: 15, + row: 78, + column: 8, }, ), custom: (), - node: Constant { - value: Str( - "foo", - ), - kind: None, - }, + node: Constant( + ExprConstant { + value: Int( + 0, + ), + kind: None, + }, + ), }, - ], - patterns: [ Located { location: Location { - row: 75, - column: 17, + row: 78, + column: 10, }, end_location: Some( Location { - row: 75, - column: 20, + row: 78, + column: 11, }, ), custom: (), - node: MatchAs { - pattern: None, - name: Some( - "bar", - ), - }, - }, - ], - rest: None, - }, - }, - guard: None, - body: [ - Located { - location: Location { - row: 76, - column: 8, - }, - end_location: Some( - Location { - row: 76, - column: 15, - }, - ), - custom: (), - node: Assign { - targets: [ - Located { - location: Location { - row: 76, - column: 8, - }, - end_location: Some( - Location { - row: 76, - column: 9, - }, - ), - custom: (), - node: Name { - id: "y", - ctx: Store, + node: Constant( + ExprConstant { + value: Int( + 1, + ), + kind: None, }, - }, - ], - value: Located { + ), + }, + Located { location: Location { - row: 76, - column: 12, + row: 78, + column: 13, }, end_location: Some( Location { - row: 76, - column: 15, + row: 78, + column: 14, }, ), custom: (), - node: Name { - id: "bar", - ctx: Load, - }, + node: Constant( + ExprConstant { + value: Int( + 2, + ), + kind: None, + }, + ), }, - type_comment: None, - }, + ], + ctx: Load, }, - ], - }, - ], - }, - }, - Located { - location: Location { - row: 78, - column: 0, - }, - end_location: Some( - Location { - row: 80, - column: 13, - }, - ), - custom: (), - node: Match { - subject: Located { - location: Location { - row: 78, - column: 6, + ), }, - end_location: Some( - Location { - row: 78, - column: 15, - }, - ), - custom: (), - node: Tuple { - elts: [ - Located { + cases: [ + MatchCase { + pattern: Located { location: Location { - row: 78, - column: 7, - }, - end_location: Some( - Location { - row: 78, - column: 8, - }, - ), - custom: (), - node: Constant { - value: Int( - 0, - ), - kind: None, - }, - }, - Located { - location: Location { - row: 78, - column: 10, - }, - end_location: Some( - Location { - row: 78, - column: 11, - }, - ), - custom: (), - node: Constant { - value: Int( - 1, - ), - kind: None, - }, - }, - Located { - location: Location { - row: 78, - column: 13, + row: 79, + column: 9, }, end_location: Some( Location { - row: 78, - column: 14, + row: 79, + column: 22, }, ), custom: (), - node: Constant { - value: Int( - 2, - ), - kind: None, - }, - }, - ], - ctx: Load, - }, - }, - cases: [ - MatchCase { - pattern: Located { - location: Location { - row: 79, - column: 9, - }, - end_location: Some( - Location { - row: 79, - column: 22, - }, - ), - custom: (), - node: MatchSequence { - patterns: [ - Located { - location: Location { - row: 79, - column: 10, - }, - end_location: Some( - Location { - row: 79, - column: 11, - }, - ), - custom: (), - node: MatchValue { - value: Located { + node: MatchSequence( + PatternMatchSequence { + patterns: [ + Located { location: Location { row: 79, column: 10, @@ -3813,29 +4216,33 @@ expression: parse_ast }, ), custom: (), - node: Constant { - value: Int( - 0, - ), - kind: None, - }, - }, - }, - }, - Located { - location: Location { - row: 79, - column: 13, - }, - end_location: Some( - Location { - row: 79, - column: 14, + node: MatchValue( + PatternMatchValue { + value: Located { + location: Location { + row: 79, + column: 10, + }, + end_location: Some( + Location { + row: 79, + column: 11, + }, + ), + custom: (), + node: Constant( + ExprConstant { + value: Int( + 0, + ), + kind: None, + }, + ), + }, + }, + ), }, - ), - custom: (), - node: MatchValue { - value: Located { + Located { location: Location { row: 79, column: 13, @@ -3847,47 +4254,53 @@ expression: parse_ast }, ), custom: (), - node: Constant { - value: Int( - 1, - ), - kind: None, - }, - }, - }, - }, - Located { - location: Location { - row: 79, - column: 16, - }, - end_location: Some( - Location { - row: 79, - column: 18, + node: MatchValue( + PatternMatchValue { + value: Located { + location: Location { + row: 79, + column: 13, + }, + end_location: Some( + Location { + row: 79, + column: 14, + }, + ), + custom: (), + node: Constant( + ExprConstant { + value: Int( + 1, + ), + kind: None, + }, + ), + }, + }, + ), }, - ), - custom: (), - node: MatchStar { - name: Some( - "x", - ), - }, - }, - Located { - location: Location { - row: 79, - column: 20, - }, - end_location: Some( - Location { - row: 79, - column: 21, + Located { + location: Location { + row: 79, + column: 16, + }, + end_location: Some( + Location { + row: 79, + column: 18, + }, + ), + custom: (), + node: MatchStar( + PatternMatchStar { + name: Some( + "x", + ), + }, + ), }, - ), - custom: (), - node: MatchValue { - value: Located { + Located { location: Location { row: 79, column: 20, @@ -3899,78 +4312,103 @@ expression: parse_ast }, ), custom: (), - node: Constant { - value: Int( - 2, - ), - kind: None, - }, + node: MatchValue( + PatternMatchValue { + value: Located { + location: Location { + row: 79, + column: 20, + }, + end_location: Some( + Location { + row: 79, + column: 21, + }, + ), + custom: (), + node: Constant( + ExprConstant { + value: Int( + 2, + ), + kind: None, + }, + ), + }, + }, + ), }, - }, + ], }, - ], + ), }, - }, - guard: None, - body: [ - Located { - location: Location { - row: 80, - column: 8, - }, - end_location: Some( - Location { + guard: None, + body: [ + Located { + location: Location { row: 80, - column: 13, + column: 8, }, - ), - custom: (), - node: Assign { - targets: [ - Located { - location: Location { - row: 80, - column: 8, - }, - end_location: Some( - Location { - row: 80, - column: 9, - }, - ), - custom: (), - node: Name { - id: "y", - ctx: Store, - }, - }, - ], - value: Located { - location: Location { + end_location: Some( + Location { row: 80, - column: 12, + column: 13, }, - end_location: Some( - Location { - row: 80, - column: 13, + ), + custom: (), + node: Assign( + StmtAssign { + targets: [ + Located { + location: Location { + row: 80, + column: 8, + }, + end_location: Some( + Location { + row: 80, + column: 9, + }, + ), + custom: (), + node: Name( + ExprName { + id: "y", + ctx: Store, + }, + ), + }, + ], + value: Located { + location: Location { + row: 80, + column: 12, + }, + end_location: Some( + Location { + row: 80, + column: 13, + }, + ), + custom: (), + node: Constant( + ExprConstant { + value: Int( + 0, + ), + kind: None, + }, + ), }, - ), - custom: (), - node: Constant { - value: Int( - 0, - ), - kind: None, + type_comment: None, }, - }, - type_comment: None, + ), }, - }, - ], - }, - ], - }, + ], + }, + ], + }, + ), }, Located { location: Location { @@ -3984,54 +4422,45 @@ expression: parse_ast }, ), custom: (), - node: Match { - subject: Located { - location: Location { - row: 82, - column: 6, - }, - end_location: Some( - Location { + node: Match( + StmtMatch { + subject: Located { + location: Location { row: 82, - column: 7, + column: 6, }, - ), - custom: (), - node: Name { - id: "x", - ctx: Load, - }, - }, - cases: [ - MatchCase { - pattern: Located { - location: Location { - row: 83, - column: 9, + end_location: Some( + Location { + row: 82, + column: 7, + }, + ), + custom: (), + node: Name( + ExprName { + id: "x", + ctx: Load, }, - end_location: Some( - Location { + ), + }, + cases: [ + MatchCase { + pattern: Located { + location: Location { row: 83, - column: 12, + column: 9, }, - ), - custom: (), - node: MatchSequence { - patterns: [ - Located { - location: Location { - row: 83, - column: 10, - }, - end_location: Some( - Location { - row: 83, - column: 11, - }, - ), - custom: (), - node: MatchValue { - value: Located { + end_location: Some( + Location { + row: 83, + column: 12, + }, + ), + custom: (), + node: MatchSequence( + PatternMatchSequence { + patterns: [ + Located { location: Location { row: 83, column: 10, @@ -4043,105 +4472,117 @@ expression: parse_ast }, ), custom: (), - node: Constant { - value: Int( - 0, - ), - kind: None, - }, + node: MatchValue( + PatternMatchValue { + value: Located { + location: Location { + row: 83, + column: 10, + }, + end_location: Some( + Location { + row: 83, + column: 11, + }, + ), + custom: (), + node: Constant( + ExprConstant { + value: Int( + 0, + ), + kind: None, + }, + ), + }, + }, + ), }, - }, + ], }, - ], + ), }, - }, - guard: None, - body: [ - Located { - location: Location { - row: 84, - column: 8, - }, - end_location: Some( - Location { + guard: None, + body: [ + Located { + location: Location { row: 84, - column: 13, + column: 8, }, - ), - custom: (), - node: Assign { - targets: [ - Located { - location: Location { - row: 84, - column: 8, - }, - end_location: Some( - Location { - row: 84, - column: 9, - }, - ), - custom: (), - node: Name { - id: "y", - ctx: Store, - }, - }, - ], - value: Located { - location: Location { + end_location: Some( + Location { row: 84, - column: 12, + column: 13, }, - end_location: Some( - Location { - row: 84, - column: 13, + ), + custom: (), + node: Assign( + StmtAssign { + targets: [ + Located { + location: Location { + row: 84, + column: 8, + }, + end_location: Some( + Location { + row: 84, + column: 9, + }, + ), + custom: (), + node: Name( + ExprName { + id: "y", + ctx: Store, + }, + ), + }, + ], + value: Located { + location: Location { + row: 84, + column: 12, + }, + end_location: Some( + Location { + row: 84, + column: 13, + }, + ), + custom: (), + node: Constant( + ExprConstant { + value: Int( + 0, + ), + kind: None, + }, + ), }, - ), - custom: (), - node: Constant { - value: Int( - 0, - ), - kind: None, + type_comment: None, }, - }, - type_comment: None, + ), }, - }, - ], - }, - MatchCase { - pattern: Located { - location: Location { - row: 85, - column: 9, - }, - end_location: Some( - Location { + ], + }, + MatchCase { + pattern: Located { + location: Location { row: 85, - column: 15, + column: 9, }, - ), - custom: (), - node: MatchSequence { - patterns: [ - Located { - location: Location { - row: 85, - column: 10, - }, - end_location: Some( - Location { - row: 85, - column: 11, - }, - ), - custom: (), - node: MatchValue { - value: Located { + end_location: Some( + Location { + row: 85, + column: 15, + }, + ), + custom: (), + node: MatchSequence( + PatternMatchSequence { + patterns: [ + Located { location: Location { row: 85, column: 10, @@ -4152,30 +4593,34 @@ expression: parse_ast column: 11, }, ), - custom: (), - node: Constant { - value: Int( - 1, - ), - kind: None, - }, - }, - }, - }, - Located { - location: Location { - row: 85, - column: 13, - }, - end_location: Some( - Location { - row: 85, - column: 14, + custom: (), + node: MatchValue( + PatternMatchValue { + value: Located { + location: Location { + row: 85, + column: 10, + }, + end_location: Some( + Location { + row: 85, + column: 11, + }, + ), + custom: (), + node: Constant( + ExprConstant { + value: Int( + 1, + ), + kind: None, + }, + ), + }, + }, + ), }, - ), - custom: (), - node: MatchValue { - value: Located { + Located { location: Location { row: 85, column: 13, @@ -4187,326 +4632,379 @@ expression: parse_ast }, ), custom: (), - node: Constant { - value: Int( - 0, - ), - kind: None, - }, + node: MatchValue( + PatternMatchValue { + value: Located { + location: Location { + row: 85, + column: 13, + }, + end_location: Some( + Location { + row: 85, + column: 14, + }, + ), + custom: (), + node: Constant( + ExprConstant { + value: Int( + 0, + ), + kind: None, + }, + ), + }, + }, + ), }, - }, + ], }, - ], + ), }, - }, - guard: Some( - Located { - location: Location { - row: 85, - column: 20, - }, - end_location: Some( - Location { + guard: Some( + Located { + location: Location { row: 85, - column: 30, - }, - ), - custom: (), - node: NamedExpr { - target: Located { - location: Location { - row: 85, - column: 20, - }, - end_location: Some( - Location { - row: 85, - column: 21, - }, - ), - custom: (), - node: Name { - id: "x", - ctx: Store, - }, + column: 20, }, - value: Located { - location: Location { + end_location: Some( + Location { row: 85, - column: 25, + column: 30, }, - end_location: Some( - Location { - row: 85, - column: 30, - }, - ), - custom: (), - node: Subscript { - value: Located { + ), + custom: (), + node: NamedExpr( + ExprNamedExpr { + target: Located { location: Location { row: 85, - column: 25, + column: 20, }, end_location: Some( Location { row: 85, - column: 26, + column: 21, }, ), custom: (), - node: Name { - id: "x", - ctx: Load, - }, + node: Name( + ExprName { + id: "x", + ctx: Store, + }, + ), }, - slice: Located { + value: Located { location: Location { row: 85, - column: 27, + column: 25, }, end_location: Some( Location { row: 85, - column: 29, + column: 30, }, ), custom: (), - node: Slice { - lower: None, - upper: Some( - Located { + node: Subscript( + ExprSubscript { + value: Located { location: Location { row: 85, - column: 28, + column: 25, }, end_location: Some( Location { row: 85, - column: 29, + column: 26, }, ), custom: (), - node: Constant { - value: Int( - 0, - ), - kind: None, + node: Name( + ExprName { + id: "x", + ctx: Load, + }, + ), + }, + slice: Located { + location: Location { + row: 85, + column: 27, }, + end_location: Some( + Location { + row: 85, + column: 29, + }, + ), + custom: (), + node: Slice( + ExprSlice { + lower: None, + upper: Some( + Located { + location: Location { + row: 85, + column: 28, + }, + end_location: Some( + Location { + row: 85, + column: 29, + }, + ), + custom: (), + node: Constant( + ExprConstant { + value: Int( + 0, + ), + kind: None, + }, + ), + }, + ), + step: None, + }, + ), + }, + ctx: Load, + }, + ), + }, + }, + ), + }, + ), + body: [ + Located { + location: Location { + row: 86, + column: 8, + }, + end_location: Some( + Location { + row: 86, + column: 13, + }, + ), + custom: (), + node: Assign( + StmtAssign { + targets: [ + Located { + location: Location { + row: 86, + column: 8, + }, + end_location: Some( + Location { + row: 86, + column: 9, }, ), - step: None, + custom: (), + node: Name( + ExprName { + id: "y", + ctx: Store, + }, + ), + }, + ], + value: Located { + location: Location { + row: 86, + column: 12, }, + end_location: Some( + Location { + row: 86, + column: 13, + }, + ), + custom: (), + node: Constant( + ExprConstant { + value: Int( + 1, + ), + kind: None, + }, + ), }, - ctx: Load, + type_comment: None, }, - }, + ), }, - }, - ), - body: [ - Located { + ], + }, + MatchCase { + pattern: Located { location: Location { - row: 86, - column: 8, + row: 87, + column: 9, }, end_location: Some( Location { - row: 86, - column: 13, + row: 87, + column: 15, }, ), custom: (), - node: Assign { - targets: [ - Located { - location: Location { - row: 86, - column: 8, - }, - end_location: Some( - Location { - row: 86, - column: 9, + node: MatchSequence( + PatternMatchSequence { + patterns: [ + Located { + location: Location { + row: 87, + column: 10, }, - ), - custom: (), - node: Name { - id: "y", - ctx: Store, - }, - }, - ], - value: Located { - location: Location { - row: 86, - column: 12, - }, - end_location: Some( - Location { - row: 86, - column: 13, - }, - ), - custom: (), - node: Constant { - value: Int( - 1, - ), - kind: None, - }, - }, - type_comment: None, - }, - }, - ], - }, - MatchCase { - pattern: Located { - location: Location { - row: 87, - column: 9, - }, - end_location: Some( - Location { - row: 87, - column: 15, - }, - ), - custom: (), - node: MatchSequence { - patterns: [ - Located { - location: Location { - row: 87, - column: 10, - }, - end_location: Some( - Location { - row: 87, - column: 11, + end_location: Some( + Location { + row: 87, + column: 11, + }, + ), + custom: (), + node: MatchValue( + PatternMatchValue { + value: Located { + location: Location { + row: 87, + column: 10, + }, + end_location: Some( + Location { + row: 87, + column: 11, + }, + ), + custom: (), + node: Constant( + ExprConstant { + value: Int( + 1, + ), + kind: None, + }, + ), + }, + }, + ), }, - ), - custom: (), - node: MatchValue { - value: Located { + Located { location: Location { row: 87, - column: 10, + column: 13, }, end_location: Some( Location { row: 87, - column: 11, + column: 14, }, ), custom: (), - node: Constant { - value: Int( - 1, - ), - kind: None, - }, + node: MatchValue( + PatternMatchValue { + value: Located { + location: Location { + row: 87, + column: 13, + }, + end_location: Some( + Location { + row: 87, + column: 14, + }, + ), + custom: (), + node: Constant( + ExprConstant { + value: Int( + 0, + ), + kind: None, + }, + ), + }, + }, + ), }, - }, + ], }, - Located { - location: Location { - row: 87, + ), + }, + guard: None, + body: [ + Located { + location: Location { + row: 88, + column: 8, + }, + end_location: Some( + Location { + row: 88, column: 13, }, - end_location: Some( - Location { - row: 87, - column: 14, - }, - ), - custom: (), - node: MatchValue { + ), + custom: (), + node: Assign( + StmtAssign { + targets: [ + Located { + location: Location { + row: 88, + column: 8, + }, + end_location: Some( + Location { + row: 88, + column: 9, + }, + ), + custom: (), + node: Name( + ExprName { + id: "y", + ctx: Store, + }, + ), + }, + ], value: Located { location: Location { - row: 87, - column: 13, + row: 88, + column: 12, }, end_location: Some( Location { - row: 87, - column: 14, + row: 88, + column: 13, }, ), custom: (), - node: Constant { - value: Int( - 0, - ), - kind: None, - }, - }, - }, - }, - ], - }, - }, - guard: None, - body: [ - Located { - location: Location { - row: 88, - column: 8, - }, - end_location: Some( - Location { - row: 88, - column: 13, - }, - ), - custom: (), - node: Assign { - targets: [ - Located { - location: Location { - row: 88, - column: 8, - }, - end_location: Some( - Location { - row: 88, - column: 9, - }, - ), - custom: (), - node: Name { - id: "y", - ctx: Store, - }, - }, - ], - value: Located { - location: Location { - row: 88, - column: 12, - }, - end_location: Some( - Location { - row: 88, - column: 13, + node: Constant( + ExprConstant { + value: Int( + 2, + ), + kind: None, + }, + ), }, - ), - custom: (), - node: Constant { - value: Int( - 2, - ), - kind: None, + type_comment: None, }, - }, - type_comment: None, + ), }, - }, - ], - }, - ], - }, + ], + }, + ], + }, + ), }, Located { location: Location { @@ -4520,157 +5018,175 @@ expression: parse_ast }, ), custom: (), - node: Match { - subject: Located { - location: Location { - row: 90, - column: 6, - }, - end_location: Some( - Location { + node: Match( + StmtMatch { + subject: Located { + location: Location { row: 90, - column: 7, + column: 6, }, - ), - custom: (), - node: Name { - id: "w", - ctx: Load, - }, - }, - cases: [ - MatchCase { - pattern: Located { - location: Location { - row: 91, - column: 9, + end_location: Some( + Location { + row: 90, + column: 7, }, - end_location: Some( - Location { - row: 91, - column: 19, - }, - ), - custom: (), - node: MatchSequence { - patterns: [ - Located { - location: Location { - row: 91, - column: 10, - }, - end_location: Some( - Location { - row: 91, - column: 11, - }, - ), - custom: (), - node: MatchAs { - pattern: None, - name: Some( - "x", - ), - }, - }, - Located { - location: Location { - row: 91, - column: 13, - }, - end_location: Some( - Location { - row: 91, - column: 14, - }, - ), - custom: (), - node: MatchAs { - pattern: None, - name: Some( - "y", - ), - }, - }, - Located { - location: Location { - row: 91, - column: 16, - }, - end_location: Some( - Location { - row: 91, - column: 18, - }, - ), - custom: (), - node: MatchStar { - name: None, - }, - }, - ], + ), + custom: (), + node: Name( + ExprName { + id: "w", + ctx: Load, }, - }, - guard: None, - body: [ - Located { + ), + }, + cases: [ + MatchCase { + pattern: Located { location: Location { - row: 92, - column: 8, + row: 91, + column: 9, }, end_location: Some( Location { - row: 92, - column: 13, + row: 91, + column: 19, }, ), custom: (), - node: Assign { - targets: [ - Located { - location: Location { - row: 92, - column: 8, + node: MatchSequence( + PatternMatchSequence { + patterns: [ + Located { + location: Location { + row: 91, + column: 10, + }, + end_location: Some( + Location { + row: 91, + column: 11, + }, + ), + custom: (), + node: MatchAs( + PatternMatchAs { + pattern: None, + name: Some( + "x", + ), + }, + ), }, - end_location: Some( - Location { - row: 92, - column: 9, + Located { + location: Location { + row: 91, + column: 13, }, - ), - custom: (), - node: Name { - id: "z", - ctx: Store, + end_location: Some( + Location { + row: 91, + column: 14, + }, + ), + custom: (), + node: MatchAs( + PatternMatchAs { + pattern: None, + name: Some( + "y", + ), + }, + ), }, - }, - ], - value: Located { - location: Location { + Located { + location: Location { + row: 91, + column: 16, + }, + end_location: Some( + Location { + row: 91, + column: 18, + }, + ), + custom: (), + node: MatchStar( + PatternMatchStar { + name: None, + }, + ), + }, + ], + }, + ), + }, + guard: None, + body: [ + Located { + location: Location { + row: 92, + column: 8, + }, + end_location: Some( + Location { row: 92, - column: 12, + column: 13, }, - end_location: Some( - Location { - row: 92, - column: 13, + ), + custom: (), + node: Assign( + StmtAssign { + targets: [ + Located { + location: Location { + row: 92, + column: 8, + }, + end_location: Some( + Location { + row: 92, + column: 9, + }, + ), + custom: (), + node: Name( + ExprName { + id: "z", + ctx: Store, + }, + ), + }, + ], + value: Located { + location: Location { + row: 92, + column: 12, + }, + end_location: Some( + Location { + row: 92, + column: 13, + }, + ), + custom: (), + node: Constant( + ExprConstant { + value: Int( + 0, + ), + kind: None, + }, + ), }, - ), - custom: (), - node: Constant { - value: Int( - 0, - ), - kind: None, + type_comment: None, }, - }, - type_comment: None, + ), }, - }, - ], - }, - ], - }, + ], + }, + ], + }, + ), }, Located { location: Location { @@ -4684,53 +5200,44 @@ expression: parse_ast }, ), custom: (), - node: Match { - subject: Located { - location: Location { - row: 94, - column: 6, - }, - end_location: Some( - Location { + node: Match( + StmtMatch { + subject: Located { + location: Location { row: 94, - column: 7, + column: 6, }, - ), - custom: (), - node: Name { - id: "x", - ctx: Load, - }, - }, - cases: [ - MatchCase { - pattern: Located { - location: Location { - row: 95, - column: 9, + end_location: Some( + Location { + row: 94, + column: 7, + }, + ), + custom: (), + node: Name( + ExprName { + id: "x", + ctx: Load, }, - end_location: Some( - Location { + ), + }, + cases: [ + MatchCase { + pattern: Located { + location: Location { row: 95, - column: 22, + column: 9, }, - ), - custom: (), - node: MatchValue { - value: Located { - location: Location { + end_location: Some( + Location { row: 95, - column: 9, + column: 22, }, - end_location: Some( - Location { - row: 95, - column: 22, - }, - ), - custom: (), - node: BinOp { - left: Located { + ), + custom: (), + node: MatchValue( + PatternMatchValue { + value: Located { location: Location { row: 95, column: 9, @@ -4738,677 +5245,768 @@ expression: parse_ast end_location: Some( Location { row: 95, - column: 14, + column: 22, }, ), custom: (), - node: UnaryOp { - op: USub, - operand: Located { + node: BinOp( + ExprBinOp { + left: Located { + location: Location { + row: 95, + column: 9, + }, + end_location: Some( + Location { + row: 95, + column: 14, + }, + ), + custom: (), + node: UnaryOp( + ExprUnaryOp { + op: USub, + operand: Located { + location: Location { + row: 95, + column: 10, + }, + end_location: Some( + Location { + row: 95, + column: 14, + }, + ), + custom: (), + node: Constant( + ExprConstant { + value: Float( + 0.25, + ), + kind: None, + }, + ), + }, + }, + ), + }, + op: Sub, + right: Located { + location: Location { + row: 95, + column: 17, + }, + end_location: Some( + Location { + row: 95, + column: 22, + }, + ), + custom: (), + node: Constant( + ExprConstant { + value: Complex { + real: 0.0, + imag: 1.75, + }, + kind: None, + }, + ), + }, + }, + ), + }, + }, + ), + }, + guard: None, + body: [ + Located { + location: Location { + row: 96, + column: 8, + }, + end_location: Some( + Location { + row: 96, + column: 13, + }, + ), + custom: (), + node: Assign( + StmtAssign { + targets: [ + Located { location: Location { - row: 95, - column: 10, + row: 96, + column: 8, }, end_location: Some( Location { - row: 95, - column: 14, + row: 96, + column: 9, }, ), custom: (), - node: Constant { - value: Float( - 0.25, + node: Name( + ExprName { + id: "y", + ctx: Store, + }, + ), + }, + ], + value: Located { + location: Location { + row: 96, + column: 12, + }, + end_location: Some( + Location { + row: 96, + column: 13, + }, + ), + custom: (), + node: Constant( + ExprConstant { + value: Int( + 0, ), kind: None, }, - }, + ), }, + type_comment: None, }, - op: Sub, - right: Located { - location: Location { - row: 95, - column: 17, + ), + }, + ], + }, + ], + }, + ), + }, + Located { + location: Location { + row: 98, + column: 0, + }, + end_location: Some( + Location { + row: 100, + column: 13, + }, + ), + custom: (), + node: Match( + StmtMatch { + subject: Located { + location: Location { + row: 98, + column: 6, + }, + end_location: Some( + Location { + row: 98, + column: 10, + }, + ), + custom: (), + node: Tuple( + ExprTuple { + elts: [ + Located { + location: Location { + row: 98, + column: 7, + }, + end_location: Some( + Location { + row: 98, + column: 8, }, - end_location: Some( - Location { - row: 95, - column: 22, - }, - ), - custom: (), - node: Constant { - value: Complex { - real: 0.0, - imag: 1.75, - }, - kind: None, + ), + custom: (), + node: Name( + ExprName { + id: "x", + ctx: Load, }, - }, + ), }, - }, + ], + ctx: Load, }, - }, - guard: None, - body: [ - Located { + ), + }, + cases: [ + MatchCase { + pattern: Located { location: Location { - row: 96, - column: 8, + row: 99, + column: 9, }, end_location: Some( Location { - row: 96, - column: 13, + row: 99, + column: 12, }, ), custom: (), - node: Assign { - targets: [ - Located { - location: Location { - row: 96, - column: 8, - }, - end_location: Some( - Location { - row: 96, - column: 9, + node: MatchSequence( + PatternMatchSequence { + patterns: [ + Located { + location: Location { + row: 99, + column: 10, }, - ), - custom: (), - node: Name { - id: "y", - ctx: Store, + end_location: Some( + Location { + row: 99, + column: 11, + }, + ), + custom: (), + node: MatchAs( + PatternMatchAs { + pattern: None, + name: Some( + "y", + ), + }, + ), }, + ], + }, + ), + }, + guard: None, + body: [ + Located { + location: Location { + row: 100, + column: 8, + }, + end_location: Some( + Location { + row: 100, + column: 13, }, - ], - value: Located { - location: Location { - row: 96, - column: 12, - }, - end_location: Some( - Location { - row: 96, - column: 13, + ), + custom: (), + node: Assign( + StmtAssign { + targets: [ + Located { + location: Location { + row: 100, + column: 8, + }, + end_location: Some( + Location { + row: 100, + column: 9, + }, + ), + custom: (), + node: Name( + ExprName { + id: "z", + ctx: Store, + }, + ), + }, + ], + value: Located { + location: Location { + row: 100, + column: 12, + }, + end_location: Some( + Location { + row: 100, + column: 13, + }, + ), + custom: (), + node: Constant( + ExprConstant { + value: Int( + 0, + ), + kind: None, + }, + ), }, - ), - custom: (), - node: Constant { - value: Int( - 0, - ), - kind: None, + type_comment: None, }, - }, - type_comment: None, + ), }, - }, - ], - }, - ], - }, + ], + }, + ], + }, + ), }, Located { location: Location { - row: 98, + row: 102, column: 0, }, end_location: Some( Location { - row: 100, + row: 104, column: 13, }, ), custom: (), - node: Match { - subject: Located { - location: Location { - row: 98, - column: 6, - }, - end_location: Some( - Location { - row: 98, - column: 10, + node: Match( + StmtMatch { + subject: Located { + location: Location { + row: 102, + column: 6, }, - ), - custom: (), - node: Tuple { - elts: [ - Located { - location: Location { - row: 98, - column: 7, - }, - end_location: Some( - Location { - row: 98, - column: 8, - }, - ), - custom: (), - node: Name { - id: "x", - ctx: Load, - }, - }, - ], - ctx: Load, - }, - }, - cases: [ - MatchCase { - pattern: Located { - location: Location { - row: 99, - column: 9, + end_location: Some( + Location { + row: 102, + column: 7, }, - end_location: Some( - Location { - row: 99, - column: 12, - }, - ), - custom: (), - node: MatchSequence { - patterns: [ - Located { - location: Location { - row: 99, - column: 10, - }, - end_location: Some( - Location { - row: 99, - column: 11, - }, - ), - custom: (), - node: MatchAs { - pattern: None, - name: Some( - "y", - ), - }, - }, - ], + ), + custom: (), + node: Name( + ExprName { + id: "x", + ctx: Load, }, - }, - guard: None, - body: [ - Located { + ), + }, + cases: [ + MatchCase { + pattern: Located { location: Location { - row: 100, - column: 8, + row: 103, + column: 9, }, end_location: Some( Location { - row: 100, - column: 13, + row: 103, + column: 16, }, ), custom: (), - node: Assign { - targets: [ - Located { + node: MatchValue( + PatternMatchValue { + value: Located { location: Location { - row: 100, - column: 8, + row: 103, + column: 9, }, end_location: Some( Location { - row: 100, - column: 9, + row: 103, + column: 16, }, ), custom: (), - node: Name { - id: "z", - ctx: Store, - }, + node: Attribute( + ExprAttribute { + value: Located { + location: Location { + row: 103, + column: 9, + }, + end_location: Some( + Location { + row: 103, + column: 14, + }, + ), + custom: (), + node: Attribute( + ExprAttribute { + value: Located { + location: Location { + row: 103, + column: 9, + }, + end_location: Some( + Location { + row: 103, + column: 12, + }, + ), + custom: (), + node: Attribute( + ExprAttribute { + value: Located { + location: Location { + row: 103, + column: 9, + }, + end_location: Some( + Location { + row: 103, + column: 10, + }, + ), + custom: (), + node: Name( + ExprName { + id: "A", + ctx: Load, + }, + ), + }, + attr: "B", + ctx: Load, + }, + ), + }, + attr: "C", + ctx: Load, + }, + ), + }, + attr: "D", + ctx: Load, + }, + ), }, - ], - value: Located { - location: Location { - row: 100, - column: 12, + }, + ), + }, + guard: None, + body: [ + Located { + location: Location { + row: 104, + column: 8, + }, + end_location: Some( + Location { + row: 104, + column: 13, }, - end_location: Some( - Location { - row: 100, - column: 13, + ), + custom: (), + node: Assign( + StmtAssign { + targets: [ + Located { + location: Location { + row: 104, + column: 8, + }, + end_location: Some( + Location { + row: 104, + column: 9, + }, + ), + custom: (), + node: Name( + ExprName { + id: "y", + ctx: Store, + }, + ), + }, + ], + value: Located { + location: Location { + row: 104, + column: 12, + }, + end_location: Some( + Location { + row: 104, + column: 13, + }, + ), + custom: (), + node: Constant( + ExprConstant { + value: Int( + 0, + ), + kind: None, + }, + ), }, - ), - custom: (), - node: Constant { - value: Int( - 0, - ), - kind: None, + type_comment: None, }, - }, - type_comment: None, + ), }, - }, - ], - }, - ], - }, + ], + }, + ], + }, + ), }, Located { location: Location { - row: 102, + row: 106, column: 0, }, end_location: Some( Location { - row: 104, + row: 108, column: 13, }, ), custom: (), - node: Match { - subject: Located { - location: Location { - row: 102, - column: 6, - }, - end_location: Some( - Location { - row: 102, - column: 7, + node: Match( + StmtMatch { + subject: Located { + location: Location { + row: 106, + column: 6, }, - ), - custom: (), - node: Name { - id: "x", - ctx: Load, - }, - }, - cases: [ - MatchCase { - pattern: Located { - location: Location { - row: 103, - column: 9, + end_location: Some( + Location { + row: 106, + column: 7, }, - end_location: Some( - Location { - row: 103, - column: 16, + ), + custom: (), + node: Name( + ExprName { + id: "x", + ctx: Load, + }, + ), + }, + cases: [ + MatchCase { + pattern: Located { + location: Location { + row: 107, + column: 9, }, - ), - custom: (), - node: MatchValue { - value: Located { + end_location: Some( + Location { + row: 107, + column: 13, + }, + ), + custom: (), + node: MatchSingleton( + PatternMatchSingleton { + value: None, + }, + ), + }, + guard: None, + body: [ + Located { location: Location { - row: 103, - column: 9, + row: 108, + column: 8, }, end_location: Some( Location { - row: 103, - column: 16, + row: 108, + column: 13, }, ), custom: (), - node: Attribute { - value: Located { - location: Location { - row: 103, - column: 9, - }, - end_location: Some( - Location { - row: 103, - column: 14, - }, - ), - custom: (), - node: Attribute { - value: Located { + node: Assign( + StmtAssign { + targets: [ + Located { location: Location { - row: 103, - column: 9, + row: 108, + column: 8, }, end_location: Some( Location { - row: 103, - column: 12, + row: 108, + column: 9, }, ), custom: (), - node: Attribute { - value: Located { - location: Location { - row: 103, - column: 9, - }, - end_location: Some( - Location { - row: 103, - column: 10, - }, - ), - custom: (), - node: Name { - id: "A", - ctx: Load, - }, + node: Name( + ExprName { + id: "y", + ctx: Store, }, - attr: "B", - ctx: Load, - }, + ), }, - attr: "C", - ctx: Load, - }, - }, - attr: "D", - ctx: Load, - }, - }, - }, - }, - guard: None, - body: [ - Located { - location: Location { - row: 104, - column: 8, - }, - end_location: Some( - Location { - row: 104, - column: 13, - }, - ), - custom: (), - node: Assign { - targets: [ - Located { - location: Location { - row: 104, - column: 8, - }, - end_location: Some( - Location { - row: 104, - column: 9, + ], + value: Located { + location: Location { + row: 108, + column: 12, }, - ), - custom: (), - node: Name { - id: "y", - ctx: Store, - }, - }, - ], - value: Located { - location: Location { - row: 104, - column: 12, - }, - end_location: Some( - Location { - row: 104, - column: 13, + end_location: Some( + Location { + row: 108, + column: 13, + }, + ), + custom: (), + node: Constant( + ExprConstant { + value: Int( + 0, + ), + kind: None, + }, + ), }, - ), - custom: (), - node: Constant { - value: Int( - 0, - ), - kind: None, + type_comment: None, }, - }, - type_comment: None, + ), }, - }, - ], - }, - ], - }, + ], + }, + ], + }, + ), }, Located { location: Location { - row: 106, + row: 110, column: 0, }, end_location: Some( Location { - row: 108, + row: 112, column: 13, }, ), custom: (), - node: Match { - subject: Located { - location: Location { - row: 106, - column: 6, - }, - end_location: Some( - Location { - row: 106, - column: 7, + node: Match( + StmtMatch { + subject: Located { + location: Location { + row: 110, + column: 6, }, - ), - custom: (), - node: Name { - id: "x", - ctx: Load, - }, - }, - cases: [ - MatchCase { - pattern: Located { - location: Location { - row: 107, - column: 9, + end_location: Some( + Location { + row: 110, + column: 7, }, - end_location: Some( - Location { - row: 107, - column: 13, - }, - ), - custom: (), - node: MatchSingleton { - value: None, + ), + custom: (), + node: Name( + ExprName { + id: "x", + ctx: Load, }, - }, - guard: None, - body: [ - Located { + ), + }, + cases: [ + MatchCase { + pattern: Located { location: Location { - row: 108, - column: 8, + row: 111, + column: 9, }, end_location: Some( Location { - row: 108, - column: 13, + row: 111, + column: 10, }, ), custom: (), - node: Assign { - targets: [ - Located { + node: MatchValue( + PatternMatchValue { + value: Located { location: Location { - row: 108, - column: 8, + row: 111, + column: 9, }, end_location: Some( Location { - row: 108, - column: 9, + row: 111, + column: 10, }, ), custom: (), - node: Name { - id: "y", - ctx: Store, - }, - }, - ], - value: Located { - location: Location { - row: 108, - column: 12, - }, - end_location: Some( - Location { - row: 108, - column: 13, - }, - ), - custom: (), - node: Constant { - value: Int( - 0, + node: Constant( + ExprConstant { + value: Int( + 0, + ), + kind: None, + }, ), - kind: None, }, }, - type_comment: None, - }, - }, - ], - }, - ], - }, - }, - Located { - location: Location { - row: 110, - column: 0, - }, - end_location: Some( - Location { - row: 112, - column: 13, - }, - ), - custom: (), - node: Match { - subject: Located { - location: Location { - row: 110, - column: 6, - }, - end_location: Some( - Location { - row: 110, - column: 7, - }, - ), - custom: (), - node: Name { - id: "x", - ctx: Load, - }, - }, - cases: [ - MatchCase { - pattern: Located { - location: Location { - row: 111, - column: 9, + ), }, - end_location: Some( - Location { - row: 111, - column: 10, - }, - ), - custom: (), - node: MatchValue { - value: Located { + guard: None, + body: [ + Located { location: Location { - row: 111, - column: 9, + row: 112, + column: 8, }, end_location: Some( Location { - row: 111, - column: 10, + row: 112, + column: 13, }, ), custom: (), - node: Constant { - value: Int( - 0, - ), - kind: None, - }, - }, - }, - }, - guard: None, - body: [ - Located { - location: Location { - row: 112, - column: 8, - }, - end_location: Some( - Location { - row: 112, - column: 13, - }, - ), - custom: (), - node: Assign { - targets: [ - Located { - location: Location { - row: 112, - column: 8, - }, - end_location: Some( - Location { + node: Assign( + StmtAssign { + targets: [ + Located { + location: Location { + row: 112, + column: 8, + }, + end_location: Some( + Location { + row: 112, + column: 9, + }, + ), + custom: (), + node: Name( + ExprName { + id: "y", + ctx: Store, + }, + ), + }, + ], + value: Located { + location: Location { row: 112, - column: 9, + column: 12, }, - ), - custom: (), - node: Name { - id: "y", - ctx: Store, - }, - }, - ], - value: Located { - location: Location { - row: 112, - column: 12, - }, - end_location: Some( - Location { - row: 112, - column: 13, + end_location: Some( + Location { + row: 112, + column: 13, + }, + ), + custom: (), + node: Constant( + ExprConstant { + value: Int( + 0, + ), + kind: None, + }, + ), }, - ), - custom: (), - node: Constant { - value: Int( - 0, - ), - kind: None, + type_comment: None, }, - }, - type_comment: None, + ), }, - }, - ], - }, - ], - }, + ], + }, + ], + }, + ), }, Located { location: Location { @@ -5422,104 +6020,116 @@ expression: parse_ast }, ), custom: (), - node: Match { - subject: Located { - location: Location { - row: 114, - column: 6, - }, - end_location: Some( - Location { + node: Match( + StmtMatch { + subject: Located { + location: Location { row: 114, - column: 7, + column: 6, }, - ), - custom: (), - node: Name { - id: "x", - ctx: Load, - }, - }, - cases: [ - MatchCase { - pattern: Located { - location: Location { - row: 115, - column: 9, + end_location: Some( + Location { + row: 114, + column: 7, }, - end_location: Some( - Location { - row: 115, - column: 14, - }, - ), - custom: (), - node: MatchSingleton { - value: Bool( - false, - ), + ), + custom: (), + node: Name( + ExprName { + id: "x", + ctx: Load, }, - }, - guard: None, - body: [ - Located { + ), + }, + cases: [ + MatchCase { + pattern: Located { location: Location { - row: 116, - column: 8, + row: 115, + column: 9, }, end_location: Some( Location { - row: 116, - column: 13, + row: 115, + column: 14, }, ), custom: (), - node: Assign { - targets: [ - Located { - location: Location { - row: 116, - column: 8, - }, - end_location: Some( - Location { - row: 116, - column: 9, - }, - ), - custom: (), - node: Name { - id: "y", - ctx: Store, - }, - }, - ], - value: Located { - location: Location { + node: MatchSingleton( + PatternMatchSingleton { + value: Bool( + false, + ), + }, + ), + }, + guard: None, + body: [ + Located { + location: Location { + row: 116, + column: 8, + }, + end_location: Some( + Location { row: 116, - column: 12, + column: 13, }, - end_location: Some( - Location { - row: 116, - column: 13, - }, - ), - custom: (), - node: Constant { - value: Int( - 0, - ), - kind: None, + ), + custom: (), + node: Assign( + StmtAssign { + targets: [ + Located { + location: Location { + row: 116, + column: 8, + }, + end_location: Some( + Location { + row: 116, + column: 9, + }, + ), + custom: (), + node: Name( + ExprName { + id: "y", + ctx: Store, + }, + ), + }, + ], + value: Located { + location: Location { + row: 116, + column: 12, + }, + end_location: Some( + Location { + row: 116, + column: 13, + }, + ), + custom: (), + node: Constant( + ExprConstant { + value: Int( + 0, + ), + kind: None, + }, + ), + }, + type_comment: None, }, - }, - type_comment: None, + ), }, - }, - ], - }, - ], - }, + ], + }, + ], + }, + ), }, Located { location: Location { @@ -5533,305 +6143,339 @@ expression: parse_ast }, ), custom: (), - node: Match { - subject: Located { - location: Location { - row: 118, - column: 6, - }, - end_location: Some( - Location { + node: Match( + StmtMatch { + subject: Located { + location: Location { row: 118, - column: 7, + column: 6, }, - ), - custom: (), - node: Name { - id: "x", - ctx: Load, - }, - }, - cases: [ - MatchCase { - pattern: Located { - location: Location { - row: 119, - column: 9, + end_location: Some( + Location { + row: 118, + column: 7, }, - end_location: Some( - Location { - row: 119, - column: 11, - }, - ), - custom: (), - node: MatchSequence { - patterns: [], + ), + custom: (), + node: Name( + ExprName { + id: "x", + ctx: Load, }, - }, - guard: None, - body: [ - Located { + ), + }, + cases: [ + MatchCase { + pattern: Located { location: Location { - row: 120, - column: 8, + row: 119, + column: 9, }, end_location: Some( Location { - row: 120, - column: 13, + row: 119, + column: 11, }, ), custom: (), - node: Assign { - targets: [ - Located { - location: Location { - row: 120, - column: 8, - }, - end_location: Some( - Location { - row: 120, - column: 9, - }, - ), - custom: (), - node: Name { - id: "y", - ctx: Store, - }, - }, - ], - value: Located { - location: Location { - row: 120, - column: 12, - }, - end_location: Some( - Location { - row: 120, - column: 13, - }, - ), - custom: (), - node: Constant { - value: Int( - 0, - ), - kind: None, - }, + node: MatchSequence( + PatternMatchSequence { + patterns: [], }, - type_comment: None, - }, - }, - ], - }, - MatchCase { - pattern: Located { - location: Location { - row: 121, - column: 9, + ), }, - end_location: Some( - Location { - row: 121, - column: 13, - }, - ), - custom: (), - node: MatchSequence { - patterns: [ - Located { - location: Location { - row: 121, - column: 10, + guard: None, + body: [ + Located { + location: Location { + row: 120, + column: 8, + }, + end_location: Some( + Location { + row: 120, + column: 13, }, - end_location: Some( - Location { - row: 121, - column: 12, - }, - ), - custom: (), - node: MatchValue { + ), + custom: (), + node: Assign( + StmtAssign { + targets: [ + Located { + location: Location { + row: 120, + column: 8, + }, + end_location: Some( + Location { + row: 120, + column: 9, + }, + ), + custom: (), + node: Name( + ExprName { + id: "y", + ctx: Store, + }, + ), + }, + ], value: Located { location: Location { - row: 121, - column: 10, + row: 120, + column: 12, }, end_location: Some( Location { - row: 121, - column: 12, + row: 120, + column: 13, }, ), custom: (), - node: Constant { - value: Str( - "", - ), - kind: None, - }, + node: Constant( + ExprConstant { + value: Int( + 0, + ), + kind: None, + }, + ), }, + type_comment: None, }, - }, - ], - }, + ), + }, + ], }, - guard: None, - body: [ - Located { + MatchCase { + pattern: Located { location: Location { - row: 122, - column: 8, + row: 121, + column: 9, }, end_location: Some( Location { - row: 122, + row: 121, column: 13, }, ), custom: (), - node: Assign { - targets: [ - Located { - location: Location { - row: 122, - column: 8, - }, - end_location: Some( - Location { - row: 122, - column: 9, + node: MatchSequence( + PatternMatchSequence { + patterns: [ + Located { + location: Location { + row: 121, + column: 10, }, - ), - custom: (), - node: Name { - id: "y", - ctx: Store, - }, - }, - ], - value: Located { - location: Location { - row: 122, - column: 12, - }, - end_location: Some( - Location { - row: 122, - column: 13, + end_location: Some( + Location { + row: 121, + column: 12, + }, + ), + custom: (), + node: MatchValue( + PatternMatchValue { + value: Located { + location: Location { + row: 121, + column: 10, + }, + end_location: Some( + Location { + row: 121, + column: 12, + }, + ), + custom: (), + node: Constant( + ExprConstant { + value: Str( + "", + ), + kind: None, + }, + ), + }, + }, + ), }, - ), - custom: (), - node: Constant { - value: Int( - 1, - ), - kind: None, - }, + ], }, - type_comment: None, - }, - }, - ], - }, - MatchCase { - pattern: Located { - location: Location { - row: 123, - column: 9, + ), }, - end_location: Some( - Location { - row: 123, - column: 11, - }, - ), - custom: (), - node: MatchValue { - value: Located { + guard: None, + body: [ + Located { location: Location { - row: 123, - column: 9, + row: 122, + column: 8, }, end_location: Some( Location { - row: 123, - column: 11, + row: 122, + column: 13, }, ), custom: (), - node: Constant { - value: Str( - "", - ), - kind: None, - }, + node: Assign( + StmtAssign { + targets: [ + Located { + location: Location { + row: 122, + column: 8, + }, + end_location: Some( + Location { + row: 122, + column: 9, + }, + ), + custom: (), + node: Name( + ExprName { + id: "y", + ctx: Store, + }, + ), + }, + ], + value: Located { + location: Location { + row: 122, + column: 12, + }, + end_location: Some( + Location { + row: 122, + column: 13, + }, + ), + custom: (), + node: Constant( + ExprConstant { + value: Int( + 1, + ), + kind: None, + }, + ), + }, + type_comment: None, + }, + ), }, - }, + ], }, - guard: None, - body: [ - Located { + MatchCase { + pattern: Located { location: Location { - row: 124, - column: 8, + row: 123, + column: 9, }, end_location: Some( Location { - row: 124, - column: 13, + row: 123, + column: 11, }, ), custom: (), - node: Assign { - targets: [ - Located { + node: MatchValue( + PatternMatchValue { + value: Located { location: Location { - row: 124, - column: 8, + row: 123, + column: 9, }, end_location: Some( Location { - row: 124, - column: 9, + row: 123, + column: 11, }, ), custom: (), - node: Name { - id: "y", - ctx: Store, - }, + node: Constant( + ExprConstant { + value: Str( + "", + ), + kind: None, + }, + ), }, - ], - value: Located { - location: Location { + }, + ), + }, + guard: None, + body: [ + Located { + location: Location { + row: 124, + column: 8, + }, + end_location: Some( + Location { row: 124, - column: 12, + column: 13, }, - end_location: Some( - Location { - row: 124, - column: 13, + ), + custom: (), + node: Assign( + StmtAssign { + targets: [ + Located { + location: Location { + row: 124, + column: 8, + }, + end_location: Some( + Location { + row: 124, + column: 9, + }, + ), + custom: (), + node: Name( + ExprName { + id: "y", + ctx: Store, + }, + ), + }, + ], + value: Located { + location: Location { + row: 124, + column: 12, + }, + end_location: Some( + Location { + row: 124, + column: 13, + }, + ), + custom: (), + node: Constant( + ExprConstant { + value: Int( + 2, + ), + kind: None, + }, + ), }, - ), - custom: (), - node: Constant { - value: Int( - 2, - ), - kind: None, + type_comment: None, }, - }, - type_comment: None, + ), }, - }, - ], - }, - ], - }, + ], + }, + ], + }, + ), }, Located { location: Location { @@ -5845,105 +6489,117 @@ expression: parse_ast }, ), custom: (), - node: Match { - subject: Located { - location: Location { - row: 126, - column: 6, - }, - end_location: Some( - Location { + node: Match( + StmtMatch { + subject: Located { + location: Location { row: 126, - column: 7, + column: 6, }, - ), - custom: (), - node: Name { - id: "x", - ctx: Load, - }, - }, - cases: [ - MatchCase { - pattern: Located { - location: Location { - row: 127, - column: 9, + end_location: Some( + Location { + row: 126, + column: 7, }, - end_location: Some( - Location { - row: 127, - column: 10, - }, - ), - custom: (), - node: MatchAs { - pattern: None, - name: Some( - "z", - ), + ), + custom: (), + node: Name( + ExprName { + id: "x", + ctx: Load, }, - }, - guard: None, - body: [ - Located { + ), + }, + cases: [ + MatchCase { + pattern: Located { location: Location { - row: 128, - column: 8, + row: 127, + column: 9, }, end_location: Some( Location { - row: 128, - column: 13, + row: 127, + column: 10, }, ), custom: (), - node: Assign { - targets: [ - Located { - location: Location { - row: 128, - column: 8, - }, - end_location: Some( - Location { - row: 128, - column: 9, - }, - ), - custom: (), - node: Name { - id: "y", - ctx: Store, - }, - }, - ], - value: Located { - location: Location { + node: MatchAs( + PatternMatchAs { + pattern: None, + name: Some( + "z", + ), + }, + ), + }, + guard: None, + body: [ + Located { + location: Location { + row: 128, + column: 8, + }, + end_location: Some( + Location { row: 128, - column: 12, + column: 13, }, - end_location: Some( - Location { - row: 128, - column: 13, + ), + custom: (), + node: Assign( + StmtAssign { + targets: [ + Located { + location: Location { + row: 128, + column: 8, + }, + end_location: Some( + Location { + row: 128, + column: 9, + }, + ), + custom: (), + node: Name( + ExprName { + id: "y", + ctx: Store, + }, + ), + }, + ], + value: Located { + location: Location { + row: 128, + column: 12, + }, + end_location: Some( + Location { + row: 128, + column: 13, + }, + ), + custom: (), + node: Constant( + ExprConstant { + value: Int( + 0, + ), + kind: None, + }, + ), }, - ), - custom: (), - node: Constant { - value: Int( - 0, - ), - kind: None, + type_comment: None, }, - }, - type_comment: None, + ), }, - }, - ], - }, - ], - }, + ], + }, + ], + }, + ), }, Located { location: Location { @@ -5957,159 +6613,177 @@ expression: parse_ast }, ), custom: (), - node: Match { - subject: Located { - location: Location { - row: 130, - column: 6, - }, - end_location: Some( - Location { + node: Match( + StmtMatch { + subject: Located { + location: Location { row: 130, - column: 7, + column: 6, }, - ), - custom: (), - node: Name { - id: "w", - ctx: Load, - }, - }, - cases: [ - MatchCase { - pattern: Located { - location: Location { - row: 131, - column: 9, + end_location: Some( + Location { + row: 130, + column: 7, }, - end_location: Some( - Location { - row: 131, - column: 22, - }, - ), - custom: (), - node: MatchSequence { - patterns: [ - Located { - location: Location { - row: 131, - column: 10, - }, - end_location: Some( - Location { - row: 131, - column: 11, - }, - ), - custom: (), - node: MatchAs { - pattern: None, - name: Some( - "x", - ), - }, - }, - Located { - location: Location { - row: 131, - column: 13, - }, - end_location: Some( - Location { - row: 131, - column: 14, - }, - ), - custom: (), - node: MatchAs { - pattern: None, - name: Some( - "y", - ), - }, - }, - Located { - location: Location { - row: 131, - column: 16, - }, - end_location: Some( - Location { - row: 131, - column: 21, - }, - ), - custom: (), - node: MatchStar { - name: Some( - "rest", - ), - }, - }, - ], + ), + custom: (), + node: Name( + ExprName { + id: "w", + ctx: Load, }, - }, - guard: None, - body: [ - Located { + ), + }, + cases: [ + MatchCase { + pattern: Located { location: Location { - row: 132, - column: 8, + row: 131, + column: 9, }, end_location: Some( Location { - row: 132, - column: 13, + row: 131, + column: 22, }, ), custom: (), - node: Assign { - targets: [ - Located { - location: Location { - row: 132, - column: 8, + node: MatchSequence( + PatternMatchSequence { + patterns: [ + Located { + location: Location { + row: 131, + column: 10, + }, + end_location: Some( + Location { + row: 131, + column: 11, + }, + ), + custom: (), + node: MatchAs( + PatternMatchAs { + pattern: None, + name: Some( + "x", + ), + }, + ), }, - end_location: Some( - Location { - row: 132, - column: 9, + Located { + location: Location { + row: 131, + column: 13, }, - ), - custom: (), - node: Name { - id: "z", - ctx: Store, + end_location: Some( + Location { + row: 131, + column: 14, + }, + ), + custom: (), + node: MatchAs( + PatternMatchAs { + pattern: None, + name: Some( + "y", + ), + }, + ), }, - }, - ], - value: Located { - location: Location { + Located { + location: Location { + row: 131, + column: 16, + }, + end_location: Some( + Location { + row: 131, + column: 21, + }, + ), + custom: (), + node: MatchStar( + PatternMatchStar { + name: Some( + "rest", + ), + }, + ), + }, + ], + }, + ), + }, + guard: None, + body: [ + Located { + location: Location { + row: 132, + column: 8, + }, + end_location: Some( + Location { row: 132, - column: 12, + column: 13, }, - end_location: Some( - Location { - row: 132, - column: 13, + ), + custom: (), + node: Assign( + StmtAssign { + targets: [ + Located { + location: Location { + row: 132, + column: 8, + }, + end_location: Some( + Location { + row: 132, + column: 9, + }, + ), + custom: (), + node: Name( + ExprName { + id: "z", + ctx: Store, + }, + ), + }, + ], + value: Located { + location: Location { + row: 132, + column: 12, + }, + end_location: Some( + Location { + row: 132, + column: 13, + }, + ), + custom: (), + node: Constant( + ExprConstant { + value: Int( + 0, + ), + kind: None, + }, + ), }, - ), - custom: (), - node: Constant { - value: Int( - 0, - ), - kind: None, + type_comment: None, }, - }, - type_comment: None, + ), }, - }, - ], - }, - ], - }, + ], + }, + ], + }, + ), }, Located { location: Location { @@ -6123,254 +6797,267 @@ expression: parse_ast }, ), custom: (), - node: Match { - subject: Located { - location: Location { - row: 134, - column: 6, - }, - end_location: Some( - Location { + node: Match( + StmtMatch { + subject: Located { + location: Location { row: 134, - column: 7, + column: 6, }, - ), - custom: (), - node: Name { - id: "x", - ctx: Load, - }, - }, - cases: [ - MatchCase { - pattern: Located { - location: Location { - row: 135, - column: 9, + end_location: Some( + Location { + row: 134, + column: 7, + }, + ), + custom: (), + node: Name( + ExprName { + id: "x", + ctx: Load, }, - end_location: Some( - Location { + ), + }, + cases: [ + MatchCase { + pattern: Located { + location: Location { row: 135, - column: 39, + column: 9, }, - ), - custom: (), - node: MatchOr { - patterns: [ - Located { - location: Location { - row: 135, - column: 9, - }, - end_location: Some( - Location { - row: 135, - column: 17, - }, - ), - custom: (), - node: MatchAs { - pattern: Some( - Located { - location: Location { + end_location: Some( + Location { + row: 135, + column: 39, + }, + ), + custom: (), + node: MatchOr( + PatternMatchOr { + patterns: [ + Located { + location: Location { + row: 135, + column: 9, + }, + end_location: Some( + Location { row: 135, - column: 10, + column: 17, }, - end_location: Some( - Location { - row: 135, - column: 11, - }, - ), - custom: (), - node: MatchValue { - value: Located { - location: Location { - row: 135, - column: 10, - }, - end_location: Some( - Location { + ), + custom: (), + node: MatchAs( + PatternMatchAs { + pattern: Some( + Located { + location: Location { row: 135, - column: 11, + column: 10, }, - ), - custom: (), - node: Constant { - value: Int( - 0, + end_location: Some( + Location { + row: 135, + column: 11, + }, + ), + custom: (), + node: MatchValue( + PatternMatchValue { + value: Located { + location: Location { + row: 135, + column: 10, + }, + end_location: Some( + Location { + row: 135, + column: 11, + }, + ), + custom: (), + node: Constant( + ExprConstant { + value: Int( + 0, + ), + kind: None, + }, + ), + }, + }, ), - kind: None, }, - }, + ), + name: Some( + "z", + ), }, - }, - ), - name: Some( - "z", - ), - }, - }, - Located { - location: Location { - row: 135, - column: 20, - }, - end_location: Some( - Location { - row: 135, - column: 28, + ), }, - ), - custom: (), - node: MatchAs { - pattern: Some( - Located { - location: Location { + Located { + location: Location { + row: 135, + column: 20, + }, + end_location: Some( + Location { row: 135, - column: 21, + column: 28, }, - end_location: Some( - Location { - row: 135, - column: 22, - }, - ), - custom: (), - node: MatchValue { - value: Located { - location: Location { - row: 135, - column: 21, - }, - end_location: Some( - Location { + ), + custom: (), + node: MatchAs( + PatternMatchAs { + pattern: Some( + Located { + location: Location { row: 135, - column: 22, + column: 21, }, - ), - custom: (), - node: Constant { - value: Int( - 1, + end_location: Some( + Location { + row: 135, + column: 22, + }, + ), + custom: (), + node: MatchValue( + PatternMatchValue { + value: Located { + location: Location { + row: 135, + column: 21, + }, + end_location: Some( + Location { + row: 135, + column: 22, + }, + ), + custom: (), + node: Constant( + ExprConstant { + value: Int( + 1, + ), + kind: None, + }, + ), + }, + }, ), - kind: None, }, - }, + ), + name: Some( + "z", + ), }, - }, - ), - name: Some( - "z", - ), - }, - }, - Located { - location: Location { - row: 135, - column: 31, - }, - end_location: Some( - Location { - row: 135, - column: 39, + ), }, - ), - custom: (), - node: MatchAs { - pattern: Some( - Located { - location: Location { + Located { + location: Location { + row: 135, + column: 31, + }, + end_location: Some( + Location { row: 135, - column: 32, + column: 39, }, - end_location: Some( - Location { - row: 135, - column: 33, - }, - ), - custom: (), - node: MatchValue { - value: Located { - location: Location { - row: 135, - column: 32, - }, - end_location: Some( - Location { + ), + custom: (), + node: MatchAs( + PatternMatchAs { + pattern: Some( + Located { + location: Location { row: 135, - column: 33, + column: 32, }, - ), - custom: (), - node: Constant { - value: Int( - 2, + end_location: Some( + Location { + row: 135, + column: 33, + }, + ), + custom: (), + node: MatchValue( + PatternMatchValue { + value: Located { + location: Location { + row: 135, + column: 32, + }, + end_location: Some( + Location { + row: 135, + column: 33, + }, + ), + custom: (), + node: Constant( + ExprConstant { + value: Int( + 2, + ), + kind: None, + }, + ), + }, + }, ), - kind: None, }, - }, + ), + name: Some( + "z", + ), }, - }, - ), - name: Some( - "z", - ), - }, + ), + }, + ], }, - ], + ), }, - }, - guard: Some( - Located { - location: Location { - row: 135, - column: 43, - }, - end_location: Some( - Location { + guard: Some( + Located { + location: Location { row: 135, - column: 53, + column: 43, }, - ), - custom: (), - node: Compare { - left: Located { - location: Location { + end_location: Some( + Location { row: 135, - column: 43, - }, - end_location: Some( - Location { - row: 135, - column: 44, - }, - ), - custom: (), - node: Name { - id: "z", - ctx: Load, + column: 53, }, - }, - ops: [ - Eq, - ], - comparators: [ - Located { - location: Location { - row: 135, - column: 48, - }, - end_location: Some( - Location { + ), + custom: (), + node: Compare( + ExprCompare { + left: Located { + location: Location { row: 135, - column: 53, + column: 43, }, - ), - custom: (), - node: BinOp { - left: Located { + end_location: Some( + Location { + row: 135, + column: 44, + }, + ), + custom: (), + node: Name( + ExprName { + id: "z", + ctx: Load, + }, + ), + }, + ops: [ + Eq, + ], + comparators: [ + Located { location: Location { row: 135, column: 48, @@ -6378,100 +7065,127 @@ expression: parse_ast end_location: Some( Location { row: 135, - column: 49, + column: 53, }, ), custom: (), - node: Name { - id: "x", - ctx: Load, - }, + node: BinOp( + ExprBinOp { + left: Located { + location: Location { + row: 135, + column: 48, + }, + end_location: Some( + Location { + row: 135, + column: 49, + }, + ), + custom: (), + node: Name( + ExprName { + id: "x", + ctx: Load, + }, + ), + }, + op: Mod, + right: Located { + location: Location { + row: 135, + column: 52, + }, + end_location: Some( + Location { + row: 135, + column: 53, + }, + ), + custom: (), + node: Constant( + ExprConstant { + value: Int( + 2, + ), + kind: None, + }, + ), + }, + }, + ), }, - op: Mod, - right: Located { + ], + }, + ), + }, + ), + body: [ + Located { + location: Location { + row: 136, + column: 8, + }, + end_location: Some( + Location { + row: 136, + column: 13, + }, + ), + custom: (), + node: Assign( + StmtAssign { + targets: [ + Located { location: Location { - row: 135, - column: 52, + row: 136, + column: 8, }, end_location: Some( Location { - row: 135, - column: 53, + row: 136, + column: 9, }, ), custom: (), - node: Constant { + node: Name( + ExprName { + id: "y", + ctx: Store, + }, + ), + }, + ], + value: Located { + location: Location { + row: 136, + column: 12, + }, + end_location: Some( + Location { + row: 136, + column: 13, + }, + ), + custom: (), + node: Constant( + ExprConstant { value: Int( - 2, + 0, ), kind: None, }, - }, - }, - }, - ], - }, - }, - ), - body: [ - Located { - location: Location { - row: 136, - column: 8, - }, - end_location: Some( - Location { - row: 136, - column: 13, - }, - ), - custom: (), - node: Assign { - targets: [ - Located { - location: Location { - row: 136, - column: 8, - }, - end_location: Some( - Location { - row: 136, - column: 9, - }, - ), - custom: (), - node: Name { - id: "y", - ctx: Store, - }, - }, - ], - value: Located { - location: Location { - row: 136, - column: 12, - }, - end_location: Some( - Location { - row: 136, - column: 13, + ), }, - ), - custom: (), - node: Constant { - value: Int( - 0, - ), - kind: None, + type_comment: None, }, - }, - type_comment: None, + ), }, - }, - ], - }, - ], - }, + ], + }, + ], + }, + ), }, Located { location: Location { @@ -6484,398 +7198,310 @@ expression: parse_ast column: 13, }, ), - custom: (), - node: Match { - subject: Located { - location: Location { - row: 138, - column: 6, - }, - end_location: Some( - Location { - row: 138, - column: 7, - }, - ), - custom: (), - node: Name { - id: "x", - ctx: Load, - }, - }, - cases: [ - MatchCase { - pattern: Located { - location: Location { - row: 139, - column: 9, - }, - end_location: Some( - Location { - row: 139, - column: 24, - }, - ), - custom: (), - node: MatchMapping { - keys: [ - Located { - location: Location { - row: 139, - column: 10, - }, - end_location: Some( - Location { - row: 139, - column: 11, - }, - ), - custom: (), - node: Constant { - value: Int( - 0, - ), - kind: None, - }, - }, - ], - patterns: [ - Located { - location: Location { - row: 139, - column: 13, - }, - end_location: Some( - Location { - row: 139, - column: 23, - }, - ), - custom: (), - node: MatchSequence { - patterns: [ - Located { - location: Location { - row: 139, - column: 14, - }, - end_location: Some( - Location { - row: 139, - column: 15, - }, - ), - custom: (), - node: MatchValue { - value: Located { - location: Location { - row: 139, - column: 14, - }, - end_location: Some( - Location { - row: 139, - column: 15, - }, - ), - custom: (), - node: Constant { - value: Int( - 1, - ), - kind: None, - }, - }, - }, - }, - Located { - location: Location { - row: 139, - column: 17, - }, - end_location: Some( - Location { - row: 139, - column: 18, - }, - ), - custom: (), - node: MatchValue { - value: Located { - location: Location { - row: 139, - column: 17, - }, - end_location: Some( - Location { - row: 139, - column: 18, - }, - ), - custom: (), - node: Constant { - value: Int( - 2, - ), - kind: None, - }, - }, - }, - }, - Located { - location: Location { - row: 139, - column: 20, - }, - end_location: Some( - Location { - row: 139, - column: 22, - }, - ), - custom: (), - node: MatchMapping { - keys: [], - patterns: [], - rest: None, - }, - }, - ], - }, - }, - ], - rest: None, - }, + custom: (), + node: Match( + StmtMatch { + subject: Located { + location: Location { + row: 138, + column: 6, }, - guard: None, - body: [ - Located { + end_location: Some( + Location { + row: 138, + column: 7, + }, + ), + custom: (), + node: Name( + ExprName { + id: "x", + ctx: Load, + }, + ), + }, + cases: [ + MatchCase { + pattern: Located { location: Location { - row: 140, - column: 8, + row: 139, + column: 9, }, end_location: Some( Location { - row: 140, - column: 13, + row: 139, + column: 24, }, ), custom: (), - node: Assign { - targets: [ - Located { - location: Location { - row: 140, - column: 8, - }, - end_location: Some( - Location { - row: 140, - column: 9, + node: MatchMapping( + PatternMatchMapping { + keys: [ + Located { + location: Location { + row: 139, + column: 10, }, - ), - custom: (), - node: Name { - id: "y", - ctx: Store, - }, - }, - ], - value: Located { - location: Location { - row: 140, - column: 12, - }, - end_location: Some( - Location { - row: 140, - column: 13, - }, - ), - custom: (), - node: Constant { - value: Int( - 0, - ), - kind: None, - }, - }, - type_comment: None, - }, - }, - ], - }, - MatchCase { - pattern: Located { - location: Location { - row: 141, - column: 9, - }, - end_location: Some( - Location { - row: 141, - column: 78, - }, - ), - custom: (), - node: MatchOr { - patterns: [ - Located { - location: Location { - row: 141, - column: 9, - }, - end_location: Some( - Location { - row: 141, - column: 32, - }, - ), - custom: (), - node: MatchMapping { - keys: [ - Located { - location: Location { - row: 141, - column: 10, + end_location: Some( + Location { + row: 139, + column: 11, }, - end_location: Some( - Location { - row: 141, - column: 11, - }, - ), - custom: (), - node: Constant { + ), + custom: (), + node: Constant( + ExprConstant { value: Int( 0, ), kind: None, }, + ), + }, + ], + patterns: [ + Located { + location: Location { + row: 139, + column: 13, }, - ], - patterns: [ - Located { - location: Location { - row: 141, - column: 13, + end_location: Some( + Location { + row: 139, + column: 23, }, - end_location: Some( - Location { - row: 141, - column: 31, - }, - ), - custom: (), - node: MatchOr { + ), + custom: (), + node: MatchSequence( + PatternMatchSequence { patterns: [ Located { location: Location { - row: 141, - column: 13, + row: 139, + column: 14, }, end_location: Some( Location { - row: 141, - column: 23, + row: 139, + column: 15, }, ), custom: (), - node: MatchSequence { - patterns: [ - Located { + node: MatchValue( + PatternMatchValue { + value: Located { location: Location { - row: 141, + row: 139, column: 14, }, end_location: Some( Location { - row: 141, + row: 139, column: 15, }, ), custom: (), - node: MatchValue { - value: Located { - location: Location { - row: 141, - column: 14, - }, - end_location: Some( - Location { - row: 141, - column: 15, - }, + node: Constant( + ExprConstant { + value: Int( + 1, ), - custom: (), - node: Constant { - value: Int( - 1, - ), - kind: None, - }, + kind: None, }, - }, + ), }, - Located { + }, + ), + }, + Located { + location: Location { + row: 139, + column: 17, + }, + end_location: Some( + Location { + row: 139, + column: 18, + }, + ), + custom: (), + node: MatchValue( + PatternMatchValue { + value: Located { location: Location { - row: 141, + row: 139, column: 17, }, end_location: Some( Location { - row: 141, + row: 139, column: 18, }, ), custom: (), - node: MatchValue { - value: Located { - location: Location { - row: 141, - column: 17, - }, - end_location: Some( - Location { - row: 141, - column: 18, - }, + node: Constant( + ExprConstant { + value: Int( + 2, ), - custom: (), - node: Constant { - value: Int( - 2, - ), - kind: None, - }, - }, - }, - }, - Located { - location: Location { - row: 141, - column: 20, - }, - end_location: Some( - Location { - row: 141, - column: 22, + kind: None, }, ), - custom: (), - node: MatchMapping { - keys: [], - patterns: [], - rest: None, - }, }, - ], + }, + ), + }, + Located { + location: Location { + row: 139, + column: 20, + }, + end_location: Some( + Location { + row: 139, + column: 22, + }, + ), + custom: (), + node: MatchMapping( + PatternMatchMapping { + keys: [], + patterns: [], + rest: None, + }, + ), + }, + ], + }, + ), + }, + ], + rest: None, + }, + ), + }, + guard: None, + body: [ + Located { + location: Location { + row: 140, + column: 8, + }, + end_location: Some( + Location { + row: 140, + column: 13, + }, + ), + custom: (), + node: Assign( + StmtAssign { + targets: [ + Located { + location: Location { + row: 140, + column: 8, + }, + end_location: Some( + Location { + row: 140, + column: 9, + }, + ), + custom: (), + node: Name( + ExprName { + id: "y", + ctx: Store, + }, + ), + }, + ], + value: Located { + location: Location { + row: 140, + column: 12, + }, + end_location: Some( + Location { + row: 140, + column: 13, + }, + ), + custom: (), + node: Constant( + ExprConstant { + value: Int( + 0, + ), + kind: None, + }, + ), + }, + type_comment: None, + }, + ), + }, + ], + }, + MatchCase { + pattern: Located { + location: Location { + row: 141, + column: 9, + }, + end_location: Some( + Location { + row: 141, + column: 78, + }, + ), + custom: (), + node: MatchOr( + PatternMatchOr { + patterns: [ + Located { + location: Location { + row: 141, + column: 9, + }, + end_location: Some( + Location { + row: 141, + column: 32, + }, + ), + custom: (), + node: MatchMapping( + PatternMatchMapping { + keys: [ + Located { + location: Location { + row: 141, + column: 10, }, + end_location: Some( + Location { + row: 141, + column: 11, + }, + ), + custom: (), + node: Constant( + ExprConstant { + value: Int( + 0, + ), + kind: None, + }, + ), }, + ], + patterns: [ Located { location: Location { row: 141, - column: 26, + column: 13, }, end_location: Some( Location { @@ -6883,440 +7509,622 @@ expression: parse_ast column: 31, }, ), - custom: (), - node: MatchSingleton { - value: Bool( - false, - ), - }, + custom: (), + node: MatchOr( + PatternMatchOr { + patterns: [ + Located { + location: Location { + row: 141, + column: 13, + }, + end_location: Some( + Location { + row: 141, + column: 23, + }, + ), + custom: (), + node: MatchSequence( + PatternMatchSequence { + patterns: [ + Located { + location: Location { + row: 141, + column: 14, + }, + end_location: Some( + Location { + row: 141, + column: 15, + }, + ), + custom: (), + node: MatchValue( + PatternMatchValue { + value: Located { + location: Location { + row: 141, + column: 14, + }, + end_location: Some( + Location { + row: 141, + column: 15, + }, + ), + custom: (), + node: Constant( + ExprConstant { + value: Int( + 1, + ), + kind: None, + }, + ), + }, + }, + ), + }, + Located { + location: Location { + row: 141, + column: 17, + }, + end_location: Some( + Location { + row: 141, + column: 18, + }, + ), + custom: (), + node: MatchValue( + PatternMatchValue { + value: Located { + location: Location { + row: 141, + column: 17, + }, + end_location: Some( + Location { + row: 141, + column: 18, + }, + ), + custom: (), + node: Constant( + ExprConstant { + value: Int( + 2, + ), + kind: None, + }, + ), + }, + }, + ), + }, + Located { + location: Location { + row: 141, + column: 20, + }, + end_location: Some( + Location { + row: 141, + column: 22, + }, + ), + custom: (), + node: MatchMapping( + PatternMatchMapping { + keys: [], + patterns: [], + rest: None, + }, + ), + }, + ], + }, + ), + }, + Located { + location: Location { + row: 141, + column: 26, + }, + end_location: Some( + Location { + row: 141, + column: 31, + }, + ), + custom: (), + node: MatchSingleton( + PatternMatchSingleton { + value: Bool( + false, + ), + }, + ), + }, + ], + }, + ), }, ], + rest: None, }, - }, - ], - rest: None, - }, - }, - Located { - location: Location { - row: 141, - column: 35, - }, - end_location: Some( - Location { - row: 141, - column: 44, + ), }, - ), - custom: (), - node: MatchMapping { - keys: [ - Located { - location: Location { - row: 141, - column: 36, - }, - end_location: Some( - Location { - row: 141, - column: 37, - }, - ), - custom: (), - node: Constant { - value: Int( - 1, - ), - kind: None, - }, + Located { + location: Location { + row: 141, + column: 35, }, - ], - patterns: [ - Located { - location: Location { + end_location: Some( + Location { row: 141, - column: 39, + column: 44, }, - end_location: Some( - Location { - row: 141, - column: 43, - }, - ), - custom: (), - node: MatchSequence { - patterns: [ + ), + custom: (), + node: MatchMapping( + PatternMatchMapping { + keys: [ Located { location: Location { row: 141, - column: 40, + column: 36, }, end_location: Some( Location { row: 141, - column: 42, + column: 37, }, ), custom: (), - node: MatchSequence { - patterns: [], - }, + node: Constant( + ExprConstant { + value: Int( + 1, + ), + kind: None, + }, + ), }, ], - }, - }, - ], - rest: None, - }, - }, - Located { - location: Location { - row: 141, - column: 47, - }, - end_location: Some( - Location { - row: 141, - column: 62, - }, - ), - custom: (), - node: MatchMapping { - keys: [ - Located { - location: Location { - row: 141, - column: 48, - }, - end_location: Some( - Location { - row: 141, - column: 49, - }, - ), - custom: (), - node: Constant { - value: Int( - 0, - ), - kind: None, - }, - }, - ], - patterns: [ - Located { - location: Location { - row: 141, - column: 51, - }, - end_location: Some( - Location { - row: 141, - column: 61, - }, - ), - custom: (), - node: MatchSequence { patterns: [ Located { location: Location { row: 141, - column: 52, + column: 39, }, end_location: Some( Location { row: 141, - column: 53, + column: 43, }, ), custom: (), - node: MatchValue { - value: Located { - location: Location { - row: 141, - column: 52, - }, - end_location: Some( - Location { - row: 141, - column: 53, + node: MatchSequence( + PatternMatchSequence { + patterns: [ + Located { + location: Location { + row: 141, + column: 40, + }, + end_location: Some( + Location { + row: 141, + column: 42, + }, + ), + custom: (), + node: MatchSequence( + PatternMatchSequence { + patterns: [], + }, + ), }, - ), - custom: (), - node: Constant { - value: Int( - 1, - ), - kind: None, - }, + ], }, - }, + ), }, + ], + rest: None, + }, + ), + }, + Located { + location: Location { + row: 141, + column: 47, + }, + end_location: Some( + Location { + row: 141, + column: 62, + }, + ), + custom: (), + node: MatchMapping( + PatternMatchMapping { + keys: [ Located { location: Location { row: 141, - column: 55, + column: 48, }, end_location: Some( Location { row: 141, - column: 56, + column: 49, }, ), custom: (), - node: MatchValue { - value: Located { - location: Location { - row: 141, - column: 55, - }, - end_location: Some( - Location { - row: 141, - column: 56, - }, + node: Constant( + ExprConstant { + value: Int( + 0, ), - custom: (), - node: Constant { - value: Int( - 2, - ), - kind: None, - }, + kind: None, }, - }, + ), }, + ], + patterns: [ Located { location: Location { row: 141, - column: 58, + column: 51, }, end_location: Some( Location { row: 141, - column: 60, + column: 61, }, ), custom: (), - node: MatchMapping { - keys: [], - patterns: [], - rest: None, - }, + node: MatchSequence( + PatternMatchSequence { + patterns: [ + Located { + location: Location { + row: 141, + column: 52, + }, + end_location: Some( + Location { + row: 141, + column: 53, + }, + ), + custom: (), + node: MatchValue( + PatternMatchValue { + value: Located { + location: Location { + row: 141, + column: 52, + }, + end_location: Some( + Location { + row: 141, + column: 53, + }, + ), + custom: (), + node: Constant( + ExprConstant { + value: Int( + 1, + ), + kind: None, + }, + ), + }, + }, + ), + }, + Located { + location: Location { + row: 141, + column: 55, + }, + end_location: Some( + Location { + row: 141, + column: 56, + }, + ), + custom: (), + node: MatchValue( + PatternMatchValue { + value: Located { + location: Location { + row: 141, + column: 55, + }, + end_location: Some( + Location { + row: 141, + column: 56, + }, + ), + custom: (), + node: Constant( + ExprConstant { + value: Int( + 2, + ), + kind: None, + }, + ), + }, + }, + ), + }, + Located { + location: Location { + row: 141, + column: 58, + }, + end_location: Some( + Location { + row: 141, + column: 60, + }, + ), + custom: (), + node: MatchMapping( + PatternMatchMapping { + keys: [], + patterns: [], + rest: None, + }, + ), + }, + ], + }, + ), }, ], + rest: None, }, - }, - ], - rest: None, - }, - }, - Located { - location: Location { - row: 141, - column: 65, - }, - end_location: Some( - Location { - row: 141, - column: 67, + ), }, - ), - custom: (), - node: MatchSequence { - patterns: [], - }, - }, - Located { - location: Location { - row: 141, - column: 70, - }, - end_location: Some( - Location { - row: 141, - column: 73, + Located { + location: Location { + row: 141, + column: 65, + }, + end_location: Some( + Location { + row: 141, + column: 67, + }, + ), + custom: (), + node: MatchSequence( + PatternMatchSequence { + patterns: [], + }, + ), }, - ), - custom: (), - node: MatchValue { - value: Located { + Located { location: Location { row: 141, column: 70, }, end_location: Some( Location { - row: 141, - column: 73, + row: 141, + column: 73, + }, + ), + custom: (), + node: MatchValue( + PatternMatchValue { + value: Located { + location: Location { + row: 141, + column: 70, + }, + end_location: Some( + Location { + row: 141, + column: 73, + }, + ), + custom: (), + node: Constant( + ExprConstant { + value: Str( + "X", + ), + kind: None, + }, + ), + }, + }, + ), + }, + Located { + location: Location { + row: 141, + column: 76, + }, + end_location: Some( + Location { + row: 141, + column: 78, + }, + ), + custom: (), + node: MatchMapping( + PatternMatchMapping { + keys: [], + patterns: [], + rest: None, + }, + ), + }, + ], + }, + ), + }, + guard: None, + body: [ + Located { + location: Location { + row: 142, + column: 8, + }, + end_location: Some( + Location { + row: 142, + column: 13, + }, + ), + custom: (), + node: Assign( + StmtAssign { + targets: [ + Located { + location: Location { + row: 142, + column: 8, + }, + end_location: Some( + Location { + row: 142, + column: 9, + }, + ), + custom: (), + node: Name( + ExprName { + id: "y", + ctx: Store, + }, + ), + }, + ], + value: Located { + location: Location { + row: 142, + column: 12, + }, + end_location: Some( + Location { + row: 142, + column: 13, }, ), custom: (), - node: Constant { - value: Str( - "X", - ), - kind: None, - }, - }, - }, - }, - Located { - location: Location { - row: 141, - column: 76, - }, - end_location: Some( - Location { - row: 141, - column: 78, + node: Constant( + ExprConstant { + value: Int( + 1, + ), + kind: None, + }, + ), }, - ), - custom: (), - node: MatchMapping { - keys: [], - patterns: [], - rest: None, + type_comment: None, }, - }, - ], - }, + ), + }, + ], }, - guard: None, - body: [ - Located { + MatchCase { + pattern: Located { location: Location { - row: 142, - column: 8, + row: 143, + column: 9, }, end_location: Some( Location { - row: 142, - column: 13, + row: 143, + column: 11, }, ), custom: (), - node: Assign { - targets: [ - Located { - location: Location { - row: 142, - column: 8, - }, - end_location: Some( - Location { - row: 142, - column: 9, - }, - ), - custom: (), - node: Name { - id: "y", - ctx: Store, - }, - }, - ], - value: Located { - location: Location { - row: 142, - column: 12, - }, - end_location: Some( - Location { - row: 142, - column: 13, - }, - ), - custom: (), - node: Constant { - value: Int( - 1, - ), - kind: None, - }, + node: MatchSequence( + PatternMatchSequence { + patterns: [], }, - type_comment: None, - }, - }, - ], - }, - MatchCase { - pattern: Located { - location: Location { - row: 143, - column: 9, - }, - end_location: Some( - Location { - row: 143, - column: 11, - }, - ), - custom: (), - node: MatchSequence { - patterns: [], + ), }, - }, - guard: None, - body: [ - Located { - location: Location { - row: 144, - column: 8, - }, - end_location: Some( - Location { + guard: None, + body: [ + Located { + location: Location { row: 144, - column: 13, + column: 8, }, - ), - custom: (), - node: Assign { - targets: [ - Located { - location: Location { - row: 144, - column: 8, - }, - end_location: Some( - Location { - row: 144, - column: 9, - }, - ), - custom: (), - node: Name { - id: "y", - ctx: Store, - }, - }, - ], - value: Located { - location: Location { + end_location: Some( + Location { row: 144, - column: 12, + column: 13, }, - end_location: Some( - Location { - row: 144, - column: 13, + ), + custom: (), + node: Assign( + StmtAssign { + targets: [ + Located { + location: Location { + row: 144, + column: 8, + }, + end_location: Some( + Location { + row: 144, + column: 9, + }, + ), + custom: (), + node: Name( + ExprName { + id: "y", + ctx: Store, + }, + ), + }, + ], + value: Located { + location: Location { + row: 144, + column: 12, + }, + end_location: Some( + Location { + row: 144, + column: 13, + }, + ), + custom: (), + node: Constant( + ExprConstant { + value: Int( + 2, + ), + kind: None, + }, + ), }, - ), - custom: (), - node: Constant { - value: Int( - 2, - ), - kind: None, + type_comment: None, }, - }, - type_comment: None, + ), }, - }, - ], - }, - ], - }, + ], + }, + ], + }, + ), }, Located { location: Location { @@ -7330,213 +8138,237 @@ expression: parse_ast }, ), custom: (), - node: Match { - subject: Located { - location: Location { - row: 146, - column: 6, - }, - end_location: Some( - Location { + node: Match( + StmtMatch { + subject: Located { + location: Location { row: 146, - column: 15, + column: 6, }, - ), - custom: (), - node: Tuple { - elts: [ - Located { - location: Location { - row: 146, - column: 7, - }, - end_location: Some( - Location { - row: 146, - column: 8, - }, - ), - custom: (), - node: Constant { - value: Int( - 0, - ), - kind: None, - }, + end_location: Some( + Location { + row: 146, + column: 15, }, - Located { - location: Location { - row: 146, - column: 10, - }, - end_location: Some( - Location { - row: 146, - column: 11, + ), + custom: (), + node: Tuple( + ExprTuple { + elts: [ + Located { + location: Location { + row: 146, + column: 7, + }, + end_location: Some( + Location { + row: 146, + column: 8, + }, + ), + custom: (), + node: Constant( + ExprConstant { + value: Int( + 0, + ), + kind: None, + }, + ), }, - ), - custom: (), - node: Constant { - value: Int( - 1, - ), - kind: None, - }, + Located { + location: Location { + row: 146, + column: 10, + }, + end_location: Some( + Location { + row: 146, + column: 11, + }, + ), + custom: (), + node: Constant( + ExprConstant { + value: Int( + 1, + ), + kind: None, + }, + ), + }, + Located { + location: Location { + row: 146, + column: 13, + }, + end_location: Some( + Location { + row: 146, + column: 14, + }, + ), + custom: (), + node: Constant( + ExprConstant { + value: Int( + 2, + ), + kind: None, + }, + ), + }, + ], + ctx: Load, }, - Located { + ), + }, + cases: [ + MatchCase { + pattern: Located { location: Location { - row: 146, - column: 13, + row: 147, + column: 9, }, end_location: Some( Location { - row: 146, + row: 147, column: 14, }, ), custom: (), - node: Constant { - value: Int( - 2, - ), - kind: None, - }, - }, - ], - ctx: Load, - }, - }, - cases: [ - MatchCase { - pattern: Located { - location: Location { - row: 147, - column: 9, - }, - end_location: Some( - Location { - row: 147, - column: 14, - }, - ), - custom: (), - node: MatchSequence { - patterns: [ - Located { - location: Location { - row: 147, - column: 9, - }, - end_location: Some( - Location { - row: 147, - column: 10, + node: MatchSequence( + PatternMatchSequence { + patterns: [ + Located { + location: Location { + row: 147, + column: 9, + }, + end_location: Some( + Location { + row: 147, + column: 10, + }, + ), + custom: (), + node: MatchValue( + PatternMatchValue { + value: Located { + location: Location { + row: 147, + column: 9, + }, + end_location: Some( + Location { + row: 147, + column: 10, + }, + ), + custom: (), + node: Constant( + ExprConstant { + value: Int( + 0, + ), + kind: None, + }, + ), + }, + }, + ), }, - ), - custom: (), - node: MatchValue { - value: Located { + Located { location: Location { row: 147, - column: 9, + column: 12, }, end_location: Some( Location { row: 147, - column: 10, + column: 14, }, ), custom: (), - node: Constant { - value: Int( - 0, - ), - kind: None, - }, - }, - }, - }, - Located { - location: Location { - row: 147, - column: 12, - }, - end_location: Some( - Location { - row: 147, - column: 14, + node: MatchStar( + PatternMatchStar { + name: Some( + "x", + ), + }, + ), }, - ), - custom: (), - node: MatchStar { - name: Some( - "x", - ), - }, + ], }, - ], + ), }, - }, - guard: None, - body: [ - Located { - location: Location { - row: 148, - column: 8, - }, - end_location: Some( - Location { + guard: None, + body: [ + Located { + location: Location { row: 148, - column: 13, + column: 8, }, - ), - custom: (), - node: Assign { - targets: [ - Located { - location: Location { - row: 148, - column: 8, - }, - end_location: Some( - Location { - row: 148, - column: 9, - }, - ), - custom: (), - node: Name { - id: "y", - ctx: Store, - }, - }, - ], - value: Located { - location: Location { + end_location: Some( + Location { row: 148, - column: 12, + column: 13, }, - end_location: Some( - Location { - row: 148, - column: 13, + ), + custom: (), + node: Assign( + StmtAssign { + targets: [ + Located { + location: Location { + row: 148, + column: 8, + }, + end_location: Some( + Location { + row: 148, + column: 9, + }, + ), + custom: (), + node: Name( + ExprName { + id: "y", + ctx: Store, + }, + ), + }, + ], + value: Located { + location: Location { + row: 148, + column: 12, + }, + end_location: Some( + Location { + row: 148, + column: 13, + }, + ), + custom: (), + node: Constant( + ExprConstant { + value: Int( + 0, + ), + kind: None, + }, + ), }, - ), - custom: (), - node: Constant { - value: Int( - 0, - ), - kind: None, + type_comment: None, }, - }, - type_comment: None, + ), }, - }, - ], - }, - ], - }, + ], + }, + ], + }, + ), }, Located { location: Location { @@ -7550,213 +8382,237 @@ expression: parse_ast }, ), custom: (), - node: Match { - subject: Located { - location: Location { - row: 150, - column: 6, - }, - end_location: Some( - Location { + node: Match( + StmtMatch { + subject: Located { + location: Location { row: 150, - column: 15, + column: 6, }, - ), - custom: (), - node: Tuple { - elts: [ - Located { - location: Location { - row: 150, - column: 7, - }, - end_location: Some( - Location { - row: 150, - column: 8, - }, - ), - custom: (), - node: Constant { - value: Int( - 0, - ), - kind: None, - }, - }, - Located { - location: Location { - row: 150, - column: 10, - }, - end_location: Some( - Location { - row: 150, - column: 11, - }, - ), - custom: (), - node: Constant { - value: Int( - 1, - ), - kind: None, - }, + end_location: Some( + Location { + row: 150, + column: 15, }, - Located { - location: Location { - row: 150, - column: 13, - }, - end_location: Some( - Location { - row: 150, - column: 14, + ), + custom: (), + node: Tuple( + ExprTuple { + elts: [ + Located { + location: Location { + row: 150, + column: 7, + }, + end_location: Some( + Location { + row: 150, + column: 8, + }, + ), + custom: (), + node: Constant( + ExprConstant { + value: Int( + 0, + ), + kind: None, + }, + ), }, - ), - custom: (), - node: Constant { - value: Int( - 2, - ), - kind: None, - }, - }, - ], - ctx: Load, - }, - }, - cases: [ - MatchCase { - pattern: Located { - location: Location { - row: 151, - column: 9, - }, - end_location: Some( - Location { - row: 151, - column: 15, - }, - ), - custom: (), - node: MatchSequence { - patterns: [ Located { location: Location { - row: 151, - column: 9, + row: 150, + column: 10, }, end_location: Some( Location { - row: 151, + row: 150, column: 11, }, ), custom: (), - node: MatchStar { - name: Some( - "x", - ), - }, + node: Constant( + ExprConstant { + value: Int( + 1, + ), + kind: None, + }, + ), }, Located { location: Location { - row: 151, + row: 150, column: 13, }, end_location: Some( Location { - row: 151, + row: 150, column: 14, }, ), custom: (), - node: MatchValue { - value: Located { + node: Constant( + ExprConstant { + value: Int( + 2, + ), + kind: None, + }, + ), + }, + ], + ctx: Load, + }, + ), + }, + cases: [ + MatchCase { + pattern: Located { + location: Location { + row: 151, + column: 9, + }, + end_location: Some( + Location { + row: 151, + column: 15, + }, + ), + custom: (), + node: MatchSequence( + PatternMatchSequence { + patterns: [ + Located { + location: Location { + row: 151, + column: 9, + }, + end_location: Some( + Location { + row: 151, + column: 11, + }, + ), + custom: (), + node: MatchStar( + PatternMatchStar { + name: Some( + "x", + ), + }, + ), + }, + Located { location: Location { row: 151, column: 13, }, end_location: Some( Location { - row: 151, - column: 14, + row: 151, + column: 14, + }, + ), + custom: (), + node: MatchValue( + PatternMatchValue { + value: Located { + location: Location { + row: 151, + column: 13, + }, + end_location: Some( + Location { + row: 151, + column: 14, + }, + ), + custom: (), + node: Constant( + ExprConstant { + value: Int( + 2, + ), + kind: None, + }, + ), + }, + }, + ), + }, + ], + }, + ), + }, + guard: None, + body: [ + Located { + location: Location { + row: 152, + column: 8, + }, + end_location: Some( + Location { + row: 152, + column: 13, + }, + ), + custom: (), + node: Assign( + StmtAssign { + targets: [ + Located { + location: Location { + row: 152, + column: 8, + }, + end_location: Some( + Location { + row: 152, + column: 9, + }, + ), + custom: (), + node: Name( + ExprName { + id: "y", + ctx: Store, + }, + ), + }, + ], + value: Located { + location: Location { + row: 152, + column: 12, + }, + end_location: Some( + Location { + row: 152, + column: 13, }, ), custom: (), - node: Constant { - value: Int( - 2, - ), - kind: None, - }, - }, - }, - }, - ], - }, - }, - guard: None, - body: [ - Located { - location: Location { - row: 152, - column: 8, - }, - end_location: Some( - Location { - row: 152, - column: 13, - }, - ), - custom: (), - node: Assign { - targets: [ - Located { - location: Location { - row: 152, - column: 8, - }, - end_location: Some( - Location { - row: 152, - column: 9, - }, - ), - custom: (), - node: Name { - id: "y", - ctx: Store, - }, - }, - ], - value: Located { - location: Location { - row: 152, - column: 12, - }, - end_location: Some( - Location { - row: 152, - column: 13, + node: Constant( + ExprConstant { + value: Int( + 0, + ), + kind: None, + }, + ), }, - ), - custom: (), - node: Constant { - value: Int( - 0, - ), - kind: None, + type_comment: None, }, - }, - type_comment: None, + ), }, - }, - ], - }, - ], - }, + ], + }, + ], + }, + ), }, Located { location: Location { @@ -7770,122 +8626,136 @@ expression: parse_ast }, ), custom: (), - node: Match { - subject: Located { - location: Location { - row: 154, - column: 6, - }, - end_location: Some( - Location { + node: Match( + StmtMatch { + subject: Located { + location: Location { row: 154, - column: 7, + column: 6, }, - ), - custom: (), - node: Name { - id: "x", - ctx: Load, - }, - }, - cases: [ - MatchCase { - pattern: Located { - location: Location { - row: 155, - column: 9, + end_location: Some( + Location { + row: 154, + column: 7, }, - end_location: Some( - Location { - row: 155, - column: 11, - }, - ), - custom: (), - node: MatchSequence { - patterns: [ - Located { - location: Location { - row: 155, - column: 9, - }, - end_location: Some( - Location { - row: 155, - column: 10, - }, - ), - custom: (), - node: MatchAs { - pattern: None, - name: Some( - "y", - ), - }, - }, - ], + ), + custom: (), + node: Name( + ExprName { + id: "x", + ctx: Load, }, - }, - guard: None, - body: [ - Located { + ), + }, + cases: [ + MatchCase { + pattern: Located { location: Location { - row: 156, - column: 8, + row: 155, + column: 9, }, end_location: Some( Location { - row: 156, - column: 13, + row: 155, + column: 11, }, ), custom: (), - node: Assign { - targets: [ - Located { - location: Location { - row: 156, - column: 8, - }, - end_location: Some( - Location { - row: 156, + node: MatchSequence( + PatternMatchSequence { + patterns: [ + Located { + location: Location { + row: 155, column: 9, }, - ), - custom: (), - node: Name { - id: "z", - ctx: Store, + end_location: Some( + Location { + row: 155, + column: 10, + }, + ), + custom: (), + node: MatchAs( + PatternMatchAs { + pattern: None, + name: Some( + "y", + ), + }, + ), }, - }, - ], - value: Located { - location: Location { + ], + }, + ), + }, + guard: None, + body: [ + Located { + location: Location { + row: 156, + column: 8, + }, + end_location: Some( + Location { row: 156, - column: 12, + column: 13, }, - end_location: Some( - Location { - row: 156, - column: 13, + ), + custom: (), + node: Assign( + StmtAssign { + targets: [ + Located { + location: Location { + row: 156, + column: 8, + }, + end_location: Some( + Location { + row: 156, + column: 9, + }, + ), + custom: (), + node: Name( + ExprName { + id: "z", + ctx: Store, + }, + ), + }, + ], + value: Located { + location: Location { + row: 156, + column: 12, + }, + end_location: Some( + Location { + row: 156, + column: 13, + }, + ), + custom: (), + node: Constant( + ExprConstant { + value: Int( + 0, + ), + kind: None, + }, + ), }, - ), - custom: (), - node: Constant { - value: Int( - 0, - ), - kind: None, + type_comment: None, }, - }, - type_comment: None, + ), }, - }, - ], - }, - ], - }, + ], + }, + ], + }, + ), }, Located { location: Location { @@ -7899,176 +8769,196 @@ expression: parse_ast }, ), custom: (), - node: Match { - subject: Located { - location: Location { - row: 158, - column: 0, - }, - end_location: Some( - Location { - row: 160, - column: 13, + node: Match( + StmtMatch { + subject: Located { + location: Location { + row: 158, + column: 0, }, - ), - custom: (), - node: Tuple { - elts: [ - Located { - location: Location { - row: 158, - column: 6, - }, - end_location: Some( - Location { - row: 158, - column: 7, - }, - ), - custom: (), - node: Name { - id: "w", - ctx: Load, - }, - }, - Located { - location: Location { - row: 158, - column: 9, - }, - end_location: Some( - Location { - row: 158, - column: 10, - }, - ), - custom: (), - node: Name { - id: "x", - ctx: Load, - }, - }, - ], - ctx: Load, - }, - }, - cases: [ - MatchCase { - pattern: Located { - location: Location { - row: 159, - column: 9, + end_location: Some( + Location { + row: 160, + column: 13, }, - end_location: Some( - Location { - row: 159, - column: 13, - }, - ), - custom: (), - node: MatchSequence { - patterns: [ + ), + custom: (), + node: Tuple( + ExprTuple { + elts: [ Located { location: Location { - row: 159, - column: 9, + row: 158, + column: 6, }, end_location: Some( Location { - row: 159, - column: 10, + row: 158, + column: 7, }, ), custom: (), - node: MatchAs { - pattern: None, - name: Some( - "y", - ), - }, + node: Name( + ExprName { + id: "w", + ctx: Load, + }, + ), }, Located { location: Location { - row: 159, - column: 12, + row: 158, + column: 9, }, end_location: Some( Location { - row: 159, - column: 13, + row: 158, + column: 10, + }, + ), + custom: (), + node: Name( + ExprName { + id: "x", + ctx: Load, + }, + ), + }, + ], + ctx: Load, + }, + ), + }, + cases: [ + MatchCase { + pattern: Located { + location: Location { + row: 159, + column: 9, + }, + end_location: Some( + Location { + row: 159, + column: 13, + }, + ), + custom: (), + node: MatchSequence( + PatternMatchSequence { + patterns: [ + Located { + location: Location { + row: 159, + column: 9, + }, + end_location: Some( + Location { + row: 159, + column: 10, + }, + ), + custom: (), + node: MatchAs( + PatternMatchAs { + pattern: None, + name: Some( + "y", + ), + }, + ), + }, + Located { + location: Location { + row: 159, + column: 12, + }, + end_location: Some( + Location { + row: 159, + column: 13, + }, + ), + custom: (), + node: MatchAs( + PatternMatchAs { + pattern: None, + name: Some( + "z", + ), + }, + ), }, - ), - custom: (), - node: MatchAs { - pattern: None, - name: Some( - "z", - ), - }, + ], }, - ], + ), }, - }, - guard: None, - body: [ - Located { - location: Location { - row: 160, - column: 8, - }, - end_location: Some( - Location { + guard: None, + body: [ + Located { + location: Location { row: 160, - column: 13, + column: 8, }, - ), - custom: (), - node: Assign { - targets: [ - Located { - location: Location { - row: 160, - column: 8, - }, - end_location: Some( - Location { - row: 160, - column: 9, - }, - ), - custom: (), - node: Name { - id: "v", - ctx: Store, - }, - }, - ], - value: Located { - location: Location { + end_location: Some( + Location { row: 160, - column: 12, + column: 13, }, - end_location: Some( - Location { - row: 160, - column: 13, + ), + custom: (), + node: Assign( + StmtAssign { + targets: [ + Located { + location: Location { + row: 160, + column: 8, + }, + end_location: Some( + Location { + row: 160, + column: 9, + }, + ), + custom: (), + node: Name( + ExprName { + id: "v", + ctx: Store, + }, + ), + }, + ], + value: Located { + location: Location { + row: 160, + column: 12, + }, + end_location: Some( + Location { + row: 160, + column: 13, + }, + ), + custom: (), + node: Constant( + ExprConstant { + value: Int( + 0, + ), + kind: None, + }, + ), }, - ), - custom: (), - node: Constant { - value: Int( - 0, - ), - kind: None, + type_comment: None, }, - }, - type_comment: None, + ), }, - }, - ], - }, - ], - }, + ], + }, + ], + }, + ), }, Located { location: Location { @@ -8082,173 +8972,193 @@ expression: parse_ast }, ), custom: (), - node: Match { - subject: Located { - location: Location { - row: 162, - column: 6, - }, - end_location: Some( - Location { + node: Match( + StmtMatch { + subject: Located { + location: Location { row: 162, - column: 12, + column: 6, }, - ), - custom: (), - node: NamedExpr { - target: Located { - location: Location { + end_location: Some( + Location { row: 162, - column: 6, + column: 12, }, - end_location: Some( - Location { - row: 162, - column: 7, + ), + custom: (), + node: NamedExpr( + ExprNamedExpr { + target: Located { + location: Location { + row: 162, + column: 6, + }, + end_location: Some( + Location { + row: 162, + column: 7, + }, + ), + custom: (), + node: Name( + ExprName { + id: "w", + ctx: Store, + }, + ), }, - ), - custom: (), - node: Name { - id: "w", - ctx: Store, - }, - }, - value: Located { - location: Location { - row: 162, - column: 11, - }, - end_location: Some( - Location { - row: 162, - column: 12, + value: Located { + location: Location { + row: 162, + column: 11, + }, + end_location: Some( + Location { + row: 162, + column: 12, + }, + ), + custom: (), + node: Name( + ExprName { + id: "x", + ctx: Load, + }, + ), }, - ), - custom: (), - node: Name { - id: "x", - ctx: Load, }, - }, + ), }, - }, - cases: [ - MatchCase { - pattern: Located { - location: Location { - row: 163, - column: 9, - }, - end_location: Some( - Location { + cases: [ + MatchCase { + pattern: Located { + location: Location { row: 163, - column: 16, + column: 9, }, - ), - custom: (), - node: MatchSequence { - patterns: [ - Located { - location: Location { - row: 163, - column: 9, - }, - end_location: Some( - Location { - row: 163, - column: 15, + end_location: Some( + Location { + row: 163, + column: 16, + }, + ), + custom: (), + node: MatchSequence( + PatternMatchSequence { + patterns: [ + Located { + location: Location { + row: 163, + column: 9, + }, + end_location: Some( + Location { + row: 163, + column: 15, + }, + ), + custom: (), + node: MatchAs( + PatternMatchAs { + pattern: Some( + Located { + location: Location { + row: 163, + column: 9, + }, + end_location: Some( + Location { + row: 163, + column: 10, + }, + ), + custom: (), + node: MatchAs( + PatternMatchAs { + pattern: None, + name: Some( + "y", + ), + }, + ), + }, + ), + name: Some( + "v", + ), + }, + ), }, - ), - custom: (), - node: MatchAs { - pattern: Some( + ], + }, + ), + }, + guard: None, + body: [ + Located { + location: Location { + row: 164, + column: 8, + }, + end_location: Some( + Location { + row: 164, + column: 13, + }, + ), + custom: (), + node: Assign( + StmtAssign { + targets: [ Located { location: Location { - row: 163, - column: 9, + row: 164, + column: 8, }, end_location: Some( Location { - row: 163, - column: 10, + row: 164, + column: 9, }, ), custom: (), - node: MatchAs { - pattern: None, - name: Some( - "y", - ), - }, + node: Name( + ExprName { + id: "z", + ctx: Store, + }, + ), }, - ), - name: Some( - "v", - ), - }, - }, - ], - }, - }, - guard: None, - body: [ - Located { - location: Location { - row: 164, - column: 8, - }, - end_location: Some( - Location { - row: 164, - column: 13, - }, - ), - custom: (), - node: Assign { - targets: [ - Located { - location: Location { - row: 164, - column: 8, - }, - end_location: Some( - Location { + ], + value: Located { + location: Location { row: 164, - column: 9, + column: 12, }, - ), - custom: (), - node: Name { - id: "z", - ctx: Store, - }, - }, - ], - value: Located { - location: Location { - row: 164, - column: 12, - }, - end_location: Some( - Location { - row: 164, - column: 13, + end_location: Some( + Location { + row: 164, + column: 13, + }, + ), + custom: (), + node: Constant( + ExprConstant { + value: Int( + 0, + ), + kind: None, + }, + ), }, - ), - custom: (), - node: Constant { - value: Int( - 0, - ), - kind: None, + type_comment: None, }, - }, - type_comment: None, + ), }, - }, - ], - }, - ], - }, + ], + }, + ], + }, + ), }, ] diff --git a/parser/src/snapshots/rustpython_parser__parser__tests__slice.snap b/parser/src/snapshots/rustpython_parser__parser__tests__slice.snap index 2d404f06..222c1c2d 100644 --- a/parser/src/snapshots/rustpython_parser__parser__tests__slice.snap +++ b/parser/src/snapshots/rustpython_parser__parser__tests__slice.snap @@ -1,5 +1,5 @@ --- -source: compiler/parser/src/parser.rs +source: parser/src/parser.rs expression: parse_ast --- Located { @@ -14,102 +14,114 @@ Located { }, ), custom: (), - node: Subscript { - value: Located { - location: Location { - row: 1, - column: 0, - }, - end_location: Some( - Location { + node: Subscript( + ExprSubscript { + value: Located { + location: Location { row: 1, - column: 1, + column: 0, }, - ), - custom: (), - node: Name { - id: "x", - ctx: Load, - }, - }, - slice: Located { - location: Location { - row: 1, - column: 2, + end_location: Some( + Location { + row: 1, + column: 1, + }, + ), + custom: (), + node: Name( + ExprName { + id: "x", + ctx: Load, + }, + ), }, - end_location: Some( - Location { + slice: Located { + location: Location { row: 1, - column: 7, + column: 2, }, - ), - custom: (), - node: Slice { - lower: Some( - Located { - location: Location { - row: 1, - column: 2, - }, - end_location: Some( - Location { - row: 1, - column: 3, - }, - ), - custom: (), - node: Constant { - value: Int( - 1, - ), - kind: None, - }, + end_location: Some( + Location { + row: 1, + column: 7, }, ), - upper: Some( - Located { - location: Location { - row: 1, - column: 4, - }, - end_location: Some( - Location { - row: 1, - column: 5, + custom: (), + node: Slice( + ExprSlice { + lower: Some( + Located { + location: Location { + row: 1, + column: 2, + }, + end_location: Some( + Location { + row: 1, + column: 3, + }, + ), + custom: (), + node: Constant( + ExprConstant { + value: Int( + 1, + ), + kind: None, + }, + ), }, ), - custom: (), - node: Constant { - value: Int( - 2, - ), - kind: None, - }, - }, - ), - step: Some( - Located { - location: Location { - row: 1, - column: 6, - }, - end_location: Some( - Location { - row: 1, - column: 7, + upper: Some( + Located { + location: Location { + row: 1, + column: 4, + }, + end_location: Some( + Location { + row: 1, + column: 5, + }, + ), + custom: (), + node: Constant( + ExprConstant { + value: Int( + 2, + ), + kind: None, + }, + ), + }, + ), + step: Some( + Located { + location: Location { + row: 1, + column: 6, + }, + end_location: Some( + Location { + row: 1, + column: 7, + }, + ), + custom: (), + node: Constant( + ExprConstant { + value: Int( + 3, + ), + kind: None, + }, + ), }, ), - custom: (), - node: Constant { - value: Int( - 3, - ), - kind: None, - }, }, ), }, + ctx: Load, }, - ctx: Load, - }, + ), } diff --git a/parser/src/snapshots/rustpython_parser__parser__tests__star_index.snap b/parser/src/snapshots/rustpython_parser__parser__tests__star_index.snap index 897edb23..50a2778f 100644 --- a/parser/src/snapshots/rustpython_parser__parser__tests__star_index.snap +++ b/parser/src/snapshots/rustpython_parser__parser__tests__star_index.snap @@ -1,5 +1,5 @@ --- -source: compiler/parser/src/parser.rs +source: parser/src/parser.rs expression: parse_ast --- [ @@ -15,166 +15,186 @@ expression: parse_ast }, ), custom: (), - node: Assign { - targets: [ - Located { - location: Location { - row: 1, - column: 0, - }, - end_location: Some( - Location { - row: 1, - column: 11, - }, - ), - custom: (), - node: Name { - id: "array_slice", - ctx: Store, - }, - }, - ], - value: Located { - location: Location { - row: 1, - column: 14, - }, - end_location: Some( - Location { - row: 1, - column: 36, - }, - ), - custom: (), - node: Subscript { - value: Located { + node: Assign( + StmtAssign { + targets: [ + Located { location: Location { row: 1, - column: 14, + column: 0, }, end_location: Some( Location { row: 1, - column: 19, + column: 11, }, ), custom: (), - node: Name { - id: "array", - ctx: Load, - }, + node: Name( + ExprName { + id: "array_slice", + ctx: Store, + }, + ), }, - slice: Located { - location: Location { + ], + value: Located { + location: Location { + row: 1, + column: 14, + }, + end_location: Some( + Location { row: 1, - column: 20, + column: 36, }, - end_location: Some( - Location { - row: 1, - column: 35, - }, - ), - custom: (), - node: Tuple { - elts: [ - Located { - location: Location { + ), + custom: (), + node: Subscript( + ExprSubscript { + value: Located { + location: Location { + row: 1, + column: 14, + }, + end_location: Some( + Location { row: 1, - column: 20, + column: 19, }, - end_location: Some( - Location { - row: 1, - column: 21, - }, - ), - custom: (), - node: Constant { - value: Int( - 0, - ), - kind: None, + ), + custom: (), + node: Name( + ExprName { + id: "array", + ctx: Load, }, + ), + }, + slice: Located { + location: Location { + row: 1, + column: 20, }, - Located { - location: Location { + end_location: Some( + Location { row: 1, - column: 23, + column: 35, }, - end_location: Some( - Location { - row: 1, - column: 31, - }, - ), - custom: (), - node: Starred { - value: Located { - location: Location { - row: 1, - column: 24, - }, - end_location: Some( - Location { + ), + custom: (), + node: Tuple( + ExprTuple { + elts: [ + Located { + location: Location { row: 1, - column: 31, + column: 20, }, - ), - custom: (), - node: Name { - id: "indexes", - ctx: Load, + end_location: Some( + Location { + row: 1, + column: 21, + }, + ), + custom: (), + node: Constant( + ExprConstant { + value: Int( + 0, + ), + kind: None, + }, + ), }, - }, - ctx: Load, - }, - }, - Located { - location: Location { - row: 1, - column: 33, - }, - end_location: Some( - Location { - row: 1, - column: 35, - }, - ), - custom: (), - node: UnaryOp { - op: USub, - operand: Located { - location: Location { - row: 1, - column: 34, + Located { + location: Location { + row: 1, + column: 23, + }, + end_location: Some( + Location { + row: 1, + column: 31, + }, + ), + custom: (), + node: Starred( + ExprStarred { + value: Located { + location: Location { + row: 1, + column: 24, + }, + end_location: Some( + Location { + row: 1, + column: 31, + }, + ), + custom: (), + node: Name( + ExprName { + id: "indexes", + ctx: Load, + }, + ), + }, + ctx: Load, + }, + ), }, - end_location: Some( - Location { + Located { + location: Location { row: 1, - column: 35, + column: 33, }, - ), - custom: (), - node: Constant { - value: Int( - 1, + end_location: Some( + Location { + row: 1, + column: 35, + }, + ), + custom: (), + node: UnaryOp( + ExprUnaryOp { + op: USub, + operand: Located { + location: Location { + row: 1, + column: 34, + }, + end_location: Some( + Location { + row: 1, + column: 35, + }, + ), + custom: (), + node: Constant( + ExprConstant { + value: Int( + 1, + ), + kind: None, + }, + ), + }, + }, ), - kind: None, }, - }, + ], + ctx: Load, }, - }, - ], + ), + }, ctx: Load, }, - }, - ctx: Load, + ), }, + type_comment: None, }, - type_comment: None, - }, + ), }, Located { location: Location { @@ -188,166 +208,186 @@ expression: parse_ast }, ), custom: (), - node: Assign { - targets: [ - Located { - location: Location { - row: 2, - column: 0, - }, - end_location: Some( - Location { + node: Assign( + StmtAssign { + targets: [ + Located { + location: Location { row: 2, - column: 22, - }, - ), - custom: (), - node: Subscript { - value: Located { - location: Location { - row: 2, - column: 0, - }, - end_location: Some( - Location { - row: 2, - column: 5, - }, - ), - custom: (), - node: Name { - id: "array", - ctx: Load, - }, + column: 0, }, - slice: Located { - location: Location { + end_location: Some( + Location { row: 2, - column: 6, + column: 22, }, - end_location: Some( - Location { - row: 2, - column: 21, - }, - ), - custom: (), - node: Tuple { - elts: [ - Located { - location: Location { + ), + custom: (), + node: Subscript( + ExprSubscript { + value: Located { + location: Location { + row: 2, + column: 0, + }, + end_location: Some( + Location { row: 2, - column: 6, + column: 5, }, - end_location: Some( - Location { - row: 2, - column: 7, - }, - ), - custom: (), - node: Constant { - value: Int( - 0, - ), - kind: None, + ), + custom: (), + node: Name( + ExprName { + id: "array", + ctx: Load, }, + ), + }, + slice: Located { + location: Location { + row: 2, + column: 6, }, - Located { - location: Location { + end_location: Some( + Location { row: 2, - column: 9, + column: 21, }, - end_location: Some( - Location { - row: 2, - column: 17, - }, - ), - custom: (), - node: Starred { - value: Located { - location: Location { - row: 2, - column: 10, - }, - end_location: Some( - Location { + ), + custom: (), + node: Tuple( + ExprTuple { + elts: [ + Located { + location: Location { row: 2, - column: 17, + column: 6, }, - ), - custom: (), - node: Name { - id: "indexes", - ctx: Load, + end_location: Some( + Location { + row: 2, + column: 7, + }, + ), + custom: (), + node: Constant( + ExprConstant { + value: Int( + 0, + ), + kind: None, + }, + ), }, - }, - ctx: Load, - }, - }, - Located { - location: Location { - row: 2, - column: 19, - }, - end_location: Some( - Location { - row: 2, - column: 21, - }, - ), - custom: (), - node: UnaryOp { - op: USub, - operand: Located { - location: Location { - row: 2, - column: 20, + Located { + location: Location { + row: 2, + column: 9, + }, + end_location: Some( + Location { + row: 2, + column: 17, + }, + ), + custom: (), + node: Starred( + ExprStarred { + value: Located { + location: Location { + row: 2, + column: 10, + }, + end_location: Some( + Location { + row: 2, + column: 17, + }, + ), + custom: (), + node: Name( + ExprName { + id: "indexes", + ctx: Load, + }, + ), + }, + ctx: Load, + }, + ), }, - end_location: Some( - Location { + Located { + location: Location { row: 2, - column: 21, + column: 19, }, - ), - custom: (), - node: Constant { - value: Int( - 1, + end_location: Some( + Location { + row: 2, + column: 21, + }, + ), + custom: (), + node: UnaryOp( + ExprUnaryOp { + op: USub, + operand: Located { + location: Location { + row: 2, + column: 20, + }, + end_location: Some( + Location { + row: 2, + column: 21, + }, + ), + custom: (), + node: Constant( + ExprConstant { + value: Int( + 1, + ), + kind: None, + }, + ), + }, + }, ), - kind: None, }, - }, + ], + ctx: Load, }, - }, - ], - ctx: Load, + ), + }, + ctx: Store, }, - }, - ctx: Store, + ), }, - }, - ], - value: Located { - location: Location { - row: 2, - column: 25, - }, - end_location: Some( - Location { + ], + value: Located { + location: Location { row: 2, - column: 36, + column: 25, }, - ), - custom: (), - node: Name { - id: "array_slice", - ctx: Load, + end_location: Some( + Location { + row: 2, + column: 36, + }, + ), + custom: (), + node: Name( + ExprName { + id: "array_slice", + ctx: Load, + }, + ), }, + type_comment: None, }, - type_comment: None, - }, + ), }, Located { location: Location { @@ -361,125 +401,141 @@ expression: parse_ast }, ), custom: (), - node: Expr { - value: Located { - location: Location { - row: 3, - column: 0, - }, - end_location: Some( - Location { + node: Expr( + StmtExpr { + value: Located { + location: Location { row: 3, - column: 45, - }, - ), - custom: (), - node: Subscript { - value: Located { - location: Location { - row: 3, - column: 0, - }, - end_location: Some( - Location { - row: 3, - column: 5, - }, - ), - custom: (), - node: Name { - id: "array", - ctx: Load, - }, + column: 0, }, - slice: Located { - location: Location { + end_location: Some( + Location { row: 3, - column: 6, + column: 45, }, - end_location: Some( - Location { - row: 3, - column: 44, - }, - ), - custom: (), - node: Tuple { - elts: [ - Located { - location: Location { + ), + custom: (), + node: Subscript( + ExprSubscript { + value: Located { + location: Location { + row: 3, + column: 0, + }, + end_location: Some( + Location { row: 3, - column: 6, + column: 5, }, - end_location: Some( - Location { - row: 3, - column: 24, - }, - ), - custom: (), - node: Starred { - value: Located { - location: Location { - row: 3, - column: 7, - }, - end_location: Some( - Location { - row: 3, - column: 24, - }, - ), - custom: (), - node: Name { - id: "indexes_to_select", - ctx: Load, - }, - }, + ), + custom: (), + node: Name( + ExprName { + id: "array", ctx: Load, }, + ), + }, + slice: Located { + location: Location { + row: 3, + column: 6, }, - Located { - location: Location { + end_location: Some( + Location { row: 3, - column: 26, + column: 44, }, - end_location: Some( - Location { - row: 3, - column: 44, - }, - ), - custom: (), - node: Starred { - value: Located { - location: Location { - row: 3, - column: 27, + ), + custom: (), + node: Tuple( + ExprTuple { + elts: [ + Located { + location: Location { + row: 3, + column: 6, + }, + end_location: Some( + Location { + row: 3, + column: 24, + }, + ), + custom: (), + node: Starred( + ExprStarred { + value: Located { + location: Location { + row: 3, + column: 7, + }, + end_location: Some( + Location { + row: 3, + column: 24, + }, + ), + custom: (), + node: Name( + ExprName { + id: "indexes_to_select", + ctx: Load, + }, + ), + }, + ctx: Load, + }, + ), }, - end_location: Some( - Location { + Located { + location: Location { row: 3, - column: 44, + column: 26, }, - ), - custom: (), - node: Name { - id: "indexes_to_select", - ctx: Load, + end_location: Some( + Location { + row: 3, + column: 44, + }, + ), + custom: (), + node: Starred( + ExprStarred { + value: Located { + location: Location { + row: 3, + column: 27, + }, + end_location: Some( + Location { + row: 3, + column: 44, + }, + ), + custom: (), + node: Name( + ExprName { + id: "indexes_to_select", + ctx: Load, + }, + ), + }, + ctx: Load, + }, + ), }, - }, + ], ctx: Load, }, - }, - ], + ), + }, ctx: Load, }, - }, - ctx: Load, + ), }, }, - }, + ), }, Located { location: Location { @@ -493,65 +549,56 @@ expression: parse_ast }, ), custom: (), - node: Expr { - value: Located { - location: Location { - row: 4, - column: 0, - }, - end_location: Some( - Location { + node: Expr( + StmtExpr { + value: Located { + location: Location { row: 4, - column: 30, - }, - ), - custom: (), - node: Subscript { - value: Located { - location: Location { - row: 4, - column: 0, - }, - end_location: Some( - Location { - row: 4, - column: 5, - }, - ), - custom: (), - node: Name { - id: "array", - ctx: Load, - }, + column: 0, }, - slice: Located { - location: Location { + end_location: Some( + Location { row: 4, - column: 6, + column: 30, }, - end_location: Some( - Location { - row: 4, - column: 29, + ), + custom: (), + node: Subscript( + ExprSubscript { + value: Located { + location: Location { + row: 4, + column: 0, + }, + end_location: Some( + Location { + row: 4, + column: 5, + }, + ), + custom: (), + node: Name( + ExprName { + id: "array", + ctx: Load, + }, + ), }, - ), - custom: (), - node: Tuple { - elts: [ - Located { - location: Location { + slice: Located { + location: Location { + row: 4, + column: 6, + }, + end_location: Some( + Location { row: 4, - column: 6, + column: 29, }, - end_location: Some( - Location { - row: 4, - column: 9, - }, - ), - custom: (), - node: Slice { - lower: Some( + ), + custom: (), + node: Tuple( + ExprTuple { + elts: [ Located { location: Location { row: 4, @@ -560,82 +607,109 @@ expression: parse_ast end_location: Some( Location { row: 4, - column: 7, + column: 9, }, ), custom: (), - node: Constant { - value: Int( - 3, - ), - kind: None, - }, + node: Slice( + ExprSlice { + lower: Some( + Located { + location: Location { + row: 4, + column: 6, + }, + end_location: Some( + Location { + row: 4, + column: 7, + }, + ), + custom: (), + node: Constant( + ExprConstant { + value: Int( + 3, + ), + kind: None, + }, + ), + }, + ), + upper: Some( + Located { + location: Location { + row: 4, + column: 8, + }, + end_location: Some( + Location { + row: 4, + column: 9, + }, + ), + custom: (), + node: Constant( + ExprConstant { + value: Int( + 5, + ), + kind: None, + }, + ), + }, + ), + step: None, + }, + ), }, - ), - upper: Some( Located { location: Location { row: 4, - column: 8, + column: 11, }, end_location: Some( Location { row: 4, - column: 9, + column: 29, }, ), custom: (), - node: Constant { - value: Int( - 5, - ), - kind: None, - }, - }, - ), - step: None, - }, - }, - Located { - location: Location { - row: 4, - column: 11, - }, - end_location: Some( - Location { - row: 4, - column: 29, - }, - ), - custom: (), - node: Starred { - value: Located { - location: Location { - row: 4, - column: 12, - }, - end_location: Some( - Location { - row: 4, - column: 29, - }, - ), - custom: (), - node: Name { - id: "indexes_to_select", - ctx: Load, + node: Starred( + ExprStarred { + value: Located { + location: Location { + row: 4, + column: 12, + }, + end_location: Some( + Location { + row: 4, + column: 29, + }, + ), + custom: (), + node: Name( + ExprName { + id: "indexes_to_select", + ctx: Load, + }, + ), + }, + ctx: Load, + }, + ), }, - }, + ], ctx: Load, }, - }, - ], + ), + }, ctx: Load, }, - }, - ctx: Load, + ), }, }, - }, + ), }, ] diff --git a/parser/src/snapshots/rustpython_parser__parser__tests__try.snap b/parser/src/snapshots/rustpython_parser__parser__tests__try.snap index 5b6037ae..ea69b37b 100644 --- a/parser/src/snapshots/rustpython_parser__parser__tests__try.snap +++ b/parser/src/snapshots/rustpython_parser__parser__tests__try.snap @@ -1,5 +1,5 @@ --- -source: compiler/parser/src/parser.rs +source: parser/src/parser.rs expression: parse_ast --- [ @@ -15,36 +15,25 @@ expression: parse_ast }, ), custom: (), - node: Try { - body: [ - Located { - location: Location { - row: 2, - column: 4, - }, - end_location: Some( - Location { + node: Try( + StmtTry { + body: [ + Located { + location: Location { row: 2, - column: 23, + column: 4, }, - ), - custom: (), - node: Raise { - exc: Some( - Located { - location: Location { - row: 2, - column: 10, - }, - end_location: Some( - Location { - row: 2, - column: 23, - }, - ), - custom: (), - node: Call { - func: Located { + end_location: Some( + Location { + row: 2, + column: 23, + }, + ), + custom: (), + node: Raise( + StmtRaise { + exc: Some( + Located { location: Location { row: 2, column: 10, @@ -52,95 +41,105 @@ expression: parse_ast end_location: Some( Location { row: 2, - column: 20, + column: 23, }, ), custom: (), - node: Name { - id: "ValueError", - ctx: Load, - }, - }, - args: [ - Located { - location: Location { - row: 2, - column: 21, - }, - end_location: Some( - Location { - row: 2, - column: 22, + node: Call( + ExprCall { + func: Located { + location: Location { + row: 2, + column: 10, + }, + end_location: Some( + Location { + row: 2, + column: 20, + }, + ), + custom: (), + node: Name( + ExprName { + id: "ValueError", + ctx: Load, + }, + ), }, - ), - custom: (), - node: Constant { - value: Int( - 1, - ), - kind: None, + args: [ + Located { + location: Location { + row: 2, + column: 21, + }, + end_location: Some( + Location { + row: 2, + column: 22, + }, + ), + custom: (), + node: Constant( + ExprConstant { + value: Int( + 1, + ), + kind: None, + }, + ), + }, + ], + keywords: [], }, - }, - ], - keywords: [], - }, + ), + }, + ), + cause: None, }, ), - cause: None, - }, - }, - ], - handlers: [ - Located { - location: Location { - row: 3, - column: 0, }, - end_location: Some( - Location { - row: 4, - column: 30, + ], + handlers: [ + Located { + location: Location { + row: 3, + column: 0, }, - ), - custom: (), - node: ExceptHandler { - type_: Some( - Located { - location: Location { - row: 3, - column: 7, - }, - end_location: Some( - Location { - row: 3, - column: 16, - }, - ), - custom: (), - node: Name { - id: "TypeError", - ctx: Load, - }, + end_location: Some( + Location { + row: 4, + column: 30, }, ), - name: Some( - "e", - ), - body: [ - Located { - location: Location { - row: 4, - column: 4, - }, - end_location: Some( - Location { - row: 4, - column: 30, + custom: (), + node: ExceptHandler( + ExcepthandlerExceptHandler { + type_: Some( + Located { + location: Location { + row: 3, + column: 7, + }, + end_location: Some( + Location { + row: 3, + column: 16, + }, + ), + custom: (), + node: Name( + ExprName { + id: "TypeError", + ctx: Load, + }, + ), }, ), - custom: (), - node: Expr { - value: Located { + name: Some( + "e", + ), + body: [ + Located { location: Location { row: 4, column: 4, @@ -152,189 +151,211 @@ expression: parse_ast }, ), custom: (), - node: Call { - func: Located { - location: Location { - row: 4, - column: 4, - }, - end_location: Some( - Location { - row: 4, - column: 9, - }, - ), - custom: (), - node: Name { - id: "print", - ctx: Load, - }, - }, - args: [ - Located { + node: Expr( + StmtExpr { + value: Located { location: Location { row: 4, - column: 10, + column: 4, }, end_location: Some( Location { row: 4, - column: 29, + column: 30, }, ), custom: (), - node: JoinedStr { - values: [ - Located { + node: Call( + ExprCall { + func: Located { location: Location { row: 4, - column: 10, + column: 4, }, end_location: Some( Location { row: 4, - column: 29, + column: 9, }, ), custom: (), - node: Constant { - value: Str( - "caught ", - ), - kind: None, - }, + node: Name( + ExprName { + id: "print", + ctx: Load, + }, + ), }, - Located { - location: Location { - row: 4, - column: 10, - }, - end_location: Some( - Location { + args: [ + Located { + location: Location { row: 4, - column: 29, + column: 10, }, - ), - custom: (), - node: FormattedValue { - value: Located { - location: Location { + end_location: Some( + Location { row: 4, - column: 20, + column: 29, }, - end_location: Some( - Location { - row: 4, - column: 27, - }, - ), - custom: (), - node: Call { - func: Located { - location: Location { - row: 4, - column: 20, - }, - end_location: Some( - Location { + ), + custom: (), + node: JoinedStr( + ExprJoinedStr { + values: [ + Located { + location: Location { row: 4, - column: 24, + column: 10, }, - ), - custom: (), - node: Name { - id: "type", - ctx: Load, + end_location: Some( + Location { + row: 4, + column: 29, + }, + ), + custom: (), + node: Constant( + ExprConstant { + value: Str( + "caught ", + ), + kind: None, + }, + ), }, - }, - args: [ Located { location: Location { row: 4, - column: 25, + column: 10, }, end_location: Some( Location { row: 4, - column: 26, + column: 29, }, ), custom: (), - node: Name { - id: "e", - ctx: Load, - }, + node: FormattedValue( + ExprFormattedValue { + value: Located { + location: Location { + row: 4, + column: 20, + }, + end_location: Some( + Location { + row: 4, + column: 27, + }, + ), + custom: (), + node: Call( + ExprCall { + func: Located { + location: Location { + row: 4, + column: 20, + }, + end_location: Some( + Location { + row: 4, + column: 24, + }, + ), + custom: (), + node: Name( + ExprName { + id: "type", + ctx: Load, + }, + ), + }, + args: [ + Located { + location: Location { + row: 4, + column: 25, + }, + end_location: Some( + Location { + row: 4, + column: 26, + }, + ), + custom: (), + node: Name( + ExprName { + id: "e", + ctx: Load, + }, + ), + }, + ], + keywords: [], + }, + ), + }, + conversion: 0, + format_spec: None, + }, + ), }, ], - keywords: [], }, - }, - conversion: 0, - format_spec: None, + ), }, - }, - ], - }, + ], + keywords: [], + }, + ), }, - ], - keywords: [], - }, + }, + ), }, - }, + ], }, - ], - }, - }, - Located { - location: Location { - row: 5, - column: 0, + ), }, - end_location: Some( - Location { - row: 6, - column: 30, + Located { + location: Location { + row: 5, + column: 0, }, - ), - custom: (), - node: ExceptHandler { - type_: Some( - Located { - location: Location { - row: 5, - column: 7, - }, - end_location: Some( - Location { - row: 5, - column: 14, - }, - ), - custom: (), - node: Name { - id: "OSError", - ctx: Load, - }, + end_location: Some( + Location { + row: 6, + column: 30, }, ), - name: Some( - "e", - ), - body: [ - Located { - location: Location { - row: 6, - column: 4, - }, - end_location: Some( - Location { - row: 6, - column: 30, + custom: (), + node: ExceptHandler( + ExcepthandlerExceptHandler { + type_: Some( + Located { + location: Location { + row: 5, + column: 7, + }, + end_location: Some( + Location { + row: 5, + column: 14, + }, + ), + custom: (), + node: Name( + ExprName { + id: "OSError", + ctx: Load, + }, + ), }, ), - custom: (), - node: Expr { - value: Located { + name: Some( + "e", + ), + body: [ + Located { location: Location { row: 6, column: 4, @@ -346,142 +367,175 @@ expression: parse_ast }, ), custom: (), - node: Call { - func: Located { - location: Location { - row: 6, - column: 4, - }, - end_location: Some( - Location { - row: 6, - column: 9, - }, - ), - custom: (), - node: Name { - id: "print", - ctx: Load, - }, - }, - args: [ - Located { + node: Expr( + StmtExpr { + value: Located { location: Location { row: 6, - column: 10, + column: 4, }, end_location: Some( Location { row: 6, - column: 29, + column: 30, }, ), custom: (), - node: JoinedStr { - values: [ - Located { + node: Call( + ExprCall { + func: Located { location: Location { row: 6, - column: 10, + column: 4, }, end_location: Some( Location { row: 6, - column: 29, + column: 9, }, ), custom: (), - node: Constant { - value: Str( - "caught ", - ), - kind: None, - }, + node: Name( + ExprName { + id: "print", + ctx: Load, + }, + ), }, - Located { - location: Location { - row: 6, - column: 10, - }, - end_location: Some( - Location { + args: [ + Located { + location: Location { row: 6, - column: 29, + column: 10, }, - ), - custom: (), - node: FormattedValue { - value: Located { - location: Location { + end_location: Some( + Location { row: 6, - column: 20, + column: 29, }, - end_location: Some( - Location { - row: 6, - column: 27, - }, - ), - custom: (), - node: Call { - func: Located { - location: Location { - row: 6, - column: 20, - }, - end_location: Some( - Location { + ), + custom: (), + node: JoinedStr( + ExprJoinedStr { + values: [ + Located { + location: Location { row: 6, - column: 24, + column: 10, }, - ), - custom: (), - node: Name { - id: "type", - ctx: Load, + end_location: Some( + Location { + row: 6, + column: 29, + }, + ), + custom: (), + node: Constant( + ExprConstant { + value: Str( + "caught ", + ), + kind: None, + }, + ), }, - }, - args: [ Located { location: Location { row: 6, - column: 25, + column: 10, }, end_location: Some( Location { row: 6, - column: 26, + column: 29, }, ), custom: (), - node: Name { - id: "e", - ctx: Load, - }, + node: FormattedValue( + ExprFormattedValue { + value: Located { + location: Location { + row: 6, + column: 20, + }, + end_location: Some( + Location { + row: 6, + column: 27, + }, + ), + custom: (), + node: Call( + ExprCall { + func: Located { + location: Location { + row: 6, + column: 20, + }, + end_location: Some( + Location { + row: 6, + column: 24, + }, + ), + custom: (), + node: Name( + ExprName { + id: "type", + ctx: Load, + }, + ), + }, + args: [ + Located { + location: Location { + row: 6, + column: 25, + }, + end_location: Some( + Location { + row: 6, + column: 26, + }, + ), + custom: (), + node: Name( + ExprName { + id: "e", + ctx: Load, + }, + ), + }, + ], + keywords: [], + }, + ), + }, + conversion: 0, + format_spec: None, + }, + ), }, ], - keywords: [], }, - }, - conversion: 0, - format_spec: None, + ), }, - }, - ], - }, + ], + keywords: [], + }, + ), }, - ], - keywords: [], - }, + }, + ), }, - }, + ], }, - ], + ), }, - }, - ], - orelse: [], - finalbody: [], - }, + ], + orelse: [], + finalbody: [], + }, + ), }, ] diff --git a/parser/src/snapshots/rustpython_parser__parser__tests__try_star.snap b/parser/src/snapshots/rustpython_parser__parser__tests__try_star.snap index 472f316b..0ab9b4f9 100644 --- a/parser/src/snapshots/rustpython_parser__parser__tests__try_star.snap +++ b/parser/src/snapshots/rustpython_parser__parser__tests__try_star.snap @@ -1,5 +1,5 @@ --- -source: compiler/parser/src/parser.rs +source: parser/src/parser.rs expression: parse_ast --- [ @@ -15,366 +15,391 @@ expression: parse_ast }, ), custom: (), - node: TryStar { - body: [ - Located { - location: Location { - row: 2, - column: 4, - }, - end_location: Some( - Location { - row: 3, - column: 62, + node: TryStar( + StmtTryStar { + body: [ + Located { + location: Location { + row: 2, + column: 4, }, - ), - custom: (), - node: Raise { - exc: Some( - Located { - location: Location { - row: 2, - column: 10, - }, - end_location: Some( - Location { - row: 3, - column: 62, - }, - ), - custom: (), - node: Call { - func: Located { + end_location: Some( + Location { + row: 3, + column: 62, + }, + ), + custom: (), + node: Raise( + StmtRaise { + exc: Some( + Located { location: Location { row: 2, column: 10, }, end_location: Some( Location { - row: 2, - column: 24, + row: 3, + column: 62, }, ), custom: (), - node: Name { - id: "ExceptionGroup", - ctx: Load, - }, - }, - args: [ - Located { - location: Location { - row: 2, - column: 25, - }, - end_location: Some( - Location { - row: 2, - column: 29, - }, - ), - custom: (), - node: Constant { - value: Str( - "eg", - ), - kind: None, - }, - }, - Located { - location: Location { - row: 3, - column: 8, - }, - end_location: Some( - Location { - row: 3, - column: 61, + node: Call( + ExprCall { + func: Located { + location: Location { + row: 2, + column: 10, + }, + end_location: Some( + Location { + row: 2, + column: 24, + }, + ), + custom: (), + node: Name( + ExprName { + id: "ExceptionGroup", + ctx: Load, + }, + ), }, - ), - custom: (), - node: List { - elts: [ + args: [ Located { location: Location { - row: 3, - column: 9, + row: 2, + column: 25, }, end_location: Some( Location { - row: 3, - column: 22, + row: 2, + column: 29, }, ), custom: (), - node: Call { - func: Located { - location: Location { - row: 3, - column: 9, - }, - end_location: Some( - Location { - row: 3, - column: 19, - }, + node: Constant( + ExprConstant { + value: Str( + "eg", ), - custom: (), - node: Name { - id: "ValueError", - ctx: Load, - }, + kind: None, }, - args: [ - Located { - location: Location { - row: 3, - column: 20, - }, - end_location: Some( - Location { - row: 3, - column: 21, - }, - ), - custom: (), - node: Constant { - value: Int( - 1, - ), - kind: None, - }, - }, - ], - keywords: [], - }, + ), }, Located { location: Location { row: 3, - column: 24, + column: 8, }, end_location: Some( Location { row: 3, - column: 36, + column: 61, }, ), custom: (), - node: Call { - func: Located { - location: Location { - row: 3, - column: 24, - }, - end_location: Some( - Location { - row: 3, - column: 33, - }, - ), - custom: (), - node: Name { - id: "TypeError", - ctx: Load, - }, - }, - args: [ - Located { - location: Location { - row: 3, - column: 34, - }, - end_location: Some( - Location { + node: List( + ExprList { + elts: [ + Located { + location: Location { row: 3, - column: 35, + column: 9, }, - ), - custom: (), - node: Constant { - value: Int( - 2, + end_location: Some( + Location { + row: 3, + column: 22, + }, + ), + custom: (), + node: Call( + ExprCall { + func: Located { + location: Location { + row: 3, + column: 9, + }, + end_location: Some( + Location { + row: 3, + column: 19, + }, + ), + custom: (), + node: Name( + ExprName { + id: "ValueError", + ctx: Load, + }, + ), + }, + args: [ + Located { + location: Location { + row: 3, + column: 20, + }, + end_location: Some( + Location { + row: 3, + column: 21, + }, + ), + custom: (), + node: Constant( + ExprConstant { + value: Int( + 1, + ), + kind: None, + }, + ), + }, + ], + keywords: [], + }, ), - kind: None, - }, - }, - ], - keywords: [], - }, - }, - Located { - location: Location { - row: 3, - column: 38, - }, - end_location: Some( - Location { - row: 3, - column: 48, - }, - ), - custom: (), - node: Call { - func: Located { - location: Location { - row: 3, - column: 38, - }, - end_location: Some( - Location { - row: 3, - column: 45, - }, - ), - custom: (), - node: Name { - id: "OSError", - ctx: Load, - }, - }, - args: [ - Located { - location: Location { - row: 3, - column: 46, }, - end_location: Some( - Location { + Located { + location: Location { row: 3, - column: 47, + column: 24, }, - ), - custom: (), - node: Constant { - value: Int( - 3, + end_location: Some( + Location { + row: 3, + column: 36, + }, + ), + custom: (), + node: Call( + ExprCall { + func: Located { + location: Location { + row: 3, + column: 24, + }, + end_location: Some( + Location { + row: 3, + column: 33, + }, + ), + custom: (), + node: Name( + ExprName { + id: "TypeError", + ctx: Load, + }, + ), + }, + args: [ + Located { + location: Location { + row: 3, + column: 34, + }, + end_location: Some( + Location { + row: 3, + column: 35, + }, + ), + custom: (), + node: Constant( + ExprConstant { + value: Int( + 2, + ), + kind: None, + }, + ), + }, + ], + keywords: [], + }, ), - kind: None, - }, - }, - ], - keywords: [], - }, - }, - Located { - location: Location { - row: 3, - column: 50, - }, - end_location: Some( - Location { - row: 3, - column: 60, - }, - ), - custom: (), - node: Call { - func: Located { - location: Location { - row: 3, - column: 50, - }, - end_location: Some( - Location { - row: 3, - column: 57, }, - ), - custom: (), - node: Name { - id: "OSError", - ctx: Load, - }, - }, - args: [ - Located { - location: Location { - row: 3, - column: 58, + Located { + location: Location { + row: 3, + column: 38, + }, + end_location: Some( + Location { + row: 3, + column: 48, + }, + ), + custom: (), + node: Call( + ExprCall { + func: Located { + location: Location { + row: 3, + column: 38, + }, + end_location: Some( + Location { + row: 3, + column: 45, + }, + ), + custom: (), + node: Name( + ExprName { + id: "OSError", + ctx: Load, + }, + ), + }, + args: [ + Located { + location: Location { + row: 3, + column: 46, + }, + end_location: Some( + Location { + row: 3, + column: 47, + }, + ), + custom: (), + node: Constant( + ExprConstant { + value: Int( + 3, + ), + kind: None, + }, + ), + }, + ], + keywords: [], + }, + ), }, - end_location: Some( - Location { + Located { + location: Location { row: 3, - column: 59, + column: 50, }, - ), - custom: (), - node: Constant { - value: Int( - 4, + end_location: Some( + Location { + row: 3, + column: 60, + }, + ), + custom: (), + node: Call( + ExprCall { + func: Located { + location: Location { + row: 3, + column: 50, + }, + end_location: Some( + Location { + row: 3, + column: 57, + }, + ), + custom: (), + node: Name( + ExprName { + id: "OSError", + ctx: Load, + }, + ), + }, + args: [ + Located { + location: Location { + row: 3, + column: 58, + }, + end_location: Some( + Location { + row: 3, + column: 59, + }, + ), + custom: (), + node: Constant( + ExprConstant { + value: Int( + 4, + ), + kind: None, + }, + ), + }, + ], + keywords: [], + }, ), - kind: None, }, - }, - ], - keywords: [], - }, + ], + ctx: Load, + }, + ), }, ], - ctx: Load, + keywords: [], }, - }, - ], - keywords: [], - }, + ), + }, + ), + cause: None, }, ), - cause: None, }, - }, - ], - handlers: [ - Located { - location: Location { - row: 4, - column: 0, - }, - end_location: Some( - Location { - row: 5, - column: 57, + ], + handlers: [ + Located { + location: Location { + row: 4, + column: 0, }, - ), - custom: (), - node: ExceptHandler { - type_: Some( - Located { - location: Location { - row: 4, - column: 8, - }, - end_location: Some( - Location { - row: 4, - column: 17, - }, - ), - custom: (), - node: Name { - id: "TypeError", - ctx: Load, - }, + end_location: Some( + Location { + row: 5, + column: 57, }, ), - name: Some( - "e", - ), - body: [ - Located { - location: Location { - row: 5, - column: 4, - }, - end_location: Some( - Location { - row: 5, - column: 57, + custom: (), + node: ExceptHandler( + ExcepthandlerExceptHandler { + type_: Some( + Located { + location: Location { + row: 4, + column: 8, + }, + end_location: Some( + Location { + row: 4, + column: 17, + }, + ), + custom: (), + node: Name( + ExprName { + id: "TypeError", + ctx: Load, + }, + ), }, ), - custom: (), - node: Expr { - value: Located { + name: Some( + "e", + ), + body: [ + Located { location: Location { row: 5, column: 4, @@ -386,259 +411,289 @@ expression: parse_ast }, ), custom: (), - node: Call { - func: Located { - location: Location { - row: 5, - column: 4, - }, - end_location: Some( - Location { - row: 5, - column: 9, - }, - ), - custom: (), - node: Name { - id: "print", - ctx: Load, - }, - }, - args: [ - Located { + node: Expr( + StmtExpr { + value: Located { location: Location { row: 5, - column: 10, + column: 4, }, end_location: Some( Location { row: 5, - column: 56, + column: 57, }, ), custom: (), - node: JoinedStr { - values: [ - Located { + node: Call( + ExprCall { + func: Located { location: Location { row: 5, - column: 10, + column: 4, }, end_location: Some( Location { row: 5, - column: 56, + column: 9, }, ), custom: (), - node: Constant { - value: Str( - "caught ", - ), - kind: None, - }, + node: Name( + ExprName { + id: "print", + ctx: Load, + }, + ), }, - Located { - location: Location { - row: 5, - column: 10, - }, - end_location: Some( - Location { + args: [ + Located { + location: Location { row: 5, - column: 56, + column: 10, }, - ), - custom: (), - node: FormattedValue { - value: Located { - location: Location { + end_location: Some( + Location { row: 5, - column: 20, + column: 56, }, - end_location: Some( - Location { - row: 5, - column: 27, - }, - ), - custom: (), - node: Call { - func: Located { - location: Location { - row: 5, - column: 20, - }, - end_location: Some( - Location { + ), + custom: (), + node: JoinedStr( + ExprJoinedStr { + values: [ + Located { + location: Location { row: 5, - column: 24, + column: 10, }, - ), - custom: (), - node: Name { - id: "type", - ctx: Load, + end_location: Some( + Location { + row: 5, + column: 56, + }, + ), + custom: (), + node: Constant( + ExprConstant { + value: Str( + "caught ", + ), + kind: None, + }, + ), }, - }, - args: [ Located { location: Location { row: 5, - column: 25, + column: 10, }, end_location: Some( Location { row: 5, - column: 26, + column: 56, }, ), custom: (), - node: Name { - id: "e", - ctx: Load, - }, + node: FormattedValue( + ExprFormattedValue { + value: Located { + location: Location { + row: 5, + column: 20, + }, + end_location: Some( + Location { + row: 5, + column: 27, + }, + ), + custom: (), + node: Call( + ExprCall { + func: Located { + location: Location { + row: 5, + column: 20, + }, + end_location: Some( + Location { + row: 5, + column: 24, + }, + ), + custom: (), + node: Name( + ExprName { + id: "type", + ctx: Load, + }, + ), + }, + args: [ + Located { + location: Location { + row: 5, + column: 25, + }, + end_location: Some( + Location { + row: 5, + column: 26, + }, + ), + custom: (), + node: Name( + ExprName { + id: "e", + ctx: Load, + }, + ), + }, + ], + keywords: [], + }, + ), + }, + conversion: 0, + format_spec: None, + }, + ), }, - ], - keywords: [], - }, - }, - conversion: 0, - format_spec: None, - }, - }, - Located { - location: Location { - row: 5, - column: 10, - }, - end_location: Some( - Location { - row: 5, - column: 56, - }, - ), - custom: (), - node: Constant { - value: Str( - " with nested ", - ), - kind: None, - }, - }, - Located { - location: Location { - row: 5, - column: 10, - }, - end_location: Some( - Location { - row: 5, - column: 56, - }, - ), - custom: (), - node: FormattedValue { - value: Located { - location: Location { - row: 5, - column: 42, - }, - end_location: Some( - Location { - row: 5, - column: 54, - }, - ), - custom: (), - node: Attribute { - value: Located { - location: Location { - row: 5, - column: 42, + Located { + location: Location { + row: 5, + column: 10, + }, + end_location: Some( + Location { + row: 5, + column: 56, + }, + ), + custom: (), + node: Constant( + ExprConstant { + value: Str( + " with nested ", + ), + kind: None, + }, + ), }, - end_location: Some( - Location { + Located { + location: Location { row: 5, - column: 43, + column: 10, }, - ), - custom: (), - node: Name { - id: "e", - ctx: Load, + end_location: Some( + Location { + row: 5, + column: 56, + }, + ), + custom: (), + node: FormattedValue( + ExprFormattedValue { + value: Located { + location: Location { + row: 5, + column: 42, + }, + end_location: Some( + Location { + row: 5, + column: 54, + }, + ), + custom: (), + node: Attribute( + ExprAttribute { + value: Located { + location: Location { + row: 5, + column: 42, + }, + end_location: Some( + Location { + row: 5, + column: 43, + }, + ), + custom: (), + node: Name( + ExprName { + id: "e", + ctx: Load, + }, + ), + }, + attr: "exceptions", + ctx: Load, + }, + ), + }, + conversion: 0, + format_spec: None, + }, + ), }, - }, - attr: "exceptions", - ctx: Load, + ], }, - }, - conversion: 0, - format_spec: None, + ), }, - }, - ], - }, + ], + keywords: [], + }, + ), }, - ], - keywords: [], - }, + }, + ), }, - }, + ], }, - ], - }, - }, - Located { - location: Location { - row: 6, - column: 0, + ), }, - end_location: Some( - Location { - row: 7, - column: 57, + Located { + location: Location { + row: 6, + column: 0, }, - ), - custom: (), - node: ExceptHandler { - type_: Some( - Located { - location: Location { - row: 6, - column: 8, - }, - end_location: Some( - Location { - row: 6, - column: 15, - }, - ), - custom: (), - node: Name { - id: "OSError", - ctx: Load, - }, + end_location: Some( + Location { + row: 7, + column: 57, }, ), - name: Some( - "e", - ), - body: [ - Located { - location: Location { - row: 7, - column: 4, - }, - end_location: Some( - Location { - row: 7, - column: 57, + custom: (), + node: ExceptHandler( + ExcepthandlerExceptHandler { + type_: Some( + Located { + location: Location { + row: 6, + column: 8, + }, + end_location: Some( + Location { + row: 6, + column: 15, + }, + ), + custom: (), + node: Name( + ExprName { + id: "OSError", + ctx: Load, + }, + ), }, ), - custom: (), - node: Expr { - value: Located { + name: Some( + "e", + ), + body: [ + Located { location: Location { row: 7, column: 4, @@ -650,212 +705,253 @@ expression: parse_ast }, ), custom: (), - node: Call { - func: Located { - location: Location { - row: 7, - column: 4, - }, - end_location: Some( - Location { - row: 7, - column: 9, - }, - ), - custom: (), - node: Name { - id: "print", - ctx: Load, - }, - }, - args: [ - Located { + node: Expr( + StmtExpr { + value: Located { location: Location { row: 7, - column: 10, + column: 4, }, end_location: Some( Location { row: 7, - column: 56, + column: 57, }, ), custom: (), - node: JoinedStr { - values: [ - Located { + node: Call( + ExprCall { + func: Located { location: Location { row: 7, - column: 10, + column: 4, }, end_location: Some( Location { row: 7, - column: 56, + column: 9, }, ), custom: (), - node: Constant { - value: Str( - "caught ", - ), - kind: None, - }, + node: Name( + ExprName { + id: "print", + ctx: Load, + }, + ), }, - Located { - location: Location { - row: 7, - column: 10, - }, - end_location: Some( - Location { + args: [ + Located { + location: Location { row: 7, - column: 56, + column: 10, }, - ), - custom: (), - node: FormattedValue { - value: Located { - location: Location { + end_location: Some( + Location { row: 7, - column: 20, + column: 56, }, - end_location: Some( - Location { - row: 7, - column: 27, - }, - ), - custom: (), - node: Call { - func: Located { - location: Location { - row: 7, - column: 20, - }, - end_location: Some( - Location { + ), + custom: (), + node: JoinedStr( + ExprJoinedStr { + values: [ + Located { + location: Location { row: 7, - column: 24, + column: 10, }, - ), - custom: (), - node: Name { - id: "type", - ctx: Load, + end_location: Some( + Location { + row: 7, + column: 56, + }, + ), + custom: (), + node: Constant( + ExprConstant { + value: Str( + "caught ", + ), + kind: None, + }, + ), }, - }, - args: [ Located { location: Location { row: 7, - column: 25, + column: 10, }, end_location: Some( Location { row: 7, - column: 26, + column: 56, }, ), custom: (), - node: Name { - id: "e", - ctx: Load, - }, + node: FormattedValue( + ExprFormattedValue { + value: Located { + location: Location { + row: 7, + column: 20, + }, + end_location: Some( + Location { + row: 7, + column: 27, + }, + ), + custom: (), + node: Call( + ExprCall { + func: Located { + location: Location { + row: 7, + column: 20, + }, + end_location: Some( + Location { + row: 7, + column: 24, + }, + ), + custom: (), + node: Name( + ExprName { + id: "type", + ctx: Load, + }, + ), + }, + args: [ + Located { + location: Location { + row: 7, + column: 25, + }, + end_location: Some( + Location { + row: 7, + column: 26, + }, + ), + custom: (), + node: Name( + ExprName { + id: "e", + ctx: Load, + }, + ), + }, + ], + keywords: [], + }, + ), + }, + conversion: 0, + format_spec: None, + }, + ), }, - ], - keywords: [], - }, - }, - conversion: 0, - format_spec: None, - }, - }, - Located { - location: Location { - row: 7, - column: 10, - }, - end_location: Some( - Location { - row: 7, - column: 56, - }, - ), - custom: (), - node: Constant { - value: Str( - " with nested ", - ), - kind: None, - }, - }, - Located { - location: Location { - row: 7, - column: 10, - }, - end_location: Some( - Location { - row: 7, - column: 56, - }, - ), - custom: (), - node: FormattedValue { - value: Located { - location: Location { - row: 7, - column: 42, - }, - end_location: Some( - Location { - row: 7, - column: 54, - }, - ), - custom: (), - node: Attribute { - value: Located { - location: Location { - row: 7, - column: 42, + Located { + location: Location { + row: 7, + column: 10, + }, + end_location: Some( + Location { + row: 7, + column: 56, + }, + ), + custom: (), + node: Constant( + ExprConstant { + value: Str( + " with nested ", + ), + kind: None, + }, + ), }, - end_location: Some( - Location { + Located { + location: Location { row: 7, - column: 43, + column: 10, }, - ), - custom: (), - node: Name { - id: "e", - ctx: Load, + end_location: Some( + Location { + row: 7, + column: 56, + }, + ), + custom: (), + node: FormattedValue( + ExprFormattedValue { + value: Located { + location: Location { + row: 7, + column: 42, + }, + end_location: Some( + Location { + row: 7, + column: 54, + }, + ), + custom: (), + node: Attribute( + ExprAttribute { + value: Located { + location: Location { + row: 7, + column: 42, + }, + end_location: Some( + Location { + row: 7, + column: 43, + }, + ), + custom: (), + node: Name( + ExprName { + id: "e", + ctx: Load, + }, + ), + }, + attr: "exceptions", + ctx: Load, + }, + ), + }, + conversion: 0, + format_spec: None, + }, + ), }, - }, - attr: "exceptions", - ctx: Load, + ], }, - }, - conversion: 0, - format_spec: None, + ), }, - }, - ], - }, + ], + keywords: [], + }, + ), }, - ], - keywords: [], - }, + }, + ), }, - }, + ], }, - ], + ), }, - }, - ], - orelse: [], - finalbody: [], - }, + ], + orelse: [], + finalbody: [], + }, + ), }, ] diff --git a/parser/src/snapshots/rustpython_parser__parser__tests__variadic_generics.snap b/parser/src/snapshots/rustpython_parser__parser__tests__variadic_generics.snap index a6875c3b..79a17e0b 100644 --- a/parser/src/snapshots/rustpython_parser__parser__tests__variadic_generics.snap +++ b/parser/src/snapshots/rustpython_parser__parser__tests__variadic_generics.snap @@ -1,5 +1,5 @@ --- -source: compiler/parser/src/parser.rs +source: parser/src/parser.rs expression: parse_ast --- [ @@ -15,174 +15,192 @@ expression: parse_ast }, ), custom: (), - node: FunctionDef { - name: "args_to_tuple", - args: Arguments { - posonlyargs: [], - args: [], - vararg: Some( + node: FunctionDef( + StmtFunctionDef { + name: "args_to_tuple", + args: Arguments { + posonlyargs: [], + args: [], + vararg: Some( + Located { + location: Location { + row: 2, + column: 19, + }, + end_location: Some( + Location { + row: 2, + column: 28, + }, + ), + custom: (), + node: ArgData { + arg: "args", + annotation: Some( + Located { + location: Location { + row: 2, + column: 25, + }, + end_location: Some( + Location { + row: 2, + column: 28, + }, + ), + custom: (), + node: Starred( + ExprStarred { + value: Located { + location: Location { + row: 2, + column: 26, + }, + end_location: Some( + Location { + row: 2, + column: 28, + }, + ), + custom: (), + node: Name( + ExprName { + id: "Ts", + ctx: Load, + }, + ), + }, + ctx: Load, + }, + ), + }, + ), + type_comment: None, + }, + }, + ), + kwonlyargs: [], + kw_defaults: [], + kwarg: None, + defaults: [], + }, + body: [ Located { location: Location { row: 2, - column: 19, + column: 45, }, end_location: Some( Location { row: 2, - column: 28, + column: 48, }, ), custom: (), - node: ArgData { - arg: "args", - annotation: Some( - Located { + node: Expr( + StmtExpr { + value: Located { location: Location { row: 2, - column: 25, + column: 45, }, end_location: Some( Location { row: 2, - column: 28, + column: 48, }, ), custom: (), - node: Starred { - value: Located { - location: Location { - row: 2, - column: 26, - }, - end_location: Some( - Location { - row: 2, - column: 28, - }, - ), - custom: (), - node: Name { - id: "Ts", - ctx: Load, - }, + node: Constant( + ExprConstant { + value: Ellipsis, + kind: None, }, - ctx: Load, - }, - }, - ), - type_comment: None, - }, - }, - ), - kwonlyargs: [], - kw_defaults: [], - kwarg: None, - defaults: [], - }, - body: [ - Located { - location: Location { - row: 2, - column: 45, - }, - end_location: Some( - Location { - row: 2, - column: 48, - }, - ), - custom: (), - node: Expr { - value: Located { - location: Location { - row: 2, - column: 45, - }, - end_location: Some( - Location { - row: 2, - column: 48, + ), }, - ), - custom: (), - node: Constant { - value: Ellipsis, - kind: None, }, - }, - }, - }, - ], - decorator_list: [], - returns: Some( - Located { - location: Location { - row: 2, - column: 33, + ), }, - end_location: Some( - Location { + ], + decorator_list: [], + returns: Some( + Located { + location: Location { row: 2, - column: 43, - }, - ), - custom: (), - node: Subscript { - value: Located { - location: Location { - row: 2, - column: 33, - }, - end_location: Some( - Location { - row: 2, - column: 38, - }, - ), - custom: (), - node: Name { - id: "Tuple", - ctx: Load, - }, + column: 33, }, - slice: Located { - location: Location { + end_location: Some( + Location { row: 2, - column: 39, + column: 43, }, - end_location: Some( - Location { - row: 2, - column: 42, - }, - ), - custom: (), - node: Starred { + ), + custom: (), + node: Subscript( + ExprSubscript { value: Located { location: Location { row: 2, - column: 40, + column: 33, }, end_location: Some( Location { row: 2, - column: 42, + column: 38, }, ), custom: (), - node: Name { - id: "Ts", - ctx: Load, + node: Name( + ExprName { + id: "Tuple", + ctx: Load, + }, + ), + }, + slice: Located { + location: Location { + row: 2, + column: 39, }, + end_location: Some( + Location { + row: 2, + column: 42, + }, + ), + custom: (), + node: Starred( + ExprStarred { + value: Located { + location: Location { + row: 2, + column: 40, + }, + end_location: Some( + Location { + row: 2, + column: 42, + }, + ), + custom: (), + node: Name( + ExprName { + id: "Ts", + ctx: Load, + }, + ), + }, + ctx: Load, + }, + ), }, ctx: Load, }, - }, - ctx: Load, + ), }, - }, - ), - type_comment: None, - }, + ), + type_comment: None, + }, + ), }, ] diff --git a/parser/src/snapshots/rustpython_parser__parser__tests__with_statement.snap b/parser/src/snapshots/rustpython_parser__parser__tests__with_statement.snap index 8ac056bb..70a5f5da 100644 --- a/parser/src/snapshots/rustpython_parser__parser__tests__with_statement.snap +++ b/parser/src/snapshots/rustpython_parser__parser__tests__with_statement.snap @@ -1,5 +1,5 @@ --- -source: compiler/parser/src/parser.rs +source: parser/src/parser.rs expression: "parse_program(source, \"\").unwrap()" --- [ @@ -15,49 +15,53 @@ expression: "parse_program(source, \"\").unwrap()" }, ), custom: (), - node: With { - items: [ - Withitem { - context_expr: Located { + node: With( + StmtWith { + items: [ + Withitem { + context_expr: Located { + location: Location { + row: 1, + column: 5, + }, + end_location: Some( + Location { + row: 1, + column: 6, + }, + ), + custom: (), + node: Constant( + ExprConstant { + value: Int( + 0, + ), + kind: None, + }, + ), + }, + optional_vars: None, + }, + ], + body: [ + Located { location: Location { row: 1, - column: 5, + column: 8, }, end_location: Some( Location { row: 1, - column: 6, + column: 12, }, ), custom: (), - node: Constant { - value: Int( - 0, - ), - kind: None, - }, + node: Pass, }, - optional_vars: None, - }, - ], - body: [ - Located { - location: Location { - row: 1, - column: 8, - }, - end_location: Some( - Location { - row: 1, - column: 12, - }, - ), - custom: (), - node: Pass, - }, - ], - type_comment: None, - }, + ], + type_comment: None, + }, + ), }, Located { location: Location { @@ -71,67 +75,73 @@ expression: "parse_program(source, \"\").unwrap()" }, ), custom: (), - node: With { - items: [ - Withitem { - context_expr: Located { - location: Location { - row: 2, - column: 5, - }, - end_location: Some( - Location { - row: 2, - column: 6, - }, - ), - custom: (), - node: Constant { - value: Int( - 0, - ), - kind: None, - }, - }, - optional_vars: Some( - Located { + node: With( + StmtWith { + items: [ + Withitem { + context_expr: Located { location: Location { row: 2, - column: 10, + column: 5, }, end_location: Some( Location { row: 2, - column: 11, + column: 6, }, ), custom: (), - node: Name { - id: "x", - ctx: Store, - }, + node: Constant( + ExprConstant { + value: Int( + 0, + ), + kind: None, + }, + ), }, - ), - }, - ], - body: [ - Located { - location: Location { - row: 2, - column: 13, + optional_vars: Some( + Located { + location: Location { + row: 2, + column: 10, + }, + end_location: Some( + Location { + row: 2, + column: 11, + }, + ), + custom: (), + node: Name( + ExprName { + id: "x", + ctx: Store, + }, + ), + }, + ), }, - end_location: Some( - Location { + ], + body: [ + Located { + location: Location { row: 2, - column: 17, + column: 13, }, - ), - custom: (), - node: Pass, - }, - ], - type_comment: None, - }, + end_location: Some( + Location { + row: 2, + column: 17, + }, + ), + custom: (), + node: Pass, + }, + ], + type_comment: None, + }, + ), }, Located { location: Location { @@ -145,71 +155,77 @@ expression: "parse_program(source, \"\").unwrap()" }, ), custom: (), - node: With { - items: [ - Withitem { - context_expr: Located { - location: Location { - row: 3, - column: 5, + node: With( + StmtWith { + items: [ + Withitem { + context_expr: Located { + location: Location { + row: 3, + column: 5, + }, + end_location: Some( + Location { + row: 3, + column: 6, + }, + ), + custom: (), + node: Constant( + ExprConstant { + value: Int( + 0, + ), + kind: None, + }, + ), }, - end_location: Some( - Location { + optional_vars: None, + }, + Withitem { + context_expr: Located { + location: Location { row: 3, - column: 6, + column: 8, }, - ), - custom: (), - node: Constant { - value: Int( - 0, + end_location: Some( + Location { + row: 3, + column: 9, + }, + ), + custom: (), + node: Constant( + ExprConstant { + value: Int( + 1, + ), + kind: None, + }, ), - kind: None, }, + optional_vars: None, }, - optional_vars: None, - }, - Withitem { - context_expr: Located { + ], + body: [ + Located { location: Location { row: 3, - column: 8, + column: 11, }, end_location: Some( Location { row: 3, - column: 9, + column: 15, }, ), custom: (), - node: Constant { - value: Int( - 1, - ), - kind: None, - }, + node: Pass, }, - optional_vars: None, - }, - ], - body: [ - Located { - location: Location { - row: 3, - column: 11, - }, - end_location: Some( - Location { - row: 3, - column: 15, - }, - ), - custom: (), - node: Pass, - }, - ], - type_comment: None, - }, + ], + type_comment: None, + }, + ), }, Located { location: Location { @@ -223,107 +239,117 @@ expression: "parse_program(source, \"\").unwrap()" }, ), custom: (), - node: With { - items: [ - Withitem { - context_expr: Located { - location: Location { - row: 4, - column: 5, - }, - end_location: Some( - Location { - row: 4, - column: 6, - }, - ), - custom: (), - node: Constant { - value: Int( - 0, - ), - kind: None, - }, - }, - optional_vars: Some( - Located { + node: With( + StmtWith { + items: [ + Withitem { + context_expr: Located { location: Location { row: 4, - column: 10, + column: 5, }, end_location: Some( Location { row: 4, - column: 11, + column: 6, }, ), custom: (), - node: Name { - id: "x", - ctx: Store, - }, - }, - ), - }, - Withitem { - context_expr: Located { - location: Location { - row: 4, - column: 13, + node: Constant( + ExprConstant { + value: Int( + 0, + ), + kind: None, + }, + ), }, - end_location: Some( - Location { - row: 4, - column: 14, + optional_vars: Some( + Located { + location: Location { + row: 4, + column: 10, + }, + end_location: Some( + Location { + row: 4, + column: 11, + }, + ), + custom: (), + node: Name( + ExprName { + id: "x", + ctx: Store, + }, + ), }, ), - custom: (), - node: Constant { - value: Int( - 1, - ), - kind: None, - }, }, - optional_vars: Some( - Located { + Withitem { + context_expr: Located { location: Location { row: 4, - column: 18, + column: 13, }, end_location: Some( Location { row: 4, - column: 19, + column: 14, }, ), custom: (), - node: Name { - id: "y", - ctx: Store, - }, + node: Constant( + ExprConstant { + value: Int( + 1, + ), + kind: None, + }, + ), }, - ), - }, - ], - body: [ - Located { - location: Location { - row: 4, - column: 21, + optional_vars: Some( + Located { + location: Location { + row: 4, + column: 18, + }, + end_location: Some( + Location { + row: 4, + column: 19, + }, + ), + custom: (), + node: Name( + ExprName { + id: "y", + ctx: Store, + }, + ), + }, + ), }, - end_location: Some( - Location { + ], + body: [ + Located { + location: Location { row: 4, - column: 25, + column: 21, }, - ), - custom: (), - node: Pass, - }, - ], - type_comment: None, - }, + end_location: Some( + Location { + row: 4, + column: 25, + }, + ), + custom: (), + node: Pass, + }, + ], + type_comment: None, + }, + ), }, Located { location: Location { @@ -337,102 +363,112 @@ expression: "parse_program(source, \"\").unwrap()" }, ), custom: (), - node: With { - items: [ - Withitem { - context_expr: Located { + node: With( + StmtWith { + items: [ + Withitem { + context_expr: Located { + location: Location { + row: 5, + column: 5, + }, + end_location: Some( + Location { + row: 5, + column: 18, + }, + ), + custom: (), + node: IfExp( + ExprIfExp { + test: Located { + location: Location { + row: 5, + column: 10, + }, + end_location: Some( + Location { + row: 5, + column: 11, + }, + ), + custom: (), + node: Constant( + ExprConstant { + value: Int( + 1, + ), + kind: None, + }, + ), + }, + body: Located { + location: Location { + row: 5, + column: 5, + }, + end_location: Some( + Location { + row: 5, + column: 6, + }, + ), + custom: (), + node: Constant( + ExprConstant { + value: Int( + 0, + ), + kind: None, + }, + ), + }, + orelse: Located { + location: Location { + row: 5, + column: 17, + }, + end_location: Some( + Location { + row: 5, + column: 18, + }, + ), + custom: (), + node: Constant( + ExprConstant { + value: Int( + 2, + ), + kind: None, + }, + ), + }, + }, + ), + }, + optional_vars: None, + }, + ], + body: [ + Located { location: Location { row: 5, - column: 5, + column: 20, }, end_location: Some( Location { row: 5, - column: 18, + column: 24, }, ), custom: (), - node: IfExp { - test: Located { - location: Location { - row: 5, - column: 10, - }, - end_location: Some( - Location { - row: 5, - column: 11, - }, - ), - custom: (), - node: Constant { - value: Int( - 1, - ), - kind: None, - }, - }, - body: Located { - location: Location { - row: 5, - column: 5, - }, - end_location: Some( - Location { - row: 5, - column: 6, - }, - ), - custom: (), - node: Constant { - value: Int( - 0, - ), - kind: None, - }, - }, - orelse: Located { - location: Location { - row: 5, - column: 17, - }, - end_location: Some( - Location { - row: 5, - column: 18, - }, - ), - custom: (), - node: Constant { - value: Int( - 2, - ), - kind: None, - }, - }, - }, + node: Pass, }, - optional_vars: None, - }, - ], - body: [ - Located { - location: Location { - row: 5, - column: 20, - }, - end_location: Some( - Location { - row: 5, - column: 24, - }, - ), - custom: (), - node: Pass, - }, - ], - type_comment: None, - }, + ], + type_comment: None, + }, + ), }, Located { location: Location { @@ -446,120 +482,132 @@ expression: "parse_program(source, \"\").unwrap()" }, ), custom: (), - node: With { - items: [ - Withitem { - context_expr: Located { - location: Location { - row: 6, - column: 5, - }, - end_location: Some( - Location { + node: With( + StmtWith { + items: [ + Withitem { + context_expr: Located { + location: Location { row: 6, - column: 18, + column: 5, }, - ), - custom: (), - node: IfExp { - test: Located { - location: Location { + end_location: Some( + Location { row: 6, - column: 10, + column: 18, }, - end_location: Some( - Location { - row: 6, - column: 11, + ), + custom: (), + node: IfExp( + ExprIfExp { + test: Located { + location: Location { + row: 6, + column: 10, + }, + end_location: Some( + Location { + row: 6, + column: 11, + }, + ), + custom: (), + node: Constant( + ExprConstant { + value: Int( + 1, + ), + kind: None, + }, + ), + }, + body: Located { + location: Location { + row: 6, + column: 5, + }, + end_location: Some( + Location { + row: 6, + column: 6, + }, + ), + custom: (), + node: Constant( + ExprConstant { + value: Int( + 0, + ), + kind: None, + }, + ), + }, + orelse: Located { + location: Location { + row: 6, + column: 17, + }, + end_location: Some( + Location { + row: 6, + column: 18, + }, + ), + custom: (), + node: Constant( + ExprConstant { + value: Int( + 2, + ), + kind: None, + }, + ), }, - ), - custom: (), - node: Constant { - value: Int( - 1, - ), - kind: None, }, - }, - body: Located { + ), + }, + optional_vars: Some( + Located { location: Location { row: 6, - column: 5, + column: 22, }, end_location: Some( Location { row: 6, - column: 6, + column: 23, }, ), custom: (), - node: Constant { - value: Int( - 0, - ), - kind: None, - }, - }, - orelse: Located { - location: Location { - row: 6, - column: 17, - }, - end_location: Some( - Location { - row: 6, - column: 18, + node: Name( + ExprName { + id: "x", + ctx: Store, }, ), - custom: (), - node: Constant { - value: Int( - 2, - ), - kind: None, - }, }, - }, + ), }, - optional_vars: Some( - Located { - location: Location { + ], + body: [ + Located { + location: Location { + row: 6, + column: 25, + }, + end_location: Some( + Location { row: 6, - column: 22, - }, - end_location: Some( - Location { - row: 6, - column: 23, - }, - ), - custom: (), - node: Name { - id: "x", - ctx: Store, + column: 29, }, - }, - ), - }, - ], - body: [ - Located { - location: Location { - row: 6, - column: 25, + ), + custom: (), + node: Pass, }, - end_location: Some( - Location { - row: 6, - column: 29, - }, - ), - custom: (), - node: Pass, - }, - ], - type_comment: None, - }, + ], + type_comment: None, + }, + ), }, Located { location: Location { @@ -573,47 +621,51 @@ expression: "parse_program(source, \"\").unwrap()" }, ), custom: (), - node: With { - items: [ - Withitem { - context_expr: Located { + node: With( + StmtWith { + items: [ + Withitem { + context_expr: Located { + location: Location { + row: 7, + column: 5, + }, + end_location: Some( + Location { + row: 7, + column: 7, + }, + ), + custom: (), + node: Tuple( + ExprTuple { + elts: [], + ctx: Load, + }, + ), + }, + optional_vars: None, + }, + ], + body: [ + Located { location: Location { row: 7, - column: 5, + column: 9, }, end_location: Some( Location { row: 7, - column: 7, + column: 13, }, ), custom: (), - node: Tuple { - elts: [], - ctx: Load, - }, + node: Pass, }, - optional_vars: None, - }, - ], - body: [ - Located { - location: Location { - row: 7, - column: 9, - }, - end_location: Some( - Location { - row: 7, - column: 13, - }, - ), - custom: (), - node: Pass, - }, - ], - type_comment: None, - }, + ], + type_comment: None, + }, + ), }, Located { location: Location { @@ -627,65 +679,71 @@ expression: "parse_program(source, \"\").unwrap()" }, ), custom: (), - node: With { - items: [ - Withitem { - context_expr: Located { - location: Location { - row: 8, - column: 5, - }, - end_location: Some( - Location { - row: 8, - column: 7, - }, - ), - custom: (), - node: Tuple { - elts: [], - ctx: Load, - }, - }, - optional_vars: Some( - Located { + node: With( + StmtWith { + items: [ + Withitem { + context_expr: Located { location: Location { row: 8, - column: 11, + column: 5, }, end_location: Some( Location { row: 8, - column: 12, + column: 7, }, ), custom: (), - node: Name { - id: "x", - ctx: Store, - }, + node: Tuple( + ExprTuple { + elts: [], + ctx: Load, + }, + ), }, - ), - }, - ], - body: [ - Located { - location: Location { - row: 8, - column: 14, + optional_vars: Some( + Located { + location: Location { + row: 8, + column: 11, + }, + end_location: Some( + Location { + row: 8, + column: 12, + }, + ), + custom: (), + node: Name( + ExprName { + id: "x", + ctx: Store, + }, + ), + }, + ), }, - end_location: Some( - Location { + ], + body: [ + Located { + location: Location { row: 8, - column: 18, + column: 14, }, - ), - custom: (), - node: Pass, - }, - ], - type_comment: None, - }, + end_location: Some( + Location { + row: 8, + column: 18, + }, + ), + custom: (), + node: Pass, + }, + ], + type_comment: None, + }, + ), }, Located { location: Location { @@ -699,49 +757,53 @@ expression: "parse_program(source, \"\").unwrap()" }, ), custom: (), - node: With { - items: [ - Withitem { - context_expr: Located { + node: With( + StmtWith { + items: [ + Withitem { + context_expr: Located { + location: Location { + row: 9, + column: 6, + }, + end_location: Some( + Location { + row: 9, + column: 7, + }, + ), + custom: (), + node: Constant( + ExprConstant { + value: Int( + 0, + ), + kind: None, + }, + ), + }, + optional_vars: None, + }, + ], + body: [ + Located { location: Location { row: 9, - column: 6, + column: 10, }, end_location: Some( Location { row: 9, - column: 7, + column: 14, }, ), custom: (), - node: Constant { - value: Int( - 0, - ), - kind: None, - }, + node: Pass, }, - optional_vars: None, - }, - ], - body: [ - Located { - location: Location { - row: 9, - column: 10, - }, - end_location: Some( - Location { - row: 9, - column: 14, - }, - ), - custom: (), - node: Pass, - }, - ], - type_comment: None, - }, + ], + type_comment: None, + }, + ), }, Located { location: Location { @@ -755,67 +817,73 @@ expression: "parse_program(source, \"\").unwrap()" }, ), custom: (), - node: With { - items: [ - Withitem { - context_expr: Located { - location: Location { - row: 10, - column: 6, - }, - end_location: Some( - Location { + node: With( + StmtWith { + items: [ + Withitem { + context_expr: Located { + location: Location { row: 10, - column: 7, - }, - ), - custom: (), - node: Constant { - value: Int( - 0, - ), - kind: None, - }, - }, - optional_vars: Some( - Located { - location: Location { - row: 10, - column: 12, + column: 6, }, end_location: Some( Location { row: 10, - column: 13, + column: 7, }, ), custom: (), - node: Name { - id: "x", - ctx: Store, - }, + node: Constant( + ExprConstant { + value: Int( + 0, + ), + kind: None, + }, + ), }, - ), - }, - ], - body: [ - Located { - location: Location { - row: 10, - column: 15, + optional_vars: Some( + Located { + location: Location { + row: 10, + column: 12, + }, + end_location: Some( + Location { + row: 10, + column: 13, + }, + ), + custom: (), + node: Name( + ExprName { + id: "x", + ctx: Store, + }, + ), + }, + ), }, - end_location: Some( - Location { + ], + body: [ + Located { + location: Location { row: 10, - column: 19, + column: 15, }, - ), - custom: (), - node: Pass, - }, - ], - type_comment: None, - }, + end_location: Some( + Location { + row: 10, + column: 19, + }, + ), + custom: (), + node: Pass, + }, + ], + type_comment: None, + }, + ), }, Located { location: Location { @@ -829,49 +897,53 @@ expression: "parse_program(source, \"\").unwrap()" }, ), custom: (), - node: With { - items: [ - Withitem { - context_expr: Located { + node: With( + StmtWith { + items: [ + Withitem { + context_expr: Located { + location: Location { + row: 11, + column: 6, + }, + end_location: Some( + Location { + row: 11, + column: 7, + }, + ), + custom: (), + node: Constant( + ExprConstant { + value: Int( + 0, + ), + kind: None, + }, + ), + }, + optional_vars: None, + }, + ], + body: [ + Located { location: Location { row: 11, - column: 6, + column: 11, }, end_location: Some( Location { row: 11, - column: 7, + column: 15, }, ), custom: (), - node: Constant { - value: Int( - 0, - ), - kind: None, - }, + node: Pass, }, - optional_vars: None, - }, - ], - body: [ - Located { - location: Location { - row: 11, - column: 11, - }, - end_location: Some( - Location { - row: 11, - column: 15, - }, - ), - custom: (), - node: Pass, - }, - ], - type_comment: None, - }, + ], + type_comment: None, + }, + ), }, Located { location: Location { @@ -885,85 +957,93 @@ expression: "parse_program(source, \"\").unwrap()" }, ), custom: (), - node: With { - items: [ - Withitem { - context_expr: Located { - location: Location { - row: 12, - column: 5, - }, - end_location: Some( - Location { - row: 12, - column: 9, - }, - ), - custom: (), - node: Tuple { - elts: [ - Located { - location: Location { - row: 12, - column: 6, - }, - end_location: Some( - Location { - row: 12, - column: 7, - }, - ), - custom: (), - node: Constant { - value: Int( - 0, - ), - kind: None, - }, - }, - ], - ctx: Load, - }, - }, - optional_vars: Some( - Located { + node: With( + StmtWith { + items: [ + Withitem { + context_expr: Located { location: Location { row: 12, - column: 13, + column: 5, }, end_location: Some( Location { row: 12, - column: 14, + column: 9, }, ), custom: (), - node: Name { - id: "x", - ctx: Store, - }, + node: Tuple( + ExprTuple { + elts: [ + Located { + location: Location { + row: 12, + column: 6, + }, + end_location: Some( + Location { + row: 12, + column: 7, + }, + ), + custom: (), + node: Constant( + ExprConstant { + value: Int( + 0, + ), + kind: None, + }, + ), + }, + ], + ctx: Load, + }, + ), }, - ), - }, - ], - body: [ - Located { - location: Location { - row: 12, - column: 16, + optional_vars: Some( + Located { + location: Location { + row: 12, + column: 13, + }, + end_location: Some( + Location { + row: 12, + column: 14, + }, + ), + custom: (), + node: Name( + ExprName { + id: "x", + ctx: Store, + }, + ), + }, + ), }, - end_location: Some( - Location { + ], + body: [ + Located { + location: Location { row: 12, - column: 20, + column: 16, }, - ), - custom: (), - node: Pass, - }, - ], - type_comment: None, - }, + end_location: Some( + Location { + row: 12, + column: 20, + }, + ), + custom: (), + node: Pass, + }, + ], + type_comment: None, + }, + ), }, Located { location: Location { @@ -977,71 +1057,77 @@ expression: "parse_program(source, \"\").unwrap()" }, ), custom: (), - node: With { - items: [ - Withitem { - context_expr: Located { - location: Location { - row: 13, - column: 6, + node: With( + StmtWith { + items: [ + Withitem { + context_expr: Located { + location: Location { + row: 13, + column: 6, + }, + end_location: Some( + Location { + row: 13, + column: 7, + }, + ), + custom: (), + node: Constant( + ExprConstant { + value: Int( + 0, + ), + kind: None, + }, + ), }, - end_location: Some( - Location { + optional_vars: None, + }, + Withitem { + context_expr: Located { + location: Location { row: 13, - column: 7, + column: 9, }, - ), - custom: (), - node: Constant { - value: Int( - 0, + end_location: Some( + Location { + row: 13, + column: 10, + }, + ), + custom: (), + node: Constant( + ExprConstant { + value: Int( + 1, + ), + kind: None, + }, ), - kind: None, }, + optional_vars: None, }, - optional_vars: None, - }, - Withitem { - context_expr: Located { + ], + body: [ + Located { location: Location { row: 13, - column: 9, + column: 13, }, end_location: Some( Location { row: 13, - column: 10, + column: 17, }, ), custom: (), - node: Constant { - value: Int( - 1, - ), - kind: None, - }, - }, - optional_vars: None, - }, - ], - body: [ - Located { - location: Location { - row: 13, - column: 13, + node: Pass, }, - end_location: Some( - Location { - row: 13, - column: 17, - }, - ), - custom: (), - node: Pass, - }, - ], - type_comment: None, - }, + ], + type_comment: None, + }, + ), }, Located { location: Location { @@ -1055,298 +1141,326 @@ expression: "parse_program(source, \"\").unwrap()" }, ), custom: (), - node: With { - items: [ - Withitem { - context_expr: Located { - location: Location { - row: 14, - column: 5, - }, - end_location: Some( - Location { - row: 14, - column: 11, - }, - ), - custom: (), - node: Tuple { - elts: [ - Located { - location: Location { - row: 14, - column: 6, - }, - end_location: Some( - Location { - row: 14, - column: 7, - }, - ), - custom: (), - node: Constant { - value: Int( - 0, - ), - kind: None, - }, - }, - Located { - location: Location { - row: 14, - column: 9, - }, - end_location: Some( - Location { - row: 14, - column: 10, - }, - ), - custom: (), - node: Constant { - value: Int( - 1, - ), - kind: None, - }, - }, - ], - ctx: Load, - }, - }, - optional_vars: Some( - Located { + node: With( + StmtWith { + items: [ + Withitem { + context_expr: Located { location: Location { row: 14, - column: 15, + column: 5, }, end_location: Some( Location { row: 14, - column: 16, + column: 11, }, ), custom: (), - node: Name { - id: "x", - ctx: Store, - }, - }, - ), - }, - ], - body: [ - Located { - location: Location { - row: 14, - column: 18, - }, - end_location: Some( - Location { - row: 14, - column: 22, - }, - ), - custom: (), - node: Pass, - }, - ], - type_comment: None, - }, - }, - Located { - location: Location { - row: 15, - column: 0, - }, - end_location: Some( - Location { - row: 15, - column: 16, - }, - ), - custom: (), - node: With { - items: [ - Withitem { - context_expr: Located { - location: Location { - row: 15, - column: 5, - }, - end_location: Some( - Location { - row: 15, - column: 10, - }, - ), - custom: (), - node: Tuple { - elts: [ - Located { - location: Location { - row: 15, - column: 6, - }, - end_location: Some( - Location { - row: 15, - column: 8, - }, - ), - custom: (), - node: Starred { - value: Located { + node: Tuple( + ExprTuple { + elts: [ + Located { location: Location { - row: 15, - column: 7, + row: 14, + column: 6, }, end_location: Some( Location { - row: 15, - column: 8, + row: 14, + column: 7, }, ), custom: (), - node: Name { - id: "a", - ctx: Load, - }, + node: Constant( + ExprConstant { + value: Int( + 0, + ), + kind: None, + }, + ), }, - ctx: Load, - }, - }, - ], - ctx: Load, - }, - }, - optional_vars: None, - }, - ], - body: [ - Located { - location: Location { - row: 15, - column: 12, + Located { + location: Location { + row: 14, + column: 9, + }, + end_location: Some( + Location { + row: 14, + column: 10, + }, + ), + custom: (), + node: Constant( + ExprConstant { + value: Int( + 1, + ), + kind: None, + }, + ), + }, + ], + ctx: Load, + }, + ), + }, + optional_vars: Some( + Located { + location: Location { + row: 14, + column: 15, + }, + end_location: Some( + Location { + row: 14, + column: 16, + }, + ), + custom: (), + node: Name( + ExprName { + id: "x", + ctx: Store, + }, + ), + }, + ), }, - end_location: Some( - Location { - row: 15, - column: 16, + ], + body: [ + Located { + location: Location { + row: 14, + column: 18, }, - ), - custom: (), - node: Pass, - }, - ], - type_comment: None, - }, + end_location: Some( + Location { + row: 14, + column: 22, + }, + ), + custom: (), + node: Pass, + }, + ], + type_comment: None, + }, + ), }, Located { location: Location { - row: 16, + row: 15, column: 0, }, end_location: Some( Location { - row: 16, - column: 21, + row: 15, + column: 16, }, ), custom: (), - node: With { - items: [ - Withitem { - context_expr: Located { - location: Location { - row: 16, - column: 5, - }, - end_location: Some( - Location { - row: 16, - column: 10, + node: With( + StmtWith { + items: [ + Withitem { + context_expr: Located { + location: Location { + row: 15, + column: 5, }, - ), - custom: (), - node: Tuple { - elts: [ - Located { - location: Location { - row: 16, - column: 6, - }, - end_location: Some( - Location { - row: 16, - column: 8, - }, - ), - custom: (), - node: Starred { - value: Located { + end_location: Some( + Location { + row: 15, + column: 10, + }, + ), + custom: (), + node: Tuple( + ExprTuple { + elts: [ + Located { location: Location { - row: 16, - column: 7, + row: 15, + column: 6, }, end_location: Some( Location { - row: 16, + row: 15, column: 8, }, ), custom: (), - node: Name { - id: "a", - ctx: Load, - }, + node: Starred( + ExprStarred { + value: Located { + location: Location { + row: 15, + column: 7, + }, + end_location: Some( + Location { + row: 15, + column: 8, + }, + ), + custom: (), + node: Name( + ExprName { + id: "a", + ctx: Load, + }, + ), + }, + ctx: Load, + }, + ), }, - ctx: Load, - }, + ], + ctx: Load, }, - ], - ctx: Load, + ), }, + optional_vars: None, + }, + ], + body: [ + Located { + location: Location { + row: 15, + column: 12, + }, + end_location: Some( + Location { + row: 15, + column: 16, + }, + ), + custom: (), + node: Pass, }, - optional_vars: Some( - Located { + ], + type_comment: None, + }, + ), + }, + Located { + location: Location { + row: 16, + column: 0, + }, + end_location: Some( + Location { + row: 16, + column: 21, + }, + ), + custom: (), + node: With( + StmtWith { + items: [ + Withitem { + context_expr: Located { location: Location { row: 16, - column: 14, + column: 5, }, end_location: Some( Location { row: 16, - column: 15, + column: 10, }, ), custom: (), - node: Name { - id: "x", - ctx: Store, - }, + node: Tuple( + ExprTuple { + elts: [ + Located { + location: Location { + row: 16, + column: 6, + }, + end_location: Some( + Location { + row: 16, + column: 8, + }, + ), + custom: (), + node: Starred( + ExprStarred { + value: Located { + location: Location { + row: 16, + column: 7, + }, + end_location: Some( + Location { + row: 16, + column: 8, + }, + ), + custom: (), + node: Name( + ExprName { + id: "a", + ctx: Load, + }, + ), + }, + ctx: Load, + }, + ), + }, + ], + ctx: Load, + }, + ), }, - ), - }, - ], - body: [ - Located { - location: Location { - row: 16, - column: 17, + optional_vars: Some( + Located { + location: Location { + row: 16, + column: 14, + }, + end_location: Some( + Location { + row: 16, + column: 15, + }, + ), + custom: (), + node: Name( + ExprName { + id: "x", + ctx: Store, + }, + ), + }, + ), }, - end_location: Some( - Location { + ], + body: [ + Located { + location: Location { row: 16, - column: 21, + column: 17, }, - ), - custom: (), - node: Pass, - }, - ], - type_comment: None, - }, + end_location: Some( + Location { + row: 16, + column: 21, + }, + ), + custom: (), + node: Pass, + }, + ], + type_comment: None, + }, + ), }, Located { location: Location { @@ -1360,59 +1474,50 @@ expression: "parse_program(source, \"\").unwrap()" }, ), custom: (), - node: With { - items: [ - Withitem { - context_expr: Located { - location: Location { - row: 17, - column: 5, - }, - end_location: Some( - Location { + node: With( + StmtWith { + items: [ + Withitem { + context_expr: Located { + location: Location { row: 17, - column: 12, + column: 5, }, - ), - custom: (), - node: Tuple { - elts: [ - Located { - location: Location { - row: 17, - column: 6, - }, - end_location: Some( - Location { - row: 17, - column: 7, - }, - ), - custom: (), - node: Constant { - value: Int( - 0, - ), - kind: None, - }, + end_location: Some( + Location { + row: 17, + column: 12, }, - Located { - location: Location { - row: 17, - column: 9, - }, - end_location: Some( - Location { - row: 17, - column: 11, + ), + custom: (), + node: Tuple( + ExprTuple { + elts: [ + Located { + location: Location { + row: 17, + column: 6, + }, + end_location: Some( + Location { + row: 17, + column: 7, + }, + ), + custom: (), + node: Constant( + ExprConstant { + value: Int( + 0, + ), + kind: None, + }, + ), }, - ), - custom: (), - node: Starred { - value: Located { + Located { location: Location { row: 17, - column: 10, + column: 9, }, end_location: Some( Location { @@ -1421,39 +1526,58 @@ expression: "parse_program(source, \"\").unwrap()" }, ), custom: (), - node: Name { - id: "a", - ctx: Load, - }, + node: Starred( + ExprStarred { + value: Located { + location: Location { + row: 17, + column: 10, + }, + end_location: Some( + Location { + row: 17, + column: 11, + }, + ), + custom: (), + node: Name( + ExprName { + id: "a", + ctx: Load, + }, + ), + }, + ctx: Load, + }, + ), }, - ctx: Load, - }, + ], + ctx: Load, }, - ], - ctx: Load, + ), }, + optional_vars: None, }, - optional_vars: None, - }, - ], - body: [ - Located { - location: Location { - row: 17, - column: 14, - }, - end_location: Some( - Location { + ], + body: [ + Located { + location: Location { row: 17, - column: 18, + column: 14, }, - ), - custom: (), - node: Pass, - }, - ], - type_comment: None, - }, + end_location: Some( + Location { + row: 17, + column: 18, + }, + ), + custom: (), + node: Pass, + }, + ], + type_comment: None, + }, + ), }, Located { location: Location { @@ -1467,59 +1591,50 @@ expression: "parse_program(source, \"\").unwrap()" }, ), custom: (), - node: With { - items: [ - Withitem { - context_expr: Located { - location: Location { - row: 18, - column: 5, - }, - end_location: Some( - Location { + node: With( + StmtWith { + items: [ + Withitem { + context_expr: Located { + location: Location { row: 18, - column: 12, + column: 5, }, - ), - custom: (), - node: Tuple { - elts: [ - Located { - location: Location { - row: 18, - column: 6, - }, - end_location: Some( - Location { - row: 18, - column: 7, - }, - ), - custom: (), - node: Constant { - value: Int( - 0, - ), - kind: None, - }, + end_location: Some( + Location { + row: 18, + column: 12, }, - Located { - location: Location { - row: 18, - column: 9, - }, - end_location: Some( - Location { - row: 18, - column: 11, + ), + custom: (), + node: Tuple( + ExprTuple { + elts: [ + Located { + location: Location { + row: 18, + column: 6, + }, + end_location: Some( + Location { + row: 18, + column: 7, + }, + ), + custom: (), + node: Constant( + ExprConstant { + value: Int( + 0, + ), + kind: None, + }, + ), }, - ), - custom: (), - node: Starred { - value: Located { + Located { location: Location { row: 18, - column: 10, + column: 9, }, end_location: Some( Location { @@ -1528,57 +1643,78 @@ expression: "parse_program(source, \"\").unwrap()" }, ), custom: (), - node: Name { - id: "a", - ctx: Load, - }, + node: Starred( + ExprStarred { + value: Located { + location: Location { + row: 18, + column: 10, + }, + end_location: Some( + Location { + row: 18, + column: 11, + }, + ), + custom: (), + node: Name( + ExprName { + id: "a", + ctx: Load, + }, + ), + }, + ctx: Load, + }, + ), }, - ctx: Load, - }, + ], + ctx: Load, }, - ], - ctx: Load, + ), }, - }, - optional_vars: Some( - Located { - location: Location { - row: 18, - column: 16, - }, - end_location: Some( - Location { + optional_vars: Some( + Located { + location: Location { row: 18, - column: 17, + column: 16, }, - ), - custom: (), - node: Name { - id: "x", - ctx: Store, + end_location: Some( + Location { + row: 18, + column: 17, + }, + ), + custom: (), + node: Name( + ExprName { + id: "x", + ctx: Store, + }, + ), }, - }, - ), - }, - ], - body: [ - Located { - location: Location { - row: 18, - column: 19, + ), }, - end_location: Some( - Location { + ], + body: [ + Located { + location: Location { row: 18, - column: 23, + column: 19, }, - ), - custom: (), - node: Pass, - }, - ], - type_comment: None, - }, + end_location: Some( + Location { + row: 18, + column: 23, + }, + ), + custom: (), + node: Pass, + }, + ], + type_comment: None, + }, + ), }, Located { location: Location { @@ -1592,81 +1728,89 @@ expression: "parse_program(source, \"\").unwrap()" }, ), custom: (), - node: With { - items: [ - Withitem { - context_expr: Located { - location: Location { - row: 19, - column: 6, - }, - end_location: Some( - Location { + node: With( + StmtWith { + items: [ + Withitem { + context_expr: Located { + location: Location { row: 19, - column: 12, + column: 6, }, - ), - custom: (), - node: NamedExpr { - target: Located { - location: Location { + end_location: Some( + Location { row: 19, - column: 6, + column: 12, }, - end_location: Some( - Location { - row: 19, - column: 7, + ), + custom: (), + node: NamedExpr( + ExprNamedExpr { + target: Located { + location: Location { + row: 19, + column: 6, + }, + end_location: Some( + Location { + row: 19, + column: 7, + }, + ), + custom: (), + node: Name( + ExprName { + id: "a", + ctx: Store, + }, + ), }, - ), - custom: (), - node: Name { - id: "a", - ctx: Store, - }, - }, - value: Located { - location: Location { - row: 19, - column: 11, - }, - end_location: Some( - Location { - row: 19, - column: 12, + value: Located { + location: Location { + row: 19, + column: 11, + }, + end_location: Some( + Location { + row: 19, + column: 12, + }, + ), + custom: (), + node: Constant( + ExprConstant { + value: Int( + 0, + ), + kind: None, + }, + ), }, - ), - custom: (), - node: Constant { - value: Int( - 0, - ), - kind: None, }, - }, + ), }, + optional_vars: None, }, - optional_vars: None, - }, - ], - body: [ - Located { - location: Location { - row: 19, - column: 15, - }, - end_location: Some( - Location { + ], + body: [ + Located { + location: Location { row: 19, - column: 19, + column: 15, }, - ), - custom: (), - node: Pass, - }, - ], - type_comment: None, - }, + end_location: Some( + Location { + row: 19, + column: 19, + }, + ), + custom: (), + node: Pass, + }, + ], + type_comment: None, + }, + ), }, Located { location: Location { @@ -1680,99 +1824,109 @@ expression: "parse_program(source, \"\").unwrap()" }, ), custom: (), - node: With { - items: [ - Withitem { - context_expr: Located { - location: Location { - row: 20, - column: 6, - }, - end_location: Some( - Location { + node: With( + StmtWith { + items: [ + Withitem { + context_expr: Located { + location: Location { row: 20, - column: 12, + column: 6, }, - ), - custom: (), - node: NamedExpr { - target: Located { - location: Location { + end_location: Some( + Location { row: 20, - column: 6, + column: 12, }, - end_location: Some( - Location { - row: 20, - column: 7, + ), + custom: (), + node: NamedExpr( + ExprNamedExpr { + target: Located { + location: Location { + row: 20, + column: 6, + }, + end_location: Some( + Location { + row: 20, + column: 7, + }, + ), + custom: (), + node: Name( + ExprName { + id: "a", + ctx: Store, + }, + ), + }, + value: Located { + location: Location { + row: 20, + column: 11, + }, + end_location: Some( + Location { + row: 20, + column: 12, + }, + ), + custom: (), + node: Constant( + ExprConstant { + value: Int( + 0, + ), + kind: None, + }, + ), }, - ), - custom: (), - node: Name { - id: "a", - ctx: Store, }, - }, - value: Located { + ), + }, + optional_vars: Some( + Located { location: Location { row: 20, - column: 11, + column: 17, }, end_location: Some( Location { row: 20, - column: 12, + column: 18, }, ), custom: (), - node: Constant { - value: Int( - 0, - ), - kind: None, - }, + node: Name( + ExprName { + id: "x", + ctx: Store, + }, + ), }, - }, + ), }, - optional_vars: Some( - Located { - location: Location { + ], + body: [ + Located { + location: Location { + row: 20, + column: 20, + }, + end_location: Some( + Location { row: 20, - column: 17, - }, - end_location: Some( - Location { - row: 20, - column: 18, - }, - ), - custom: (), - node: Name { - id: "x", - ctx: Store, + column: 24, }, - }, - ), - }, - ], - body: [ - Located { - location: Location { - row: 20, - column: 20, + ), + custom: (), + node: Pass, }, - end_location: Some( - Location { - row: 20, - column: 24, - }, - ), - custom: (), - node: Pass, - }, - ], - type_comment: None, - }, + ], + type_comment: None, + }, + ), }, Located { location: Location { @@ -1786,37 +1940,26 @@ expression: "parse_program(source, \"\").unwrap()" }, ), custom: (), - node: With { - items: [ - Withitem { - context_expr: Located { - location: Location { - row: 21, - column: 5, - }, - end_location: Some( - Location { + node: With( + StmtWith { + items: [ + Withitem { + context_expr: Located { + location: Location { row: 21, - column: 21, + column: 5, }, - ), - custom: (), - node: Tuple { - elts: [ - Located { - location: Location { - row: 21, - column: 6, - }, - end_location: Some( - Location { - row: 21, - column: 12, - }, - ), - custom: (), - node: NamedExpr { - target: Located { + end_location: Some( + Location { + row: 21, + column: 21, + }, + ), + custom: (), + node: Tuple( + ExprTuple { + elts: [ + Located { location: Location { row: 21, column: 6, @@ -1824,50 +1967,56 @@ expression: "parse_program(source, \"\").unwrap()" end_location: Some( Location { row: 21, - column: 7, + column: 12, }, ), custom: (), - node: Name { - id: "a", - ctx: Store, - }, - }, - value: Located { - location: Location { - row: 21, - column: 11, - }, - end_location: Some( - Location { - row: 21, - column: 12, + node: NamedExpr( + ExprNamedExpr { + target: Located { + location: Location { + row: 21, + column: 6, + }, + end_location: Some( + Location { + row: 21, + column: 7, + }, + ), + custom: (), + node: Name( + ExprName { + id: "a", + ctx: Store, + }, + ), + }, + value: Located { + location: Location { + row: 21, + column: 11, + }, + end_location: Some( + Location { + row: 21, + column: 12, + }, + ), + custom: (), + node: Constant( + ExprConstant { + value: Int( + 0, + ), + kind: None, + }, + ), + }, }, ), - custom: (), - node: Constant { - value: Int( - 0, - ), - kind: None, - }, - }, - }, - }, - Located { - location: Location { - row: 21, - column: 14, - }, - end_location: Some( - Location { - row: 21, - column: 20, }, - ), - custom: (), - node: NamedExpr { - target: Located { + Located { location: Location { row: 21, column: 14, @@ -1875,61 +2024,82 @@ expression: "parse_program(source, \"\").unwrap()" end_location: Some( Location { row: 21, - column: 15, + column: 20, }, ), custom: (), - node: Name { - id: "b", - ctx: Store, - }, - }, - value: Located { - location: Location { - row: 21, - column: 19, - }, - end_location: Some( - Location { - row: 21, - column: 20, + node: NamedExpr( + ExprNamedExpr { + target: Located { + location: Location { + row: 21, + column: 14, + }, + end_location: Some( + Location { + row: 21, + column: 15, + }, + ), + custom: (), + node: Name( + ExprName { + id: "b", + ctx: Store, + }, + ), + }, + value: Located { + location: Location { + row: 21, + column: 19, + }, + end_location: Some( + Location { + row: 21, + column: 20, + }, + ), + custom: (), + node: Constant( + ExprConstant { + value: Int( + 1, + ), + kind: None, + }, + ), + }, }, ), - custom: (), - node: Constant { - value: Int( - 1, - ), - kind: None, - }, }, - }, + ], + ctx: Load, }, - ], - ctx: Load, + ), }, + optional_vars: None, }, - optional_vars: None, - }, - ], - body: [ - Located { - location: Location { - row: 21, - column: 23, - }, - end_location: Some( - Location { + ], + body: [ + Located { + location: Location { row: 21, - column: 27, + column: 23, }, - ), - custom: (), - node: Pass, - }, - ], - type_comment: None, - }, + end_location: Some( + Location { + row: 21, + column: 27, + }, + ), + custom: (), + node: Pass, + }, + ], + type_comment: None, + }, + ), }, Located { location: Location { @@ -1943,37 +2113,26 @@ expression: "parse_program(source, \"\").unwrap()" }, ), custom: (), - node: With { - items: [ - Withitem { - context_expr: Located { - location: Location { - row: 22, - column: 5, - }, - end_location: Some( - Location { + node: With( + StmtWith { + items: [ + Withitem { + context_expr: Located { + location: Location { row: 22, - column: 21, + column: 5, }, - ), - custom: (), - node: Tuple { - elts: [ - Located { - location: Location { - row: 22, - column: 6, - }, - end_location: Some( - Location { - row: 22, - column: 12, - }, - ), - custom: (), - node: NamedExpr { - target: Located { + end_location: Some( + Location { + row: 22, + column: 21, + }, + ), + custom: (), + node: Tuple( + ExprTuple { + elts: [ + Located { location: Location { row: 22, column: 6, @@ -1981,50 +2140,56 @@ expression: "parse_program(source, \"\").unwrap()" end_location: Some( Location { row: 22, - column: 7, + column: 12, }, ), custom: (), - node: Name { - id: "a", - ctx: Store, - }, - }, - value: Located { - location: Location { - row: 22, - column: 11, - }, - end_location: Some( - Location { - row: 22, - column: 12, + node: NamedExpr( + ExprNamedExpr { + target: Located { + location: Location { + row: 22, + column: 6, + }, + end_location: Some( + Location { + row: 22, + column: 7, + }, + ), + custom: (), + node: Name( + ExprName { + id: "a", + ctx: Store, + }, + ), + }, + value: Located { + location: Location { + row: 22, + column: 11, + }, + end_location: Some( + Location { + row: 22, + column: 12, + }, + ), + custom: (), + node: Constant( + ExprConstant { + value: Int( + 0, + ), + kind: None, + }, + ), + }, }, ), - custom: (), - node: Constant { - value: Int( - 0, - ), - kind: None, - }, - }, - }, - }, - Located { - location: Location { - row: 22, - column: 14, - }, - end_location: Some( - Location { - row: 22, - column: 20, }, - ), - custom: (), - node: NamedExpr { - target: Located { + Located { location: Location { row: 22, column: 14, @@ -2032,79 +2197,102 @@ expression: "parse_program(source, \"\").unwrap()" end_location: Some( Location { row: 22, - column: 15, + column: 20, }, ), custom: (), - node: Name { - id: "b", - ctx: Store, - }, - }, - value: Located { - location: Location { - row: 22, - column: 19, - }, - end_location: Some( - Location { - row: 22, - column: 20, + node: NamedExpr( + ExprNamedExpr { + target: Located { + location: Location { + row: 22, + column: 14, + }, + end_location: Some( + Location { + row: 22, + column: 15, + }, + ), + custom: (), + node: Name( + ExprName { + id: "b", + ctx: Store, + }, + ), + }, + value: Located { + location: Location { + row: 22, + column: 19, + }, + end_location: Some( + Location { + row: 22, + column: 20, + }, + ), + custom: (), + node: Constant( + ExprConstant { + value: Int( + 1, + ), + kind: None, + }, + ), + }, }, ), - custom: (), - node: Constant { - value: Int( - 1, - ), - kind: None, - }, }, - }, + ], + ctx: Load, }, - ], - ctx: Load, + ), }, - }, - optional_vars: Some( - Located { - location: Location { - row: 22, - column: 25, - }, - end_location: Some( - Location { + optional_vars: Some( + Located { + location: Location { row: 22, - column: 26, + column: 25, }, - ), - custom: (), - node: Name { - id: "x", - ctx: Store, + end_location: Some( + Location { + row: 22, + column: 26, + }, + ), + custom: (), + node: Name( + ExprName { + id: "x", + ctx: Store, + }, + ), }, - }, - ), - }, - ], - body: [ - Located { - location: Location { - row: 22, - column: 28, + ), }, - end_location: Some( - Location { + ], + body: [ + Located { + location: Location { row: 22, - column: 32, + column: 28, }, - ), - custom: (), - node: Pass, - }, - ], - type_comment: None, - }, + end_location: Some( + Location { + row: 22, + column: 32, + }, + ), + custom: (), + node: Pass, + }, + ], + type_comment: None, + }, + ), }, Located { location: Location { @@ -2118,67 +2306,73 @@ expression: "parse_program(source, \"\").unwrap()" }, ), custom: (), - node: With { - items: [ - Withitem { - context_expr: Located { - location: Location { - row: 23, - column: 6, - }, - end_location: Some( - Location { - row: 23, - column: 7, - }, - ), - custom: (), - node: Constant { - value: Int( - 0, - ), - kind: None, - }, - }, - optional_vars: Some( - Located { + node: With( + StmtWith { + items: [ + Withitem { + context_expr: Located { location: Location { row: 23, - column: 11, + column: 6, }, end_location: Some( Location { row: 23, - column: 12, + column: 7, }, ), custom: (), - node: Name { - id: "a", - ctx: Store, - }, + node: Constant( + ExprConstant { + value: Int( + 0, + ), + kind: None, + }, + ), }, - ), - }, - ], - body: [ - Located { - location: Location { - row: 23, - column: 15, + optional_vars: Some( + Located { + location: Location { + row: 23, + column: 11, + }, + end_location: Some( + Location { + row: 23, + column: 12, + }, + ), + custom: (), + node: Name( + ExprName { + id: "a", + ctx: Store, + }, + ), + }, + ), }, - end_location: Some( - Location { + ], + body: [ + Located { + location: Location { row: 23, - column: 19, + column: 15, }, - ), - custom: (), - node: Pass, - }, - ], - type_comment: None, - }, + end_location: Some( + Location { + row: 23, + column: 19, + }, + ), + custom: (), + node: Pass, + }, + ], + type_comment: None, + }, + ), }, Located { location: Location { @@ -2192,67 +2386,73 @@ expression: "parse_program(source, \"\").unwrap()" }, ), custom: (), - node: With { - items: [ - Withitem { - context_expr: Located { - location: Location { - row: 24, - column: 6, - }, - end_location: Some( - Location { - row: 24, - column: 7, - }, - ), - custom: (), - node: Constant { - value: Int( - 0, - ), - kind: None, - }, - }, - optional_vars: Some( - Located { + node: With( + StmtWith { + items: [ + Withitem { + context_expr: Located { location: Location { row: 24, - column: 11, + column: 6, }, end_location: Some( Location { row: 24, - column: 12, + column: 7, }, ), custom: (), - node: Name { - id: "a", - ctx: Store, - }, + node: Constant( + ExprConstant { + value: Int( + 0, + ), + kind: None, + }, + ), }, - ), - }, - ], - body: [ - Located { - location: Location { - row: 24, - column: 16, + optional_vars: Some( + Located { + location: Location { + row: 24, + column: 11, + }, + end_location: Some( + Location { + row: 24, + column: 12, + }, + ), + custom: (), + node: Name( + ExprName { + id: "a", + ctx: Store, + }, + ), + }, + ), }, - end_location: Some( - Location { + ], + body: [ + Located { + location: Location { row: 24, - column: 20, + column: 16, }, - ), - custom: (), - node: Pass, - }, - ], - type_comment: None, - }, + end_location: Some( + Location { + row: 24, + column: 20, + }, + ), + custom: (), + node: Pass, + }, + ], + type_comment: None, + }, + ), }, Located { location: Location { @@ -2266,107 +2466,117 @@ expression: "parse_program(source, \"\").unwrap()" }, ), custom: (), - node: With { - items: [ - Withitem { - context_expr: Located { - location: Location { - row: 25, - column: 6, - }, - end_location: Some( - Location { - row: 25, - column: 7, - }, - ), - custom: (), - node: Constant { - value: Int( - 0, - ), - kind: None, - }, - }, - optional_vars: Some( - Located { + node: With( + StmtWith { + items: [ + Withitem { + context_expr: Located { location: Location { row: 25, - column: 11, + column: 6, }, end_location: Some( Location { row: 25, - column: 12, + column: 7, }, ), custom: (), - node: Name { - id: "a", - ctx: Store, - }, - }, - ), - }, - Withitem { - context_expr: Located { - location: Location { - row: 25, - column: 14, + node: Constant( + ExprConstant { + value: Int( + 0, + ), + kind: None, + }, + ), }, - end_location: Some( - Location { - row: 25, - column: 15, + optional_vars: Some( + Located { + location: Location { + row: 25, + column: 11, + }, + end_location: Some( + Location { + row: 25, + column: 12, + }, + ), + custom: (), + node: Name( + ExprName { + id: "a", + ctx: Store, + }, + ), }, ), - custom: (), - node: Constant { - value: Int( - 1, - ), - kind: None, - }, }, - optional_vars: Some( - Located { + Withitem { + context_expr: Located { location: Location { row: 25, - column: 19, + column: 14, }, end_location: Some( Location { row: 25, - column: 20, + column: 15, }, ), custom: (), - node: Name { - id: "b", - ctx: Store, - }, + node: Constant( + ExprConstant { + value: Int( + 1, + ), + kind: None, + }, + ), }, - ), - }, - ], - body: [ - Located { - location: Location { - row: 25, - column: 23, + optional_vars: Some( + Located { + location: Location { + row: 25, + column: 19, + }, + end_location: Some( + Location { + row: 25, + column: 20, + }, + ), + custom: (), + node: Name( + ExprName { + id: "b", + ctx: Store, + }, + ), + }, + ), }, - end_location: Some( - Location { + ], + body: [ + Located { + location: Location { row: 25, - column: 27, + column: 23, }, - ), - custom: (), - node: Pass, - }, - ], - type_comment: None, - }, + end_location: Some( + Location { + row: 25, + column: 27, + }, + ), + custom: (), + node: Pass, + }, + ], + type_comment: None, + }, + ), }, Located { location: Location { @@ -2380,106 +2590,116 @@ expression: "parse_program(source, \"\").unwrap()" }, ), custom: (), - node: With { - items: [ - Withitem { - context_expr: Located { - location: Location { - row: 26, - column: 6, - }, - end_location: Some( - Location { - row: 26, - column: 7, - }, - ), - custom: (), - node: Constant { - value: Int( - 0, - ), - kind: None, - }, - }, - optional_vars: Some( - Located { + node: With( + StmtWith { + items: [ + Withitem { + context_expr: Located { location: Location { row: 26, - column: 11, + column: 6, }, end_location: Some( Location { row: 26, - column: 12, + column: 7, }, ), custom: (), - node: Name { - id: "a", - ctx: Store, - }, - }, - ), - }, - Withitem { - context_expr: Located { - location: Location { - row: 26, - column: 14, + node: Constant( + ExprConstant { + value: Int( + 0, + ), + kind: None, + }, + ), }, - end_location: Some( - Location { - row: 26, - column: 15, + optional_vars: Some( + Located { + location: Location { + row: 26, + column: 11, + }, + end_location: Some( + Location { + row: 26, + column: 12, + }, + ), + custom: (), + node: Name( + ExprName { + id: "a", + ctx: Store, + }, + ), }, ), - custom: (), - node: Constant { - value: Int( - 1, - ), - kind: None, - }, }, - optional_vars: Some( - Located { + Withitem { + context_expr: Located { location: Location { row: 26, - column: 19, + column: 14, }, end_location: Some( Location { row: 26, - column: 20, + column: 15, }, ), custom: (), - node: Name { - id: "b", - ctx: Store, - }, + node: Constant( + ExprConstant { + value: Int( + 1, + ), + kind: None, + }, + ), }, - ), - }, - ], - body: [ - Located { - location: Location { - row: 26, - column: 24, + optional_vars: Some( + Located { + location: Location { + row: 26, + column: 19, + }, + end_location: Some( + Location { + row: 26, + column: 20, + }, + ), + custom: (), + node: Name( + ExprName { + id: "b", + ctx: Store, + }, + ), + }, + ), }, - end_location: Some( - Location { + ], + body: [ + Located { + location: Location { row: 26, - column: 28, + column: 24, }, - ), - custom: (), - node: Pass, - }, - ], - type_comment: None, - }, + end_location: Some( + Location { + row: 26, + column: 28, + }, + ), + custom: (), + node: Pass, + }, + ], + type_comment: None, + }, + ), }, ] diff --git a/parser/src/snapshots/rustpython_parser__string__tests__backspace_alias.snap b/parser/src/snapshots/rustpython_parser__string__tests__backspace_alias.snap index eea97869..0e228bf4 100644 --- a/parser/src/snapshots/rustpython_parser__string__tests__backspace_alias.snap +++ b/parser/src/snapshots/rustpython_parser__string__tests__backspace_alias.snap @@ -1,5 +1,5 @@ --- -source: compiler/parser/src/string.rs +source: parser/src/string.rs expression: parse_ast --- [ @@ -15,26 +15,30 @@ expression: parse_ast }, ), custom: (), - node: Expr { - value: Located { - location: Location { - row: 1, - column: 0, - }, - end_location: Some( - Location { + node: Expr( + StmtExpr { + value: Located { + location: Location { row: 1, - column: 15, + column: 0, }, - ), - custom: (), - node: Constant { - value: Str( - "\u{8}", + end_location: Some( + Location { + row: 1, + column: 15, + }, + ), + custom: (), + node: Constant( + ExprConstant { + value: Str( + "\u{8}", + ), + kind: None, + }, ), - kind: None, }, }, - }, + ), }, ] diff --git a/parser/src/snapshots/rustpython_parser__string__tests__bell_alias.snap b/parser/src/snapshots/rustpython_parser__string__tests__bell_alias.snap index cf04fd68..ba39e8fb 100644 --- a/parser/src/snapshots/rustpython_parser__string__tests__bell_alias.snap +++ b/parser/src/snapshots/rustpython_parser__string__tests__bell_alias.snap @@ -1,5 +1,5 @@ --- -source: compiler/parser/src/string.rs +source: parser/src/string.rs expression: parse_ast --- [ @@ -15,26 +15,30 @@ expression: parse_ast }, ), custom: (), - node: Expr { - value: Located { - location: Location { - row: 1, - column: 0, - }, - end_location: Some( - Location { + node: Expr( + StmtExpr { + value: Located { + location: Location { row: 1, - column: 9, + column: 0, }, - ), - custom: (), - node: Constant { - value: Str( - "\u{7}", + end_location: Some( + Location { + row: 1, + column: 9, + }, + ), + custom: (), + node: Constant( + ExprConstant { + value: Str( + "\u{7}", + ), + kind: None, + }, ), - kind: None, }, }, - }, + ), }, ] diff --git a/parser/src/snapshots/rustpython_parser__string__tests__carriage_return_alias.snap b/parser/src/snapshots/rustpython_parser__string__tests__carriage_return_alias.snap index 33a84d22..ddb73293 100644 --- a/parser/src/snapshots/rustpython_parser__string__tests__carriage_return_alias.snap +++ b/parser/src/snapshots/rustpython_parser__string__tests__carriage_return_alias.snap @@ -1,5 +1,5 @@ --- -source: compiler/parser/src/string.rs +source: parser/src/string.rs expression: parse_ast --- [ @@ -15,26 +15,30 @@ expression: parse_ast }, ), custom: (), - node: Expr { - value: Located { - location: Location { - row: 1, - column: 0, - }, - end_location: Some( - Location { + node: Expr( + StmtExpr { + value: Located { + location: Location { row: 1, - column: 21, + column: 0, }, - ), - custom: (), - node: Constant { - value: Str( - "\r", + end_location: Some( + Location { + row: 1, + column: 21, + }, + ), + custom: (), + node: Constant( + ExprConstant { + value: Str( + "\r", + ), + kind: None, + }, ), - kind: None, }, }, - }, + ), }, ] diff --git a/parser/src/snapshots/rustpython_parser__string__tests__character_tabulation_with_justification_alias.snap b/parser/src/snapshots/rustpython_parser__string__tests__character_tabulation_with_justification_alias.snap index 282706f8..36ec8586 100644 --- a/parser/src/snapshots/rustpython_parser__string__tests__character_tabulation_with_justification_alias.snap +++ b/parser/src/snapshots/rustpython_parser__string__tests__character_tabulation_with_justification_alias.snap @@ -1,5 +1,5 @@ --- -source: compiler/parser/src/string.rs +source: parser/src/string.rs expression: parse_ast --- [ @@ -15,26 +15,30 @@ expression: parse_ast }, ), custom: (), - node: Expr { - value: Located { - location: Location { - row: 1, - column: 0, - }, - end_location: Some( - Location { + node: Expr( + StmtExpr { + value: Located { + location: Location { row: 1, - column: 45, + column: 0, }, - ), - custom: (), - node: Constant { - value: Str( - "\u{89}", + end_location: Some( + Location { + row: 1, + column: 45, + }, + ), + custom: (), + node: Constant( + ExprConstant { + value: Str( + "\u{89}", + ), + kind: None, + }, ), - kind: None, }, }, - }, + ), }, ] diff --git a/parser/src/snapshots/rustpython_parser__string__tests__delete_alias.snap b/parser/src/snapshots/rustpython_parser__string__tests__delete_alias.snap index 06e74d24..7307b3fb 100644 --- a/parser/src/snapshots/rustpython_parser__string__tests__delete_alias.snap +++ b/parser/src/snapshots/rustpython_parser__string__tests__delete_alias.snap @@ -1,5 +1,5 @@ --- -source: compiler/parser/src/string.rs +source: parser/src/string.rs expression: parse_ast --- [ @@ -15,26 +15,30 @@ expression: parse_ast }, ), custom: (), - node: Expr { - value: Located { - location: Location { - row: 1, - column: 0, - }, - end_location: Some( - Location { + node: Expr( + StmtExpr { + value: Located { + location: Location { row: 1, - column: 12, + column: 0, }, - ), - custom: (), - node: Constant { - value: Str( - "\u{7f}", + end_location: Some( + Location { + row: 1, + column: 12, + }, + ), + custom: (), + node: Constant( + ExprConstant { + value: Str( + "\u{7f}", + ), + kind: None, + }, ), - kind: None, }, }, - }, + ), }, ] diff --git a/parser/src/snapshots/rustpython_parser__string__tests__double_quoted_byte.snap b/parser/src/snapshots/rustpython_parser__string__tests__double_quoted_byte.snap index 0d8c8c9a..997e84d7 100644 --- a/parser/src/snapshots/rustpython_parser__string__tests__double_quoted_byte.snap +++ b/parser/src/snapshots/rustpython_parser__string__tests__double_quoted_byte.snap @@ -1,5 +1,5 @@ --- -source: compiler/parser/src/string.rs +source: parser/src/string.rs expression: parse_ast --- [ @@ -15,283 +15,287 @@ expression: parse_ast }, ), custom: (), - node: Expr { - value: Located { - location: Location { - row: 1, - column: 0, - }, - end_location: Some( - Location { + node: Expr( + StmtExpr { + value: Located { + location: Location { row: 1, - column: 738, + column: 0, }, - ), - custom: (), - node: Constant { - value: Bytes( - [ - 0, - 1, - 2, - 3, - 4, - 5, - 6, - 7, - 8, - 9, - 10, - 11, - 12, - 13, - 14, - 15, - 16, - 17, - 18, - 19, - 20, - 21, - 22, - 23, - 24, - 25, - 26, - 27, - 28, - 29, - 30, - 31, - 32, - 33, - 34, - 35, - 36, - 37, - 38, - 39, - 40, - 41, - 42, - 43, - 44, - 45, - 46, - 47, - 48, - 49, - 50, - 51, - 52, - 53, - 54, - 55, - 56, - 57, - 58, - 59, - 60, - 61, - 62, - 63, - 64, - 65, - 66, - 67, - 68, - 69, - 70, - 71, - 72, - 73, - 74, - 75, - 76, - 77, - 78, - 79, - 80, - 81, - 82, - 83, - 84, - 85, - 86, - 87, - 88, - 89, - 90, - 91, - 92, - 93, - 94, - 95, - 96, - 97, - 98, - 99, - 100, - 101, - 102, - 103, - 104, - 105, - 106, - 107, - 108, - 109, - 110, - 111, - 112, - 113, - 114, - 115, - 116, - 117, - 118, - 119, - 120, - 121, - 122, - 123, - 124, - 125, - 126, - 127, - 128, - 129, - 130, - 131, - 132, - 133, - 134, - 135, - 136, - 137, - 138, - 139, - 140, - 141, - 142, - 143, - 144, - 145, - 146, - 147, - 148, - 149, - 150, - 151, - 152, - 153, - 154, - 155, - 156, - 157, - 158, - 159, - 160, - 161, - 162, - 163, - 164, - 165, - 166, - 167, - 168, - 169, - 170, - 171, - 172, - 173, - 174, - 175, - 176, - 177, - 178, - 179, - 180, - 181, - 182, - 183, - 184, - 185, - 186, - 187, - 188, - 189, - 190, - 191, - 192, - 193, - 194, - 195, - 196, - 197, - 198, - 199, - 200, - 201, - 202, - 203, - 204, - 205, - 206, - 207, - 208, - 209, - 210, - 211, - 212, - 213, - 214, - 215, - 216, - 217, - 218, - 219, - 220, - 221, - 222, - 223, - 224, - 225, - 226, - 227, - 228, - 229, - 230, - 231, - 232, - 233, - 234, - 235, - 236, - 237, - 238, - 239, - 240, - 241, - 242, - 243, - 244, - 245, - 246, - 247, - 248, - 249, - 250, - 251, - 252, - 253, - 254, - 255, - ], + end_location: Some( + Location { + row: 1, + column: 738, + }, + ), + custom: (), + node: Constant( + ExprConstant { + value: Bytes( + [ + 0, + 1, + 2, + 3, + 4, + 5, + 6, + 7, + 8, + 9, + 10, + 11, + 12, + 13, + 14, + 15, + 16, + 17, + 18, + 19, + 20, + 21, + 22, + 23, + 24, + 25, + 26, + 27, + 28, + 29, + 30, + 31, + 32, + 33, + 34, + 35, + 36, + 37, + 38, + 39, + 40, + 41, + 42, + 43, + 44, + 45, + 46, + 47, + 48, + 49, + 50, + 51, + 52, + 53, + 54, + 55, + 56, + 57, + 58, + 59, + 60, + 61, + 62, + 63, + 64, + 65, + 66, + 67, + 68, + 69, + 70, + 71, + 72, + 73, + 74, + 75, + 76, + 77, + 78, + 79, + 80, + 81, + 82, + 83, + 84, + 85, + 86, + 87, + 88, + 89, + 90, + 91, + 92, + 93, + 94, + 95, + 96, + 97, + 98, + 99, + 100, + 101, + 102, + 103, + 104, + 105, + 106, + 107, + 108, + 109, + 110, + 111, + 112, + 113, + 114, + 115, + 116, + 117, + 118, + 119, + 120, + 121, + 122, + 123, + 124, + 125, + 126, + 127, + 128, + 129, + 130, + 131, + 132, + 133, + 134, + 135, + 136, + 137, + 138, + 139, + 140, + 141, + 142, + 143, + 144, + 145, + 146, + 147, + 148, + 149, + 150, + 151, + 152, + 153, + 154, + 155, + 156, + 157, + 158, + 159, + 160, + 161, + 162, + 163, + 164, + 165, + 166, + 167, + 168, + 169, + 170, + 171, + 172, + 173, + 174, + 175, + 176, + 177, + 178, + 179, + 180, + 181, + 182, + 183, + 184, + 185, + 186, + 187, + 188, + 189, + 190, + 191, + 192, + 193, + 194, + 195, + 196, + 197, + 198, + 199, + 200, + 201, + 202, + 203, + 204, + 205, + 206, + 207, + 208, + 209, + 210, + 211, + 212, + 213, + 214, + 215, + 216, + 217, + 218, + 219, + 220, + 221, + 222, + 223, + 224, + 225, + 226, + 227, + 228, + 229, + 230, + 231, + 232, + 233, + 234, + 235, + 236, + 237, + 238, + 239, + 240, + 241, + 242, + 243, + 244, + 245, + 246, + 247, + 248, + 249, + 250, + 251, + 252, + 253, + 254, + 255, + ], + ), + kind: None, + }, ), - kind: None, }, }, - }, + ), }, ] diff --git a/parser/src/snapshots/rustpython_parser__string__tests__escape_alias.snap b/parser/src/snapshots/rustpython_parser__string__tests__escape_alias.snap index 751456db..a74628bd 100644 --- a/parser/src/snapshots/rustpython_parser__string__tests__escape_alias.snap +++ b/parser/src/snapshots/rustpython_parser__string__tests__escape_alias.snap @@ -1,5 +1,5 @@ --- -source: compiler/parser/src/string.rs +source: parser/src/string.rs expression: parse_ast --- [ @@ -15,26 +15,30 @@ expression: parse_ast }, ), custom: (), - node: Expr { - value: Located { - location: Location { - row: 1, - column: 0, - }, - end_location: Some( - Location { + node: Expr( + StmtExpr { + value: Located { + location: Location { row: 1, - column: 12, + column: 0, }, - ), - custom: (), - node: Constant { - value: Str( - "\u{1b}", + end_location: Some( + Location { + row: 1, + column: 12, + }, + ), + custom: (), + node: Constant( + ExprConstant { + value: Str( + "\u{1b}", + ), + kind: None, + }, ), - kind: None, }, }, - }, + ), }, ] diff --git a/parser/src/snapshots/rustpython_parser__string__tests__escape_char_in_byte_literal.snap b/parser/src/snapshots/rustpython_parser__string__tests__escape_char_in_byte_literal.snap index 98fc3c79..a4b2127f 100644 --- a/parser/src/snapshots/rustpython_parser__string__tests__escape_char_in_byte_literal.snap +++ b/parser/src/snapshots/rustpython_parser__string__tests__escape_char_in_byte_literal.snap @@ -1,5 +1,5 @@ --- -source: compiler/parser/src/string.rs +source: parser/src/string.rs expression: parse_ast --- [ @@ -15,37 +15,41 @@ expression: parse_ast }, ), custom: (), - node: Expr { - value: Located { - location: Location { - row: 1, - column: 0, - }, - end_location: Some( - Location { + node: Expr( + StmtExpr { + value: Located { + location: Location { row: 1, - column: 13, + column: 0, }, - ), - custom: (), - node: Constant { - value: Bytes( - [ - 111, - 109, - 107, - 109, - 111, - 107, - 92, - 88, - 97, - 97, - ], + end_location: Some( + Location { + row: 1, + column: 13, + }, + ), + custom: (), + node: Constant( + ExprConstant { + value: Bytes( + [ + 111, + 109, + 107, + 109, + 111, + 107, + 92, + 88, + 97, + 97, + ], + ), + kind: None, + }, ), - kind: None, }, }, - }, + ), }, ] diff --git a/parser/src/snapshots/rustpython_parser__string__tests__escape_octet.snap b/parser/src/snapshots/rustpython_parser__string__tests__escape_octet.snap index 677e3f9f..22ba1e4d 100644 --- a/parser/src/snapshots/rustpython_parser__string__tests__escape_octet.snap +++ b/parser/src/snapshots/rustpython_parser__string__tests__escape_octet.snap @@ -1,5 +1,5 @@ --- -source: compiler/parser/src/string.rs +source: parser/src/string.rs expression: parse_ast --- [ @@ -15,32 +15,36 @@ expression: parse_ast }, ), custom: (), - node: Expr { - value: Located { - location: Location { - row: 1, - column: 0, - }, - end_location: Some( - Location { + node: Expr( + StmtExpr { + value: Located { + location: Location { row: 1, - column: 14, + column: 0, }, - ), - custom: (), - node: Constant { - value: Bytes( - [ - 35, - 97, - 4, - 83, - 52, - ], + end_location: Some( + Location { + row: 1, + column: 14, + }, + ), + custom: (), + node: Constant( + ExprConstant { + value: Bytes( + [ + 35, + 97, + 4, + 83, + 52, + ], + ), + kind: None, + }, ), - kind: None, }, }, - }, + ), }, ] diff --git a/parser/src/snapshots/rustpython_parser__string__tests__form_feed_alias.snap b/parser/src/snapshots/rustpython_parser__string__tests__form_feed_alias.snap index b91c10eb..e9d3f648 100644 --- a/parser/src/snapshots/rustpython_parser__string__tests__form_feed_alias.snap +++ b/parser/src/snapshots/rustpython_parser__string__tests__form_feed_alias.snap @@ -1,5 +1,5 @@ --- -source: compiler/parser/src/string.rs +source: parser/src/string.rs expression: parse_ast --- [ @@ -15,26 +15,30 @@ expression: parse_ast }, ), custom: (), - node: Expr { - value: Located { - location: Location { - row: 1, - column: 0, - }, - end_location: Some( - Location { + node: Expr( + StmtExpr { + value: Located { + location: Location { row: 1, - column: 15, + column: 0, }, - ), - custom: (), - node: Constant { - value: Str( - "\u{c}", + end_location: Some( + Location { + row: 1, + column: 15, + }, + ), + custom: (), + node: Constant( + ExprConstant { + value: Str( + "\u{c}", + ), + kind: None, + }, ), - kind: None, }, }, - }, + ), }, ] diff --git a/parser/src/snapshots/rustpython_parser__string__tests__fstring_escaped_character.snap b/parser/src/snapshots/rustpython_parser__string__tests__fstring_escaped_character.snap index 7ab1247b..1fe6e98b 100644 --- a/parser/src/snapshots/rustpython_parser__string__tests__fstring_escaped_character.snap +++ b/parser/src/snapshots/rustpython_parser__string__tests__fstring_escaped_character.snap @@ -1,5 +1,5 @@ --- -source: compiler/parser/src/string.rs +source: parser/src/string.rs expression: parse_ast --- [ @@ -15,77 +15,87 @@ expression: parse_ast }, ), custom: (), - node: Expr { - value: Located { - location: Location { - row: 1, - column: 0, - }, - end_location: Some( - Location { + node: Expr( + StmtExpr { + value: Located { + location: Location { row: 1, - column: 8, + column: 0, }, - ), - custom: (), - node: JoinedStr { - values: [ - Located { - location: Location { - row: 1, - column: 0, - }, - end_location: Some( - Location { - row: 1, - column: 8, - }, - ), - custom: (), - node: Constant { - value: Str( - "\\", - ), - kind: None, - }, + end_location: Some( + Location { + row: 1, + column: 8, }, - Located { - location: Location { - row: 1, - column: 0, - }, - end_location: Some( - Location { - row: 1, - column: 8, - }, - ), - custom: (), - node: FormattedValue { - value: Located { + ), + custom: (), + node: JoinedStr( + ExprJoinedStr { + values: [ + Located { location: Location { row: 1, - column: 5, + column: 0, }, end_location: Some( Location { row: 1, - column: 6, + column: 8, }, ), custom: (), - node: Name { - id: "x", - ctx: Load, + node: Constant( + ExprConstant { + value: Str( + "\\", + ), + kind: None, + }, + ), + }, + Located { + location: Location { + row: 1, + column: 0, }, + end_location: Some( + Location { + row: 1, + column: 8, + }, + ), + custom: (), + node: FormattedValue( + ExprFormattedValue { + value: Located { + location: Location { + row: 1, + column: 5, + }, + end_location: Some( + Location { + row: 1, + column: 6, + }, + ), + custom: (), + node: Name( + ExprName { + id: "x", + ctx: Load, + }, + ), + }, + conversion: 0, + format_spec: None, + }, + ), }, - conversion: 0, - format_spec: None, - }, + ], }, - ], + ), }, }, - }, + ), }, ] diff --git a/parser/src/snapshots/rustpython_parser__string__tests__fstring_escaped_newline.snap b/parser/src/snapshots/rustpython_parser__string__tests__fstring_escaped_newline.snap index 83598459..0fdda54a 100644 --- a/parser/src/snapshots/rustpython_parser__string__tests__fstring_escaped_newline.snap +++ b/parser/src/snapshots/rustpython_parser__string__tests__fstring_escaped_newline.snap @@ -1,5 +1,5 @@ --- -source: compiler/parser/src/string.rs +source: parser/src/string.rs expression: parse_ast --- [ @@ -15,77 +15,87 @@ expression: parse_ast }, ), custom: (), - node: Expr { - value: Located { - location: Location { - row: 1, - column: 0, - }, - end_location: Some( - Location { + node: Expr( + StmtExpr { + value: Located { + location: Location { row: 1, - column: 8, + column: 0, }, - ), - custom: (), - node: JoinedStr { - values: [ - Located { - location: Location { - row: 1, - column: 0, - }, - end_location: Some( - Location { - row: 1, - column: 8, - }, - ), - custom: (), - node: Constant { - value: Str( - "\n", - ), - kind: None, - }, + end_location: Some( + Location { + row: 1, + column: 8, }, - Located { - location: Location { - row: 1, - column: 0, - }, - end_location: Some( - Location { - row: 1, - column: 8, - }, - ), - custom: (), - node: FormattedValue { - value: Located { + ), + custom: (), + node: JoinedStr( + ExprJoinedStr { + values: [ + Located { location: Location { row: 1, - column: 5, + column: 0, }, end_location: Some( Location { row: 1, - column: 6, + column: 8, }, ), custom: (), - node: Name { - id: "x", - ctx: Load, + node: Constant( + ExprConstant { + value: Str( + "\n", + ), + kind: None, + }, + ), + }, + Located { + location: Location { + row: 1, + column: 0, }, + end_location: Some( + Location { + row: 1, + column: 8, + }, + ), + custom: (), + node: FormattedValue( + ExprFormattedValue { + value: Located { + location: Location { + row: 1, + column: 5, + }, + end_location: Some( + Location { + row: 1, + column: 6, + }, + ), + custom: (), + node: Name( + ExprName { + id: "x", + ctx: Load, + }, + ), + }, + conversion: 0, + format_spec: None, + }, + ), }, - conversion: 0, - format_spec: None, - }, + ], }, - ], + ), }, }, - }, + ), }, ] diff --git a/parser/src/snapshots/rustpython_parser__string__tests__fstring_line_continuation.snap b/parser/src/snapshots/rustpython_parser__string__tests__fstring_line_continuation.snap index 2f6167d4..55cc1800 100644 --- a/parser/src/snapshots/rustpython_parser__string__tests__fstring_line_continuation.snap +++ b/parser/src/snapshots/rustpython_parser__string__tests__fstring_line_continuation.snap @@ -1,5 +1,5 @@ --- -source: compiler/parser/src/string.rs +source: parser/src/string.rs expression: parse_ast --- [ @@ -15,77 +15,87 @@ expression: parse_ast }, ), custom: (), - node: Expr { - value: Located { - location: Location { - row: 1, - column: 0, - }, - end_location: Some( - Location { - row: 2, - column: 4, + node: Expr( + StmtExpr { + value: Located { + location: Location { + row: 1, + column: 0, }, - ), - custom: (), - node: JoinedStr { - values: [ - Located { - location: Location { - row: 1, - column: 0, - }, - end_location: Some( - Location { - row: 2, - column: 4, - }, - ), - custom: (), - node: Constant { - value: Str( - "\\\n", - ), - kind: None, - }, + end_location: Some( + Location { + row: 2, + column: 4, }, - Located { - location: Location { - row: 1, - column: 0, - }, - end_location: Some( - Location { - row: 2, - column: 4, - }, - ), - custom: (), - node: FormattedValue { - value: Located { + ), + custom: (), + node: JoinedStr( + ExprJoinedStr { + values: [ + Located { location: Location { - row: 2, - column: 1, + row: 1, + column: 0, }, end_location: Some( Location { row: 2, - column: 2, + column: 4, }, ), custom: (), - node: Name { - id: "x", - ctx: Load, + node: Constant( + ExprConstant { + value: Str( + "\\\n", + ), + kind: None, + }, + ), + }, + Located { + location: Location { + row: 1, + column: 0, }, + end_location: Some( + Location { + row: 2, + column: 4, + }, + ), + custom: (), + node: FormattedValue( + ExprFormattedValue { + value: Located { + location: Location { + row: 2, + column: 1, + }, + end_location: Some( + Location { + row: 2, + column: 2, + }, + ), + custom: (), + node: Name( + ExprName { + id: "x", + ctx: Load, + }, + ), + }, + conversion: 0, + format_spec: None, + }, + ), }, - conversion: 0, - format_spec: None, - }, + ], }, - ], + ), }, }, - }, + ), }, ] diff --git a/parser/src/snapshots/rustpython_parser__string__tests__fstring_parse_self_documenting_base.snap b/parser/src/snapshots/rustpython_parser__string__tests__fstring_parse_self_documenting_base.snap index 125c6af7..7fe9d3d0 100644 --- a/parser/src/snapshots/rustpython_parser__string__tests__fstring_parse_self_documenting_base.snap +++ b/parser/src/snapshots/rustpython_parser__string__tests__fstring_parse_self_documenting_base.snap @@ -1,5 +1,5 @@ --- -source: compiler/parser/src/string.rs +source: parser/src/string.rs expression: parse_ast --- [ @@ -15,12 +15,14 @@ expression: parse_ast }, ), custom: (), - node: Constant { - value: Str( - "user=", - ), - kind: None, - }, + node: Constant( + ExprConstant { + value: Str( + "user=", + ), + kind: None, + }, + ), }, Located { location: Location { @@ -34,12 +36,14 @@ expression: parse_ast }, ), custom: (), - node: Constant { - value: Str( - "", - ), - kind: None, - }, + node: Constant( + ExprConstant { + value: Str( + "", + ), + kind: None, + }, + ), }, Located { location: Location { @@ -53,26 +57,30 @@ expression: parse_ast }, ), custom: (), - node: FormattedValue { - value: Located { - location: Location { - row: 1, - column: 3, - }, - end_location: Some( - Location { + node: FormattedValue( + ExprFormattedValue { + value: Located { + location: Location { row: 1, - column: 7, + column: 3, }, - ), - custom: (), - node: Name { - id: "user", - ctx: Load, + end_location: Some( + Location { + row: 1, + column: 7, + }, + ), + custom: (), + node: Name( + ExprName { + id: "user", + ctx: Load, + }, + ), }, + conversion: 114, + format_spec: None, }, - conversion: 114, - format_spec: None, - }, + ), }, ] diff --git a/parser/src/snapshots/rustpython_parser__string__tests__fstring_parse_self_documenting_base_more.snap b/parser/src/snapshots/rustpython_parser__string__tests__fstring_parse_self_documenting_base_more.snap index 14a20345..0a99d7a7 100644 --- a/parser/src/snapshots/rustpython_parser__string__tests__fstring_parse_self_documenting_base_more.snap +++ b/parser/src/snapshots/rustpython_parser__string__tests__fstring_parse_self_documenting_base_more.snap @@ -1,5 +1,5 @@ --- -source: compiler/parser/src/string.rs +source: parser/src/string.rs expression: parse_ast --- [ @@ -15,12 +15,14 @@ expression: parse_ast }, ), custom: (), - node: Constant { - value: Str( - "mix ", - ), - kind: None, - }, + node: Constant( + ExprConstant { + value: Str( + "mix ", + ), + kind: None, + }, + ), }, Located { location: Location { @@ -34,12 +36,14 @@ expression: parse_ast }, ), custom: (), - node: Constant { - value: Str( - "user=", - ), - kind: None, - }, + node: Constant( + ExprConstant { + value: Str( + "user=", + ), + kind: None, + }, + ), }, Located { location: Location { @@ -53,12 +57,14 @@ expression: parse_ast }, ), custom: (), - node: Constant { - value: Str( - "", - ), - kind: None, - }, + node: Constant( + ExprConstant { + value: Str( + "", + ), + kind: None, + }, + ), }, Located { location: Location { @@ -72,27 +78,31 @@ expression: parse_ast }, ), custom: (), - node: FormattedValue { - value: Located { - location: Location { - row: 1, - column: 7, - }, - end_location: Some( - Location { + node: FormattedValue( + ExprFormattedValue { + value: Located { + location: Location { row: 1, - column: 11, + column: 7, }, - ), - custom: (), - node: Name { - id: "user", - ctx: Load, + end_location: Some( + Location { + row: 1, + column: 11, + }, + ), + custom: (), + node: Name( + ExprName { + id: "user", + ctx: Load, + }, + ), }, + conversion: 114, + format_spec: None, }, - conversion: 114, - format_spec: None, - }, + ), }, Located { location: Location { @@ -106,12 +116,14 @@ expression: parse_ast }, ), custom: (), - node: Constant { - value: Str( - " with text and ", - ), - kind: None, - }, + node: Constant( + ExprConstant { + value: Str( + " with text and ", + ), + kind: None, + }, + ), }, Located { location: Location { @@ -125,12 +137,14 @@ expression: parse_ast }, ), custom: (), - node: Constant { - value: Str( - "second=", - ), - kind: None, - }, + node: Constant( + ExprConstant { + value: Str( + "second=", + ), + kind: None, + }, + ), }, Located { location: Location { @@ -144,12 +158,14 @@ expression: parse_ast }, ), custom: (), - node: Constant { - value: Str( - "", - ), - kind: None, - }, + node: Constant( + ExprConstant { + value: Str( + "", + ), + kind: None, + }, + ), }, Located { location: Location { @@ -163,26 +179,30 @@ expression: parse_ast }, ), custom: (), - node: FormattedValue { - value: Located { - location: Location { - row: 1, - column: 29, - }, - end_location: Some( - Location { + node: FormattedValue( + ExprFormattedValue { + value: Located { + location: Location { row: 1, - column: 35, + column: 29, }, - ), - custom: (), - node: Name { - id: "second", - ctx: Load, + end_location: Some( + Location { + row: 1, + column: 35, + }, + ), + custom: (), + node: Name( + ExprName { + id: "second", + ctx: Load, + }, + ), }, + conversion: 114, + format_spec: None, }, - conversion: 114, - format_spec: None, - }, + ), }, ] diff --git a/parser/src/snapshots/rustpython_parser__string__tests__fstring_parse_self_documenting_format.snap b/parser/src/snapshots/rustpython_parser__string__tests__fstring_parse_self_documenting_format.snap index c7f62883..fcb1ed06 100644 --- a/parser/src/snapshots/rustpython_parser__string__tests__fstring_parse_self_documenting_format.snap +++ b/parser/src/snapshots/rustpython_parser__string__tests__fstring_parse_self_documenting_format.snap @@ -1,5 +1,5 @@ --- -source: compiler/parser/src/string.rs +source: parser/src/string.rs expression: parse_ast --- [ @@ -15,12 +15,14 @@ expression: parse_ast }, ), custom: (), - node: Constant { - value: Str( - "user=", - ), - kind: None, - }, + node: Constant( + ExprConstant { + value: Str( + "user=", + ), + kind: None, + }, + ), }, Located { location: Location { @@ -34,12 +36,14 @@ expression: parse_ast }, ), custom: (), - node: Constant { - value: Str( - "", - ), - kind: None, - }, + node: Constant( + ExprConstant { + value: Str( + "", + ), + kind: None, + }, + ), }, Located { location: Location { @@ -53,63 +57,71 @@ expression: parse_ast }, ), custom: (), - node: FormattedValue { - value: Located { - location: Location { - row: 1, - column: 3, - }, - end_location: Some( - Location { - row: 1, - column: 7, - }, - ), - custom: (), - node: Name { - id: "user", - ctx: Load, - }, - }, - conversion: 0, - format_spec: Some( - Located { + node: FormattedValue( + ExprFormattedValue { + value: Located { location: Location { row: 1, - column: 0, + column: 3, }, end_location: Some( Location { row: 1, - column: 14, + column: 7, }, ), custom: (), - node: JoinedStr { - values: [ - Located { - location: Location { - row: 1, - column: 0, - }, - end_location: Some( - Location { - row: 1, - column: 14, + node: Name( + ExprName { + id: "user", + ctx: Load, + }, + ), + }, + conversion: 0, + format_spec: Some( + Located { + location: Location { + row: 1, + column: 0, + }, + end_location: Some( + Location { + row: 1, + column: 14, + }, + ), + custom: (), + node: JoinedStr( + ExprJoinedStr { + values: [ + Located { + location: Location { + row: 1, + column: 0, + }, + end_location: Some( + Location { + row: 1, + column: 14, + }, + ), + custom: (), + node: Constant( + ExprConstant { + value: Str( + ">10", + ), + kind: None, + }, + ), }, - ), - custom: (), - node: Constant { - value: Str( - ">10", - ), - kind: None, - }, + ], }, - ], + ), }, - }, - ), - }, + ), + }, + ), }, ] diff --git a/parser/src/snapshots/rustpython_parser__string__tests__fstring_unescaped_newline.snap b/parser/src/snapshots/rustpython_parser__string__tests__fstring_unescaped_newline.snap index b44c3299..4d282a93 100644 --- a/parser/src/snapshots/rustpython_parser__string__tests__fstring_unescaped_newline.snap +++ b/parser/src/snapshots/rustpython_parser__string__tests__fstring_unescaped_newline.snap @@ -1,5 +1,5 @@ --- -source: compiler/parser/src/string.rs +source: parser/src/string.rs expression: parse_ast --- [ @@ -15,77 +15,87 @@ expression: parse_ast }, ), custom: (), - node: Expr { - value: Located { - location: Location { - row: 1, - column: 0, - }, - end_location: Some( - Location { - row: 2, - column: 6, + node: Expr( + StmtExpr { + value: Located { + location: Location { + row: 1, + column: 0, }, - ), - custom: (), - node: JoinedStr { - values: [ - Located { - location: Location { - row: 1, - column: 0, - }, - end_location: Some( - Location { - row: 2, - column: 6, - }, - ), - custom: (), - node: Constant { - value: Str( - "\n", - ), - kind: None, - }, + end_location: Some( + Location { + row: 2, + column: 6, }, - Located { - location: Location { - row: 1, - column: 0, - }, - end_location: Some( - Location { - row: 2, - column: 6, - }, - ), - custom: (), - node: FormattedValue { - value: Located { + ), + custom: (), + node: JoinedStr( + ExprJoinedStr { + values: [ + Located { location: Location { - row: 2, - column: 1, + row: 1, + column: 0, }, end_location: Some( Location { row: 2, - column: 2, + column: 6, }, ), custom: (), - node: Name { - id: "x", - ctx: Load, + node: Constant( + ExprConstant { + value: Str( + "\n", + ), + kind: None, + }, + ), + }, + Located { + location: Location { + row: 1, + column: 0, }, + end_location: Some( + Location { + row: 2, + column: 6, + }, + ), + custom: (), + node: FormattedValue( + ExprFormattedValue { + value: Located { + location: Location { + row: 2, + column: 1, + }, + end_location: Some( + Location { + row: 2, + column: 2, + }, + ), + custom: (), + node: Name( + ExprName { + id: "x", + ctx: Load, + }, + ), + }, + conversion: 0, + format_spec: None, + }, + ), }, - conversion: 0, - format_spec: None, - }, + ], }, - ], + ), }, }, - }, + ), }, ] diff --git a/parser/src/snapshots/rustpython_parser__string__tests__hts_alias.snap b/parser/src/snapshots/rustpython_parser__string__tests__hts_alias.snap index 73f12074..3abcd1a4 100644 --- a/parser/src/snapshots/rustpython_parser__string__tests__hts_alias.snap +++ b/parser/src/snapshots/rustpython_parser__string__tests__hts_alias.snap @@ -1,5 +1,5 @@ --- -source: compiler/parser/src/string.rs +source: parser/src/string.rs expression: parse_ast --- [ @@ -15,26 +15,30 @@ expression: parse_ast }, ), custom: (), - node: Expr { - value: Located { - location: Location { - row: 1, - column: 0, - }, - end_location: Some( - Location { + node: Expr( + StmtExpr { + value: Located { + location: Location { row: 1, - column: 9, + column: 0, }, - ), - custom: (), - node: Constant { - value: Str( - "\u{88}", + end_location: Some( + Location { + row: 1, + column: 9, + }, + ), + custom: (), + node: Constant( + ExprConstant { + value: Str( + "\u{88}", + ), + kind: None, + }, ), - kind: None, }, }, - }, + ), }, ] diff --git a/parser/src/snapshots/rustpython_parser__string__tests__parse_f_string_concat_1.snap b/parser/src/snapshots/rustpython_parser__string__tests__parse_f_string_concat_1.snap index bfe109e1..3d9cee15 100644 --- a/parser/src/snapshots/rustpython_parser__string__tests__parse_f_string_concat_1.snap +++ b/parser/src/snapshots/rustpython_parser__string__tests__parse_f_string_concat_1.snap @@ -1,5 +1,5 @@ --- -source: compiler/parser/src/string.rs +source: parser/src/string.rs expression: parse_ast --- [ @@ -15,43 +15,49 @@ expression: parse_ast }, ), custom: (), - node: Expr { - value: Located { - location: Location { - row: 1, - column: 0, - }, - end_location: Some( - Location { + node: Expr( + StmtExpr { + value: Located { + location: Location { row: 1, - column: 17, + column: 0, }, - ), - custom: (), - node: JoinedStr { - values: [ - Located { - location: Location { - row: 1, - column: 0, - }, - end_location: Some( - Location { - row: 1, - column: 17, + end_location: Some( + Location { + row: 1, + column: 17, + }, + ), + custom: (), + node: JoinedStr( + ExprJoinedStr { + values: [ + Located { + location: Location { + row: 1, + column: 0, + }, + end_location: Some( + Location { + row: 1, + column: 17, + }, + ), + custom: (), + node: Constant( + ExprConstant { + value: Str( + "Hello world", + ), + kind: None, + }, + ), }, - ), - custom: (), - node: Constant { - value: Str( - "Hello world", - ), - kind: None, - }, + ], }, - ], + ), }, }, - }, + ), }, ] diff --git a/parser/src/snapshots/rustpython_parser__string__tests__parse_f_string_concat_2.snap b/parser/src/snapshots/rustpython_parser__string__tests__parse_f_string_concat_2.snap index bfe109e1..3d9cee15 100644 --- a/parser/src/snapshots/rustpython_parser__string__tests__parse_f_string_concat_2.snap +++ b/parser/src/snapshots/rustpython_parser__string__tests__parse_f_string_concat_2.snap @@ -1,5 +1,5 @@ --- -source: compiler/parser/src/string.rs +source: parser/src/string.rs expression: parse_ast --- [ @@ -15,43 +15,49 @@ expression: parse_ast }, ), custom: (), - node: Expr { - value: Located { - location: Location { - row: 1, - column: 0, - }, - end_location: Some( - Location { + node: Expr( + StmtExpr { + value: Located { + location: Location { row: 1, - column: 17, + column: 0, }, - ), - custom: (), - node: JoinedStr { - values: [ - Located { - location: Location { - row: 1, - column: 0, - }, - end_location: Some( - Location { - row: 1, - column: 17, + end_location: Some( + Location { + row: 1, + column: 17, + }, + ), + custom: (), + node: JoinedStr( + ExprJoinedStr { + values: [ + Located { + location: Location { + row: 1, + column: 0, + }, + end_location: Some( + Location { + row: 1, + column: 17, + }, + ), + custom: (), + node: Constant( + ExprConstant { + value: Str( + "Hello world", + ), + kind: None, + }, + ), }, - ), - custom: (), - node: Constant { - value: Str( - "Hello world", - ), - kind: None, - }, + ], }, - ], + ), }, }, - }, + ), }, ] diff --git a/parser/src/snapshots/rustpython_parser__string__tests__parse_f_string_concat_3.snap b/parser/src/snapshots/rustpython_parser__string__tests__parse_f_string_concat_3.snap index 0fdc8e82..6f69734f 100644 --- a/parser/src/snapshots/rustpython_parser__string__tests__parse_f_string_concat_3.snap +++ b/parser/src/snapshots/rustpython_parser__string__tests__parse_f_string_concat_3.snap @@ -1,5 +1,5 @@ --- -source: compiler/parser/src/string.rs +source: parser/src/string.rs expression: parse_ast --- [ @@ -15,79 +15,89 @@ expression: parse_ast }, ), custom: (), - node: Expr { - value: Located { - location: Location { - row: 1, - column: 0, - }, - end_location: Some( - Location { + node: Expr( + StmtExpr { + value: Located { + location: Location { row: 1, - column: 22, + column: 0, }, - ), - custom: (), - node: JoinedStr { - values: [ - Located { - location: Location { - row: 1, - column: 0, - }, - end_location: Some( - Location { - row: 1, - column: 22, - }, - ), - custom: (), - node: Constant { - value: Str( - "Hello world", - ), - kind: None, - }, + end_location: Some( + Location { + row: 1, + column: 22, }, - Located { - location: Location { - row: 1, - column: 9, - }, - end_location: Some( - Location { - row: 1, - column: 22, - }, - ), - custom: (), - node: FormattedValue { - value: Located { + ), + custom: (), + node: JoinedStr( + ExprJoinedStr { + values: [ + Located { location: Location { row: 1, - column: 17, + column: 0, }, end_location: Some( Location { row: 1, - column: 20, + column: 22, }, ), custom: (), - node: Constant { - value: Str( - "!", - ), - kind: None, + node: Constant( + ExprConstant { + value: Str( + "Hello world", + ), + kind: None, + }, + ), + }, + Located { + location: Location { + row: 1, + column: 9, }, + end_location: Some( + Location { + row: 1, + column: 22, + }, + ), + custom: (), + node: FormattedValue( + ExprFormattedValue { + value: Located { + location: Location { + row: 1, + column: 17, + }, + end_location: Some( + Location { + row: 1, + column: 20, + }, + ), + custom: (), + node: Constant( + ExprConstant { + value: Str( + "!", + ), + kind: None, + }, + ), + }, + conversion: 0, + format_spec: None, + }, + ), }, - conversion: 0, - format_spec: None, - }, + ], }, - ], + ), }, }, - }, + ), }, ] diff --git a/parser/src/snapshots/rustpython_parser__string__tests__parse_fstring.snap b/parser/src/snapshots/rustpython_parser__string__tests__parse_fstring.snap index 4355fd70..4466900f 100644 --- a/parser/src/snapshots/rustpython_parser__string__tests__parse_fstring.snap +++ b/parser/src/snapshots/rustpython_parser__string__tests__parse_fstring.snap @@ -1,5 +1,5 @@ --- -source: compiler/parser/src/string.rs +source: parser/src/string.rs expression: parse_ast --- [ @@ -15,27 +15,31 @@ expression: parse_ast }, ), custom: (), - node: FormattedValue { - value: Located { - location: Location { - row: 1, - column: 3, - }, - end_location: Some( - Location { + node: FormattedValue( + ExprFormattedValue { + value: Located { + location: Location { row: 1, - column: 4, + column: 3, }, - ), - custom: (), - node: Name { - id: "a", - ctx: Load, + end_location: Some( + Location { + row: 1, + column: 4, + }, + ), + custom: (), + node: Name( + ExprName { + id: "a", + ctx: Load, + }, + ), }, + conversion: 0, + format_spec: None, }, - conversion: 0, - format_spec: None, - }, + ), }, Located { location: Location { @@ -49,27 +53,31 @@ expression: parse_ast }, ), custom: (), - node: FormattedValue { - value: Located { - location: Location { - row: 1, - column: 7, - }, - end_location: Some( - Location { + node: FormattedValue( + ExprFormattedValue { + value: Located { + location: Location { row: 1, - column: 8, + column: 7, }, - ), - custom: (), - node: Name { - id: "b", - ctx: Load, + end_location: Some( + Location { + row: 1, + column: 8, + }, + ), + custom: (), + node: Name( + ExprName { + id: "b", + ctx: Load, + }, + ), }, + conversion: 0, + format_spec: None, }, - conversion: 0, - format_spec: None, - }, + ), }, Located { location: Location { @@ -83,11 +91,13 @@ expression: parse_ast }, ), custom: (), - node: Constant { - value: Str( - "{foo}", - ), - kind: None, - }, + node: Constant( + ExprConstant { + value: Str( + "{foo}", + ), + kind: None, + }, + ), }, ] diff --git a/parser/src/snapshots/rustpython_parser__string__tests__parse_fstring_equals.snap b/parser/src/snapshots/rustpython_parser__string__tests__parse_fstring_equals.snap index c8c20522..688b4087 100644 --- a/parser/src/snapshots/rustpython_parser__string__tests__parse_fstring_equals.snap +++ b/parser/src/snapshots/rustpython_parser__string__tests__parse_fstring_equals.snap @@ -1,5 +1,5 @@ --- -source: compiler/parser/src/string.rs +source: parser/src/string.rs expression: parse_ast --- [ @@ -15,67 +15,75 @@ expression: parse_ast }, ), custom: (), - node: FormattedValue { - value: Located { - location: Location { - row: 1, - column: 3, - }, - end_location: Some( - Location { + node: FormattedValue( + ExprFormattedValue { + value: Located { + location: Location { row: 1, - column: 11, + column: 3, }, - ), - custom: (), - node: Compare { - left: Located { - location: Location { + end_location: Some( + Location { row: 1, - column: 3, - }, - end_location: Some( - Location { - row: 1, - column: 5, - }, - ), - custom: (), - node: Constant { - value: Int( - 42, - ), - kind: None, + column: 11, }, - }, - ops: [ - Eq, - ], - comparators: [ - Located { - location: Location { - row: 1, - column: 9, - }, - end_location: Some( - Location { + ), + custom: (), + node: Compare( + ExprCompare { + left: Located { + location: Location { row: 1, - column: 11, + column: 3, }, - ), - custom: (), - node: Constant { - value: Int( - 42, + end_location: Some( + Location { + row: 1, + column: 5, + }, + ), + custom: (), + node: Constant( + ExprConstant { + value: Int( + 42, + ), + kind: None, + }, ), - kind: None, }, + ops: [ + Eq, + ], + comparators: [ + Located { + location: Location { + row: 1, + column: 9, + }, + end_location: Some( + Location { + row: 1, + column: 11, + }, + ), + custom: (), + node: Constant( + ExprConstant { + value: Int( + 42, + ), + kind: None, + }, + ), + }, + ], }, - ], + ), }, + conversion: 0, + format_spec: None, }, - conversion: 0, - format_spec: None, - }, + ), }, ] diff --git a/parser/src/snapshots/rustpython_parser__string__tests__parse_fstring_nested_spec.snap b/parser/src/snapshots/rustpython_parser__string__tests__parse_fstring_nested_spec.snap index 61549489..88e6a5ce 100644 --- a/parser/src/snapshots/rustpython_parser__string__tests__parse_fstring_nested_spec.snap +++ b/parser/src/snapshots/rustpython_parser__string__tests__parse_fstring_nested_spec.snap @@ -1,5 +1,5 @@ --- -source: compiler/parser/src/string.rs +source: parser/src/string.rs expression: parse_ast --- [ @@ -15,78 +15,88 @@ expression: parse_ast }, ), custom: (), - node: FormattedValue { - value: Located { - location: Location { - row: 1, - column: 3, - }, - end_location: Some( - Location { - row: 1, - column: 6, - }, - ), - custom: (), - node: Name { - id: "foo", - ctx: Load, - }, - }, - conversion: 0, - format_spec: Some( - Located { + node: FormattedValue( + ExprFormattedValue { + value: Located { location: Location { row: 1, - column: 0, + column: 3, }, end_location: Some( Location { row: 1, - column: 15, + column: 6, }, ), custom: (), - node: JoinedStr { - values: [ - Located { - location: Location { - row: 1, - column: 0, - }, - end_location: Some( - Location { - row: 1, - column: 15, - }, - ), - custom: (), - node: FormattedValue { - value: Located { + node: Name( + ExprName { + id: "foo", + ctx: Load, + }, + ), + }, + conversion: 0, + format_spec: Some( + Located { + location: Location { + row: 1, + column: 0, + }, + end_location: Some( + Location { + row: 1, + column: 15, + }, + ), + custom: (), + node: JoinedStr( + ExprJoinedStr { + values: [ + Located { location: Location { row: 1, - column: 8, + column: 0, }, end_location: Some( Location { row: 1, - column: 12, + column: 15, }, ), custom: (), - node: Name { - id: "spec", - ctx: Load, - }, + node: FormattedValue( + ExprFormattedValue { + value: Located { + location: Location { + row: 1, + column: 8, + }, + end_location: Some( + Location { + row: 1, + column: 12, + }, + ), + custom: (), + node: Name( + ExprName { + id: "spec", + ctx: Load, + }, + ), + }, + conversion: 0, + format_spec: None, + }, + ), }, - conversion: 0, - format_spec: None, - }, + ], }, - ], + ), }, - }, - ), - }, + ), + }, + ), }, ] diff --git a/parser/src/snapshots/rustpython_parser__string__tests__parse_fstring_not_equals.snap b/parser/src/snapshots/rustpython_parser__string__tests__parse_fstring_not_equals.snap index 029b5ee1..e2db2a98 100644 --- a/parser/src/snapshots/rustpython_parser__string__tests__parse_fstring_not_equals.snap +++ b/parser/src/snapshots/rustpython_parser__string__tests__parse_fstring_not_equals.snap @@ -1,5 +1,5 @@ --- -source: compiler/parser/src/string.rs +source: parser/src/string.rs expression: parse_ast --- [ @@ -15,67 +15,75 @@ expression: parse_ast }, ), custom: (), - node: FormattedValue { - value: Located { - location: Location { - row: 1, - column: 3, - }, - end_location: Some( - Location { + node: FormattedValue( + ExprFormattedValue { + value: Located { + location: Location { row: 1, - column: 9, + column: 3, }, - ), - custom: (), - node: Compare { - left: Located { - location: Location { + end_location: Some( + Location { row: 1, - column: 3, - }, - end_location: Some( - Location { - row: 1, - column: 4, - }, - ), - custom: (), - node: Constant { - value: Int( - 1, - ), - kind: None, + column: 9, }, - }, - ops: [ - NotEq, - ], - comparators: [ - Located { - location: Location { - row: 1, - column: 8, - }, - end_location: Some( - Location { + ), + custom: (), + node: Compare( + ExprCompare { + left: Located { + location: Location { row: 1, - column: 9, + column: 3, }, - ), - custom: (), - node: Constant { - value: Int( - 2, + end_location: Some( + Location { + row: 1, + column: 4, + }, + ), + custom: (), + node: Constant( + ExprConstant { + value: Int( + 1, + ), + kind: None, + }, ), - kind: None, }, + ops: [ + NotEq, + ], + comparators: [ + Located { + location: Location { + row: 1, + column: 8, + }, + end_location: Some( + Location { + row: 1, + column: 9, + }, + ), + custom: (), + node: Constant( + ExprConstant { + value: Int( + 2, + ), + kind: None, + }, + ), + }, + ], }, - ], + ), }, + conversion: 0, + format_spec: None, }, - conversion: 0, - format_spec: None, - }, + ), }, ] diff --git a/parser/src/snapshots/rustpython_parser__string__tests__parse_fstring_not_nested_spec.snap b/parser/src/snapshots/rustpython_parser__string__tests__parse_fstring_not_nested_spec.snap index 8b26d295..faceb8c7 100644 --- a/parser/src/snapshots/rustpython_parser__string__tests__parse_fstring_not_nested_spec.snap +++ b/parser/src/snapshots/rustpython_parser__string__tests__parse_fstring_not_nested_spec.snap @@ -1,5 +1,5 @@ --- -source: compiler/parser/src/string.rs +source: parser/src/string.rs expression: parse_ast --- [ @@ -15,63 +15,71 @@ expression: parse_ast }, ), custom: (), - node: FormattedValue { - value: Located { - location: Location { - row: 1, - column: 3, - }, - end_location: Some( - Location { - row: 1, - column: 6, - }, - ), - custom: (), - node: Name { - id: "foo", - ctx: Load, - }, - }, - conversion: 0, - format_spec: Some( - Located { + node: FormattedValue( + ExprFormattedValue { + value: Located { location: Location { row: 1, - column: 0, + column: 3, }, end_location: Some( Location { row: 1, - column: 13, + column: 6, }, ), custom: (), - node: JoinedStr { - values: [ - Located { - location: Location { - row: 1, - column: 0, - }, - end_location: Some( - Location { - row: 1, - column: 13, + node: Name( + ExprName { + id: "foo", + ctx: Load, + }, + ), + }, + conversion: 0, + format_spec: Some( + Located { + location: Location { + row: 1, + column: 0, + }, + end_location: Some( + Location { + row: 1, + column: 13, + }, + ), + custom: (), + node: JoinedStr( + ExprJoinedStr { + values: [ + Located { + location: Location { + row: 1, + column: 0, + }, + end_location: Some( + Location { + row: 1, + column: 13, + }, + ), + custom: (), + node: Constant( + ExprConstant { + value: Str( + "spec", + ), + kind: None, + }, + ), }, - ), - custom: (), - node: Constant { - value: Str( - "spec", - ), - kind: None, - }, + ], }, - ], + ), }, - }, - ), - }, + ), + }, + ), }, ] diff --git a/parser/src/snapshots/rustpython_parser__string__tests__parse_fstring_self_doc_prec_space.snap b/parser/src/snapshots/rustpython_parser__string__tests__parse_fstring_self_doc_prec_space.snap index f48f688e..40b69905 100644 --- a/parser/src/snapshots/rustpython_parser__string__tests__parse_fstring_self_doc_prec_space.snap +++ b/parser/src/snapshots/rustpython_parser__string__tests__parse_fstring_self_doc_prec_space.snap @@ -1,5 +1,5 @@ --- -source: compiler/parser/src/string.rs +source: parser/src/string.rs expression: parse_ast --- [ @@ -15,12 +15,14 @@ expression: parse_ast }, ), custom: (), - node: Constant { - value: Str( - "x =", - ), - kind: None, - }, + node: Constant( + ExprConstant { + value: Str( + "x =", + ), + kind: None, + }, + ), }, Located { location: Location { @@ -34,12 +36,14 @@ expression: parse_ast }, ), custom: (), - node: Constant { - value: Str( - "", - ), - kind: None, - }, + node: Constant( + ExprConstant { + value: Str( + "", + ), + kind: None, + }, + ), }, Located { location: Location { @@ -53,26 +57,30 @@ expression: parse_ast }, ), custom: (), - node: FormattedValue { - value: Located { - location: Location { - row: 1, - column: 3, - }, - end_location: Some( - Location { + node: FormattedValue( + ExprFormattedValue { + value: Located { + location: Location { row: 1, - column: 4, + column: 3, }, - ), - custom: (), - node: Name { - id: "x", - ctx: Load, + end_location: Some( + Location { + row: 1, + column: 4, + }, + ), + custom: (), + node: Name( + ExprName { + id: "x", + ctx: Load, + }, + ), }, + conversion: 114, + format_spec: None, }, - conversion: 114, - format_spec: None, - }, + ), }, ] diff --git a/parser/src/snapshots/rustpython_parser__string__tests__parse_fstring_self_doc_trailing_space.snap b/parser/src/snapshots/rustpython_parser__string__tests__parse_fstring_self_doc_trailing_space.snap index e1ced214..ed0bce7f 100644 --- a/parser/src/snapshots/rustpython_parser__string__tests__parse_fstring_self_doc_trailing_space.snap +++ b/parser/src/snapshots/rustpython_parser__string__tests__parse_fstring_self_doc_trailing_space.snap @@ -1,5 +1,5 @@ --- -source: compiler/parser/src/string.rs +source: parser/src/string.rs expression: parse_ast --- [ @@ -15,12 +15,14 @@ expression: parse_ast }, ), custom: (), - node: Constant { - value: Str( - "x=", - ), - kind: None, - }, + node: Constant( + ExprConstant { + value: Str( + "x=", + ), + kind: None, + }, + ), }, Located { location: Location { @@ -34,12 +36,14 @@ expression: parse_ast }, ), custom: (), - node: Constant { - value: Str( - " ", - ), - kind: None, - }, + node: Constant( + ExprConstant { + value: Str( + " ", + ), + kind: None, + }, + ), }, Located { location: Location { @@ -53,26 +57,30 @@ expression: parse_ast }, ), custom: (), - node: FormattedValue { - value: Located { - location: Location { - row: 1, - column: 3, - }, - end_location: Some( - Location { + node: FormattedValue( + ExprFormattedValue { + value: Located { + location: Location { row: 1, - column: 4, + column: 3, }, - ), - custom: (), - node: Name { - id: "x", - ctx: Load, + end_location: Some( + Location { + row: 1, + column: 4, + }, + ), + custom: (), + node: Name( + ExprName { + id: "x", + ctx: Load, + }, + ), }, + conversion: 114, + format_spec: None, }, - conversion: 114, - format_spec: None, - }, + ), }, ] diff --git a/parser/src/snapshots/rustpython_parser__string__tests__parse_fstring_yield_expr.snap b/parser/src/snapshots/rustpython_parser__string__tests__parse_fstring_yield_expr.snap index 90223888..0fad54a7 100644 --- a/parser/src/snapshots/rustpython_parser__string__tests__parse_fstring_yield_expr.snap +++ b/parser/src/snapshots/rustpython_parser__string__tests__parse_fstring_yield_expr.snap @@ -1,5 +1,5 @@ --- -source: compiler/parser/src/string.rs +source: parser/src/string.rs expression: parse_ast --- [ @@ -15,25 +15,29 @@ expression: parse_ast }, ), custom: (), - node: FormattedValue { - value: Located { - location: Location { - row: 1, - column: 3, - }, - end_location: Some( - Location { + node: FormattedValue( + ExprFormattedValue { + value: Located { + location: Location { row: 1, - column: 8, + column: 3, }, - ), - custom: (), - node: Yield { - value: None, + end_location: Some( + Location { + row: 1, + column: 8, + }, + ), + custom: (), + node: Yield( + ExprYield { + value: None, + }, + ), }, + conversion: 0, + format_spec: None, }, - conversion: 0, - format_spec: None, - }, + ), }, ] diff --git a/parser/src/snapshots/rustpython_parser__string__tests__parse_string_concat.snap b/parser/src/snapshots/rustpython_parser__string__tests__parse_string_concat.snap index a8744263..4078989a 100644 --- a/parser/src/snapshots/rustpython_parser__string__tests__parse_string_concat.snap +++ b/parser/src/snapshots/rustpython_parser__string__tests__parse_string_concat.snap @@ -1,5 +1,5 @@ --- -source: compiler/parser/src/string.rs +source: parser/src/string.rs expression: parse_ast --- [ @@ -15,26 +15,30 @@ expression: parse_ast }, ), custom: (), - node: Expr { - value: Located { - location: Location { - row: 1, - column: 0, - }, - end_location: Some( - Location { + node: Expr( + StmtExpr { + value: Located { + location: Location { row: 1, - column: 16, + column: 0, }, - ), - custom: (), - node: Constant { - value: Str( - "Hello world", + end_location: Some( + Location { + row: 1, + column: 16, + }, + ), + custom: (), + node: Constant( + ExprConstant { + value: Str( + "Hello world", + ), + kind: None, + }, ), - kind: None, }, }, - }, + ), }, ] diff --git a/parser/src/snapshots/rustpython_parser__string__tests__parse_string_triple_quotes_with_kind.snap b/parser/src/snapshots/rustpython_parser__string__tests__parse_string_triple_quotes_with_kind.snap index 0616991c..5bcd2070 100644 --- a/parser/src/snapshots/rustpython_parser__string__tests__parse_string_triple_quotes_with_kind.snap +++ b/parser/src/snapshots/rustpython_parser__string__tests__parse_string_triple_quotes_with_kind.snap @@ -1,5 +1,5 @@ --- -source: compiler/parser/src/string.rs +source: parser/src/string.rs expression: parse_ast --- [ @@ -15,28 +15,32 @@ expression: parse_ast }, ), custom: (), - node: Expr { - value: Located { - location: Location { - row: 1, - column: 0, - }, - end_location: Some( - Location { + node: Expr( + StmtExpr { + value: Located { + location: Location { row: 1, - column: 20, + column: 0, }, - ), - custom: (), - node: Constant { - value: Str( - "Hello, world!", + end_location: Some( + Location { + row: 1, + column: 20, + }, ), - kind: Some( - "u", + custom: (), + node: Constant( + ExprConstant { + value: Str( + "Hello, world!", + ), + kind: Some( + "u", + ), + }, ), }, }, - }, + ), }, ] diff --git a/parser/src/snapshots/rustpython_parser__string__tests__parse_u_f_string_concat_1.snap b/parser/src/snapshots/rustpython_parser__string__tests__parse_u_f_string_concat_1.snap index 76e6b1d2..5fa16c10 100644 --- a/parser/src/snapshots/rustpython_parser__string__tests__parse_u_f_string_concat_1.snap +++ b/parser/src/snapshots/rustpython_parser__string__tests__parse_u_f_string_concat_1.snap @@ -1,5 +1,5 @@ --- -source: compiler/parser/src/string.rs +source: parser/src/string.rs expression: parse_ast --- [ @@ -15,45 +15,51 @@ expression: parse_ast }, ), custom: (), - node: Expr { - value: Located { - location: Location { - row: 1, - column: 0, - }, - end_location: Some( - Location { + node: Expr( + StmtExpr { + value: Located { + location: Location { row: 1, - column: 18, + column: 0, }, - ), - custom: (), - node: JoinedStr { - values: [ - Located { - location: Location { - row: 1, - column: 0, - }, - end_location: Some( - Location { - row: 1, - column: 18, + end_location: Some( + Location { + row: 1, + column: 18, + }, + ), + custom: (), + node: JoinedStr( + ExprJoinedStr { + values: [ + Located { + location: Location { + row: 1, + column: 0, + }, + end_location: Some( + Location { + row: 1, + column: 18, + }, + ), + custom: (), + node: Constant( + ExprConstant { + value: Str( + "Hello world", + ), + kind: Some( + "u", + ), + }, + ), }, - ), - custom: (), - node: Constant { - value: Str( - "Hello world", - ), - kind: Some( - "u", - ), - }, + ], }, - ], + ), }, }, - }, + ), }, ] diff --git a/parser/src/snapshots/rustpython_parser__string__tests__parse_u_f_string_concat_2.snap b/parser/src/snapshots/rustpython_parser__string__tests__parse_u_f_string_concat_2.snap index 8c073fd9..dd275d2a 100644 --- a/parser/src/snapshots/rustpython_parser__string__tests__parse_u_f_string_concat_2.snap +++ b/parser/src/snapshots/rustpython_parser__string__tests__parse_u_f_string_concat_2.snap @@ -1,5 +1,5 @@ --- -source: compiler/parser/src/string.rs +source: parser/src/string.rs expression: parse_ast --- [ @@ -15,45 +15,51 @@ expression: parse_ast }, ), custom: (), - node: Expr { - value: Located { - location: Location { - row: 1, - column: 0, - }, - end_location: Some( - Location { + node: Expr( + StmtExpr { + value: Located { + location: Location { row: 1, - column: 22, + column: 0, }, - ), - custom: (), - node: JoinedStr { - values: [ - Located { - location: Location { - row: 1, - column: 0, - }, - end_location: Some( - Location { - row: 1, - column: 22, + end_location: Some( + Location { + row: 1, + column: 22, + }, + ), + custom: (), + node: JoinedStr( + ExprJoinedStr { + values: [ + Located { + location: Location { + row: 1, + column: 0, + }, + end_location: Some( + Location { + row: 1, + column: 22, + }, + ), + custom: (), + node: Constant( + ExprConstant { + value: Str( + "Hello world!", + ), + kind: Some( + "u", + ), + }, + ), }, - ), - custom: (), - node: Constant { - value: Str( - "Hello world!", - ), - kind: Some( - "u", - ), - }, + ], }, - ], + ), }, }, - }, + ), }, ] diff --git a/parser/src/snapshots/rustpython_parser__string__tests__parse_u_string_concat_1.snap b/parser/src/snapshots/rustpython_parser__string__tests__parse_u_string_concat_1.snap index 868ba813..35655818 100644 --- a/parser/src/snapshots/rustpython_parser__string__tests__parse_u_string_concat_1.snap +++ b/parser/src/snapshots/rustpython_parser__string__tests__parse_u_string_concat_1.snap @@ -1,5 +1,5 @@ --- -source: compiler/parser/src/string.rs +source: parser/src/string.rs expression: parse_ast --- [ @@ -15,26 +15,30 @@ expression: parse_ast }, ), custom: (), - node: Expr { - value: Located { - location: Location { - row: 1, - column: 0, - }, - end_location: Some( - Location { + node: Expr( + StmtExpr { + value: Located { + location: Location { row: 1, - column: 17, + column: 0, }, - ), - custom: (), - node: Constant { - value: Str( - "Hello world", + end_location: Some( + Location { + row: 1, + column: 17, + }, + ), + custom: (), + node: Constant( + ExprConstant { + value: Str( + "Hello world", + ), + kind: None, + }, ), - kind: None, }, }, - }, + ), }, ] diff --git a/parser/src/snapshots/rustpython_parser__string__tests__parse_u_string_concat_2.snap b/parser/src/snapshots/rustpython_parser__string__tests__parse_u_string_concat_2.snap index a24fc2b3..a16dec2b 100644 --- a/parser/src/snapshots/rustpython_parser__string__tests__parse_u_string_concat_2.snap +++ b/parser/src/snapshots/rustpython_parser__string__tests__parse_u_string_concat_2.snap @@ -1,5 +1,5 @@ --- -source: compiler/parser/src/string.rs +source: parser/src/string.rs expression: parse_ast --- [ @@ -15,28 +15,32 @@ expression: parse_ast }, ), custom: (), - node: Expr { - value: Located { - location: Location { - row: 1, - column: 0, - }, - end_location: Some( - Location { + node: Expr( + StmtExpr { + value: Located { + location: Location { row: 1, - column: 17, + column: 0, }, - ), - custom: (), - node: Constant { - value: Str( - "Hello world", + end_location: Some( + Location { + row: 1, + column: 17, + }, ), - kind: Some( - "u", + custom: (), + node: Constant( + ExprConstant { + value: Str( + "Hello world", + ), + kind: Some( + "u", + ), + }, ), }, }, - }, + ), }, ] diff --git a/parser/src/snapshots/rustpython_parser__string__tests__raw_byte_literal_1.snap b/parser/src/snapshots/rustpython_parser__string__tests__raw_byte_literal_1.snap index 14daedd9..bbccb406 100644 --- a/parser/src/snapshots/rustpython_parser__string__tests__raw_byte_literal_1.snap +++ b/parser/src/snapshots/rustpython_parser__string__tests__raw_byte_literal_1.snap @@ -1,5 +1,5 @@ --- -source: compiler/parser/src/string.rs +source: parser/src/string.rs expression: parse_ast --- [ @@ -15,31 +15,35 @@ expression: parse_ast }, ), custom: (), - node: Expr { - value: Located { - location: Location { - row: 1, - column: 0, - }, - end_location: Some( - Location { + node: Expr( + StmtExpr { + value: Located { + location: Location { row: 1, - column: 8, + column: 0, }, - ), - custom: (), - node: Constant { - value: Bytes( - [ - 92, - 120, - 49, - 122, - ], + end_location: Some( + Location { + row: 1, + column: 8, + }, + ), + custom: (), + node: Constant( + ExprConstant { + value: Bytes( + [ + 92, + 120, + 49, + 122, + ], + ), + kind: None, + }, ), - kind: None, }, }, - }, + ), }, ] diff --git a/parser/src/snapshots/rustpython_parser__string__tests__raw_byte_literal_2.snap b/parser/src/snapshots/rustpython_parser__string__tests__raw_byte_literal_2.snap index d34d8c88..e4f53784 100644 --- a/parser/src/snapshots/rustpython_parser__string__tests__raw_byte_literal_2.snap +++ b/parser/src/snapshots/rustpython_parser__string__tests__raw_byte_literal_2.snap @@ -1,5 +1,5 @@ --- -source: compiler/parser/src/string.rs +source: parser/src/string.rs expression: parse_ast --- [ @@ -15,29 +15,33 @@ expression: parse_ast }, ), custom: (), - node: Expr { - value: Located { - location: Location { - row: 1, - column: 0, - }, - end_location: Some( - Location { + node: Expr( + StmtExpr { + value: Located { + location: Location { row: 1, - column: 6, + column: 0, }, - ), - custom: (), - node: Constant { - value: Bytes( - [ - 92, - 92, - ], + end_location: Some( + Location { + row: 1, + column: 6, + }, + ), + custom: (), + node: Constant( + ExprConstant { + value: Bytes( + [ + 92, + 92, + ], + ), + kind: None, + }, ), - kind: None, }, }, - }, + ), }, ] diff --git a/parser/src/snapshots/rustpython_parser__string__tests__raw_fstring.snap b/parser/src/snapshots/rustpython_parser__string__tests__raw_fstring.snap index e53b8610..e24a31cb 100644 --- a/parser/src/snapshots/rustpython_parser__string__tests__raw_fstring.snap +++ b/parser/src/snapshots/rustpython_parser__string__tests__raw_fstring.snap @@ -1,5 +1,5 @@ --- -source: compiler/parser/src/string.rs +source: parser/src/string.rs expression: parse_ast --- [ @@ -15,58 +15,66 @@ expression: parse_ast }, ), custom: (), - node: Expr { - value: Located { - location: Location { - row: 1, - column: 0, - }, - end_location: Some( - Location { + node: Expr( + StmtExpr { + value: Located { + location: Location { row: 1, - column: 7, + column: 0, }, - ), - custom: (), - node: JoinedStr { - values: [ - Located { - location: Location { - row: 1, - column: 0, - }, - end_location: Some( - Location { - row: 1, - column: 7, - }, - ), - custom: (), - node: FormattedValue { - value: Located { + end_location: Some( + Location { + row: 1, + column: 7, + }, + ), + custom: (), + node: JoinedStr( + ExprJoinedStr { + values: [ + Located { location: Location { row: 1, - column: 4, + column: 0, }, end_location: Some( Location { row: 1, - column: 5, + column: 7, }, ), custom: (), - node: Name { - id: "x", - ctx: Load, - }, + node: FormattedValue( + ExprFormattedValue { + value: Located { + location: Location { + row: 1, + column: 4, + }, + end_location: Some( + Location { + row: 1, + column: 5, + }, + ), + custom: (), + node: Name( + ExprName { + id: "x", + ctx: Load, + }, + ), + }, + conversion: 0, + format_spec: None, + }, + ), }, - conversion: 0, - format_spec: None, - }, + ], }, - ], + ), }, }, - }, + ), }, ] diff --git a/parser/src/snapshots/rustpython_parser__string__tests__single_quoted_byte.snap b/parser/src/snapshots/rustpython_parser__string__tests__single_quoted_byte.snap index 0d8c8c9a..997e84d7 100644 --- a/parser/src/snapshots/rustpython_parser__string__tests__single_quoted_byte.snap +++ b/parser/src/snapshots/rustpython_parser__string__tests__single_quoted_byte.snap @@ -1,5 +1,5 @@ --- -source: compiler/parser/src/string.rs +source: parser/src/string.rs expression: parse_ast --- [ @@ -15,283 +15,287 @@ expression: parse_ast }, ), custom: (), - node: Expr { - value: Located { - location: Location { - row: 1, - column: 0, - }, - end_location: Some( - Location { + node: Expr( + StmtExpr { + value: Located { + location: Location { row: 1, - column: 738, + column: 0, }, - ), - custom: (), - node: Constant { - value: Bytes( - [ - 0, - 1, - 2, - 3, - 4, - 5, - 6, - 7, - 8, - 9, - 10, - 11, - 12, - 13, - 14, - 15, - 16, - 17, - 18, - 19, - 20, - 21, - 22, - 23, - 24, - 25, - 26, - 27, - 28, - 29, - 30, - 31, - 32, - 33, - 34, - 35, - 36, - 37, - 38, - 39, - 40, - 41, - 42, - 43, - 44, - 45, - 46, - 47, - 48, - 49, - 50, - 51, - 52, - 53, - 54, - 55, - 56, - 57, - 58, - 59, - 60, - 61, - 62, - 63, - 64, - 65, - 66, - 67, - 68, - 69, - 70, - 71, - 72, - 73, - 74, - 75, - 76, - 77, - 78, - 79, - 80, - 81, - 82, - 83, - 84, - 85, - 86, - 87, - 88, - 89, - 90, - 91, - 92, - 93, - 94, - 95, - 96, - 97, - 98, - 99, - 100, - 101, - 102, - 103, - 104, - 105, - 106, - 107, - 108, - 109, - 110, - 111, - 112, - 113, - 114, - 115, - 116, - 117, - 118, - 119, - 120, - 121, - 122, - 123, - 124, - 125, - 126, - 127, - 128, - 129, - 130, - 131, - 132, - 133, - 134, - 135, - 136, - 137, - 138, - 139, - 140, - 141, - 142, - 143, - 144, - 145, - 146, - 147, - 148, - 149, - 150, - 151, - 152, - 153, - 154, - 155, - 156, - 157, - 158, - 159, - 160, - 161, - 162, - 163, - 164, - 165, - 166, - 167, - 168, - 169, - 170, - 171, - 172, - 173, - 174, - 175, - 176, - 177, - 178, - 179, - 180, - 181, - 182, - 183, - 184, - 185, - 186, - 187, - 188, - 189, - 190, - 191, - 192, - 193, - 194, - 195, - 196, - 197, - 198, - 199, - 200, - 201, - 202, - 203, - 204, - 205, - 206, - 207, - 208, - 209, - 210, - 211, - 212, - 213, - 214, - 215, - 216, - 217, - 218, - 219, - 220, - 221, - 222, - 223, - 224, - 225, - 226, - 227, - 228, - 229, - 230, - 231, - 232, - 233, - 234, - 235, - 236, - 237, - 238, - 239, - 240, - 241, - 242, - 243, - 244, - 245, - 246, - 247, - 248, - 249, - 250, - 251, - 252, - 253, - 254, - 255, - ], + end_location: Some( + Location { + row: 1, + column: 738, + }, + ), + custom: (), + node: Constant( + ExprConstant { + value: Bytes( + [ + 0, + 1, + 2, + 3, + 4, + 5, + 6, + 7, + 8, + 9, + 10, + 11, + 12, + 13, + 14, + 15, + 16, + 17, + 18, + 19, + 20, + 21, + 22, + 23, + 24, + 25, + 26, + 27, + 28, + 29, + 30, + 31, + 32, + 33, + 34, + 35, + 36, + 37, + 38, + 39, + 40, + 41, + 42, + 43, + 44, + 45, + 46, + 47, + 48, + 49, + 50, + 51, + 52, + 53, + 54, + 55, + 56, + 57, + 58, + 59, + 60, + 61, + 62, + 63, + 64, + 65, + 66, + 67, + 68, + 69, + 70, + 71, + 72, + 73, + 74, + 75, + 76, + 77, + 78, + 79, + 80, + 81, + 82, + 83, + 84, + 85, + 86, + 87, + 88, + 89, + 90, + 91, + 92, + 93, + 94, + 95, + 96, + 97, + 98, + 99, + 100, + 101, + 102, + 103, + 104, + 105, + 106, + 107, + 108, + 109, + 110, + 111, + 112, + 113, + 114, + 115, + 116, + 117, + 118, + 119, + 120, + 121, + 122, + 123, + 124, + 125, + 126, + 127, + 128, + 129, + 130, + 131, + 132, + 133, + 134, + 135, + 136, + 137, + 138, + 139, + 140, + 141, + 142, + 143, + 144, + 145, + 146, + 147, + 148, + 149, + 150, + 151, + 152, + 153, + 154, + 155, + 156, + 157, + 158, + 159, + 160, + 161, + 162, + 163, + 164, + 165, + 166, + 167, + 168, + 169, + 170, + 171, + 172, + 173, + 174, + 175, + 176, + 177, + 178, + 179, + 180, + 181, + 182, + 183, + 184, + 185, + 186, + 187, + 188, + 189, + 190, + 191, + 192, + 193, + 194, + 195, + 196, + 197, + 198, + 199, + 200, + 201, + 202, + 203, + 204, + 205, + 206, + 207, + 208, + 209, + 210, + 211, + 212, + 213, + 214, + 215, + 216, + 217, + 218, + 219, + 220, + 221, + 222, + 223, + 224, + 225, + 226, + 227, + 228, + 229, + 230, + 231, + 232, + 233, + 234, + 235, + 236, + 237, + 238, + 239, + 240, + 241, + 242, + 243, + 244, + 245, + 246, + 247, + 248, + 249, + 250, + 251, + 252, + 253, + 254, + 255, + ], + ), + kind: None, + }, ), - kind: None, }, }, - }, + ), }, ] diff --git a/parser/src/snapshots/rustpython_parser__string__tests__triple_quoted_raw_fstring.snap b/parser/src/snapshots/rustpython_parser__string__tests__triple_quoted_raw_fstring.snap index 19975d53..180c8113 100644 --- a/parser/src/snapshots/rustpython_parser__string__tests__triple_quoted_raw_fstring.snap +++ b/parser/src/snapshots/rustpython_parser__string__tests__triple_quoted_raw_fstring.snap @@ -1,5 +1,5 @@ --- -source: compiler/parser/src/string.rs +source: parser/src/string.rs expression: parse_ast --- [ @@ -15,58 +15,66 @@ expression: parse_ast }, ), custom: (), - node: Expr { - value: Located { - location: Location { - row: 1, - column: 0, - }, - end_location: Some( - Location { + node: Expr( + StmtExpr { + value: Located { + location: Location { row: 1, - column: 11, + column: 0, }, - ), - custom: (), - node: JoinedStr { - values: [ - Located { - location: Location { - row: 1, - column: 0, - }, - end_location: Some( - Location { - row: 1, - column: 11, - }, - ), - custom: (), - node: FormattedValue { - value: Located { + end_location: Some( + Location { + row: 1, + column: 11, + }, + ), + custom: (), + node: JoinedStr( + ExprJoinedStr { + values: [ + Located { location: Location { row: 1, - column: 6, + column: 0, }, end_location: Some( Location { row: 1, - column: 7, + column: 11, }, ), custom: (), - node: Name { - id: "x", - ctx: Load, - }, + node: FormattedValue( + ExprFormattedValue { + value: Located { + location: Location { + row: 1, + column: 6, + }, + end_location: Some( + Location { + row: 1, + column: 7, + }, + ), + custom: (), + node: Name( + ExprName { + id: "x", + ctx: Load, + }, + ), + }, + conversion: 0, + format_spec: None, + }, + ), }, - conversion: 0, - format_spec: None, - }, + ], }, - ], + ), }, }, - }, + ), }, ] diff --git a/parser/src/string.rs b/parser/src/string.rs index 14f5ce1c..6cf25d35 100644 --- a/parser/src/string.rs +++ b/parser/src/string.rs @@ -4,7 +4,7 @@ // regular strings. Since the parser has no definition of f-string formats (Pending PEP 701) // we have to do the parsing here, manually. use crate::{ - ast::{Constant, ConversionFlag, Expr, ExprKind, Location}, + ast::{self, Constant, ConversionFlag, Expr, ExprKind, Location}, lexer::{LexicalError, LexicalErrorType}, parser::{parse_expression_located, LalrpopError, ParseError, ParseErrorType}, token::{StringKind, Tok}, @@ -230,9 +230,14 @@ impl<'a> StringParser<'a> { ':' if delimiters.is_empty() => { let parsed_spec = self.parse_spec(nested)?; - spec = Some(Box::new(self.expr(ExprKind::JoinedStr { - values: parsed_spec, - }))); + spec = Some(Box::new( + self.expr( + ast::ExprJoinedStr { + values: parsed_spec, + } + .into(), + ), + )); } '(' | '{' | '[' => { expression.push(ch); @@ -296,29 +301,8 @@ impl<'a> StringParser<'a> { } let ret = if !self_documenting { - vec![self.expr(ExprKind::FormattedValue { - value: Box::new(parse_fstring_expr(&expression, location).map_err( - |e| { - FStringError::new( - InvalidExpression(Box::new(e.error)), - location, - ) - }, - )?), - conversion: conversion as _, - format_spec: spec, - })] - } else { - vec![ - self.expr(ExprKind::Constant { - value: Constant::Str(expression.to_owned() + "="), - kind: None, - }), - self.expr(ExprKind::Constant { - value: trailing_seq.into(), - kind: None, - }), - self.expr(ExprKind::FormattedValue { + vec![self.expr( + ast::ExprFormattedValue { value: Box::new( parse_fstring_expr(&expression, location).map_err(|e| { FStringError::new( @@ -327,14 +311,48 @@ impl<'a> StringParser<'a> { ) })?, ), - conversion: (if conversion == ConversionFlag::None && spec.is_none() - { - ConversionFlag::Repr - } else { - conversion - }) as _, + conversion: conversion as _, format_spec: spec, - }), + } + .into(), + )] + } else { + vec![ + self.expr( + ast::ExprConstant { + value: Constant::Str(expression.to_owned() + "="), + kind: None, + } + .into(), + ), + self.expr( + ast::ExprConstant { + value: trailing_seq.into(), + kind: None, + } + .into(), + ), + self.expr( + ast::ExprFormattedValue { + value: Box::new( + parse_fstring_expr(&expression, location).map_err(|e| { + FStringError::new( + InvalidExpression(Box::new(e.error)), + location, + ) + })?, + ), + conversion: (if conversion == ConversionFlag::None + && spec.is_none() + { + ConversionFlag::Repr + } else { + conversion + }) as _, + format_spec: spec, + } + .into(), + ), ] }; return Ok(ret); @@ -374,10 +392,15 @@ impl<'a> StringParser<'a> { match next { '{' => { if !constant_piece.is_empty() { - spec_constructor.push(self.expr(ExprKind::Constant { - value: constant_piece.drain(..).collect::().into(), - kind: None, - })); + spec_constructor.push( + self.expr( + ast::ExprConstant { + value: constant_piece.drain(..).collect::().into(), + kind: None, + } + .into(), + ), + ); } let parsed_expr = self.parse_fstring(nested + 1)?; spec_constructor.extend(parsed_expr); @@ -393,10 +416,15 @@ impl<'a> StringParser<'a> { self.next_char(); } if !constant_piece.is_empty() { - spec_constructor.push(self.expr(ExprKind::Constant { - value: constant_piece.drain(..).collect::().into(), - kind: None, - })); + spec_constructor.push( + self.expr( + ast::ExprConstant { + value: constant_piece.drain(..).collect::().into(), + kind: None, + } + .into(), + ), + ); } Ok(spec_constructor) } @@ -429,10 +457,15 @@ impl<'a> StringParser<'a> { } } if !content.is_empty() { - values.push(self.expr(ExprKind::Constant { - value: content.drain(..).collect::().into(), - kind: None, - })); + values.push( + self.expr( + ast::ExprConstant { + value: content.drain(..).collect::().into(), + kind: None, + } + .into(), + ), + ); } let parsed_values = self.parse_formatted_value(nested)?; @@ -462,10 +495,15 @@ impl<'a> StringParser<'a> { } if !content.is_empty() { - values.push(self.expr(ExprKind::Constant { - value: content.into(), - kind: None, - })) + values.push( + self.expr( + ast::ExprConstant { + value: content.into(), + kind: None, + } + .into(), + ), + ) } Ok(values) @@ -492,10 +530,13 @@ impl<'a> StringParser<'a> { } } - Ok(self.expr(ExprKind::Constant { - value: Constant::Bytes(content.chars().map(|c| c as u8).collect()), - kind: None, - })) + Ok(self.expr( + ast::ExprConstant { + value: Constant::Bytes(content.chars().map(|c| c as u8).collect()), + kind: None, + } + .into(), + )) } fn parse_string(&mut self) -> Result { @@ -508,10 +549,13 @@ impl<'a> StringParser<'a> { ch => content.push(ch), } } - Ok(self.expr(ExprKind::Constant { - value: Constant::Str(content), - kind: self.kind.is_unicode().then(|| "u".to_string()), - })) + Ok(self.expr( + ast::ExprConstant { + value: Constant::Str(content), + kind: self.kind.is_unicode().then(|| "u".to_string()), + } + .into(), + )) } fn parse(&mut self) -> Result, LexicalError> { @@ -568,10 +612,10 @@ pub(crate) fn parse_strings( for (start, (source, kind, triple_quoted), end) in values { for value in parse_string(&source, kind, triple_quoted, start, end)? { match value.node { - ExprKind::Constant { + ExprKind::Constant(ast::ExprConstant { value: Constant::Bytes(value), .. - } => content.extend(value), + }) => content.extend(value), _ => unreachable!("Unexpected non-bytes expression."), } } @@ -579,10 +623,11 @@ pub(crate) fn parse_strings( return Ok(Expr::new( initial_start, last_end, - ExprKind::Constant { + ast::ExprConstant { value: Constant::Bytes(content), kind: None, - }, + } + .into(), )); } @@ -591,10 +636,10 @@ pub(crate) fn parse_strings( for (start, (source, kind, triple_quoted), end) in values { for value in parse_string(&source, kind, triple_quoted, start, end)? { match value.node { - ExprKind::Constant { + ExprKind::Constant(ast::ExprConstant { value: Constant::Str(value), .. - } => content.push(value), + }) => content.push(value), _ => unreachable!("Unexpected non-string expression."), } } @@ -602,10 +647,11 @@ pub(crate) fn parse_strings( return Ok(Expr::new( initial_start, last_end, - ExprKind::Constant { + ast::ExprConstant { value: Constant::Str(content.join("")), kind: initial_kind, - }, + } + .into(), )); } @@ -617,10 +663,11 @@ pub(crate) fn parse_strings( Expr::new( initial_start, last_end, - ExprKind::Constant { + ast::ExprConstant { value: Constant::Str(current.drain(..).join("")), kind: initial_kind.clone(), - }, + } + .into(), ) }; @@ -633,10 +680,10 @@ pub(crate) fn parse_strings( } deduped.push(value) } - ExprKind::Constant { + ExprKind::Constant(ast::ExprConstant { value: Constant::Str(value), .. - } => current.push(value), + }) => current.push(value), _ => unreachable!("Unexpected non-string expression."), } } @@ -648,7 +695,7 @@ pub(crate) fn parse_strings( Ok(Expr::new( initial_start, last_end, - ExprKind::JoinedStr { values: deduped }, + ast::ExprJoinedStr { values: deduped }.into(), )) }