Move `range` from `Attributed` to `Node`s (#22)

* Move `range` from `Attributed` to `Node`s

* No Attributed + custom for Range PoC

* Generate all located variants, generate enum implementations

* Implement `Copy` on simple enums

* Move `Suite` to `ranged` and `located`

* Update tests
---------

Co-authored-by: Jeong YunWon <jeong@youknowone.org>
This commit is contained in:
Micha Reiser 2023-05-15 08:08:12 +02:00 committed by GitHub
parent a983f4383f
commit 192379cede
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
126 changed files with 29410 additions and 30670 deletions

View File

@ -17,7 +17,7 @@ members = [
[workspace.dependencies] [workspace.dependencies]
rustpython-ast = { path = "ast", default-features = false } rustpython-ast = { path = "ast", default-features = false }
rustpython-parser-core = { path = "core", default-features = false } rustpython-parser-core = { path = "core", features = [] }
rustpython-literal = { path = "literal" } rustpython-literal = { path = "literal" }
ahash = "0.7.6" ahash = "0.7.6"

View File

@ -14,6 +14,7 @@ location = ["fold", "rustpython-parser-core/location"]
fold = [] fold = []
unparse = ["rustpython-literal"] unparse = ["rustpython-literal"]
visitor = [] visitor = []
all-nodes-with-ranges = []
[dependencies] [dependencies]
rustpython-parser-core = { workspace = true } rustpython-parser-core = { workspace = true }
@ -21,3 +22,4 @@ rustpython-literal = { workspace = true, optional = true }
is-macro = { workspace = true } is-macro = { workspace = true }
num-bigint = { workspace = true } num-bigint = { workspace = true }
static_assertions = "1.1.0"

View File

@ -84,6 +84,7 @@ class TypeInfo:
enum_name: Optional[str] enum_name: Optional[str]
has_user_data: Optional[bool] has_user_data: Optional[bool]
has_attributes: bool has_attributes: bool
is_simple: bool
empty_field: bool empty_field: bool
children: set children: set
boxed: bool boxed: bool
@ -95,6 +96,7 @@ class TypeInfo:
self.enum_name = None self.enum_name = None
self.has_user_data = None self.has_user_data = None
self.has_attributes = False self.has_attributes = False
self.is_simple = False
self.empty_field = False self.empty_field = False
self.children = set() self.children = set()
self.boxed = False self.boxed = False
@ -104,6 +106,14 @@ class TypeInfo:
def __repr__(self): def __repr__(self):
return f"<TypeInfo: {self.name}>" return f"<TypeInfo: {self.name}>"
def no_cfg(self, typeinfo):
if self.product:
return self.has_attributes
elif self.enum_name:
return typeinfo[self.enum_name].has_attributes
else:
return self.has_attributes
@property @property
def rust_name(self): def rust_name(self):
return rust_type_name(self.name) return rust_type_name(self.name)
@ -124,19 +134,6 @@ class TypeInfo:
name = rust_type_name(self.enum_name) + rust_name name = rust_type_name(self.enum_name) + rust_name
return name return name
@property
def rust_suffix(self):
if self.product:
if self.has_attributes:
return "Data"
else:
return ""
else:
if self.has_attributes:
return "Kind"
else:
return ""
def determine_user_data(self, type_info, stack): def determine_user_data(self, type_info, stack):
if self.name in stack: if self.name in stack:
return None return None
@ -160,7 +157,8 @@ class TypeInfoMixin:
return self.type_info[typ].has_user_data return self.type_info[typ].has_user_data
def apply_generics(self, typ, *generics): def apply_generics(self, typ, *generics):
if self.has_user_data(typ): needs_generics = not self.type_info[typ].is_simple
if needs_generics:
return [f"<{g}>" for g in generics] return [f"<{g}>" for g in generics]
else: else:
return ["" for g in generics] return ["" for g in generics]
@ -208,6 +206,7 @@ class FindUserDataTypesVisitor(asdl.VisitorBase):
info = self.type_info[name] info = self.type_info[name]
if is_simple(sum): if is_simple(sum):
info.has_user_data = False info.has_user_data = False
info.is_simple = True
else: else:
for t in sum.types: for t in sum.types:
t_info = TypeInfo(t.name) t_info = TypeInfo(t.name)
@ -218,7 +217,7 @@ class FindUserDataTypesVisitor(asdl.VisitorBase):
if len(sum.types) > 1: if len(sum.types) > 1:
info.boxed = True info.boxed = True
if sum.attributes: if sum.attributes:
# attributes means located, which has the `custom: U` field # attributes means located, which has the `range: R` field
info.has_user_data = True info.has_user_data = True
info.has_attributes = True info.has_attributes = True
@ -228,7 +227,7 @@ class FindUserDataTypesVisitor(asdl.VisitorBase):
def visitProduct(self, product, name): def visitProduct(self, product, name):
info = self.type_info[name] info = self.type_info[name]
if product.attributes: if product.attributes:
# attributes means located, which has the `custom: U` field # attributes means located, which has the `range: R` field
info.has_user_data = True info.has_user_data = True
info.has_attributes = True info.has_attributes = True
info.has_expr = product_has_expr(product) info.has_expr = product_has_expr(product)
@ -277,10 +276,16 @@ class StructVisitor(EmitVisitor):
def emit_attrs(self, depth): def emit_attrs(self, depth):
self.emit("#[derive(Clone, Debug, PartialEq)]", depth) self.emit("#[derive(Clone, Debug, PartialEq)]", depth)
def emit_range(self, has_attributes, depth):
if has_attributes:
self.emit("pub range: R,", depth + 1)
else:
self.emit("pub range: crate::ranged::OptionalRange<R>,", depth + 1)
def simple_sum(self, sum, name, depth): def simple_sum(self, sum, name, depth):
rust_name = rust_type_name(name) rust_name = rust_type_name(name)
self.emit_attrs(depth) self.emit_attrs(depth)
self.emit("#[derive(is_macro::Is)]", depth) self.emit("#[derive(is_macro::Is, Copy, Hash, Eq)]", depth)
self.emit(f"pub enum {rust_name} {{", depth) self.emit(f"pub enum {rust_name} {{", depth)
for variant in sum.types: for variant in sum.types:
self.emit(f"{variant.name},", depth + 1) self.emit(f"{variant.name},", depth + 1)
@ -289,20 +294,16 @@ class StructVisitor(EmitVisitor):
def sum_with_constructors(self, sum, name, depth): def sum_with_constructors(self, sum, name, depth):
type_info = self.type_info[name] type_info = self.type_info[name]
suffix = type_info.rust_suffix
rust_name = rust_type_name(name) rust_name = rust_type_name(name)
# all the attributes right now are for location, so if it has attrs we # all the attributes right now are for location, so if it has attrs we
# can just wrap it in Attributed<> # can just wrap it in Attributed<>
for t in sum.types: for t in sum.types:
if not t.fields:
continue
self.sum_subtype_struct(type_info, t, rust_name, depth) self.sum_subtype_struct(type_info, t, rust_name, depth)
generics, generics_applied = self.apply_generics(name, "U = ()", "U")
self.emit_attrs(depth) self.emit_attrs(depth)
self.emit("#[derive(is_macro::Is)]", depth) self.emit("#[derive(is_macro::Is)]", depth)
self.emit(f"pub enum {rust_name}{suffix}{generics} {{", depth) self.emit(f"pub enum {rust_name}<R = TextRange> {{", depth)
needs_escape = any(rust_field_name(t.name) in RUST_KEYWORDS for t in sum.types) needs_escape = any(rust_field_name(t.name) in RUST_KEYWORDS for t in sum.types)
for t in sum.types: for t in sum.types:
if needs_escape: if needs_escape:
@ -310,35 +311,29 @@ class StructVisitor(EmitVisitor):
f'#[is(name = "{rust_field_name(t.name)}_{rust_name.lower()}")]', f'#[is(name = "{rust_field_name(t.name)}_{rust_name.lower()}")]',
depth + 1, depth + 1,
) )
if t.fields: self.emit(f"{t.name}({rust_name}{t.name}<R>),", depth + 1)
(t_generics_applied,) = self.apply_generics(t.name, "U")
self.emit(
f"{t.name}({rust_name}{t.name}{t_generics_applied}),", depth + 1
)
else:
self.emit(f"{t.name},", depth + 1)
self.emit("}", depth) self.emit("}", depth)
if type_info.has_attributes:
self.emit(
f"pub type {rust_name}<U = ()> = Attributed<{rust_name}{suffix}{generics_applied}, U>;",
depth,
)
self.emit("", depth) self.emit("", depth)
def sum_subtype_struct(self, sum_type_info, t, rust_name, depth): def sum_subtype_struct(self, sum_type_info, t, rust_name, depth):
self.emit_attrs(depth) self.emit_attrs(depth)
generics, generics_applied = self.apply_generics(t.name, "U = ()", "U")
payload_name = f"{rust_name}{t.name}" payload_name = f"{rust_name}{t.name}"
self.emit(f"pub struct {payload_name}{generics} {{", depth) self.emit(f"pub struct {payload_name}<R = TextRange> {{", depth)
self.emit_range(sum_type_info.has_attributes, depth)
for f in t.fields: for f in t.fields:
self.visit(f, sum_type_info, "pub ", depth + 1, t.name) self.visit(f, sum_type_info, "pub ", depth + 1, t.name)
assert sum_type_info.has_attributes == self.type_info[t.name].no_cfg(
self.type_info
)
self.emit("}", depth) self.emit("}", depth)
self.emit( self.emit(
textwrap.dedent( textwrap.dedent(
f""" f"""
impl{generics_applied} From<{payload_name}{generics_applied}> for {rust_name}{sum_type_info.rust_suffix}{generics_applied} {{ impl<R> From<{payload_name}<R>> for {rust_name}<R> {{
fn from(payload: {payload_name}{generics_applied}) -> Self {{ fn from(payload: {payload_name}<R>) -> Self {{
{rust_name}{sum_type_info.rust_suffix}::{t.name}(payload) {rust_name}::{t.name}(payload)
}} }}
}} }}
""" """
@ -346,6 +341,8 @@ class StructVisitor(EmitVisitor):
depth, depth,
) )
self.emit("", depth)
def visitConstructor(self, cons, parent, depth): def visitConstructor(self, cons, parent, depth):
if cons.fields: if cons.fields:
self.emit(f"{cons.name} {{", depth) self.emit(f"{cons.name} {{", depth)
@ -358,8 +355,8 @@ class StructVisitor(EmitVisitor):
def visitField(self, field, parent, vis, depth, constructor=None): def visitField(self, field, parent, vis, depth, constructor=None):
typ = rust_type_name(field.type) typ = rust_type_name(field.type)
field_type = self.type_info.get(field.type) field_type = self.type_info.get(field.type)
if field_type and field_type.has_user_data: if field_type and not field_type.is_simple:
typ = f"{typ}<U>" typ = f"{typ}<R>"
# don't box if we're doing Vec<T>, but do box if we're doing Vec<Option<Box<T>>> # don't box if we're doing Vec<T>, but do box if we're doing Vec<Option<Box<T>>>
if ( if (
field_type field_type
@ -384,28 +381,15 @@ class StructVisitor(EmitVisitor):
def visitProduct(self, product, name, depth): def visitProduct(self, product, name, depth):
type_info = self.type_info[name] type_info = self.type_info[name]
generics, generics_applied = self.apply_generics(name, "U = ()", "U") product_name = rust_type_name(name)
data_name = rust_name = rust_type_name(name)
if product.attributes:
data_name = rust_name + "Data"
self.emit_attrs(depth) self.emit_attrs(depth)
has_expr = product_has_expr(product)
if has_expr: self.emit(f"pub struct {product_name}<R = TextRange> {{", depth)
data_def = f"{data_name}{generics}"
else:
data_def = data_name
self.emit(f"pub struct {data_def} {{", depth)
for f in product.fields: for f in product.fields:
self.visit(f, type_info, "pub ", depth + 1) self.visit(f, type_info, "pub ", depth + 1)
assert bool(product.attributes) == type_info.no_cfg(self.type_info)
self.emit_range(product.attributes, depth + 1)
self.emit("}", depth) self.emit("}", depth)
if product.attributes:
# attributes should just be location info
if not has_expr:
generics_applied = ""
self.emit(
f"pub type {rust_name}<U = ()> = Attributed<{data_name}{generics_applied}, U>;",
depth,
)
self.emit("", depth) self.emit("", depth)
@ -414,16 +398,18 @@ class FoldTraitDefVisitor(EmitVisitor):
self.emit("pub trait Fold<U> {", depth) self.emit("pub trait Fold<U> {", depth)
self.emit("type TargetU;", depth + 1) self.emit("type TargetU;", depth + 1)
self.emit("type Error;", depth + 1) self.emit("type Error;", depth + 1)
self.emit(
"fn map_user(&mut self, user: U) -> Result<Self::TargetU, Self::Error>;",
depth + 1,
)
self.emit( self.emit(
""" """
fn map_attributed<T>(&mut self, attributed: Attributed<T, U>) -> Result<Attributed<T, Self::TargetU>, Self::Error> { fn map_user(&mut self, user: U) -> Result<Self::TargetU, Self::Error>;
let custom = self.map_user(attributed.custom)?; #[cfg(feature = "all-nodes-with-ranges")]
Ok(Attributed { range: attributed.range, custom, node: attributed.node }) fn map_user_cfg(&mut self, user: U) -> Result<Self::TargetU, Self::Error> {
}""", self.map_user(user)
}
#[cfg(not(feature = "all-nodes-with-ranges"))]
fn map_user_cfg(&mut self, _user: crate::EmptyRange<U>) -> Result<crate::EmptyRange<Self::TargetU>, Self::Error> {
Ok(crate::EmptyRange::default())
}
""",
depth + 1, depth + 1,
) )
self.emit( self.emit(
@ -451,15 +437,6 @@ class FoldTraitDefVisitor(EmitVisitor):
class FoldImplVisitor(EmitVisitor): class FoldImplVisitor(EmitVisitor):
def visitModule(self, mod, depth): def visitModule(self, mod, depth):
self.emit(
"fn fold_attributed<U, F: Fold<U> + ?Sized, T, MT>(folder: &mut F, node: Attributed<T, U>, f: impl FnOnce(&mut F, T) -> Result<MT, F::Error>) -> Result<Attributed<MT, F::TargetU>, F::Error> {",
depth,
)
self.emit(
"let node = folder.map_attributed(node)?; Ok(Attributed { custom: node.custom, range: node.range, node: f(folder, node.node)? })",
depth + 1,
)
self.emit("}", depth)
for dfn in mod.dfns: for dfn in mod.dfns:
self.visit(dfn, depth) self.visit(dfn, depth)
@ -472,6 +449,7 @@ class FoldImplVisitor(EmitVisitor):
name, "T", "U", "F::TargetU" name, "T", "U", "F::TargetU"
) )
enum_name = rust_type_name(name) enum_name = rust_type_name(name)
simple = is_simple(sum)
self.emit(f"impl<T, U> Foldable<T, U> for {enum_name}{apply_t} {{", depth) self.emit(f"impl<T, U> Foldable<T, U> for {enum_name}{apply_t} {{", depth)
self.emit(f"type Mapped = {enum_name}{apply_u};", depth + 1) self.emit(f"type Mapped = {enum_name}{apply_u};", depth + 1)
@ -487,25 +465,29 @@ class FoldImplVisitor(EmitVisitor):
f"pub fn fold_{name}<U, F: Fold<U> + ?Sized>(#[allow(unused)] folder: &mut F, node: {enum_name}{apply_u}) -> Result<{enum_name}{apply_target_u}, F::Error> {{", f"pub fn fold_{name}<U, F: Fold<U> + ?Sized>(#[allow(unused)] folder: &mut F, node: {enum_name}{apply_u}) -> Result<{enum_name}{apply_target_u}, F::Error> {{",
depth, depth,
) )
if type_info.has_attributes:
self.emit("fold_attributed(folder, node, |folder, node| {", depth) if simple:
self.emit("Ok(node) }", depth + 1)
return
self.emit("match node {", depth + 1) self.emit("match node {", depth + 1)
for cons in sum.types: for cons in sum.types:
fields_pattern = self.make_pattern( fields_pattern = self.make_pattern(enum_name, cons.name, cons.fields)
enum_name, type_info.rust_suffix, cons.name, cons.fields
)
self.emit( self.emit(
f"{fields_pattern[0]} {{ {fields_pattern[1]}}} {fields_pattern[2]} => {{", f"{fields_pattern[0]} {{ {fields_pattern[1]}}} {fields_pattern[2]} => {{",
depth + 2, depth + 2,
) )
map_user_suffix = "" if type_info.has_attributes else "_cfg"
self.emit(
f"let range = folder.map_user{map_user_suffix}(range)?;", depth + 3
)
self.gen_construction( self.gen_construction(
fields_pattern[0], cons.fields, fields_pattern[2], depth + 3 fields_pattern[0], cons.fields, fields_pattern[2], depth + 3
) )
self.emit("}", depth + 2) self.emit("}", depth + 2)
self.emit("}", depth + 1) self.emit("}", depth + 1)
if type_info.has_attributes:
self.emit("})", depth)
self.emit("}", depth) self.emit("}", depth)
def visitProduct(self, product, name, depth): def visitProduct(self, product, name, depth):
@ -529,27 +511,26 @@ class FoldImplVisitor(EmitVisitor):
f"pub fn fold_{name}<U, F: Fold<U> + ?Sized>(#[allow(unused)] folder: &mut F, node: {struct_name}{apply_u}) -> Result<{struct_name}{apply_target_u}, F::Error> {{", f"pub fn fold_{name}<U, F: Fold<U> + ?Sized>(#[allow(unused)] folder: &mut F, node: {struct_name}{apply_u}) -> Result<{struct_name}{apply_target_u}, F::Error> {{",
depth, depth,
) )
if has_attributes:
self.emit("fold_attributed(folder, node, |folder, node| {", depth) fields_pattern = self.make_pattern(struct_name, struct_name, product.fields)
rust_name = struct_name + "Data" self.emit(f"let {struct_name} {{ {fields_pattern[1]} }} = node;", depth + 1)
else:
rust_name = struct_name map_user_suffix = "" if has_attributes else "_cfg"
fields_pattern = self.make_pattern(rust_name, struct_name, None, product.fields) self.emit(f"let range = folder.map_user{map_user_suffix}(range)?;", depth + 3)
self.emit(f"let {rust_name} {{ {fields_pattern[1]} }} = node;", depth + 1)
self.gen_construction(rust_name, product.fields, "", depth + 1) self.gen_construction(struct_name, product.fields, "", depth + 1)
if has_attributes:
self.emit("})", depth)
self.emit("}", depth) self.emit("}", depth)
def make_pattern(self, rust_name, suffix, fieldname, fields): def make_pattern(self, rust_name, fieldname: str, fields):
if fields: header = f"{rust_name}::{fieldname}({rust_name}{fieldname}"
header = f"{rust_name}{suffix}::{fieldname}({rust_name}{fieldname}"
footer = ")" footer = ")"
else:
header = f"{rust_name}{suffix}::{fieldname}"
footer = ""
body = ",".join(rust_field(f.name) for f in fields) body = ",".join(rust_field(f.name) for f in fields)
if body:
body += ","
body += "range"
return header, body, footer return header, body, footer
def gen_construction(self, header, fields, footer, depth): def gen_construction(self, header, fields, footer, depth):
@ -557,6 +538,8 @@ class FoldImplVisitor(EmitVisitor):
for field in fields: for field in fields:
name = rust_field(field.name) name = rust_field(field.name)
self.emit(f"{name}: Foldable::fold({name}, folder)?,", depth + 1) self.emit(f"{name}: Foldable::fold({name}, folder)?,", depth + 1)
self.emit("range,", depth + 1)
self.emit(f"}}{footer})", depth) self.emit(f"}}{footer})", depth)
@ -584,7 +567,7 @@ class VisitorTraitDefVisitor(StructVisitor):
return rust_type_name(name) return rust_type_name(name)
def visitModule(self, mod, depth): def visitModule(self, mod, depth):
self.emit("pub trait Visitor<U=()> {", depth) self.emit("pub trait Visitor<R=crate::text_size::TextRange> {", depth)
for dfn in mod.dfns: for dfn in mod.dfns:
self.visit(dfn, depth + 1) self.visit(dfn, depth + 1)
@ -595,16 +578,14 @@ class VisitorTraitDefVisitor(StructVisitor):
def emit_visitor(self, nodename, depth, has_node=True): def emit_visitor(self, nodename, depth, has_node=True):
type_info = self.type_info[nodename] type_info = self.type_info[nodename]
if has_node:
node_type = type_info.rust_sum_name node_type = type_info.rust_sum_name
node_value = "node" generic, = self.apply_generics(nodename, "R")
else:
node_type = "()"
node_value = "()"
self.emit( self.emit(
f"fn visit_{type_info.sum_name}(&mut self, node: {node_type}) {{", depth f"fn visit_{type_info.sum_name}(&mut self, node: {node_type}{generic}) {{", depth
) )
self.emit(f"self.generic_visit_{type_info.sum_name}({node_value})", depth + 1) if has_node:
self.emit(f"self.generic_visit_{type_info.sum_name}(node)", depth + 1)
self.emit("}", depth) self.emit("}", depth)
def emit_generic_visitor_signature(self, nodename, depth, has_node=True): def emit_generic_visitor_signature(self, nodename, depth, has_node=True):
@ -613,8 +594,9 @@ class VisitorTraitDefVisitor(StructVisitor):
node_type = type_info.rust_sum_name node_type = type_info.rust_sum_name
else: else:
node_type = "()" node_type = "()"
generic, = self.apply_generics(nodename, "R")
self.emit( self.emit(
f"fn generic_visit_{type_info.sum_name}(&mut self, node: {node_type}) {{", f"fn generic_visit_{type_info.sum_name}(&mut self, node: {node_type}{generic}) {{",
depth, depth,
) )
@ -628,16 +610,15 @@ class VisitorTraitDefVisitor(StructVisitor):
def visit_match_for_type(self, nodename, rust_name, type_, depth): def visit_match_for_type(self, nodename, rust_name, type_, depth):
self.emit(f"{rust_name}::{type_.name}", depth) self.emit(f"{rust_name}::{type_.name}", depth)
if type_.fields:
self.emit("(data)", depth) self.emit("(data)", depth)
data = "data" self.emit(f"=> self.visit_{nodename}_{type_.name}(data),", depth)
else:
data = "()"
self.emit(f"=> self.visit_{nodename}_{type_.name}({data}),", depth)
def visit_sum_type(self, name, type_, depth): def visit_sum_type(self, name, type_, depth):
self.emit_visitor(type_.name, depth, has_node=type_.fields) self.emit_visitor(type_.name, depth, has_node=type_.fields)
self.emit_generic_visitor_signature(type_.name, depth, has_node=type_.fields) if not type_.fields:
return
self.emit_generic_visitor_signature(type_.name, depth, has_node=True)
for f in type_.fields: for f in type_.fields:
fieldname = rust_field(f.name) fieldname = rust_field(f.name)
field_type = self.type_info.get(f.type) field_type = self.type_info.get(f.type)
@ -669,15 +650,13 @@ class VisitorTraitDefVisitor(StructVisitor):
if not sum.attributes: if not sum.attributes:
return return
rust_name = enum_name = rust_type_name(name) enum_name = rust_type_name(name)
if sum.attributes:
rust_name = enum_name + "Kind"
self.emit_visitor(name, depth) self.emit_visitor(name, depth)
self.emit_generic_visitor_signature(name, depth) self.emit_generic_visitor_signature(name, depth)
depth += 1 depth += 1
self.emit("match node.node {", depth) self.emit("match node {", depth)
for t in sum.types: for t in sum.types:
self.visit_match_for_type(name, rust_name, t, depth + 1) self.visit_match_for_type(name, enum_name, t, depth + 1)
self.emit("}", depth) self.emit("}", depth)
depth -= 1 depth -= 1
self.emit("}", depth) self.emit("}", depth)
@ -838,8 +817,6 @@ class TraitImplVisitor(EmitVisitor):
def visitProduct(self, product, name, depth): def visitProduct(self, product, name, depth):
struct_name = rust_type_name(name) struct_name = rust_type_name(name)
if product.attributes:
struct_name += "Data"
self.emit(f"impl NamedNode for ast::located::{struct_name} {{", depth) self.emit(f"impl NamedNode for ast::located::{struct_name} {{", depth)
self.emit(f"const NAME: &'static str = {json.dumps(name)};", depth + 1) self.emit(f"const NAME: &'static str = {json.dumps(name)};", depth + 1)
@ -945,6 +922,124 @@ class TraitImplVisitor(EmitVisitor):
return f"Node::ast_from_object(_vm, get_node_field(_vm, &_object, {name}, {json.dumps(typename)})?)?" return f"Node::ast_from_object(_vm, get_node_field(_vm, &_object, {name}, {json.dumps(typename)})?)?"
class RangedDefVisitor(EmitVisitor):
def visitModule(self, mod):
for dfn in mod.dfns:
self.visit(dfn)
def visitType(self, type, depth=0):
self.visit(type.value, type.name, depth)
def visitSum(self, sum, name, depth):
info = self.type_info[name]
if info.is_simple:
return
sum_match_arms = ""
for ty in sum.types:
variant_info = self.type_info[ty.name]
sum_match_arms += f" Self::{variant_info.rust_name}(node) => node.range(),"
self.emit_ranged_impl(variant_info)
if not info.no_cfg(self.type_info):
self.emit('#[cfg(feature = "all-nodes-with-ranges")]', 0)
self.emit(f"""
impl Ranged for crate::{info.rust_sum_name} {{
fn range(&self) -> TextRange {{
match self {{
{sum_match_arms}
}}
}}
}}
""".lstrip(), 0)
def visitProduct(self, product, name, depth):
info = self.type_info[name]
self.emit_ranged_impl(info)
def emit_ranged_impl(self, info):
if not info.no_cfg(self.type_info):
self.emit('#[cfg(feature = "all-nodes-with-ranges")]', 0)
self.file.write(
f"""
impl Ranged for crate::generic::{info.rust_sum_name}::<TextRange> {{
fn range(&self) -> TextRange {{
self.range
}}
}}
""".strip()
)
class LocatedDefVisitor(EmitVisitor):
def visitModule(self, mod):
for dfn in mod.dfns:
self.visit(dfn)
def visitType(self, type, depth=0):
self.visit(type.value, type.name, depth)
def visitSum(self, sum, name, depth):
info = self.type_info[name]
self.emit_type_alias(info)
if info.is_simple:
return
sum_match_arms = ""
for ty in sum.types:
variant_info = self.type_info[ty.name]
sum_match_arms += f" Self::{variant_info.rust_name}(node) => node.range(),"
self.emit_type_alias(variant_info)
self.emit_located_impl(variant_info)
if not info.no_cfg(self.type_info):
self.emit('#[cfg(feature = "all-nodes-with-ranges")]', 0)
self.emit(f"""
impl Located for {info.rust_sum_name} {{
fn range(&self) -> SourceRange {{
match self {{
{sum_match_arms}
}}
}}
}}
""".lstrip(), 0)
def visitProduct(self, product, name, depth):
info = self.type_info[name]
self.emit_type_alias(info)
self.emit_located_impl(info)
def emit_type_alias(self, info):
generics = "" if info.is_simple else "::<SourceRange>"
self.emit(f"pub type {info.rust_sum_name} = crate::generic::{info.rust_sum_name}{generics};", 0)
self.emit("", 0)
def emit_located_impl(self, info):
if not info.no_cfg(self.type_info):
self.emit('#[cfg(feature = "all-nodes-with-ranges")]', 0)
self.emit(
f"""
impl Located for {info.rust_sum_name} {{
fn range(&self) -> SourceRange {{
self.range
}}
}}
"""
, 0)
class ChainOfVisitors: class ChainOfVisitors:
def __init__(self, *visitors): def __init__(self, *visitors):
self.visitors = visitors self.visitors = visitors
@ -956,6 +1051,7 @@ class ChainOfVisitors:
def write_ast_def(mod, type_info, f): def write_ast_def(mod, type_info, f):
f.write("use crate::text_size::TextRange;")
StructVisitor(f, type_info).visit(mod) StructVisitor(f, type_info).visit(mod)
@ -967,32 +1063,12 @@ def write_visitor_def(mod, type_info, f):
VisitorModuleVisitor(f, type_info).visit(mod) VisitorModuleVisitor(f, type_info).visit(mod)
def write_located_def(mod, type_info, f): def write_ranged_def(mod, type_info, f):
f.write( RangedDefVisitor(f, type_info).visit(mod)
textwrap.dedent(
"""
use rustpython_parser_core::source_code::SourceRange;
pub type Located<T> = super::generic::Attributed<T, SourceRange>;
""" def write_located_def(mod, type_info, f):
) LocatedDefVisitor(f, type_info).visit(mod)
)
for info in type_info.values():
if info.empty_field:
continue
if info.has_user_data:
generics = "::<SourceRange>"
else:
generics = ""
f.write(
f"pub type {info.rust_sum_name} = super::generic::{info.rust_sum_name}{generics};\n"
)
if info.rust_suffix:
if info.rust_suffix == "Data" and not info.has_expr:
generics = ""
f.write(
f"pub type {info.rust_sum_name}{info.rust_suffix} = super::generic::{info.rust_sum_name}{info.rust_suffix}{generics};\n"
)
def write_ast_mod(mod, type_info, f): def write_ast_mod(mod, type_info, f):
@ -1035,6 +1111,7 @@ def main(
for filename, write in [ for filename, write in [
("generic", write_ast_def), ("generic", write_ast_def),
("fold", write_fold_def), ("fold", write_fold_def),
("ranged", write_ranged_def),
("located", write_located_def), ("located", write_located_def),
("visitor", write_visitor_def), ("visitor", write_visitor_def),
]: ]:

View File

@ -1,7 +1,6 @@
//! `builtin_types` in asdl.py and Attributed //! `builtin_types` in asdl.py and Attributed
use num_bigint::BigInt; use num_bigint::BigInt;
use rustpython_parser_core::text_size::{TextRange, TextSize};
pub type String = std::string::String; pub type String = std::string::String;
@ -205,64 +204,6 @@ impl std::fmt::Display for Constant {
} }
} }
#[derive(Clone, Debug, PartialEq)]
pub struct Attributed<T, U = ()> {
pub range: TextRange,
pub custom: U,
pub node: T,
}
impl<T, U> Attributed<T, U> {
/// Returns the node
#[inline]
pub fn node(&self) -> &T {
&self.node
}
/// Returns the `range` of the node. The range offsets are absolute to the start of the document.
#[inline]
pub const fn range(&self) -> TextRange {
self.range
}
/// Returns the absolute start position of the node from the beginning of the document.
#[inline]
pub const fn start(&self) -> TextSize {
self.range.start()
}
/// Returns the absolute position at which the node ends in the source document.
#[inline]
pub const fn end(&self) -> TextSize {
self.range.end()
}
}
impl<T> Attributed<T, ()> {
/// Creates a new node that spans the position specified by `range`.
pub fn new(range: impl Into<TextRange>, node: impl Into<T>) -> Self {
Self {
range: range.into(),
custom: (),
node: node.into(),
}
}
/// Consumes self and returns the node.
#[inline]
pub fn into_node(self) -> T {
self.node
}
}
impl<T, U> std::ops::Deref for Attributed<T, U> {
type Target = T;
fn deref(&self) -> &Self::Target {
&self.node
}
}
#[cfg(test)] #[cfg(test)]
mod tests { mod tests {
use super::*; use super::*;

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -1,95 +1,753 @@
// File automatically generated by ast/asdl_rs.py. // File automatically generated by ast/asdl_rs.py.
use rustpython_parser_core::source_code::SourceRange; pub type Mod = crate::generic::Mod<SourceRange>;
pub type Located<T> = super::generic::Attributed<T, SourceRange>; pub type ModModule = crate::generic::ModModule<SourceRange>;
pub type Mod = super::generic::Mod<SourceRange>;
pub type ModModule = super::generic::ModModule<SourceRange>; #[cfg(feature = "all-nodes-with-ranges")]
pub type ModInteractive = super::generic::ModInteractive<SourceRange>;
pub type ModExpression = super::generic::ModExpression<SourceRange>; impl Located for ModModule {
pub type ModFunctionType = super::generic::ModFunctionType<SourceRange>; fn range(&self) -> SourceRange {
pub type Stmt = super::generic::Stmt<SourceRange>; self.range
pub type StmtKind = super::generic::StmtKind<SourceRange>; }
pub type StmtFunctionDef = super::generic::StmtFunctionDef<SourceRange>; }
pub type StmtAsyncFunctionDef = super::generic::StmtAsyncFunctionDef<SourceRange>;
pub type StmtClassDef = super::generic::StmtClassDef<SourceRange>; pub type ModInteractive = crate::generic::ModInteractive<SourceRange>;
pub type StmtReturn = super::generic::StmtReturn<SourceRange>;
pub type StmtDelete = super::generic::StmtDelete<SourceRange>; #[cfg(feature = "all-nodes-with-ranges")]
pub type StmtAssign = super::generic::StmtAssign<SourceRange>;
pub type StmtAugAssign = super::generic::StmtAugAssign<SourceRange>; impl Located for ModInteractive {
pub type StmtAnnAssign = super::generic::StmtAnnAssign<SourceRange>; fn range(&self) -> SourceRange {
pub type StmtFor = super::generic::StmtFor<SourceRange>; self.range
pub type StmtAsyncFor = super::generic::StmtAsyncFor<SourceRange>; }
pub type StmtWhile = super::generic::StmtWhile<SourceRange>; }
pub type StmtIf = super::generic::StmtIf<SourceRange>;
pub type StmtWith = super::generic::StmtWith<SourceRange>; pub type ModExpression = crate::generic::ModExpression<SourceRange>;
pub type StmtAsyncWith = super::generic::StmtAsyncWith<SourceRange>;
pub type StmtMatch = super::generic::StmtMatch<SourceRange>; #[cfg(feature = "all-nodes-with-ranges")]
pub type StmtRaise = super::generic::StmtRaise<SourceRange>;
pub type StmtTry = super::generic::StmtTry<SourceRange>; impl Located for ModExpression {
pub type StmtTryStar = super::generic::StmtTryStar<SourceRange>; fn range(&self) -> SourceRange {
pub type StmtAssert = super::generic::StmtAssert<SourceRange>; self.range
pub type StmtImport = super::generic::StmtImport<SourceRange>; }
pub type StmtImportFrom = super::generic::StmtImportFrom<SourceRange>; }
pub type StmtGlobal = super::generic::StmtGlobal;
pub type StmtNonlocal = super::generic::StmtNonlocal; pub type ModFunctionType = crate::generic::ModFunctionType<SourceRange>;
pub type StmtExpr = super::generic::StmtExpr<SourceRange>;
pub type Expr = super::generic::Expr<SourceRange>; #[cfg(feature = "all-nodes-with-ranges")]
pub type ExprKind = super::generic::ExprKind<SourceRange>;
pub type ExprBoolOp = super::generic::ExprBoolOp<SourceRange>; impl Located for ModFunctionType {
pub type ExprNamedExpr = super::generic::ExprNamedExpr<SourceRange>; fn range(&self) -> SourceRange {
pub type ExprBinOp = super::generic::ExprBinOp<SourceRange>; self.range
pub type ExprUnaryOp = super::generic::ExprUnaryOp<SourceRange>; }
pub type ExprLambda = super::generic::ExprLambda<SourceRange>; }
pub type ExprIfExp = super::generic::ExprIfExp<SourceRange>;
pub type ExprDict = super::generic::ExprDict<SourceRange>; #[cfg(feature = "all-nodes-with-ranges")]
pub type ExprSet = super::generic::ExprSet<SourceRange>; impl Located for Mod {
pub type ExprListComp = super::generic::ExprListComp<SourceRange>; fn range(&self) -> SourceRange {
pub type ExprSetComp = super::generic::ExprSetComp<SourceRange>; match self {
pub type ExprDictComp = super::generic::ExprDictComp<SourceRange>; Self::Module(node) => node.range(),
pub type ExprGeneratorExp = super::generic::ExprGeneratorExp<SourceRange>; Self::Interactive(node) => node.range(),
pub type ExprAwait = super::generic::ExprAwait<SourceRange>; Self::Expression(node) => node.range(),
pub type ExprYield = super::generic::ExprYield<SourceRange>; Self::FunctionType(node) => node.range(),
pub type ExprYieldFrom = super::generic::ExprYieldFrom<SourceRange>; }
pub type ExprCompare = super::generic::ExprCompare<SourceRange>; }
pub type ExprCall = super::generic::ExprCall<SourceRange>; }
pub type ExprFormattedValue = super::generic::ExprFormattedValue<SourceRange>;
pub type ExprJoinedStr = super::generic::ExprJoinedStr<SourceRange>; pub type Stmt = crate::generic::Stmt<SourceRange>;
pub type ExprConstant = super::generic::ExprConstant;
pub type ExprAttribute = super::generic::ExprAttribute<SourceRange>; pub type StmtFunctionDef = crate::generic::StmtFunctionDef<SourceRange>;
pub type ExprSubscript = super::generic::ExprSubscript<SourceRange>;
pub type ExprStarred = super::generic::ExprStarred<SourceRange>; impl Located for StmtFunctionDef {
pub type ExprName = super::generic::ExprName; fn range(&self) -> SourceRange {
pub type ExprList = super::generic::ExprList<SourceRange>; self.range
pub type ExprTuple = super::generic::ExprTuple<SourceRange>; }
pub type ExprSlice = super::generic::ExprSlice<SourceRange>; }
pub type ExprContext = super::generic::ExprContext;
pub type Boolop = super::generic::Boolop; pub type StmtAsyncFunctionDef = crate::generic::StmtAsyncFunctionDef<SourceRange>;
pub type Operator = super::generic::Operator;
pub type Unaryop = super::generic::Unaryop; impl Located for StmtAsyncFunctionDef {
pub type Cmpop = super::generic::Cmpop; fn range(&self) -> SourceRange {
pub type Comprehension = super::generic::Comprehension<SourceRange>; self.range
pub type Excepthandler = super::generic::Excepthandler<SourceRange>; }
pub type ExcepthandlerKind = super::generic::ExcepthandlerKind<SourceRange>; }
pub type ExcepthandlerExceptHandler = super::generic::ExcepthandlerExceptHandler<SourceRange>;
pub type Arguments = super::generic::Arguments<SourceRange>; pub type StmtClassDef = crate::generic::StmtClassDef<SourceRange>;
pub type Arg = super::generic::Arg<SourceRange>;
pub type ArgData = super::generic::ArgData<SourceRange>; impl Located for StmtClassDef {
pub type Keyword = super::generic::Keyword<SourceRange>; fn range(&self) -> SourceRange {
pub type KeywordData = super::generic::KeywordData<SourceRange>; self.range
pub type Alias = super::generic::Alias<SourceRange>; }
pub type AliasData = super::generic::AliasData; }
pub type Withitem = super::generic::Withitem<SourceRange>;
pub type MatchCase = super::generic::MatchCase<SourceRange>; pub type StmtReturn = crate::generic::StmtReturn<SourceRange>;
pub type Pattern = super::generic::Pattern<SourceRange>;
pub type PatternKind = super::generic::PatternKind<SourceRange>; impl Located for StmtReturn {
pub type PatternMatchValue = super::generic::PatternMatchValue<SourceRange>; fn range(&self) -> SourceRange {
pub type PatternMatchSingleton = super::generic::PatternMatchSingleton; self.range
pub type PatternMatchSequence = super::generic::PatternMatchSequence<SourceRange>; }
pub type PatternMatchMapping = super::generic::PatternMatchMapping<SourceRange>; }
pub type PatternMatchClass = super::generic::PatternMatchClass<SourceRange>;
pub type PatternMatchStar = super::generic::PatternMatchStar; pub type StmtDelete = crate::generic::StmtDelete<SourceRange>;
pub type PatternMatchAs = super::generic::PatternMatchAs<SourceRange>;
pub type PatternMatchOr = super::generic::PatternMatchOr<SourceRange>; impl Located for StmtDelete {
pub type TypeIgnore = super::generic::TypeIgnore; fn range(&self) -> SourceRange {
pub type TypeIgnoreTypeIgnore = super::generic::TypeIgnoreTypeIgnore; self.range
}
}
pub type StmtAssign = crate::generic::StmtAssign<SourceRange>;
impl Located for StmtAssign {
fn range(&self) -> SourceRange {
self.range
}
}
pub type StmtAugAssign = crate::generic::StmtAugAssign<SourceRange>;
impl Located for StmtAugAssign {
fn range(&self) -> SourceRange {
self.range
}
}
pub type StmtAnnAssign = crate::generic::StmtAnnAssign<SourceRange>;
impl Located for StmtAnnAssign {
fn range(&self) -> SourceRange {
self.range
}
}
pub type StmtFor = crate::generic::StmtFor<SourceRange>;
impl Located for StmtFor {
fn range(&self) -> SourceRange {
self.range
}
}
pub type StmtAsyncFor = crate::generic::StmtAsyncFor<SourceRange>;
impl Located for StmtAsyncFor {
fn range(&self) -> SourceRange {
self.range
}
}
pub type StmtWhile = crate::generic::StmtWhile<SourceRange>;
impl Located for StmtWhile {
fn range(&self) -> SourceRange {
self.range
}
}
pub type StmtIf = crate::generic::StmtIf<SourceRange>;
impl Located for StmtIf {
fn range(&self) -> SourceRange {
self.range
}
}
pub type StmtWith = crate::generic::StmtWith<SourceRange>;
impl Located for StmtWith {
fn range(&self) -> SourceRange {
self.range
}
}
pub type StmtAsyncWith = crate::generic::StmtAsyncWith<SourceRange>;
impl Located for StmtAsyncWith {
fn range(&self) -> SourceRange {
self.range
}
}
pub type StmtMatch = crate::generic::StmtMatch<SourceRange>;
impl Located for StmtMatch {
fn range(&self) -> SourceRange {
self.range
}
}
pub type StmtRaise = crate::generic::StmtRaise<SourceRange>;
impl Located for StmtRaise {
fn range(&self) -> SourceRange {
self.range
}
}
pub type StmtTry = crate::generic::StmtTry<SourceRange>;
impl Located for StmtTry {
fn range(&self) -> SourceRange {
self.range
}
}
pub type StmtTryStar = crate::generic::StmtTryStar<SourceRange>;
impl Located for StmtTryStar {
fn range(&self) -> SourceRange {
self.range
}
}
pub type StmtAssert = crate::generic::StmtAssert<SourceRange>;
impl Located for StmtAssert {
fn range(&self) -> SourceRange {
self.range
}
}
pub type StmtImport = crate::generic::StmtImport<SourceRange>;
impl Located for StmtImport {
fn range(&self) -> SourceRange {
self.range
}
}
pub type StmtImportFrom = crate::generic::StmtImportFrom<SourceRange>;
impl Located for StmtImportFrom {
fn range(&self) -> SourceRange {
self.range
}
}
pub type StmtGlobal = crate::generic::StmtGlobal<SourceRange>;
impl Located for StmtGlobal {
fn range(&self) -> SourceRange {
self.range
}
}
pub type StmtNonlocal = crate::generic::StmtNonlocal<SourceRange>;
impl Located for StmtNonlocal {
fn range(&self) -> SourceRange {
self.range
}
}
pub type StmtExpr = crate::generic::StmtExpr<SourceRange>;
impl Located for StmtExpr {
fn range(&self) -> SourceRange {
self.range
}
}
pub type StmtPass = crate::generic::StmtPass<SourceRange>;
impl Located for StmtPass {
fn range(&self) -> SourceRange {
self.range
}
}
pub type StmtBreak = crate::generic::StmtBreak<SourceRange>;
impl Located for StmtBreak {
fn range(&self) -> SourceRange {
self.range
}
}
pub type StmtContinue = crate::generic::StmtContinue<SourceRange>;
impl Located for StmtContinue {
fn range(&self) -> SourceRange {
self.range
}
}
impl Located for Stmt {
fn range(&self) -> SourceRange {
match self {
Self::FunctionDef(node) => node.range(),
Self::AsyncFunctionDef(node) => node.range(),
Self::ClassDef(node) => node.range(),
Self::Return(node) => node.range(),
Self::Delete(node) => node.range(),
Self::Assign(node) => node.range(),
Self::AugAssign(node) => node.range(),
Self::AnnAssign(node) => node.range(),
Self::For(node) => node.range(),
Self::AsyncFor(node) => node.range(),
Self::While(node) => node.range(),
Self::If(node) => node.range(),
Self::With(node) => node.range(),
Self::AsyncWith(node) => node.range(),
Self::Match(node) => node.range(),
Self::Raise(node) => node.range(),
Self::Try(node) => node.range(),
Self::TryStar(node) => node.range(),
Self::Assert(node) => node.range(),
Self::Import(node) => node.range(),
Self::ImportFrom(node) => node.range(),
Self::Global(node) => node.range(),
Self::Nonlocal(node) => node.range(),
Self::Expr(node) => node.range(),
Self::Pass(node) => node.range(),
Self::Break(node) => node.range(),
Self::Continue(node) => node.range(),
}
}
}
pub type Expr = crate::generic::Expr<SourceRange>;
pub type ExprBoolOp = crate::generic::ExprBoolOp<SourceRange>;
impl Located for ExprBoolOp {
fn range(&self) -> SourceRange {
self.range
}
}
pub type ExprNamedExpr = crate::generic::ExprNamedExpr<SourceRange>;
impl Located for ExprNamedExpr {
fn range(&self) -> SourceRange {
self.range
}
}
pub type ExprBinOp = crate::generic::ExprBinOp<SourceRange>;
impl Located for ExprBinOp {
fn range(&self) -> SourceRange {
self.range
}
}
pub type ExprUnaryOp = crate::generic::ExprUnaryOp<SourceRange>;
impl Located for ExprUnaryOp {
fn range(&self) -> SourceRange {
self.range
}
}
pub type ExprLambda = crate::generic::ExprLambda<SourceRange>;
impl Located for ExprLambda {
fn range(&self) -> SourceRange {
self.range
}
}
pub type ExprIfExp = crate::generic::ExprIfExp<SourceRange>;
impl Located for ExprIfExp {
fn range(&self) -> SourceRange {
self.range
}
}
pub type ExprDict = crate::generic::ExprDict<SourceRange>;
impl Located for ExprDict {
fn range(&self) -> SourceRange {
self.range
}
}
pub type ExprSet = crate::generic::ExprSet<SourceRange>;
impl Located for ExprSet {
fn range(&self) -> SourceRange {
self.range
}
}
pub type ExprListComp = crate::generic::ExprListComp<SourceRange>;
impl Located for ExprListComp {
fn range(&self) -> SourceRange {
self.range
}
}
pub type ExprSetComp = crate::generic::ExprSetComp<SourceRange>;
impl Located for ExprSetComp {
fn range(&self) -> SourceRange {
self.range
}
}
pub type ExprDictComp = crate::generic::ExprDictComp<SourceRange>;
impl Located for ExprDictComp {
fn range(&self) -> SourceRange {
self.range
}
}
pub type ExprGeneratorExp = crate::generic::ExprGeneratorExp<SourceRange>;
impl Located for ExprGeneratorExp {
fn range(&self) -> SourceRange {
self.range
}
}
pub type ExprAwait = crate::generic::ExprAwait<SourceRange>;
impl Located for ExprAwait {
fn range(&self) -> SourceRange {
self.range
}
}
pub type ExprYield = crate::generic::ExprYield<SourceRange>;
impl Located for ExprYield {
fn range(&self) -> SourceRange {
self.range
}
}
pub type ExprYieldFrom = crate::generic::ExprYieldFrom<SourceRange>;
impl Located for ExprYieldFrom {
fn range(&self) -> SourceRange {
self.range
}
}
pub type ExprCompare = crate::generic::ExprCompare<SourceRange>;
impl Located for ExprCompare {
fn range(&self) -> SourceRange {
self.range
}
}
pub type ExprCall = crate::generic::ExprCall<SourceRange>;
impl Located for ExprCall {
fn range(&self) -> SourceRange {
self.range
}
}
pub type ExprFormattedValue = crate::generic::ExprFormattedValue<SourceRange>;
impl Located for ExprFormattedValue {
fn range(&self) -> SourceRange {
self.range
}
}
pub type ExprJoinedStr = crate::generic::ExprJoinedStr<SourceRange>;
impl Located for ExprJoinedStr {
fn range(&self) -> SourceRange {
self.range
}
}
pub type ExprConstant = crate::generic::ExprConstant<SourceRange>;
impl Located for ExprConstant {
fn range(&self) -> SourceRange {
self.range
}
}
pub type ExprAttribute = crate::generic::ExprAttribute<SourceRange>;
impl Located for ExprAttribute {
fn range(&self) -> SourceRange {
self.range
}
}
pub type ExprSubscript = crate::generic::ExprSubscript<SourceRange>;
impl Located for ExprSubscript {
fn range(&self) -> SourceRange {
self.range
}
}
pub type ExprStarred = crate::generic::ExprStarred<SourceRange>;
impl Located for ExprStarred {
fn range(&self) -> SourceRange {
self.range
}
}
pub type ExprName = crate::generic::ExprName<SourceRange>;
impl Located for ExprName {
fn range(&self) -> SourceRange {
self.range
}
}
pub type ExprList = crate::generic::ExprList<SourceRange>;
impl Located for ExprList {
fn range(&self) -> SourceRange {
self.range
}
}
pub type ExprTuple = crate::generic::ExprTuple<SourceRange>;
impl Located for ExprTuple {
fn range(&self) -> SourceRange {
self.range
}
}
pub type ExprSlice = crate::generic::ExprSlice<SourceRange>;
impl Located for ExprSlice {
fn range(&self) -> SourceRange {
self.range
}
}
impl Located for Expr {
fn range(&self) -> SourceRange {
match self {
Self::BoolOp(node) => node.range(),
Self::NamedExpr(node) => node.range(),
Self::BinOp(node) => node.range(),
Self::UnaryOp(node) => node.range(),
Self::Lambda(node) => node.range(),
Self::IfExp(node) => node.range(),
Self::Dict(node) => node.range(),
Self::Set(node) => node.range(),
Self::ListComp(node) => node.range(),
Self::SetComp(node) => node.range(),
Self::DictComp(node) => node.range(),
Self::GeneratorExp(node) => node.range(),
Self::Await(node) => node.range(),
Self::Yield(node) => node.range(),
Self::YieldFrom(node) => node.range(),
Self::Compare(node) => node.range(),
Self::Call(node) => node.range(),
Self::FormattedValue(node) => node.range(),
Self::JoinedStr(node) => node.range(),
Self::Constant(node) => node.range(),
Self::Attribute(node) => node.range(),
Self::Subscript(node) => node.range(),
Self::Starred(node) => node.range(),
Self::Name(node) => node.range(),
Self::List(node) => node.range(),
Self::Tuple(node) => node.range(),
Self::Slice(node) => node.range(),
}
}
}
pub type ExprContext = crate::generic::ExprContext;
pub type Boolop = crate::generic::Boolop;
pub type Operator = crate::generic::Operator;
pub type Unaryop = crate::generic::Unaryop;
pub type Cmpop = crate::generic::Cmpop;
pub type Comprehension = crate::generic::Comprehension<SourceRange>;
#[cfg(feature = "all-nodes-with-ranges")]
impl Located for Comprehension {
fn range(&self) -> SourceRange {
self.range
}
}
pub type Excepthandler = crate::generic::Excepthandler<SourceRange>;
pub type ExcepthandlerExceptHandler = crate::generic::ExcepthandlerExceptHandler<SourceRange>;
impl Located for ExcepthandlerExceptHandler {
fn range(&self) -> SourceRange {
self.range
}
}
impl Located for Excepthandler {
fn range(&self) -> SourceRange {
match self {
Self::ExceptHandler(node) => node.range(),
}
}
}
pub type Arguments = crate::generic::Arguments<SourceRange>;
#[cfg(feature = "all-nodes-with-ranges")]
impl Located for Arguments {
fn range(&self) -> SourceRange {
self.range
}
}
pub type Arg = crate::generic::Arg<SourceRange>;
impl Located for Arg {
fn range(&self) -> SourceRange {
self.range
}
}
pub type Keyword = crate::generic::Keyword<SourceRange>;
impl Located for Keyword {
fn range(&self) -> SourceRange {
self.range
}
}
pub type Alias = crate::generic::Alias<SourceRange>;
impl Located for Alias {
fn range(&self) -> SourceRange {
self.range
}
}
pub type Withitem = crate::generic::Withitem<SourceRange>;
#[cfg(feature = "all-nodes-with-ranges")]
impl Located for Withitem {
fn range(&self) -> SourceRange {
self.range
}
}
pub type MatchCase = crate::generic::MatchCase<SourceRange>;
#[cfg(feature = "all-nodes-with-ranges")]
impl Located for MatchCase {
fn range(&self) -> SourceRange {
self.range
}
}
pub type Pattern = crate::generic::Pattern<SourceRange>;
pub type PatternMatchValue = crate::generic::PatternMatchValue<SourceRange>;
impl Located for PatternMatchValue {
fn range(&self) -> SourceRange {
self.range
}
}
pub type PatternMatchSingleton = crate::generic::PatternMatchSingleton<SourceRange>;
impl Located for PatternMatchSingleton {
fn range(&self) -> SourceRange {
self.range
}
}
pub type PatternMatchSequence = crate::generic::PatternMatchSequence<SourceRange>;
impl Located for PatternMatchSequence {
fn range(&self) -> SourceRange {
self.range
}
}
pub type PatternMatchMapping = crate::generic::PatternMatchMapping<SourceRange>;
impl Located for PatternMatchMapping {
fn range(&self) -> SourceRange {
self.range
}
}
pub type PatternMatchClass = crate::generic::PatternMatchClass<SourceRange>;
impl Located for PatternMatchClass {
fn range(&self) -> SourceRange {
self.range
}
}
pub type PatternMatchStar = crate::generic::PatternMatchStar<SourceRange>;
impl Located for PatternMatchStar {
fn range(&self) -> SourceRange {
self.range
}
}
pub type PatternMatchAs = crate::generic::PatternMatchAs<SourceRange>;
impl Located for PatternMatchAs {
fn range(&self) -> SourceRange {
self.range
}
}
pub type PatternMatchOr = crate::generic::PatternMatchOr<SourceRange>;
impl Located for PatternMatchOr {
fn range(&self) -> SourceRange {
self.range
}
}
impl Located for Pattern {
fn range(&self) -> SourceRange {
match self {
Self::MatchValue(node) => node.range(),
Self::MatchSingleton(node) => node.range(),
Self::MatchSequence(node) => node.range(),
Self::MatchMapping(node) => node.range(),
Self::MatchClass(node) => node.range(),
Self::MatchStar(node) => node.range(),
Self::MatchAs(node) => node.range(),
Self::MatchOr(node) => node.range(),
}
}
}
pub type TypeIgnore = crate::generic::TypeIgnore<SourceRange>;
pub type TypeIgnoreTypeIgnore = crate::generic::TypeIgnoreTypeIgnore<SourceRange>;
#[cfg(feature = "all-nodes-with-ranges")]
impl Located for TypeIgnoreTypeIgnore {
fn range(&self) -> SourceRange {
self.range
}
}
#[cfg(feature = "all-nodes-with-ranges")]
impl Located for TypeIgnore {
fn range(&self) -> SourceRange {
match self {
Self::TypeIgnore(node) => node.range(),
}
}
}

497
ast/src/gen/ranged.rs Normal file
View File

@ -0,0 +1,497 @@
// File automatically generated by ast/asdl_rs.py.
#[cfg(feature = "all-nodes-with-ranges")]
impl Ranged for crate::generic::ModModule<TextRange> {
fn range(&self) -> TextRange {
self.range
}
}
#[cfg(feature = "all-nodes-with-ranges")]
impl Ranged for crate::generic::ModInteractive<TextRange> {
fn range(&self) -> TextRange {
self.range
}
}
#[cfg(feature = "all-nodes-with-ranges")]
impl Ranged for crate::generic::ModExpression<TextRange> {
fn range(&self) -> TextRange {
self.range
}
}
#[cfg(feature = "all-nodes-with-ranges")]
impl Ranged for crate::generic::ModFunctionType<TextRange> {
fn range(&self) -> TextRange {
self.range
}
}
#[cfg(feature = "all-nodes-with-ranges")]
impl Ranged for crate::Mod {
fn range(&self) -> TextRange {
match self {
Self::Module(node) => node.range(),
Self::Interactive(node) => node.range(),
Self::Expression(node) => node.range(),
Self::FunctionType(node) => node.range(),
}
}
}
impl Ranged for crate::generic::StmtFunctionDef<TextRange> {
fn range(&self) -> TextRange {
self.range
}
}
impl Ranged for crate::generic::StmtAsyncFunctionDef<TextRange> {
fn range(&self) -> TextRange {
self.range
}
}
impl Ranged for crate::generic::StmtClassDef<TextRange> {
fn range(&self) -> TextRange {
self.range
}
}
impl Ranged for crate::generic::StmtReturn<TextRange> {
fn range(&self) -> TextRange {
self.range
}
}
impl Ranged for crate::generic::StmtDelete<TextRange> {
fn range(&self) -> TextRange {
self.range
}
}
impl Ranged for crate::generic::StmtAssign<TextRange> {
fn range(&self) -> TextRange {
self.range
}
}
impl Ranged for crate::generic::StmtAugAssign<TextRange> {
fn range(&self) -> TextRange {
self.range
}
}
impl Ranged for crate::generic::StmtAnnAssign<TextRange> {
fn range(&self) -> TextRange {
self.range
}
}
impl Ranged for crate::generic::StmtFor<TextRange> {
fn range(&self) -> TextRange {
self.range
}
}
impl Ranged for crate::generic::StmtAsyncFor<TextRange> {
fn range(&self) -> TextRange {
self.range
}
}
impl Ranged for crate::generic::StmtWhile<TextRange> {
fn range(&self) -> TextRange {
self.range
}
}
impl Ranged for crate::generic::StmtIf<TextRange> {
fn range(&self) -> TextRange {
self.range
}
}
impl Ranged for crate::generic::StmtWith<TextRange> {
fn range(&self) -> TextRange {
self.range
}
}
impl Ranged for crate::generic::StmtAsyncWith<TextRange> {
fn range(&self) -> TextRange {
self.range
}
}
impl Ranged for crate::generic::StmtMatch<TextRange> {
fn range(&self) -> TextRange {
self.range
}
}
impl Ranged for crate::generic::StmtRaise<TextRange> {
fn range(&self) -> TextRange {
self.range
}
}
impl Ranged for crate::generic::StmtTry<TextRange> {
fn range(&self) -> TextRange {
self.range
}
}
impl Ranged for crate::generic::StmtTryStar<TextRange> {
fn range(&self) -> TextRange {
self.range
}
}
impl Ranged for crate::generic::StmtAssert<TextRange> {
fn range(&self) -> TextRange {
self.range
}
}
impl Ranged for crate::generic::StmtImport<TextRange> {
fn range(&self) -> TextRange {
self.range
}
}
impl Ranged for crate::generic::StmtImportFrom<TextRange> {
fn range(&self) -> TextRange {
self.range
}
}
impl Ranged for crate::generic::StmtGlobal<TextRange> {
fn range(&self) -> TextRange {
self.range
}
}
impl Ranged for crate::generic::StmtNonlocal<TextRange> {
fn range(&self) -> TextRange {
self.range
}
}
impl Ranged for crate::generic::StmtExpr<TextRange> {
fn range(&self) -> TextRange {
self.range
}
}
impl Ranged for crate::generic::StmtPass<TextRange> {
fn range(&self) -> TextRange {
self.range
}
}
impl Ranged for crate::generic::StmtBreak<TextRange> {
fn range(&self) -> TextRange {
self.range
}
}
impl Ranged for crate::generic::StmtContinue<TextRange> {
fn range(&self) -> TextRange {
self.range
}
}
impl Ranged for crate::Stmt {
fn range(&self) -> TextRange {
match self {
Self::FunctionDef(node) => node.range(),
Self::AsyncFunctionDef(node) => node.range(),
Self::ClassDef(node) => node.range(),
Self::Return(node) => node.range(),
Self::Delete(node) => node.range(),
Self::Assign(node) => node.range(),
Self::AugAssign(node) => node.range(),
Self::AnnAssign(node) => node.range(),
Self::For(node) => node.range(),
Self::AsyncFor(node) => node.range(),
Self::While(node) => node.range(),
Self::If(node) => node.range(),
Self::With(node) => node.range(),
Self::AsyncWith(node) => node.range(),
Self::Match(node) => node.range(),
Self::Raise(node) => node.range(),
Self::Try(node) => node.range(),
Self::TryStar(node) => node.range(),
Self::Assert(node) => node.range(),
Self::Import(node) => node.range(),
Self::ImportFrom(node) => node.range(),
Self::Global(node) => node.range(),
Self::Nonlocal(node) => node.range(),
Self::Expr(node) => node.range(),
Self::Pass(node) => node.range(),
Self::Break(node) => node.range(),
Self::Continue(node) => node.range(),
}
}
}
impl Ranged for crate::generic::ExprBoolOp<TextRange> {
fn range(&self) -> TextRange {
self.range
}
}
impl Ranged for crate::generic::ExprNamedExpr<TextRange> {
fn range(&self) -> TextRange {
self.range
}
}
impl Ranged for crate::generic::ExprBinOp<TextRange> {
fn range(&self) -> TextRange {
self.range
}
}
impl Ranged for crate::generic::ExprUnaryOp<TextRange> {
fn range(&self) -> TextRange {
self.range
}
}
impl Ranged for crate::generic::ExprLambda<TextRange> {
fn range(&self) -> TextRange {
self.range
}
}
impl Ranged for crate::generic::ExprIfExp<TextRange> {
fn range(&self) -> TextRange {
self.range
}
}
impl Ranged for crate::generic::ExprDict<TextRange> {
fn range(&self) -> TextRange {
self.range
}
}
impl Ranged for crate::generic::ExprSet<TextRange> {
fn range(&self) -> TextRange {
self.range
}
}
impl Ranged for crate::generic::ExprListComp<TextRange> {
fn range(&self) -> TextRange {
self.range
}
}
impl Ranged for crate::generic::ExprSetComp<TextRange> {
fn range(&self) -> TextRange {
self.range
}
}
impl Ranged for crate::generic::ExprDictComp<TextRange> {
fn range(&self) -> TextRange {
self.range
}
}
impl Ranged for crate::generic::ExprGeneratorExp<TextRange> {
fn range(&self) -> TextRange {
self.range
}
}
impl Ranged for crate::generic::ExprAwait<TextRange> {
fn range(&self) -> TextRange {
self.range
}
}
impl Ranged for crate::generic::ExprYield<TextRange> {
fn range(&self) -> TextRange {
self.range
}
}
impl Ranged for crate::generic::ExprYieldFrom<TextRange> {
fn range(&self) -> TextRange {
self.range
}
}
impl Ranged for crate::generic::ExprCompare<TextRange> {
fn range(&self) -> TextRange {
self.range
}
}
impl Ranged for crate::generic::ExprCall<TextRange> {
fn range(&self) -> TextRange {
self.range
}
}
impl Ranged for crate::generic::ExprFormattedValue<TextRange> {
fn range(&self) -> TextRange {
self.range
}
}
impl Ranged for crate::generic::ExprJoinedStr<TextRange> {
fn range(&self) -> TextRange {
self.range
}
}
impl Ranged for crate::generic::ExprConstant<TextRange> {
fn range(&self) -> TextRange {
self.range
}
}
impl Ranged for crate::generic::ExprAttribute<TextRange> {
fn range(&self) -> TextRange {
self.range
}
}
impl Ranged for crate::generic::ExprSubscript<TextRange> {
fn range(&self) -> TextRange {
self.range
}
}
impl Ranged for crate::generic::ExprStarred<TextRange> {
fn range(&self) -> TextRange {
self.range
}
}
impl Ranged for crate::generic::ExprName<TextRange> {
fn range(&self) -> TextRange {
self.range
}
}
impl Ranged for crate::generic::ExprList<TextRange> {
fn range(&self) -> TextRange {
self.range
}
}
impl Ranged for crate::generic::ExprTuple<TextRange> {
fn range(&self) -> TextRange {
self.range
}
}
impl Ranged for crate::generic::ExprSlice<TextRange> {
fn range(&self) -> TextRange {
self.range
}
}
impl Ranged for crate::Expr {
fn range(&self) -> TextRange {
match self {
Self::BoolOp(node) => node.range(),
Self::NamedExpr(node) => node.range(),
Self::BinOp(node) => node.range(),
Self::UnaryOp(node) => node.range(),
Self::Lambda(node) => node.range(),
Self::IfExp(node) => node.range(),
Self::Dict(node) => node.range(),
Self::Set(node) => node.range(),
Self::ListComp(node) => node.range(),
Self::SetComp(node) => node.range(),
Self::DictComp(node) => node.range(),
Self::GeneratorExp(node) => node.range(),
Self::Await(node) => node.range(),
Self::Yield(node) => node.range(),
Self::YieldFrom(node) => node.range(),
Self::Compare(node) => node.range(),
Self::Call(node) => node.range(),
Self::FormattedValue(node) => node.range(),
Self::JoinedStr(node) => node.range(),
Self::Constant(node) => node.range(),
Self::Attribute(node) => node.range(),
Self::Subscript(node) => node.range(),
Self::Starred(node) => node.range(),
Self::Name(node) => node.range(),
Self::List(node) => node.range(),
Self::Tuple(node) => node.range(),
Self::Slice(node) => node.range(),
}
}
}
#[cfg(feature = "all-nodes-with-ranges")]
impl Ranged for crate::generic::Comprehension<TextRange> {
fn range(&self) -> TextRange {
self.range
}
}
impl Ranged for crate::generic::ExcepthandlerExceptHandler<TextRange> {
fn range(&self) -> TextRange {
self.range
}
}
impl Ranged for crate::Excepthandler {
fn range(&self) -> TextRange {
match self {
Self::ExceptHandler(node) => node.range(),
}
}
}
#[cfg(feature = "all-nodes-with-ranges")]
impl Ranged for crate::generic::Arguments<TextRange> {
fn range(&self) -> TextRange {
self.range
}
}
impl Ranged for crate::generic::Arg<TextRange> {
fn range(&self) -> TextRange {
self.range
}
}
impl Ranged for crate::generic::Keyword<TextRange> {
fn range(&self) -> TextRange {
self.range
}
}
impl Ranged for crate::generic::Alias<TextRange> {
fn range(&self) -> TextRange {
self.range
}
}
#[cfg(feature = "all-nodes-with-ranges")]
impl Ranged for crate::generic::Withitem<TextRange> {
fn range(&self) -> TextRange {
self.range
}
}
#[cfg(feature = "all-nodes-with-ranges")]
impl Ranged for crate::generic::MatchCase<TextRange> {
fn range(&self) -> TextRange {
self.range
}
}
impl Ranged for crate::generic::PatternMatchValue<TextRange> {
fn range(&self) -> TextRange {
self.range
}
}
impl Ranged for crate::generic::PatternMatchSingleton<TextRange> {
fn range(&self) -> TextRange {
self.range
}
}
impl Ranged for crate::generic::PatternMatchSequence<TextRange> {
fn range(&self) -> TextRange {
self.range
}
}
impl Ranged for crate::generic::PatternMatchMapping<TextRange> {
fn range(&self) -> TextRange {
self.range
}
}
impl Ranged for crate::generic::PatternMatchClass<TextRange> {
fn range(&self) -> TextRange {
self.range
}
}
impl Ranged for crate::generic::PatternMatchStar<TextRange> {
fn range(&self) -> TextRange {
self.range
}
}
impl Ranged for crate::generic::PatternMatchAs<TextRange> {
fn range(&self) -> TextRange {
self.range
}
}
impl Ranged for crate::generic::PatternMatchOr<TextRange> {
fn range(&self) -> TextRange {
self.range
}
}
impl Ranged for crate::Pattern {
fn range(&self) -> TextRange {
match self {
Self::MatchValue(node) => node.range(),
Self::MatchSingleton(node) => node.range(),
Self::MatchSequence(node) => node.range(),
Self::MatchMapping(node) => node.range(),
Self::MatchClass(node) => node.range(),
Self::MatchStar(node) => node.range(),
Self::MatchAs(node) => node.range(),
Self::MatchOr(node) => node.range(),
}
}
}
#[cfg(feature = "all-nodes-with-ranges")]
impl Ranged for crate::generic::TypeIgnoreTypeIgnore<TextRange> {
fn range(&self) -> TextRange {
self.range
}
}
#[cfg(feature = "all-nodes-with-ranges")]
impl Ranged for crate::TypeIgnore {
fn range(&self) -> TextRange {
match self {
Self::TypeIgnore(node) => node.range(),
}
}
}

View File

@ -1,45 +1,45 @@
// File automatically generated by ast/asdl_rs.py. // File automatically generated by ast/asdl_rs.py.
#[allow(unused_variables, non_snake_case)] #[allow(unused_variables, non_snake_case)]
pub trait Visitor<U = ()> { pub trait Visitor<R = crate::text_size::TextRange> {
fn visit_stmt(&mut self, node: Stmt) { fn visit_stmt(&mut self, node: Stmt<R>) {
self.generic_visit_stmt(node) self.generic_visit_stmt(node)
} }
fn generic_visit_stmt(&mut self, node: Stmt) { fn generic_visit_stmt(&mut self, node: Stmt<R>) {
match node.node { match node {
StmtKind::FunctionDef(data) => self.visit_stmt_FunctionDef(data), Stmt::FunctionDef(data) => self.visit_stmt_FunctionDef(data),
StmtKind::AsyncFunctionDef(data) => self.visit_stmt_AsyncFunctionDef(data), Stmt::AsyncFunctionDef(data) => self.visit_stmt_AsyncFunctionDef(data),
StmtKind::ClassDef(data) => self.visit_stmt_ClassDef(data), Stmt::ClassDef(data) => self.visit_stmt_ClassDef(data),
StmtKind::Return(data) => self.visit_stmt_Return(data), Stmt::Return(data) => self.visit_stmt_Return(data),
StmtKind::Delete(data) => self.visit_stmt_Delete(data), Stmt::Delete(data) => self.visit_stmt_Delete(data),
StmtKind::Assign(data) => self.visit_stmt_Assign(data), Stmt::Assign(data) => self.visit_stmt_Assign(data),
StmtKind::AugAssign(data) => self.visit_stmt_AugAssign(data), Stmt::AugAssign(data) => self.visit_stmt_AugAssign(data),
StmtKind::AnnAssign(data) => self.visit_stmt_AnnAssign(data), Stmt::AnnAssign(data) => self.visit_stmt_AnnAssign(data),
StmtKind::For(data) => self.visit_stmt_For(data), Stmt::For(data) => self.visit_stmt_For(data),
StmtKind::AsyncFor(data) => self.visit_stmt_AsyncFor(data), Stmt::AsyncFor(data) => self.visit_stmt_AsyncFor(data),
StmtKind::While(data) => self.visit_stmt_While(data), Stmt::While(data) => self.visit_stmt_While(data),
StmtKind::If(data) => self.visit_stmt_If(data), Stmt::If(data) => self.visit_stmt_If(data),
StmtKind::With(data) => self.visit_stmt_With(data), Stmt::With(data) => self.visit_stmt_With(data),
StmtKind::AsyncWith(data) => self.visit_stmt_AsyncWith(data), Stmt::AsyncWith(data) => self.visit_stmt_AsyncWith(data),
StmtKind::Match(data) => self.visit_stmt_Match(data), Stmt::Match(data) => self.visit_stmt_Match(data),
StmtKind::Raise(data) => self.visit_stmt_Raise(data), Stmt::Raise(data) => self.visit_stmt_Raise(data),
StmtKind::Try(data) => self.visit_stmt_Try(data), Stmt::Try(data) => self.visit_stmt_Try(data),
StmtKind::TryStar(data) => self.visit_stmt_TryStar(data), Stmt::TryStar(data) => self.visit_stmt_TryStar(data),
StmtKind::Assert(data) => self.visit_stmt_Assert(data), Stmt::Assert(data) => self.visit_stmt_Assert(data),
StmtKind::Import(data) => self.visit_stmt_Import(data), Stmt::Import(data) => self.visit_stmt_Import(data),
StmtKind::ImportFrom(data) => self.visit_stmt_ImportFrom(data), Stmt::ImportFrom(data) => self.visit_stmt_ImportFrom(data),
StmtKind::Global(data) => self.visit_stmt_Global(data), Stmt::Global(data) => self.visit_stmt_Global(data),
StmtKind::Nonlocal(data) => self.visit_stmt_Nonlocal(data), Stmt::Nonlocal(data) => self.visit_stmt_Nonlocal(data),
StmtKind::Expr(data) => self.visit_stmt_Expr(data), Stmt::Expr(data) => self.visit_stmt_Expr(data),
StmtKind::Pass => self.visit_stmt_Pass(()), Stmt::Pass(data) => self.visit_stmt_Pass(data),
StmtKind::Break => self.visit_stmt_Break(()), Stmt::Break(data) => self.visit_stmt_Break(data),
StmtKind::Continue => self.visit_stmt_Continue(()), Stmt::Continue(data) => self.visit_stmt_Continue(data),
} }
} }
fn visit_stmt_FunctionDef(&mut self, node: StmtFunctionDef) { fn visit_stmt_FunctionDef(&mut self, node: StmtFunctionDef<R>) {
self.generic_visit_stmt_FunctionDef(node) self.generic_visit_stmt_FunctionDef(node)
} }
fn generic_visit_stmt_FunctionDef(&mut self, node: StmtFunctionDef) { fn generic_visit_stmt_FunctionDef(&mut self, node: StmtFunctionDef<R>) {
{ {
let value = node.args; let value = node.args;
self.visit_arguments(*value); self.visit_arguments(*value);
@ -54,10 +54,10 @@ pub trait Visitor<U = ()> {
self.visit_expr(*value); self.visit_expr(*value);
} }
} }
fn visit_stmt_AsyncFunctionDef(&mut self, node: StmtAsyncFunctionDef) { fn visit_stmt_AsyncFunctionDef(&mut self, node: StmtAsyncFunctionDef<R>) {
self.generic_visit_stmt_AsyncFunctionDef(node) self.generic_visit_stmt_AsyncFunctionDef(node)
} }
fn generic_visit_stmt_AsyncFunctionDef(&mut self, node: StmtAsyncFunctionDef) { fn generic_visit_stmt_AsyncFunctionDef(&mut self, node: StmtAsyncFunctionDef<R>) {
{ {
let value = node.args; let value = node.args;
self.visit_arguments(*value); self.visit_arguments(*value);
@ -72,10 +72,10 @@ pub trait Visitor<U = ()> {
self.visit_expr(*value); self.visit_expr(*value);
} }
} }
fn visit_stmt_ClassDef(&mut self, node: StmtClassDef) { fn visit_stmt_ClassDef(&mut self, node: StmtClassDef<R>) {
self.generic_visit_stmt_ClassDef(node) self.generic_visit_stmt_ClassDef(node)
} }
fn generic_visit_stmt_ClassDef(&mut self, node: StmtClassDef) { fn generic_visit_stmt_ClassDef(&mut self, node: StmtClassDef<R>) {
for value in node.bases { for value in node.bases {
self.visit_expr(value); self.visit_expr(value);
} }
@ -89,26 +89,26 @@ pub trait Visitor<U = ()> {
self.visit_expr(value); self.visit_expr(value);
} }
} }
fn visit_stmt_Return(&mut self, node: StmtReturn) { fn visit_stmt_Return(&mut self, node: StmtReturn<R>) {
self.generic_visit_stmt_Return(node) self.generic_visit_stmt_Return(node)
} }
fn generic_visit_stmt_Return(&mut self, node: StmtReturn) { fn generic_visit_stmt_Return(&mut self, node: StmtReturn<R>) {
if let Some(value) = node.value { if let Some(value) = node.value {
self.visit_expr(*value); self.visit_expr(*value);
} }
} }
fn visit_stmt_Delete(&mut self, node: StmtDelete) { fn visit_stmt_Delete(&mut self, node: StmtDelete<R>) {
self.generic_visit_stmt_Delete(node) self.generic_visit_stmt_Delete(node)
} }
fn generic_visit_stmt_Delete(&mut self, node: StmtDelete) { fn generic_visit_stmt_Delete(&mut self, node: StmtDelete<R>) {
for value in node.targets { for value in node.targets {
self.visit_expr(value); self.visit_expr(value);
} }
} }
fn visit_stmt_Assign(&mut self, node: StmtAssign) { fn visit_stmt_Assign(&mut self, node: StmtAssign<R>) {
self.generic_visit_stmt_Assign(node) self.generic_visit_stmt_Assign(node)
} }
fn generic_visit_stmt_Assign(&mut self, node: StmtAssign) { fn generic_visit_stmt_Assign(&mut self, node: StmtAssign<R>) {
for value in node.targets { for value in node.targets {
self.visit_expr(value); self.visit_expr(value);
} }
@ -117,10 +117,10 @@ pub trait Visitor<U = ()> {
self.visit_expr(*value); self.visit_expr(*value);
} }
} }
fn visit_stmt_AugAssign(&mut self, node: StmtAugAssign) { fn visit_stmt_AugAssign(&mut self, node: StmtAugAssign<R>) {
self.generic_visit_stmt_AugAssign(node) self.generic_visit_stmt_AugAssign(node)
} }
fn generic_visit_stmt_AugAssign(&mut self, node: StmtAugAssign) { fn generic_visit_stmt_AugAssign(&mut self, node: StmtAugAssign<R>) {
{ {
let value = node.target; let value = node.target;
self.visit_expr(*value); self.visit_expr(*value);
@ -130,10 +130,10 @@ pub trait Visitor<U = ()> {
self.visit_expr(*value); self.visit_expr(*value);
} }
} }
fn visit_stmt_AnnAssign(&mut self, node: StmtAnnAssign) { fn visit_stmt_AnnAssign(&mut self, node: StmtAnnAssign<R>) {
self.generic_visit_stmt_AnnAssign(node) self.generic_visit_stmt_AnnAssign(node)
} }
fn generic_visit_stmt_AnnAssign(&mut self, node: StmtAnnAssign) { fn generic_visit_stmt_AnnAssign(&mut self, node: StmtAnnAssign<R>) {
{ {
let value = node.target; let value = node.target;
self.visit_expr(*value); self.visit_expr(*value);
@ -146,10 +146,10 @@ pub trait Visitor<U = ()> {
self.visit_expr(*value); self.visit_expr(*value);
} }
} }
fn visit_stmt_For(&mut self, node: StmtFor) { fn visit_stmt_For(&mut self, node: StmtFor<R>) {
self.generic_visit_stmt_For(node) self.generic_visit_stmt_For(node)
} }
fn generic_visit_stmt_For(&mut self, node: StmtFor) { fn generic_visit_stmt_For(&mut self, node: StmtFor<R>) {
{ {
let value = node.target; let value = node.target;
self.visit_expr(*value); self.visit_expr(*value);
@ -165,10 +165,10 @@ pub trait Visitor<U = ()> {
self.visit_stmt(value); self.visit_stmt(value);
} }
} }
fn visit_stmt_AsyncFor(&mut self, node: StmtAsyncFor) { fn visit_stmt_AsyncFor(&mut self, node: StmtAsyncFor<R>) {
self.generic_visit_stmt_AsyncFor(node) self.generic_visit_stmt_AsyncFor(node)
} }
fn generic_visit_stmt_AsyncFor(&mut self, node: StmtAsyncFor) { fn generic_visit_stmt_AsyncFor(&mut self, node: StmtAsyncFor<R>) {
{ {
let value = node.target; let value = node.target;
self.visit_expr(*value); self.visit_expr(*value);
@ -184,10 +184,10 @@ pub trait Visitor<U = ()> {
self.visit_stmt(value); self.visit_stmt(value);
} }
} }
fn visit_stmt_While(&mut self, node: StmtWhile) { fn visit_stmt_While(&mut self, node: StmtWhile<R>) {
self.generic_visit_stmt_While(node) self.generic_visit_stmt_While(node)
} }
fn generic_visit_stmt_While(&mut self, node: StmtWhile) { fn generic_visit_stmt_While(&mut self, node: StmtWhile<R>) {
{ {
let value = node.test; let value = node.test;
self.visit_expr(*value); self.visit_expr(*value);
@ -199,10 +199,10 @@ pub trait Visitor<U = ()> {
self.visit_stmt(value); self.visit_stmt(value);
} }
} }
fn visit_stmt_If(&mut self, node: StmtIf) { fn visit_stmt_If(&mut self, node: StmtIf<R>) {
self.generic_visit_stmt_If(node) self.generic_visit_stmt_If(node)
} }
fn generic_visit_stmt_If(&mut self, node: StmtIf) { fn generic_visit_stmt_If(&mut self, node: StmtIf<R>) {
{ {
let value = node.test; let value = node.test;
self.visit_expr(*value); self.visit_expr(*value);
@ -214,10 +214,10 @@ pub trait Visitor<U = ()> {
self.visit_stmt(value); self.visit_stmt(value);
} }
} }
fn visit_stmt_With(&mut self, node: StmtWith) { fn visit_stmt_With(&mut self, node: StmtWith<R>) {
self.generic_visit_stmt_With(node) self.generic_visit_stmt_With(node)
} }
fn generic_visit_stmt_With(&mut self, node: StmtWith) { fn generic_visit_stmt_With(&mut self, node: StmtWith<R>) {
for value in node.items { for value in node.items {
self.visit_withitem(value); self.visit_withitem(value);
} }
@ -225,10 +225,10 @@ pub trait Visitor<U = ()> {
self.visit_stmt(value); self.visit_stmt(value);
} }
} }
fn visit_stmt_AsyncWith(&mut self, node: StmtAsyncWith) { fn visit_stmt_AsyncWith(&mut self, node: StmtAsyncWith<R>) {
self.generic_visit_stmt_AsyncWith(node) self.generic_visit_stmt_AsyncWith(node)
} }
fn generic_visit_stmt_AsyncWith(&mut self, node: StmtAsyncWith) { fn generic_visit_stmt_AsyncWith(&mut self, node: StmtAsyncWith<R>) {
for value in node.items { for value in node.items {
self.visit_withitem(value); self.visit_withitem(value);
} }
@ -236,10 +236,10 @@ pub trait Visitor<U = ()> {
self.visit_stmt(value); self.visit_stmt(value);
} }
} }
fn visit_stmt_Match(&mut self, node: StmtMatch) { fn visit_stmt_Match(&mut self, node: StmtMatch<R>) {
self.generic_visit_stmt_Match(node) self.generic_visit_stmt_Match(node)
} }
fn generic_visit_stmt_Match(&mut self, node: StmtMatch) { fn generic_visit_stmt_Match(&mut self, node: StmtMatch<R>) {
{ {
let value = node.subject; let value = node.subject;
self.visit_expr(*value); self.visit_expr(*value);
@ -248,10 +248,10 @@ pub trait Visitor<U = ()> {
self.visit_match_case(value); self.visit_match_case(value);
} }
} }
fn visit_stmt_Raise(&mut self, node: StmtRaise) { fn visit_stmt_Raise(&mut self, node: StmtRaise<R>) {
self.generic_visit_stmt_Raise(node) self.generic_visit_stmt_Raise(node)
} }
fn generic_visit_stmt_Raise(&mut self, node: StmtRaise) { fn generic_visit_stmt_Raise(&mut self, node: StmtRaise<R>) {
if let Some(value) = node.exc { if let Some(value) = node.exc {
self.visit_expr(*value); self.visit_expr(*value);
} }
@ -259,10 +259,10 @@ pub trait Visitor<U = ()> {
self.visit_expr(*value); self.visit_expr(*value);
} }
} }
fn visit_stmt_Try(&mut self, node: StmtTry) { fn visit_stmt_Try(&mut self, node: StmtTry<R>) {
self.generic_visit_stmt_Try(node) self.generic_visit_stmt_Try(node)
} }
fn generic_visit_stmt_Try(&mut self, node: StmtTry) { fn generic_visit_stmt_Try(&mut self, node: StmtTry<R>) {
for value in node.body { for value in node.body {
self.visit_stmt(value); self.visit_stmt(value);
} }
@ -276,10 +276,10 @@ pub trait Visitor<U = ()> {
self.visit_stmt(value); self.visit_stmt(value);
} }
} }
fn visit_stmt_TryStar(&mut self, node: StmtTryStar) { fn visit_stmt_TryStar(&mut self, node: StmtTryStar<R>) {
self.generic_visit_stmt_TryStar(node) self.generic_visit_stmt_TryStar(node)
} }
fn generic_visit_stmt_TryStar(&mut self, node: StmtTryStar) { fn generic_visit_stmt_TryStar(&mut self, node: StmtTryStar<R>) {
for value in node.body { for value in node.body {
self.visit_stmt(value); self.visit_stmt(value);
} }
@ -293,10 +293,10 @@ pub trait Visitor<U = ()> {
self.visit_stmt(value); self.visit_stmt(value);
} }
} }
fn visit_stmt_Assert(&mut self, node: StmtAssert) { fn visit_stmt_Assert(&mut self, node: StmtAssert<R>) {
self.generic_visit_stmt_Assert(node) self.generic_visit_stmt_Assert(node)
} }
fn generic_visit_stmt_Assert(&mut self, node: StmtAssert) { fn generic_visit_stmt_Assert(&mut self, node: StmtAssert<R>) {
{ {
let value = node.test; let value = node.test;
self.visit_expr(*value); self.visit_expr(*value);
@ -305,97 +305,88 @@ pub trait Visitor<U = ()> {
self.visit_expr(*value); self.visit_expr(*value);
} }
} }
fn visit_stmt_Import(&mut self, node: StmtImport) { fn visit_stmt_Import(&mut self, node: StmtImport<R>) {
self.generic_visit_stmt_Import(node) self.generic_visit_stmt_Import(node)
} }
fn generic_visit_stmt_Import(&mut self, node: StmtImport) { fn generic_visit_stmt_Import(&mut self, node: StmtImport<R>) {
for value in node.names { for value in node.names {
self.visit_alias(value); self.visit_alias(value);
} }
} }
fn visit_stmt_ImportFrom(&mut self, node: StmtImportFrom) { fn visit_stmt_ImportFrom(&mut self, node: StmtImportFrom<R>) {
self.generic_visit_stmt_ImportFrom(node) self.generic_visit_stmt_ImportFrom(node)
} }
fn generic_visit_stmt_ImportFrom(&mut self, node: StmtImportFrom) { fn generic_visit_stmt_ImportFrom(&mut self, node: StmtImportFrom<R>) {
for value in node.names { for value in node.names {
self.visit_alias(value); self.visit_alias(value);
} }
} }
fn visit_stmt_Global(&mut self, node: StmtGlobal) { fn visit_stmt_Global(&mut self, node: StmtGlobal<R>) {
self.generic_visit_stmt_Global(node) self.generic_visit_stmt_Global(node)
} }
fn generic_visit_stmt_Global(&mut self, node: StmtGlobal) {} fn generic_visit_stmt_Global(&mut self, node: StmtGlobal<R>) {}
fn visit_stmt_Nonlocal(&mut self, node: StmtNonlocal) { fn visit_stmt_Nonlocal(&mut self, node: StmtNonlocal<R>) {
self.generic_visit_stmt_Nonlocal(node) self.generic_visit_stmt_Nonlocal(node)
} }
fn generic_visit_stmt_Nonlocal(&mut self, node: StmtNonlocal) {} fn generic_visit_stmt_Nonlocal(&mut self, node: StmtNonlocal<R>) {}
fn visit_stmt_Expr(&mut self, node: StmtExpr) { fn visit_stmt_Expr(&mut self, node: StmtExpr<R>) {
self.generic_visit_stmt_Expr(node) self.generic_visit_stmt_Expr(node)
} }
fn generic_visit_stmt_Expr(&mut self, node: StmtExpr) { fn generic_visit_stmt_Expr(&mut self, node: StmtExpr<R>) {
{ {
let value = node.value; let value = node.value;
self.visit_expr(*value); self.visit_expr(*value);
} }
} }
fn visit_stmt_Pass(&mut self, node: ()) { fn visit_stmt_Pass(&mut self, node: StmtPass<R>) {}
self.generic_visit_stmt_Pass(()) fn visit_stmt_Break(&mut self, node: StmtBreak<R>) {}
} fn visit_stmt_Continue(&mut self, node: StmtContinue<R>) {}
fn generic_visit_stmt_Pass(&mut self, node: ()) {} fn visit_expr(&mut self, node: Expr<R>) {
fn visit_stmt_Break(&mut self, node: ()) {
self.generic_visit_stmt_Break(())
}
fn generic_visit_stmt_Break(&mut self, node: ()) {}
fn visit_stmt_Continue(&mut self, node: ()) {
self.generic_visit_stmt_Continue(())
}
fn generic_visit_stmt_Continue(&mut self, node: ()) {}
fn visit_expr(&mut self, node: Expr) {
self.generic_visit_expr(node) self.generic_visit_expr(node)
} }
fn generic_visit_expr(&mut self, node: Expr) { fn generic_visit_expr(&mut self, node: Expr<R>) {
match node.node { match node {
ExprKind::BoolOp(data) => self.visit_expr_BoolOp(data), Expr::BoolOp(data) => self.visit_expr_BoolOp(data),
ExprKind::NamedExpr(data) => self.visit_expr_NamedExpr(data), Expr::NamedExpr(data) => self.visit_expr_NamedExpr(data),
ExprKind::BinOp(data) => self.visit_expr_BinOp(data), Expr::BinOp(data) => self.visit_expr_BinOp(data),
ExprKind::UnaryOp(data) => self.visit_expr_UnaryOp(data), Expr::UnaryOp(data) => self.visit_expr_UnaryOp(data),
ExprKind::Lambda(data) => self.visit_expr_Lambda(data), Expr::Lambda(data) => self.visit_expr_Lambda(data),
ExprKind::IfExp(data) => self.visit_expr_IfExp(data), Expr::IfExp(data) => self.visit_expr_IfExp(data),
ExprKind::Dict(data) => self.visit_expr_Dict(data), Expr::Dict(data) => self.visit_expr_Dict(data),
ExprKind::Set(data) => self.visit_expr_Set(data), Expr::Set(data) => self.visit_expr_Set(data),
ExprKind::ListComp(data) => self.visit_expr_ListComp(data), Expr::ListComp(data) => self.visit_expr_ListComp(data),
ExprKind::SetComp(data) => self.visit_expr_SetComp(data), Expr::SetComp(data) => self.visit_expr_SetComp(data),
ExprKind::DictComp(data) => self.visit_expr_DictComp(data), Expr::DictComp(data) => self.visit_expr_DictComp(data),
ExprKind::GeneratorExp(data) => self.visit_expr_GeneratorExp(data), Expr::GeneratorExp(data) => self.visit_expr_GeneratorExp(data),
ExprKind::Await(data) => self.visit_expr_Await(data), Expr::Await(data) => self.visit_expr_Await(data),
ExprKind::Yield(data) => self.visit_expr_Yield(data), Expr::Yield(data) => self.visit_expr_Yield(data),
ExprKind::YieldFrom(data) => self.visit_expr_YieldFrom(data), Expr::YieldFrom(data) => self.visit_expr_YieldFrom(data),
ExprKind::Compare(data) => self.visit_expr_Compare(data), Expr::Compare(data) => self.visit_expr_Compare(data),
ExprKind::Call(data) => self.visit_expr_Call(data), Expr::Call(data) => self.visit_expr_Call(data),
ExprKind::FormattedValue(data) => self.visit_expr_FormattedValue(data), Expr::FormattedValue(data) => self.visit_expr_FormattedValue(data),
ExprKind::JoinedStr(data) => self.visit_expr_JoinedStr(data), Expr::JoinedStr(data) => self.visit_expr_JoinedStr(data),
ExprKind::Constant(data) => self.visit_expr_Constant(data), Expr::Constant(data) => self.visit_expr_Constant(data),
ExprKind::Attribute(data) => self.visit_expr_Attribute(data), Expr::Attribute(data) => self.visit_expr_Attribute(data),
ExprKind::Subscript(data) => self.visit_expr_Subscript(data), Expr::Subscript(data) => self.visit_expr_Subscript(data),
ExprKind::Starred(data) => self.visit_expr_Starred(data), Expr::Starred(data) => self.visit_expr_Starred(data),
ExprKind::Name(data) => self.visit_expr_Name(data), Expr::Name(data) => self.visit_expr_Name(data),
ExprKind::List(data) => self.visit_expr_List(data), Expr::List(data) => self.visit_expr_List(data),
ExprKind::Tuple(data) => self.visit_expr_Tuple(data), Expr::Tuple(data) => self.visit_expr_Tuple(data),
ExprKind::Slice(data) => self.visit_expr_Slice(data), Expr::Slice(data) => self.visit_expr_Slice(data),
} }
} }
fn visit_expr_BoolOp(&mut self, node: ExprBoolOp) { fn visit_expr_BoolOp(&mut self, node: ExprBoolOp<R>) {
self.generic_visit_expr_BoolOp(node) self.generic_visit_expr_BoolOp(node)
} }
fn generic_visit_expr_BoolOp(&mut self, node: ExprBoolOp) { fn generic_visit_expr_BoolOp(&mut self, node: ExprBoolOp<R>) {
for value in node.values { for value in node.values {
self.visit_expr(value); self.visit_expr(value);
} }
} }
fn visit_expr_NamedExpr(&mut self, node: ExprNamedExpr) { fn visit_expr_NamedExpr(&mut self, node: ExprNamedExpr<R>) {
self.generic_visit_expr_NamedExpr(node) self.generic_visit_expr_NamedExpr(node)
} }
fn generic_visit_expr_NamedExpr(&mut self, node: ExprNamedExpr) { fn generic_visit_expr_NamedExpr(&mut self, node: ExprNamedExpr<R>) {
{ {
let value = node.target; let value = node.target;
self.visit_expr(*value); self.visit_expr(*value);
@ -405,10 +396,10 @@ pub trait Visitor<U = ()> {
self.visit_expr(*value); self.visit_expr(*value);
} }
} }
fn visit_expr_BinOp(&mut self, node: ExprBinOp) { fn visit_expr_BinOp(&mut self, node: ExprBinOp<R>) {
self.generic_visit_expr_BinOp(node) self.generic_visit_expr_BinOp(node)
} }
fn generic_visit_expr_BinOp(&mut self, node: ExprBinOp) { fn generic_visit_expr_BinOp(&mut self, node: ExprBinOp<R>) {
{ {
let value = node.left; let value = node.left;
self.visit_expr(*value); self.visit_expr(*value);
@ -418,19 +409,19 @@ pub trait Visitor<U = ()> {
self.visit_expr(*value); self.visit_expr(*value);
} }
} }
fn visit_expr_UnaryOp(&mut self, node: ExprUnaryOp) { fn visit_expr_UnaryOp(&mut self, node: ExprUnaryOp<R>) {
self.generic_visit_expr_UnaryOp(node) self.generic_visit_expr_UnaryOp(node)
} }
fn generic_visit_expr_UnaryOp(&mut self, node: ExprUnaryOp) { fn generic_visit_expr_UnaryOp(&mut self, node: ExprUnaryOp<R>) {
{ {
let value = node.operand; let value = node.operand;
self.visit_expr(*value); self.visit_expr(*value);
} }
} }
fn visit_expr_Lambda(&mut self, node: ExprLambda) { fn visit_expr_Lambda(&mut self, node: ExprLambda<R>) {
self.generic_visit_expr_Lambda(node) self.generic_visit_expr_Lambda(node)
} }
fn generic_visit_expr_Lambda(&mut self, node: ExprLambda) { fn generic_visit_expr_Lambda(&mut self, node: ExprLambda<R>) {
{ {
let value = node.args; let value = node.args;
self.visit_arguments(*value); self.visit_arguments(*value);
@ -440,10 +431,10 @@ pub trait Visitor<U = ()> {
self.visit_expr(*value); self.visit_expr(*value);
} }
} }
fn visit_expr_IfExp(&mut self, node: ExprIfExp) { fn visit_expr_IfExp(&mut self, node: ExprIfExp<R>) {
self.generic_visit_expr_IfExp(node) self.generic_visit_expr_IfExp(node)
} }
fn generic_visit_expr_IfExp(&mut self, node: ExprIfExp) { fn generic_visit_expr_IfExp(&mut self, node: ExprIfExp<R>) {
{ {
let value = node.test; let value = node.test;
self.visit_expr(*value); self.visit_expr(*value);
@ -457,10 +448,10 @@ pub trait Visitor<U = ()> {
self.visit_expr(*value); self.visit_expr(*value);
} }
} }
fn visit_expr_Dict(&mut self, node: ExprDict) { fn visit_expr_Dict(&mut self, node: ExprDict<R>) {
self.generic_visit_expr_Dict(node) self.generic_visit_expr_Dict(node)
} }
fn generic_visit_expr_Dict(&mut self, node: ExprDict) { fn generic_visit_expr_Dict(&mut self, node: ExprDict<R>) {
for value in node.keys.into_iter().flatten() { for value in node.keys.into_iter().flatten() {
self.visit_expr(value); self.visit_expr(value);
} }
@ -468,18 +459,18 @@ pub trait Visitor<U = ()> {
self.visit_expr(value); self.visit_expr(value);
} }
} }
fn visit_expr_Set(&mut self, node: ExprSet) { fn visit_expr_Set(&mut self, node: ExprSet<R>) {
self.generic_visit_expr_Set(node) self.generic_visit_expr_Set(node)
} }
fn generic_visit_expr_Set(&mut self, node: ExprSet) { fn generic_visit_expr_Set(&mut self, node: ExprSet<R>) {
for value in node.elts { for value in node.elts {
self.visit_expr(value); self.visit_expr(value);
} }
} }
fn visit_expr_ListComp(&mut self, node: ExprListComp) { fn visit_expr_ListComp(&mut self, node: ExprListComp<R>) {
self.generic_visit_expr_ListComp(node) self.generic_visit_expr_ListComp(node)
} }
fn generic_visit_expr_ListComp(&mut self, node: ExprListComp) { fn generic_visit_expr_ListComp(&mut self, node: ExprListComp<R>) {
{ {
let value = node.elt; let value = node.elt;
self.visit_expr(*value); self.visit_expr(*value);
@ -488,10 +479,10 @@ pub trait Visitor<U = ()> {
self.visit_comprehension(value); self.visit_comprehension(value);
} }
} }
fn visit_expr_SetComp(&mut self, node: ExprSetComp) { fn visit_expr_SetComp(&mut self, node: ExprSetComp<R>) {
self.generic_visit_expr_SetComp(node) self.generic_visit_expr_SetComp(node)
} }
fn generic_visit_expr_SetComp(&mut self, node: ExprSetComp) { fn generic_visit_expr_SetComp(&mut self, node: ExprSetComp<R>) {
{ {
let value = node.elt; let value = node.elt;
self.visit_expr(*value); self.visit_expr(*value);
@ -500,10 +491,10 @@ pub trait Visitor<U = ()> {
self.visit_comprehension(value); self.visit_comprehension(value);
} }
} }
fn visit_expr_DictComp(&mut self, node: ExprDictComp) { fn visit_expr_DictComp(&mut self, node: ExprDictComp<R>) {
self.generic_visit_expr_DictComp(node) self.generic_visit_expr_DictComp(node)
} }
fn generic_visit_expr_DictComp(&mut self, node: ExprDictComp) { fn generic_visit_expr_DictComp(&mut self, node: ExprDictComp<R>) {
{ {
let value = node.key; let value = node.key;
self.visit_expr(*value); self.visit_expr(*value);
@ -516,10 +507,10 @@ pub trait Visitor<U = ()> {
self.visit_comprehension(value); self.visit_comprehension(value);
} }
} }
fn visit_expr_GeneratorExp(&mut self, node: ExprGeneratorExp) { fn visit_expr_GeneratorExp(&mut self, node: ExprGeneratorExp<R>) {
self.generic_visit_expr_GeneratorExp(node) self.generic_visit_expr_GeneratorExp(node)
} }
fn generic_visit_expr_GeneratorExp(&mut self, node: ExprGeneratorExp) { fn generic_visit_expr_GeneratorExp(&mut self, node: ExprGeneratorExp<R>) {
{ {
let value = node.elt; let value = node.elt;
self.visit_expr(*value); self.visit_expr(*value);
@ -528,36 +519,36 @@ pub trait Visitor<U = ()> {
self.visit_comprehension(value); self.visit_comprehension(value);
} }
} }
fn visit_expr_Await(&mut self, node: ExprAwait) { fn visit_expr_Await(&mut self, node: ExprAwait<R>) {
self.generic_visit_expr_Await(node) self.generic_visit_expr_Await(node)
} }
fn generic_visit_expr_Await(&mut self, node: ExprAwait) { fn generic_visit_expr_Await(&mut self, node: ExprAwait<R>) {
{ {
let value = node.value; let value = node.value;
self.visit_expr(*value); self.visit_expr(*value);
} }
} }
fn visit_expr_Yield(&mut self, node: ExprYield) { fn visit_expr_Yield(&mut self, node: ExprYield<R>) {
self.generic_visit_expr_Yield(node) self.generic_visit_expr_Yield(node)
} }
fn generic_visit_expr_Yield(&mut self, node: ExprYield) { fn generic_visit_expr_Yield(&mut self, node: ExprYield<R>) {
if let Some(value) = node.value { if let Some(value) = node.value {
self.visit_expr(*value); self.visit_expr(*value);
} }
} }
fn visit_expr_YieldFrom(&mut self, node: ExprYieldFrom) { fn visit_expr_YieldFrom(&mut self, node: ExprYieldFrom<R>) {
self.generic_visit_expr_YieldFrom(node) self.generic_visit_expr_YieldFrom(node)
} }
fn generic_visit_expr_YieldFrom(&mut self, node: ExprYieldFrom) { fn generic_visit_expr_YieldFrom(&mut self, node: ExprYieldFrom<R>) {
{ {
let value = node.value; let value = node.value;
self.visit_expr(*value); self.visit_expr(*value);
} }
} }
fn visit_expr_Compare(&mut self, node: ExprCompare) { fn visit_expr_Compare(&mut self, node: ExprCompare<R>) {
self.generic_visit_expr_Compare(node) self.generic_visit_expr_Compare(node)
} }
fn generic_visit_expr_Compare(&mut self, node: ExprCompare) { fn generic_visit_expr_Compare(&mut self, node: ExprCompare<R>) {
{ {
let value = node.left; let value = node.left;
self.visit_expr(*value); self.visit_expr(*value);
@ -566,10 +557,10 @@ pub trait Visitor<U = ()> {
self.visit_expr(value); self.visit_expr(value);
} }
} }
fn visit_expr_Call(&mut self, node: ExprCall) { fn visit_expr_Call(&mut self, node: ExprCall<R>) {
self.generic_visit_expr_Call(node) self.generic_visit_expr_Call(node)
} }
fn generic_visit_expr_Call(&mut self, node: ExprCall) { fn generic_visit_expr_Call(&mut self, node: ExprCall<R>) {
{ {
let value = node.func; let value = node.func;
self.visit_expr(*value); self.visit_expr(*value);
@ -581,10 +572,10 @@ pub trait Visitor<U = ()> {
self.visit_keyword(value); self.visit_keyword(value);
} }
} }
fn visit_expr_FormattedValue(&mut self, node: ExprFormattedValue) { fn visit_expr_FormattedValue(&mut self, node: ExprFormattedValue<R>) {
self.generic_visit_expr_FormattedValue(node) self.generic_visit_expr_FormattedValue(node)
} }
fn generic_visit_expr_FormattedValue(&mut self, node: ExprFormattedValue) { fn generic_visit_expr_FormattedValue(&mut self, node: ExprFormattedValue<R>) {
{ {
let value = node.value; let value = node.value;
self.visit_expr(*value); self.visit_expr(*value);
@ -593,31 +584,31 @@ pub trait Visitor<U = ()> {
self.visit_expr(*value); self.visit_expr(*value);
} }
} }
fn visit_expr_JoinedStr(&mut self, node: ExprJoinedStr) { fn visit_expr_JoinedStr(&mut self, node: ExprJoinedStr<R>) {
self.generic_visit_expr_JoinedStr(node) self.generic_visit_expr_JoinedStr(node)
} }
fn generic_visit_expr_JoinedStr(&mut self, node: ExprJoinedStr) { fn generic_visit_expr_JoinedStr(&mut self, node: ExprJoinedStr<R>) {
for value in node.values { for value in node.values {
self.visit_expr(value); self.visit_expr(value);
} }
} }
fn visit_expr_Constant(&mut self, node: ExprConstant) { fn visit_expr_Constant(&mut self, node: ExprConstant<R>) {
self.generic_visit_expr_Constant(node) self.generic_visit_expr_Constant(node)
} }
fn generic_visit_expr_Constant(&mut self, node: ExprConstant) {} fn generic_visit_expr_Constant(&mut self, node: ExprConstant<R>) {}
fn visit_expr_Attribute(&mut self, node: ExprAttribute) { fn visit_expr_Attribute(&mut self, node: ExprAttribute<R>) {
self.generic_visit_expr_Attribute(node) self.generic_visit_expr_Attribute(node)
} }
fn generic_visit_expr_Attribute(&mut self, node: ExprAttribute) { fn generic_visit_expr_Attribute(&mut self, node: ExprAttribute<R>) {
{ {
let value = node.value; let value = node.value;
self.visit_expr(*value); self.visit_expr(*value);
} }
} }
fn visit_expr_Subscript(&mut self, node: ExprSubscript) { fn visit_expr_Subscript(&mut self, node: ExprSubscript<R>) {
self.generic_visit_expr_Subscript(node) self.generic_visit_expr_Subscript(node)
} }
fn generic_visit_expr_Subscript(&mut self, node: ExprSubscript) { fn generic_visit_expr_Subscript(&mut self, node: ExprSubscript<R>) {
{ {
let value = node.value; let value = node.value;
self.visit_expr(*value); self.visit_expr(*value);
@ -627,39 +618,39 @@ pub trait Visitor<U = ()> {
self.visit_expr(*value); self.visit_expr(*value);
} }
} }
fn visit_expr_Starred(&mut self, node: ExprStarred) { fn visit_expr_Starred(&mut self, node: ExprStarred<R>) {
self.generic_visit_expr_Starred(node) self.generic_visit_expr_Starred(node)
} }
fn generic_visit_expr_Starred(&mut self, node: ExprStarred) { fn generic_visit_expr_Starred(&mut self, node: ExprStarred<R>) {
{ {
let value = node.value; let value = node.value;
self.visit_expr(*value); self.visit_expr(*value);
} }
} }
fn visit_expr_Name(&mut self, node: ExprName) { fn visit_expr_Name(&mut self, node: ExprName<R>) {
self.generic_visit_expr_Name(node) self.generic_visit_expr_Name(node)
} }
fn generic_visit_expr_Name(&mut self, node: ExprName) {} fn generic_visit_expr_Name(&mut self, node: ExprName<R>) {}
fn visit_expr_List(&mut self, node: ExprList) { fn visit_expr_List(&mut self, node: ExprList<R>) {
self.generic_visit_expr_List(node) self.generic_visit_expr_List(node)
} }
fn generic_visit_expr_List(&mut self, node: ExprList) { fn generic_visit_expr_List(&mut self, node: ExprList<R>) {
for value in node.elts { for value in node.elts {
self.visit_expr(value); self.visit_expr(value);
} }
} }
fn visit_expr_Tuple(&mut self, node: ExprTuple) { fn visit_expr_Tuple(&mut self, node: ExprTuple<R>) {
self.generic_visit_expr_Tuple(node) self.generic_visit_expr_Tuple(node)
} }
fn generic_visit_expr_Tuple(&mut self, node: ExprTuple) { fn generic_visit_expr_Tuple(&mut self, node: ExprTuple<R>) {
for value in node.elts { for value in node.elts {
self.visit_expr(value); self.visit_expr(value);
} }
} }
fn visit_expr_Slice(&mut self, node: ExprSlice) { fn visit_expr_Slice(&mut self, node: ExprSlice<R>) {
self.generic_visit_expr_Slice(node) self.generic_visit_expr_Slice(node)
} }
fn generic_visit_expr_Slice(&mut self, node: ExprSlice) { fn generic_visit_expr_Slice(&mut self, node: ExprSlice<R>) {
if let Some(value) = node.lower { if let Some(value) = node.lower {
self.visit_expr(*value); self.visit_expr(*value);
} }
@ -690,22 +681,22 @@ pub trait Visitor<U = ()> {
self.generic_visit_cmpop(node) self.generic_visit_cmpop(node)
} }
fn generic_visit_cmpop(&mut self, node: Cmpop) {} fn generic_visit_cmpop(&mut self, node: Cmpop) {}
fn visit_comprehension(&mut self, node: Comprehension) { fn visit_comprehension(&mut self, node: Comprehension<R>) {
self.generic_visit_comprehension(node) self.generic_visit_comprehension(node)
} }
fn generic_visit_comprehension(&mut self, node: Comprehension) {} fn generic_visit_comprehension(&mut self, node: Comprehension<R>) {}
fn visit_excepthandler(&mut self, node: Excepthandler) { fn visit_excepthandler(&mut self, node: Excepthandler<R>) {
self.generic_visit_excepthandler(node) self.generic_visit_excepthandler(node)
} }
fn generic_visit_excepthandler(&mut self, node: Excepthandler) { fn generic_visit_excepthandler(&mut self, node: Excepthandler<R>) {
match node.node { match node {
ExcepthandlerKind::ExceptHandler(data) => self.visit_excepthandler_ExceptHandler(data), Excepthandler::ExceptHandler(data) => self.visit_excepthandler_ExceptHandler(data),
} }
} }
fn visit_excepthandler_ExceptHandler(&mut self, node: ExcepthandlerExceptHandler) { fn visit_excepthandler_ExceptHandler(&mut self, node: ExcepthandlerExceptHandler<R>) {
self.generic_visit_excepthandler_ExceptHandler(node) self.generic_visit_excepthandler_ExceptHandler(node)
} }
fn generic_visit_excepthandler_ExceptHandler(&mut self, node: ExcepthandlerExceptHandler) { fn generic_visit_excepthandler_ExceptHandler(&mut self, node: ExcepthandlerExceptHandler<R>) {
if let Some(value) = node.type_ { if let Some(value) = node.type_ {
self.visit_expr(*value); self.visit_expr(*value);
} }
@ -713,70 +704,70 @@ pub trait Visitor<U = ()> {
self.visit_stmt(value); self.visit_stmt(value);
} }
} }
fn visit_arguments(&mut self, node: Arguments) { fn visit_arguments(&mut self, node: Arguments<R>) {
self.generic_visit_arguments(node) self.generic_visit_arguments(node)
} }
fn generic_visit_arguments(&mut self, node: Arguments) {} fn generic_visit_arguments(&mut self, node: Arguments<R>) {}
fn visit_arg(&mut self, node: Arg) { fn visit_arg(&mut self, node: Arg<R>) {
self.generic_visit_arg(node) self.generic_visit_arg(node)
} }
fn generic_visit_arg(&mut self, node: Arg) {} fn generic_visit_arg(&mut self, node: Arg<R>) {}
fn visit_keyword(&mut self, node: Keyword) { fn visit_keyword(&mut self, node: Keyword<R>) {
self.generic_visit_keyword(node) self.generic_visit_keyword(node)
} }
fn generic_visit_keyword(&mut self, node: Keyword) {} fn generic_visit_keyword(&mut self, node: Keyword<R>) {}
fn visit_alias(&mut self, node: Alias) { fn visit_alias(&mut self, node: Alias<R>) {
self.generic_visit_alias(node) self.generic_visit_alias(node)
} }
fn generic_visit_alias(&mut self, node: Alias) {} fn generic_visit_alias(&mut self, node: Alias<R>) {}
fn visit_withitem(&mut self, node: Withitem) { fn visit_withitem(&mut self, node: Withitem<R>) {
self.generic_visit_withitem(node) self.generic_visit_withitem(node)
} }
fn generic_visit_withitem(&mut self, node: Withitem) {} fn generic_visit_withitem(&mut self, node: Withitem<R>) {}
fn visit_match_case(&mut self, node: MatchCase) { fn visit_match_case(&mut self, node: MatchCase<R>) {
self.generic_visit_match_case(node) self.generic_visit_match_case(node)
} }
fn generic_visit_match_case(&mut self, node: MatchCase) {} fn generic_visit_match_case(&mut self, node: MatchCase<R>) {}
fn visit_pattern(&mut self, node: Pattern) { fn visit_pattern(&mut self, node: Pattern<R>) {
self.generic_visit_pattern(node) self.generic_visit_pattern(node)
} }
fn generic_visit_pattern(&mut self, node: Pattern) { fn generic_visit_pattern(&mut self, node: Pattern<R>) {
match node.node { match node {
PatternKind::MatchValue(data) => self.visit_pattern_MatchValue(data), Pattern::MatchValue(data) => self.visit_pattern_MatchValue(data),
PatternKind::MatchSingleton(data) => self.visit_pattern_MatchSingleton(data), Pattern::MatchSingleton(data) => self.visit_pattern_MatchSingleton(data),
PatternKind::MatchSequence(data) => self.visit_pattern_MatchSequence(data), Pattern::MatchSequence(data) => self.visit_pattern_MatchSequence(data),
PatternKind::MatchMapping(data) => self.visit_pattern_MatchMapping(data), Pattern::MatchMapping(data) => self.visit_pattern_MatchMapping(data),
PatternKind::MatchClass(data) => self.visit_pattern_MatchClass(data), Pattern::MatchClass(data) => self.visit_pattern_MatchClass(data),
PatternKind::MatchStar(data) => self.visit_pattern_MatchStar(data), Pattern::MatchStar(data) => self.visit_pattern_MatchStar(data),
PatternKind::MatchAs(data) => self.visit_pattern_MatchAs(data), Pattern::MatchAs(data) => self.visit_pattern_MatchAs(data),
PatternKind::MatchOr(data) => self.visit_pattern_MatchOr(data), Pattern::MatchOr(data) => self.visit_pattern_MatchOr(data),
} }
} }
fn visit_pattern_MatchValue(&mut self, node: PatternMatchValue) { fn visit_pattern_MatchValue(&mut self, node: PatternMatchValue<R>) {
self.generic_visit_pattern_MatchValue(node) self.generic_visit_pattern_MatchValue(node)
} }
fn generic_visit_pattern_MatchValue(&mut self, node: PatternMatchValue) { fn generic_visit_pattern_MatchValue(&mut self, node: PatternMatchValue<R>) {
{ {
let value = node.value; let value = node.value;
self.visit_expr(*value); self.visit_expr(*value);
} }
} }
fn visit_pattern_MatchSingleton(&mut self, node: PatternMatchSingleton) { fn visit_pattern_MatchSingleton(&mut self, node: PatternMatchSingleton<R>) {
self.generic_visit_pattern_MatchSingleton(node) self.generic_visit_pattern_MatchSingleton(node)
} }
fn generic_visit_pattern_MatchSingleton(&mut self, node: PatternMatchSingleton) {} fn generic_visit_pattern_MatchSingleton(&mut self, node: PatternMatchSingleton<R>) {}
fn visit_pattern_MatchSequence(&mut self, node: PatternMatchSequence) { fn visit_pattern_MatchSequence(&mut self, node: PatternMatchSequence<R>) {
self.generic_visit_pattern_MatchSequence(node) self.generic_visit_pattern_MatchSequence(node)
} }
fn generic_visit_pattern_MatchSequence(&mut self, node: PatternMatchSequence) { fn generic_visit_pattern_MatchSequence(&mut self, node: PatternMatchSequence<R>) {
for value in node.patterns { for value in node.patterns {
self.visit_pattern(value); self.visit_pattern(value);
} }
} }
fn visit_pattern_MatchMapping(&mut self, node: PatternMatchMapping) { fn visit_pattern_MatchMapping(&mut self, node: PatternMatchMapping<R>) {
self.generic_visit_pattern_MatchMapping(node) self.generic_visit_pattern_MatchMapping(node)
} }
fn generic_visit_pattern_MatchMapping(&mut self, node: PatternMatchMapping) { fn generic_visit_pattern_MatchMapping(&mut self, node: PatternMatchMapping<R>) {
for value in node.keys { for value in node.keys {
self.visit_expr(value); self.visit_expr(value);
} }
@ -784,10 +775,10 @@ pub trait Visitor<U = ()> {
self.visit_pattern(value); self.visit_pattern(value);
} }
} }
fn visit_pattern_MatchClass(&mut self, node: PatternMatchClass) { fn visit_pattern_MatchClass(&mut self, node: PatternMatchClass<R>) {
self.generic_visit_pattern_MatchClass(node) self.generic_visit_pattern_MatchClass(node)
} }
fn generic_visit_pattern_MatchClass(&mut self, node: PatternMatchClass) { fn generic_visit_pattern_MatchClass(&mut self, node: PatternMatchClass<R>) {
{ {
let value = node.cls; let value = node.cls;
self.visit_expr(*value); self.visit_expr(*value);
@ -799,22 +790,22 @@ pub trait Visitor<U = ()> {
self.visit_pattern(value); self.visit_pattern(value);
} }
} }
fn visit_pattern_MatchStar(&mut self, node: PatternMatchStar) { fn visit_pattern_MatchStar(&mut self, node: PatternMatchStar<R>) {
self.generic_visit_pattern_MatchStar(node) self.generic_visit_pattern_MatchStar(node)
} }
fn generic_visit_pattern_MatchStar(&mut self, node: PatternMatchStar) {} fn generic_visit_pattern_MatchStar(&mut self, node: PatternMatchStar<R>) {}
fn visit_pattern_MatchAs(&mut self, node: PatternMatchAs) { fn visit_pattern_MatchAs(&mut self, node: PatternMatchAs<R>) {
self.generic_visit_pattern_MatchAs(node) self.generic_visit_pattern_MatchAs(node)
} }
fn generic_visit_pattern_MatchAs(&mut self, node: PatternMatchAs) { fn generic_visit_pattern_MatchAs(&mut self, node: PatternMatchAs<R>) {
if let Some(value) = node.pattern { if let Some(value) = node.pattern {
self.visit_pattern(*value); self.visit_pattern(*value);
} }
} }
fn visit_pattern_MatchOr(&mut self, node: PatternMatchOr) { fn visit_pattern_MatchOr(&mut self, node: PatternMatchOr<R>) {
self.generic_visit_pattern_MatchOr(node) self.generic_visit_pattern_MatchOr(node)
} }
fn generic_visit_pattern_MatchOr(&mut self, node: PatternMatchOr) { fn generic_visit_pattern_MatchOr(&mut self, node: PatternMatchOr<R>) {
for value in node.patterns { for value in node.patterns {
self.visit_pattern(value); self.visit_pattern(value);
} }

View File

@ -1,19 +1,17 @@
use crate::{Constant, ExprKind}; use crate::{Constant, Excepthandler, Expr, Pattern, Stmt};
impl<U> ExprKind<U> { impl<R> Expr<R> {
/// Returns a short name for the node suitable for use in error messages. /// Returns a short name for the node suitable for use in error messages.
pub fn python_name(&self) -> &'static str { pub fn python_name(&self) -> &'static str {
match self { match self {
ExprKind::BoolOp { .. } | ExprKind::BinOp { .. } | ExprKind::UnaryOp { .. } => { Expr::BoolOp { .. } | Expr::BinOp { .. } | Expr::UnaryOp { .. } => "operator",
"operator" Expr::Subscript { .. } => "subscript",
} Expr::Await { .. } => "await expression",
ExprKind::Subscript { .. } => "subscript", Expr::Yield { .. } | Expr::YieldFrom { .. } => "yield expression",
ExprKind::Await { .. } => "await expression", Expr::Compare { .. } => "comparison",
ExprKind::Yield { .. } | ExprKind::YieldFrom { .. } => "yield expression", Expr::Attribute { .. } => "attribute",
ExprKind::Compare { .. } => "comparison", Expr::Call { .. } => "function call",
ExprKind::Attribute { .. } => "attribute", Expr::Constant(crate::ExprConstant { value, .. }) => match value {
ExprKind::Call { .. } => "function call",
ExprKind::Constant(crate::ExprConstant { value, .. }) => match value {
Constant::Str(_) Constant::Str(_)
| Constant::Int(_) | Constant::Int(_)
| Constant::Float(_) | Constant::Float(_)
@ -30,31 +28,37 @@ impl<U> ExprKind<U> {
Constant::None => "None", Constant::None => "None",
Constant::Ellipsis => "ellipsis", Constant::Ellipsis => "ellipsis",
}, },
ExprKind::List { .. } => "list", Expr::List { .. } => "list",
ExprKind::Tuple { .. } => "tuple", Expr::Tuple { .. } => "tuple",
ExprKind::Dict { .. } => "dict display", Expr::Dict { .. } => "dict display",
ExprKind::Set { .. } => "set display", Expr::Set { .. } => "set display",
ExprKind::ListComp { .. } => "list comprehension", Expr::ListComp { .. } => "list comprehension",
ExprKind::DictComp { .. } => "dict comprehension", Expr::DictComp { .. } => "dict comprehension",
ExprKind::SetComp { .. } => "set comprehension", Expr::SetComp { .. } => "set comprehension",
ExprKind::GeneratorExp { .. } => "generator expression", Expr::GeneratorExp { .. } => "generator expression",
ExprKind::Starred { .. } => "starred", Expr::Starred { .. } => "starred",
ExprKind::Slice { .. } => "slice", Expr::Slice { .. } => "slice",
ExprKind::JoinedStr(crate::ExprJoinedStr { values }) => { Expr::JoinedStr(crate::ExprJoinedStr { values, .. }) => {
if values if values.iter().any(|e| e.is_joined_str_expr()) {
.iter()
.any(|e| matches!(e.node, ExprKind::JoinedStr { .. }))
{
"f-string expression" "f-string expression"
} else { } else {
"literal" "literal"
} }
} }
ExprKind::FormattedValue { .. } => "f-string expression", Expr::FormattedValue { .. } => "f-string expression",
ExprKind::Name { .. } => "name", Expr::Name { .. } => "name",
ExprKind::Lambda { .. } => "lambda", Expr::Lambda { .. } => "lambda",
ExprKind::IfExp { .. } => "conditional expression", Expr::IfExp { .. } => "conditional expression",
ExprKind::NamedExpr { .. } => "named expression", Expr::NamedExpr { .. } => "named expression",
} }
} }
} }
#[cfg(target_arch = "x86_64")]
static_assertions::assert_eq_size!(Expr, [u8; 72]);
#[cfg(target_arch = "x86_64")]
static_assertions::assert_eq_size!(Stmt, [u8; 136]);
#[cfg(target_arch = "x86_64")]
static_assertions::assert_eq_size!(Pattern, [u8; 96]);
#[cfg(target_arch = "x86_64")]
static_assertions::assert_eq_size!(Excepthandler, [u8; 64]);

View File

@ -8,6 +8,7 @@ mod generic {
include!("gen/generic.rs"); include!("gen/generic.rs");
} }
mod impls; mod impls;
mod ranged;
#[cfg(feature = "location")] #[cfg(feature = "location")]
mod source_locator; mod source_locator;
#[cfg(feature = "unparse")] #[cfg(feature = "unparse")]
@ -15,13 +16,13 @@ mod unparse;
pub use builtin::*; pub use builtin::*;
pub use generic::*; pub use generic::*;
pub use ranged::{EmptyRange, OptionalRange, Ranged, Suite};
pub use rustpython_parser_core::{text_size, ConversionFlag}; pub use rustpython_parser_core::{text_size, ConversionFlag};
pub type Suite<U = ()> = Vec<Stmt<U>>;
#[cfg(feature = "fold")] #[cfg(feature = "fold")]
pub mod fold { pub mod fold {
use super::generic::*; use super::generic::*;
include!("gen/fold.rs"); include!("gen/fold.rs");
} }
@ -33,9 +34,7 @@ mod visitor {
} }
#[cfg(feature = "location")] #[cfg(feature = "location")]
pub mod located { pub mod located;
include!("gen/located.rs");
}
#[cfg(feature = "location")] #[cfg(feature = "location")]
pub use rustpython_parser_core::source_code; pub use rustpython_parser_core::source_code;

19
ast/src/located.rs Normal file
View File

@ -0,0 +1,19 @@
#![allow(clippy::derive_partial_eq_without_eq)]
use crate::source_code::{SourceLocation, SourceRange};
pub trait Located {
fn range(&self) -> SourceRange;
fn location(&self) -> SourceLocation {
self.range().start
}
fn end_location(&self) -> Option<SourceLocation> {
self.range().end
}
}
pub type Suite = Vec<Stmt>;
pub use crate::builtin::*;
include!("gen/located.rs");

View File

@ -20,35 +20,29 @@ impl<U> crate::fold::Fold<U> for ConstantOptimizer {
Ok(user) Ok(user)
} }
fn fold_expr(&mut self, node: crate::Expr<U>) -> Result<crate::Expr<U>, Self::Error> { fn fold_expr(&mut self, node: crate::Expr<U>) -> Result<crate::Expr<U>, Self::Error> {
match node.node { match node {
crate::ExprKind::Tuple(crate::ExprTuple { elts, ctx }) => { crate::Expr::Tuple(crate::ExprTuple { elts, ctx, range }) => {
let elts = elts let elts = elts
.into_iter() .into_iter()
.map(|x| self.fold_expr(x)) .map(|x| self.fold_expr(x))
.collect::<Result<Vec<_>, _>>()?; .collect::<Result<Vec<_>, _>>()?;
let expr = if elts let expr = if elts.iter().all(|e| e.is_constant_expr()) {
.iter()
.all(|e| matches!(e.node, crate::ExprKind::Constant { .. }))
{
let tuple = elts let tuple = elts
.into_iter() .into_iter()
.map(|e| match e.node { .map(|e| match e {
crate::ExprKind::Constant(crate::ExprConstant { value, .. }) => value, crate::Expr::Constant(crate::ExprConstant { value, .. }) => value,
_ => unreachable!(), _ => unreachable!(),
}) })
.collect(); .collect();
crate::ExprKind::Constant(crate::ExprConstant { crate::Expr::Constant(crate::ExprConstant {
value: Constant::Tuple(tuple), value: Constant::Tuple(tuple),
kind: None, kind: None,
range,
}) })
} else { } else {
crate::ExprKind::Tuple(crate::ExprTuple { elts, ctx }) crate::Expr::Tuple(crate::ExprTuple { elts, ctx, range })
}; };
Ok(crate::Expr { Ok(expr)
node: expr,
custom: node.custom,
range: node.range,
})
} }
_ => crate::fold::fold_expr(self, node), _ => crate::fold::fold_expr(self, node),
} }
@ -66,82 +60,55 @@ mod tests {
use crate::{fold::Fold, *}; use crate::{fold::Fold, *};
let range = TextRange::default(); let range = TextRange::default();
#[allow(clippy::let_unit_value)] let ast = ExprTuple {
let custom = ();
let ast = Attributed {
range,
custom,
node: ExprTuple {
ctx: ExprContext::Load, ctx: ExprContext::Load,
elts: vec![ elts: vec![
Attributed { ExprConstant {
range,
custom,
node: ExprConstant {
value: BigInt::from(1).into(), value: BigInt::from(1).into(),
kind: None, kind: None,
range,
} }
.into(), .into(),
}, ExprConstant {
Attributed {
range,
custom,
node: ExprConstant {
value: BigInt::from(2).into(), value: BigInt::from(2).into(),
kind: None, kind: None,
range,
} }
.into(), .into(),
}, ExprTuple {
Attributed {
range,
custom,
node: ExprTuple {
ctx: ExprContext::Load, ctx: ExprContext::Load,
elts: vec![ elts: vec![
Attributed { ExprConstant {
range,
custom,
node: ExprConstant {
value: BigInt::from(3).into(), value: BigInt::from(3).into(),
kind: None, kind: None,
range,
} }
.into(), .into(),
}, ExprConstant {
Attributed {
range,
custom,
node: ExprConstant {
value: BigInt::from(4).into(), value: BigInt::from(4).into(),
kind: None, kind: None,
range,
} }
.into(), .into(),
}, ExprConstant {
Attributed {
range,
custom,
node: ExprConstant {
value: BigInt::from(5).into(), value: BigInt::from(5).into(),
kind: None, kind: None,
range,
} }
.into(), .into(),
},
], ],
range,
} }
.into(), .into(),
},
], ],
} range,
.into(),
}; };
let new_ast = ConstantOptimizer::new() let new_ast = ConstantOptimizer::new()
.fold_expr(ast) .fold_expr(ast.into())
.unwrap_or_else(|e| match e {}); .unwrap_or_else(|e| match e {});
assert_eq!( assert_eq!(
new_ast, new_ast,
Attributed { ExprConstant {
range,
custom,
node: ExprConstant {
value: Constant::Tuple(vec![ value: Constant::Tuple(vec![
BigInt::from(1).into(), BigInt::from(1).into(),
BigInt::from(2).into(), BigInt::from(2).into(),
@ -151,10 +118,10 @@ mod tests {
BigInt::from(5).into(), BigInt::from(5).into(),
]) ])
]), ]),
kind: None kind: None,
range,
} }
.into(), .into(),
}
); );
} }
} }

62
ast/src/ranged.rs Normal file
View File

@ -0,0 +1,62 @@
use crate::text_size::{TextRange, TextSize};
use std::fmt::{Debug, Display, Formatter};
use std::marker::PhantomData;
pub use crate::builtin::*;
use crate::Stmt;
pub trait Ranged {
fn range(&self) -> TextRange;
fn start(&self) -> TextSize {
self.range().start()
}
fn end(&self) -> TextSize {
self.range().end()
}
}
pub type Suite<R = TextRange> = Vec<Stmt<R>>;
#[cfg(feature = "all-nodes-with-ranges")]
pub type OptionalRange<R> = R;
#[cfg(not(feature = "all-nodes-with-ranges"))]
pub type OptionalRange<R> = EmptyRange<R>;
#[derive(Eq, PartialEq, Hash, Copy, Clone)]
pub struct EmptyRange<R> {
phantom: PhantomData<R>,
}
impl<R> EmptyRange<R> {
#[inline(always)]
pub fn new(_start: TextSize, _end: TextSize) -> Self {
Self {
phantom: PhantomData,
}
}
}
impl<R> Display for EmptyRange<R> {
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
f.write_str("()")
}
}
impl<R> Debug for EmptyRange<R> {
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
Display::fmt(self, f)
}
}
impl<R> Default for EmptyRange<R> {
fn default() -> Self {
EmptyRange {
phantom: PhantomData,
}
}
}
include!("gen/ranged.rs");

View File

@ -1,39 +1,15 @@
use crate::builtin::Attributed; use rustpython_parser_core::{
use rustpython_parser_core::source_code::{SourceLocation, SourceLocator, SourceRange}; source_code::{SourceLocator, SourceRange},
text_size::TextRange,
};
impl crate::fold::Fold<()> for SourceLocator<'_> { impl crate::fold::Fold<TextRange> for SourceLocator<'_> {
type TargetU = SourceRange; type TargetU = SourceRange;
type Error = std::convert::Infallible; type Error = std::convert::Infallible;
#[cold] fn map_user(&mut self, user: TextRange) -> Result<Self::TargetU, Self::Error> {
fn map_user(&mut self, _user: ()) -> Result<Self::TargetU, Self::Error> { let start = self.locate(user.start());
unreachable!("implemented map_attributed"); let end = self.locate(user.end());
} Ok((start..end).into())
fn map_attributed<T>(
&mut self,
node: Attributed<T, ()>,
) -> Result<Attributed<T, Self::TargetU>, Self::Error> {
let start = self.locate(node.range.start());
let end = self.locate(node.range.end());
Ok(Attributed {
range: node.range,
custom: (start..end).into(),
node: node.node,
})
}
}
impl<T> Attributed<T, SourceRange> {
/// Returns the absolute start position of the node from the beginning of the document.
#[inline]
pub const fn location(&self) -> SourceLocation {
self.custom.start
}
/// Returns the absolute position at which the node ends in the source document.
#[inline]
pub const fn end_location(&self) -> Option<SourceLocation> {
self.custom.end
} }
} }

View File

@ -1,7 +1,5 @@
use crate::ConversionFlag; use crate::ConversionFlag;
use crate::{ use crate::{Arg, Arguments, Boolop, Cmpop, Comprehension, Constant, Expr, Identifier, Operator};
Arg, Arguments, Boolop, Cmpop, Comprehension, Constant, Expr, ExprKind, Identifier, Operator,
};
use std::fmt; use std::fmt;
mod precedence { mod precedence {
@ -73,8 +71,12 @@ impl<'a> Unparser<'a> {
ret ret
}}; }};
} }
match &ast.node { match &ast {
ExprKind::BoolOp(crate::ExprBoolOp { op, values }) => { Expr::BoolOp(crate::ExprBoolOp {
op,
values,
range: _range,
}) => {
let (op, prec) = op_prec!(bin, op, Boolop, And("and", AND), Or("or", OR)); let (op, prec) = op_prec!(bin, op, Boolop, And("and", AND), Or("or", OR));
group_if!(prec, { group_if!(prec, {
let mut first = true; let mut first = true;
@ -84,14 +86,23 @@ impl<'a> Unparser<'a> {
} }
}) })
} }
ExprKind::NamedExpr(crate::ExprNamedExpr { target, value }) => { Expr::NamedExpr(crate::ExprNamedExpr {
target,
value,
range: _range,
}) => {
group_if!(precedence::TUPLE, { group_if!(precedence::TUPLE, {
self.unparse_expr(target, precedence::ATOM)?; self.unparse_expr(target, precedence::ATOM)?;
self.p(" := ")?; self.p(" := ")?;
self.unparse_expr(value, precedence::ATOM)?; self.unparse_expr(value, precedence::ATOM)?;
}) })
} }
ExprKind::BinOp(crate::ExprBinOp { left, op, right }) => { Expr::BinOp(crate::ExprBinOp {
left,
op,
right,
range: _range,
}) => {
let right_associative = matches!(op, Operator::Pow); let right_associative = matches!(op, Operator::Pow);
let (op, prec) = op_prec!( let (op, prec) = op_prec!(
bin, bin,
@ -117,7 +128,11 @@ impl<'a> Unparser<'a> {
self.unparse_expr(right, prec + !right_associative as u8)?; self.unparse_expr(right, prec + !right_associative as u8)?;
}) })
} }
ExprKind::UnaryOp(crate::ExprUnaryOp { op, operand }) => { Expr::UnaryOp(crate::ExprUnaryOp {
op,
operand,
range: _range,
}) => {
let (op, prec) = op_prec!( let (op, prec) = op_prec!(
un, un,
op, op,
@ -132,7 +147,11 @@ impl<'a> Unparser<'a> {
self.unparse_expr(operand, prec)?; self.unparse_expr(operand, prec)?;
}) })
} }
ExprKind::Lambda(crate::ExprLambda { args, body }) => { Expr::Lambda(crate::ExprLambda {
args,
body,
range: _range,
}) => {
group_if!(precedence::TEST, { group_if!(precedence::TEST, {
let pos = args.args.len() + args.posonlyargs.len(); let pos = args.args.len() + args.posonlyargs.len();
self.p(if pos > 0 { "lambda " } else { "lambda" })?; self.p(if pos > 0 { "lambda " } else { "lambda" })?;
@ -140,7 +159,12 @@ impl<'a> Unparser<'a> {
write!(self, ": {}", **body)?; write!(self, ": {}", **body)?;
}) })
} }
ExprKind::IfExp(crate::ExprIfExp { test, body, orelse }) => { Expr::IfExp(crate::ExprIfExp {
test,
body,
orelse,
range: _range,
}) => {
group_if!(precedence::TEST, { group_if!(precedence::TEST, {
self.unparse_expr(body, precedence::TEST + 1)?; self.unparse_expr(body, precedence::TEST + 1)?;
self.p(" if ")?; self.p(" if ")?;
@ -149,7 +173,11 @@ impl<'a> Unparser<'a> {
self.unparse_expr(orelse, precedence::TEST)?; self.unparse_expr(orelse, precedence::TEST)?;
}) })
} }
ExprKind::Dict(crate::ExprDict { keys, values }) => { Expr::Dict(crate::ExprDict {
keys,
values,
range: _range,
}) => {
self.p("{")?; self.p("{")?;
let mut first = true; let mut first = true;
let (packed, unpacked) = values.split_at(keys.len()); let (packed, unpacked) = values.split_at(keys.len());
@ -167,7 +195,10 @@ impl<'a> Unparser<'a> {
} }
self.p("}")?; self.p("}")?;
} }
ExprKind::Set(crate::ExprSet { elts }) => { Expr::Set(crate::ExprSet {
elts,
range: _range,
}) => {
self.p("{")?; self.p("{")?;
let mut first = true; let mut first = true;
for v in elts { for v in elts {
@ -176,22 +207,31 @@ impl<'a> Unparser<'a> {
} }
self.p("}")?; self.p("}")?;
} }
ExprKind::ListComp(crate::ExprListComp { elt, generators }) => { Expr::ListComp(crate::ExprListComp {
elt,
generators,
range: _range,
}) => {
self.p("[")?; self.p("[")?;
self.unparse_expr(elt, precedence::TEST)?; self.unparse_expr(elt, precedence::TEST)?;
self.unparse_comp(generators)?; self.unparse_comp(generators)?;
self.p("]")?; self.p("]")?;
} }
ExprKind::SetComp(crate::ExprSetComp { elt, generators }) => { Expr::SetComp(crate::ExprSetComp {
elt,
generators,
range: _range,
}) => {
self.p("{")?; self.p("{")?;
self.unparse_expr(elt, precedence::TEST)?; self.unparse_expr(elt, precedence::TEST)?;
self.unparse_comp(generators)?; self.unparse_comp(generators)?;
self.p("}")?; self.p("}")?;
} }
ExprKind::DictComp(crate::ExprDictComp { Expr::DictComp(crate::ExprDictComp {
key, key,
value, value,
generators, generators,
range: _range,
}) => { }) => {
self.p("{")?; self.p("{")?;
self.unparse_expr(key, precedence::TEST)?; self.unparse_expr(key, precedence::TEST)?;
@ -200,32 +240,46 @@ impl<'a> Unparser<'a> {
self.unparse_comp(generators)?; self.unparse_comp(generators)?;
self.p("}")?; self.p("}")?;
} }
ExprKind::GeneratorExp(crate::ExprGeneratorExp { elt, generators }) => { Expr::GeneratorExp(crate::ExprGeneratorExp {
elt,
generators,
range: _range,
}) => {
self.p("(")?; self.p("(")?;
self.unparse_expr(elt, precedence::TEST)?; self.unparse_expr(elt, precedence::TEST)?;
self.unparse_comp(generators)?; self.unparse_comp(generators)?;
self.p(")")?; self.p(")")?;
} }
ExprKind::Await(crate::ExprAwait { value }) => { Expr::Await(crate::ExprAwait {
value,
range: _range,
}) => {
group_if!(precedence::AWAIT, { group_if!(precedence::AWAIT, {
self.p("await ")?; self.p("await ")?;
self.unparse_expr(value, precedence::ATOM)?; self.unparse_expr(value, precedence::ATOM)?;
}) })
} }
ExprKind::Yield(crate::ExprYield { value }) => { Expr::Yield(crate::ExprYield {
value,
range: _range,
}) => {
if let Some(value) = value { if let Some(value) = value {
write!(self, "(yield {})", **value)?; write!(self, "(yield {})", **value)?;
} else { } else {
self.p("(yield)")?; self.p("(yield)")?;
} }
} }
ExprKind::YieldFrom(crate::ExprYieldFrom { value }) => { Expr::YieldFrom(crate::ExprYieldFrom {
value,
range: _range,
}) => {
write!(self, "(yield from {})", **value)?; write!(self, "(yield from {})", **value)?;
} }
ExprKind::Compare(crate::ExprCompare { Expr::Compare(crate::ExprCompare {
left, left,
ops, ops,
comparators, comparators,
range: _range,
}) => { }) => {
group_if!(precedence::CMP, { group_if!(precedence::CMP, {
let new_lvl = precedence::CMP + 1; let new_lvl = precedence::CMP + 1;
@ -248,18 +302,20 @@ impl<'a> Unparser<'a> {
} }
}) })
} }
ExprKind::Call(crate::ExprCall { Expr::Call(crate::ExprCall {
func, func,
args, args,
keywords, keywords,
range: _range,
}) => { }) => {
self.unparse_expr(func, precedence::ATOM)?; self.unparse_expr(func, precedence::ATOM)?;
self.p("(")?; self.p("(")?;
if let ( if let (
[Expr { [Expr::GeneratorExp(crate::ExprGeneratorExp {
node: ExprKind::GeneratorExp(crate::ExprGeneratorExp { elt, generators }), elt,
.. generators,
}], range: _range,
})],
[], [],
) = (&**args, &**keywords) ) = (&**args, &**keywords)
{ {
@ -274,26 +330,32 @@ impl<'a> Unparser<'a> {
} }
for kw in keywords { for kw in keywords {
self.p_delim(&mut first, ", ")?; self.p_delim(&mut first, ", ")?;
if let Some(arg) = &kw.node.arg { if let Some(arg) = &kw.arg {
self.p_id(arg)?; self.p_id(arg)?;
self.p("=")?; self.p("=")?;
} else { } else {
self.p("**")?; self.p("**")?;
} }
self.unparse_expr(&kw.node.value, precedence::TEST)?; self.unparse_expr(&kw.value, precedence::TEST)?;
} }
} }
self.p(")")?; self.p(")")?;
} }
ExprKind::FormattedValue(crate::ExprFormattedValue { Expr::FormattedValue(crate::ExprFormattedValue {
value, value,
conversion, conversion,
format_spec, format_spec,
range: _range,
}) => self.unparse_formatted(value, conversion.to_u32(), format_spec.as_deref())?, }) => self.unparse_formatted(value, conversion.to_u32(), format_spec.as_deref())?,
ExprKind::JoinedStr(crate::ExprJoinedStr { values }) => { Expr::JoinedStr(crate::ExprJoinedStr {
self.unparse_joined_str(values, false)? values,
} range: _range,
ExprKind::Constant(crate::ExprConstant { value, kind }) => { }) => self.unparse_joined_str(values, false)?,
Expr::Constant(crate::ExprConstant {
value,
kind,
range: _range,
}) => {
if let Some(kind) = kind { if let Some(kind) = kind {
self.p(kind)?; self.p(kind)?;
} }
@ -309,12 +371,12 @@ impl<'a> Unparser<'a> {
_ => fmt::Display::fmt(value, &mut self.f)?, _ => fmt::Display::fmt(value, &mut self.f)?,
} }
} }
ExprKind::Attribute(crate::ExprAttribute { value, attr, .. }) => { Expr::Attribute(crate::ExprAttribute { value, attr, .. }) => {
self.unparse_expr(value, precedence::ATOM)?; self.unparse_expr(value, precedence::ATOM)?;
let period = if let ExprKind::Constant(crate::ExprConstant { let period = if let Expr::Constant(crate::ExprConstant {
value: Constant::Int(_), value: Constant::Int(_),
.. ..
}) = &value.node }) = value.as_ref()
{ {
" ." " ."
} else { } else {
@ -323,14 +385,11 @@ impl<'a> Unparser<'a> {
self.p(period)?; self.p(period)?;
self.p_id(attr)?; self.p_id(attr)?;
} }
ExprKind::Subscript(crate::ExprSubscript { value, slice, .. }) => { Expr::Subscript(crate::ExprSubscript { value, slice, .. }) => {
self.unparse_expr(value, precedence::ATOM)?; self.unparse_expr(value, precedence::ATOM)?;
let mut lvl = precedence::TUPLE; let mut lvl = precedence::TUPLE;
if let ExprKind::Tuple(crate::ExprTuple { elts, .. }) = &slice.node { if let Expr::Tuple(crate::ExprTuple { elts, .. }) = slice.as_ref() {
if elts if elts.iter().any(|expr| expr.is_starred_expr()) {
.iter()
.any(|expr| matches!(expr.node, ExprKind::Starred { .. }))
{
lvl += 1 lvl += 1
} }
} }
@ -338,12 +397,12 @@ impl<'a> Unparser<'a> {
self.unparse_expr(slice, lvl)?; self.unparse_expr(slice, lvl)?;
self.p("]")?; self.p("]")?;
} }
ExprKind::Starred(crate::ExprStarred { value, .. }) => { Expr::Starred(crate::ExprStarred { value, .. }) => {
self.p("*")?; self.p("*")?;
self.unparse_expr(value, precedence::EXPR)?; self.unparse_expr(value, precedence::EXPR)?;
} }
ExprKind::Name(crate::ExprName { id, .. }) => self.p_id(id)?, Expr::Name(crate::ExprName { id, .. }) => self.p_id(id)?,
ExprKind::List(crate::ExprList { elts, .. }) => { Expr::List(crate::ExprList { elts, .. }) => {
self.p("[")?; self.p("[")?;
let mut first = true; let mut first = true;
for elt in elts { for elt in elts {
@ -352,7 +411,7 @@ impl<'a> Unparser<'a> {
} }
self.p("]")?; self.p("]")?;
} }
ExprKind::Tuple(crate::ExprTuple { elts, .. }) => { Expr::Tuple(crate::ExprTuple { elts, .. }) => {
if elts.is_empty() { if elts.is_empty() {
self.p("()")?; self.p("()")?;
} else { } else {
@ -366,7 +425,12 @@ impl<'a> Unparser<'a> {
}) })
} }
} }
ExprKind::Slice(crate::ExprSlice { lower, upper, step }) => { Expr::Slice(crate::ExprSlice {
lower,
upper,
step,
range: _range,
}) => {
if let Some(lower) = lower { if let Some(lower) = lower {
self.unparse_expr(lower, precedence::TEST)?; self.unparse_expr(lower, precedence::TEST)?;
} }
@ -420,8 +484,8 @@ impl<'a> Unparser<'a> {
Ok(()) Ok(())
} }
fn unparse_arg<U>(&mut self, arg: &Arg<U>) -> fmt::Result { fn unparse_arg<U>(&mut self, arg: &Arg<U>) -> fmt::Result {
self.p_id(&arg.node.arg)?; self.p_id(&arg.arg)?;
if let Some(ann) = &arg.node.annotation { if let Some(ann) = &arg.annotation {
write!(self, ": {}", **ann)?; write!(self, ": {}", **ann)?;
} }
Ok(()) Ok(())
@ -487,21 +551,23 @@ impl<'a> Unparser<'a> {
} }
fn unparse_fstring_elem<U>(&mut self, expr: &Expr<U>, is_spec: bool) -> fmt::Result { fn unparse_fstring_elem<U>(&mut self, expr: &Expr<U>, is_spec: bool) -> fmt::Result {
match &expr.node { match &expr {
ExprKind::Constant(crate::ExprConstant { value, .. }) => { Expr::Constant(crate::ExprConstant { value, .. }) => {
if let Constant::Str(s) = value { if let Constant::Str(s) = value {
self.unparse_fstring_str(s) self.unparse_fstring_str(s)
} else { } else {
unreachable!() unreachable!()
} }
} }
ExprKind::JoinedStr(crate::ExprJoinedStr { values }) => { Expr::JoinedStr(crate::ExprJoinedStr {
self.unparse_joined_str(values, is_spec) values,
} range: _range,
ExprKind::FormattedValue(crate::ExprFormattedValue { }) => self.unparse_joined_str(values, is_spec),
Expr::FormattedValue(crate::ExprFormattedValue {
value, value,
conversion, conversion,
format_spec, format_spec,
range: _range,
}) => self.unparse_formatted(value, conversion.to_u32(), format_spec.as_deref()), }) => self.unparse_formatted(value, conversion.to_u32(), format_spec.as_deref()),
_ => unreachable!(), _ => unreachable!(),
} }

View File

@ -16,4 +16,4 @@ serde = { version = "1.0.133", optional = true, default-features = false, featur
[features] [features]
default = [] default = []
location = ["ruff_source_location"] location = ["dep:ruff_source_location"]

View File

@ -3,7 +3,7 @@ pub use ruff_source_location::*;
pub type LineNumber = OneIndexed; pub type LineNumber = OneIndexed;
#[derive(Debug)] #[derive(Debug, Copy, Clone)]
pub struct SourceRange { pub struct SourceRange {
pub start: SourceLocation, pub start: SourceLocation,
pub end: Option<SourceLocation>, pub end: Option<SourceLocation>,

View File

@ -10,8 +10,9 @@ edition = "2021"
[features] [features]
default = ["location"] default = ["location"]
location = ["rustpython-ast/location"] location = ["rustpython-ast/location", "rustpython-parser-core/location"]
serde = ["dep:serde", "rustpython-parser-core/serde"] serde = ["dep:serde", "rustpython-parser-core/serde"]
all-nodes-with-ranges = ["rustpython-ast/all-nodes-with-ranges"]
[build-dependencies] [build-dependencies]
anyhow = { workspace = true } anyhow = { workspace = true }

View File

@ -1,49 +1,48 @@
use crate::ast::{self, Expr, ExprContext, ExprKind}; use crate::ast::{self, Expr, ExprContext};
pub(crate) fn set_context(expr: Expr, ctx: ExprContext) -> Expr { pub(crate) fn set_context(expr: Expr, ctx: ExprContext) -> Expr {
match expr.node { match expr {
ExprKind::Name(ast::ExprName { id, .. }) => Expr { Expr::Name(ast::ExprName { id, range, .. }) => ast::ExprName { id, ctx, range }.into(),
node: ast::ExprName { id, ctx }.into(), Expr::Tuple(ast::ExprTuple { elts, range, .. }) => ast::ExprTuple {
..expr elts: elts.into_iter().map(|elt| set_context(elt, ctx)).collect(),
}, range,
ExprKind::Tuple(ast::ExprTuple { elts, .. }) => Expr {
node: ast::ExprTuple {
elts: elts
.into_iter()
.map(|elt| set_context(elt, ctx.clone()))
.collect(),
ctx, ctx,
} }
.into(), .into(),
..expr
}, Expr::List(ast::ExprList { elts, range, .. }) => ast::ExprList {
ExprKind::List(ast::ExprList { elts, .. }) => Expr { elts: elts.into_iter().map(|elt| set_context(elt, ctx)).collect(),
node: ast::ExprList { range,
elts: elts
.into_iter()
.map(|elt| set_context(elt, ctx.clone()))
.collect(),
ctx, ctx,
} }
.into(), .into(),
..expr Expr::Attribute(ast::ExprAttribute {
}, value, attr, range, ..
ExprKind::Attribute(ast::ExprAttribute { value, attr, .. }) => Expr { }) => ast::ExprAttribute {
node: ast::ExprAttribute { value, attr, ctx }.into(), value,
..expr attr,
}, range,
ExprKind::Subscript(ast::ExprSubscript { value, slice, .. }) => Expr { ctx,
node: ast::ExprSubscript { value, slice, ctx }.into(), }
..expr .into(),
}, Expr::Subscript(ast::ExprSubscript {
ExprKind::Starred(ast::ExprStarred { value, .. }) => Expr { value,
node: ast::ExprStarred { slice,
value: Box::new(set_context(*value, ctx.clone())), range,
..
}) => ast::ExprSubscript {
value,
slice,
range,
ctx,
}
.into(),
Expr::Starred(ast::ExprStarred { value, range, .. }) => ast::ExprStarred {
value: Box::new(set_context(*value, ctx)),
range,
ctx, ctx,
} }
.into(), .into(),
..expr
},
_ => expr, _ => expr,
} }
} }
@ -67,6 +66,7 @@ mod tests {
} }
#[test] #[test]
#[cfg(not(feature = "all-nodes-with-ranges"))]
fn test_assign_list() { fn test_assign_list() {
let source = "[x, y] = (1, 2, 3)"; let source = "[x, y] = (1, 2, 3)";
let parse_ast = parse_program(source, "<test>").unwrap(); let parse_ast = parse_program(source, "<test>").unwrap();
@ -102,6 +102,7 @@ mod tests {
} }
#[test] #[test]
#[cfg(not(feature = "all-nodes-with-ranges"))]
fn test_assign_list_comp() { fn test_assign_list_comp() {
let source = "x = [y for y in (1, 2, 3)]"; let source = "x = [y for y in (1, 2, 3)]";
let parse_ast = parse_program(source, "<test>").unwrap(); let parse_ast = parse_program(source, "<test>").unwrap();
@ -109,6 +110,7 @@ mod tests {
} }
#[test] #[test]
#[cfg(not(feature = "all-nodes-with-ranges"))]
fn test_assign_set_comp() { fn test_assign_set_comp() {
let source = "x = {y for y in (1, 2, 3)}"; let source = "x = {y for y in (1, 2, 3)}";
let parse_ast = parse_program(source, "<test>").unwrap(); let parse_ast = parse_program(source, "<test>").unwrap();
@ -116,6 +118,7 @@ mod tests {
} }
#[test] #[test]
#[cfg(not(feature = "all-nodes-with-ranges"))]
fn test_assign_with() { fn test_assign_with() {
let source = "with 1 as x: pass"; let source = "with 1 as x: pass";
let parse_ast = parse_program(source, "<test>").unwrap(); let parse_ast = parse_program(source, "<test>").unwrap();

View File

@ -1,11 +1,13 @@
// Contains functions that perform validation and parsing of arguments and parameters. // Contains functions that perform validation and parsing of arguments and parameters.
// Checks apply both to functions and to lambdas. // Checks apply both to functions and to lambdas.
use crate::text_size::TextRange;
use crate::{ use crate::{
ast, ast,
lexer::{LexicalError, LexicalErrorType}, lexer::{LexicalError, LexicalErrorType},
text_size::TextSize, text_size::TextSize,
}; };
use rustc_hash::FxHashSet; use rustc_hash::FxHashSet;
use rustpython_ast::Ranged;
pub(crate) struct ArgumentList { pub(crate) struct ArgumentList {
pub args: Vec<ast::Expr>, pub args: Vec<ast::Expr>,
@ -19,7 +21,7 @@ type ParameterDef = (ast::Arg, Option<ast::Expr>);
pub(crate) fn validate_arguments( pub(crate) fn validate_arguments(
arguments: ast::Arguments, arguments: ast::Arguments,
) -> Result<ast::Arguments, LexicalError> { ) -> Result<ast::Arguments, LexicalError> {
let mut all_args: Vec<&ast::Attributed<ast::ArgData>> = vec![]; let mut all_args: Vec<&ast::Arg> = vec![];
all_args.extend(arguments.posonlyargs.iter()); all_args.extend(arguments.posonlyargs.iter());
all_args.extend(arguments.args.iter()); all_args.extend(arguments.args.iter());
@ -116,13 +118,11 @@ pub(crate) fn parse_args(func_args: Vec<FunctionArgument>) -> Result<ArgumentLis
double_starred = true; double_starred = true;
} }
keywords.push(ast::Keyword::new( keywords.push(ast::Keyword {
start..end,
ast::KeywordData {
arg: name.map(ast::Identifier::new), arg: name.map(ast::Identifier::new),
value, value,
}, range: TextRange::new(start, end),
)); });
} }
None => { None => {
// Positional arguments mustn't follow keyword arguments. // Positional arguments mustn't follow keyword arguments.
@ -148,8 +148,8 @@ pub(crate) fn parse_args(func_args: Vec<FunctionArgument>) -> Result<ArgumentLis
} }
// Check if an expression is a starred expression. // Check if an expression is a starred expression.
fn is_starred(exp: &ast::Expr) -> bool { const fn is_starred(exp: &ast::Expr) -> bool {
matches!(exp.node, ast::ExprKind::Starred { .. }) exp.is_starred_expr()
} }
#[cfg(test)] #[cfg(test)]
@ -157,6 +157,7 @@ mod tests {
use super::*; use super::*;
use crate::parser::{parse_program, ParseErrorType}; use crate::parser::{parse_program, ParseErrorType};
#[cfg(not(feature = "all-nodes-with-ranges"))]
macro_rules! function_and_lambda { macro_rules! function_and_lambda {
($($name:ident: $code:expr,)*) => { ($($name:ident: $code:expr,)*) => {
$( $(
@ -169,6 +170,7 @@ mod tests {
} }
} }
#[cfg(not(feature = "all-nodes-with-ranges"))]
function_and_lambda! { function_and_lambda! {
test_function_no_args: "def f(): pass", test_function_no_args: "def f(): pass",
test_function_pos_args: "def f(a, b, c): pass", test_function_pos_args: "def f(a, b, c): pass",

View File

@ -23,7 +23,9 @@ use crate::{
use itertools::Itertools; use itertools::Itertools;
use std::iter; use std::iter;
use crate::text_size::TextRange;
pub(super) use lalrpop_util::ParseError as LalrpopError; pub(super) use lalrpop_util::ParseError as LalrpopError;
use rustpython_ast::OptionalRange;
/// Parse a full Python program usually consisting of multiple lines. /// Parse a full Python program usually consisting of multiple lines.
/// ///
@ -95,7 +97,7 @@ pub fn parse_expression_starts_at(
offset: TextSize, offset: TextSize,
) -> Result<ast::Expr, ParseError> { ) -> Result<ast::Expr, ParseError> {
parse_starts_at(source, Mode::Expression, path, offset).map(|top| match top { parse_starts_at(source, Mode::Expression, path, offset).map(|top| match top {
ast::Mod::Expression(ast::ModExpression { body }) => *body, ast::Mod::Expression(ast::ModExpression { body, .. }) => *body,
_ => unreachable!(), _ => unreachable!(),
}) })
} }
@ -318,6 +320,11 @@ impl ParseErrorType {
} }
} }
#[inline(always)]
pub(super) fn optional_range(start: TextSize, end: TextSize) -> OptionalRange<TextRange> {
OptionalRange::<TextRange>::new(start, end)
}
#[cfg(test)] #[cfg(test)]
mod tests { mod tests {
use super::*; use super::*;
@ -371,6 +378,7 @@ mod tests {
} }
#[test] #[test]
#[cfg(not(feature = "all-nodes-with-ranges"))]
fn test_parse_lambda() { fn test_parse_lambda() {
let source = "lambda x, y: x * y"; // lambda(x, y): x * y"; let source = "lambda x, y: x * y"; // lambda(x, y): x * y";
let parse_ast = parse_program(source, "<test>").unwrap(); let parse_ast = parse_program(source, "<test>").unwrap();
@ -385,6 +393,7 @@ mod tests {
} }
#[test] #[test]
#[cfg(not(feature = "all-nodes-with-ranges"))]
fn test_parse_class() { fn test_parse_class() {
let source = "\ let source = "\
class Foo(A, B): class Foo(A, B):
@ -397,6 +406,7 @@ class Foo(A, B):
} }
#[test] #[test]
#[cfg(not(feature = "all-nodes-with-ranges"))]
fn test_parse_dict_comprehension() { fn test_parse_dict_comprehension() {
let source = "{x1: x2 for y in z}"; let source = "{x1: x2 for y in z}";
let parse_ast = parse_expression(source, "<test>").unwrap(); let parse_ast = parse_expression(source, "<test>").unwrap();
@ -404,6 +414,7 @@ class Foo(A, B):
} }
#[test] #[test]
#[cfg(not(feature = "all-nodes-with-ranges"))]
fn test_parse_list_comprehension() { fn test_parse_list_comprehension() {
let source = "[x for y in z]"; let source = "[x for y in z]";
let parse_ast = parse_expression(source, "<test>").unwrap(); let parse_ast = parse_expression(source, "<test>").unwrap();
@ -411,6 +422,7 @@ class Foo(A, B):
} }
#[test] #[test]
#[cfg(not(feature = "all-nodes-with-ranges"))]
fn test_parse_double_list_comprehension() { fn test_parse_double_list_comprehension() {
let source = "[x for y, y2 in z for a in b if a < 5 if a > 10]"; let source = "[x for y, y2 in z for a in b if a < 5 if a > 10]";
let parse_ast = parse_expression(source, "<test>").unwrap(); let parse_ast = parse_expression(source, "<test>").unwrap();
@ -418,6 +430,7 @@ class Foo(A, B):
} }
#[test] #[test]
#[cfg(not(feature = "all-nodes-with-ranges"))]
fn test_parse_generator_comprehension() { fn test_parse_generator_comprehension() {
let source = "(x for y in z)"; let source = "(x for y in z)";
let parse_ast = parse_expression(source, "<test>").unwrap(); let parse_ast = parse_expression(source, "<test>").unwrap();
@ -425,6 +438,7 @@ class Foo(A, B):
} }
#[test] #[test]
#[cfg(not(feature = "all-nodes-with-ranges"))]
fn test_parse_named_expression_generator_comprehension() { fn test_parse_named_expression_generator_comprehension() {
let source = "(x := y + 1 for y in z)"; let source = "(x := y + 1 for y in z)";
let parse_ast = parse_expression(source, "<test>").unwrap(); let parse_ast = parse_expression(source, "<test>").unwrap();
@ -432,6 +446,7 @@ class Foo(A, B):
} }
#[test] #[test]
#[cfg(not(feature = "all-nodes-with-ranges"))]
fn test_parse_if_else_generator_comprehension() { fn test_parse_if_else_generator_comprehension() {
let source = "(x if y else y for y in z)"; let source = "(x if y else y for y in z)";
let parse_ast = parse_expression(source, "<test>").unwrap(); let parse_ast = parse_expression(source, "<test>").unwrap();
@ -460,6 +475,7 @@ class Foo(A, B):
} }
#[test] #[test]
#[cfg(not(feature = "all-nodes-with-ranges"))]
fn test_with_statement() { fn test_with_statement() {
let source = "\ let source = "\
with 0: pass with 0: pass
@ -529,6 +545,7 @@ array[3:5, *indexes_to_select]
} }
#[test] #[test]
#[cfg(not(feature = "all-nodes-with-ranges"))]
fn test_generator_expression_argument() { fn test_generator_expression_argument() {
let source = r#"' '.join( let source = r#"' '.join(
sql sql
@ -588,6 +605,7 @@ except* OSError as e:
} }
#[test] #[test]
#[cfg(not(feature = "all-nodes-with-ranges"))]
fn test_match_as_identifier() { fn test_match_as_identifier() {
let parse_ast = parse_program( let parse_ast = parse_program(
r#" r#"
@ -620,6 +638,7 @@ print(match(12))
} }
#[test] #[test]
#[cfg(not(feature = "all-nodes-with-ranges"))]
fn test_patma() { fn test_patma() {
let source = r#"# Cases sampled from Lib/test/test_patma.py let source = r#"# Cases sampled from Lib/test/test_patma.py
@ -791,6 +810,7 @@ match w := x,:
} }
#[test] #[test]
#[cfg(not(feature = "all-nodes-with-ranges"))]
fn test_match() { fn test_match() {
let parse_ast = parse_program( let parse_ast = parse_program(
r#" r#"
@ -821,6 +841,7 @@ match x:
} }
#[test] #[test]
#[cfg(not(feature = "all-nodes-with-ranges"))]
fn test_variadic_generics() { fn test_variadic_generics() {
let parse_ast = parse_program( let parse_ast = parse_program(
r#" r#"

File diff suppressed because it is too large Load Diff

27858
parser/src/python.rs generated

File diff suppressed because it is too large Load Diff

View File

@ -3,51 +3,39 @@ source: parser/src/context.rs
expression: parse_ast expression: parse_ast
--- ---
[ [
Attributed { AnnAssign(
range: 0..10,
custom: (),
node: AnnAssign(
StmtAnnAssign { StmtAnnAssign {
target: Attributed { range: 0..10,
range: 0..1, target: Name(
custom: (),
node: Name(
ExprName { ExprName {
range: 0..1,
id: Identifier( id: Identifier(
"x", "x",
), ),
ctx: Store, ctx: Store,
}, },
), ),
}, annotation: Name(
annotation: Attributed {
range: 3..6,
custom: (),
node: Name(
ExprName { ExprName {
range: 3..6,
id: Identifier( id: Identifier(
"int", "int",
), ),
ctx: Load, ctx: Load,
}, },
), ),
},
value: Some( value: Some(
Attributed { Constant(
range: 9..10,
custom: (),
node: Constant(
ExprConstant { ExprConstant {
range: 9..10,
value: Int( value: Int(
1, 1,
), ),
kind: None, kind: None,
}, },
), ),
},
), ),
simple: true, simple: true,
}, },
), ),
},
] ]

View File

@ -3,86 +3,65 @@ source: parser/src/context.rs
expression: parse_ast expression: parse_ast
--- ---
[ [
Attributed { Assign(
range: 0..15,
custom: (),
node: Assign(
StmtAssign { StmtAssign {
range: 0..15,
targets: [ targets: [
Attributed { Attribute(
range: 0..3,
custom: (),
node: Attribute(
ExprAttribute { ExprAttribute {
value: Attributed { range: 0..3,
range: 0..1, value: Name(
custom: (),
node: Name(
ExprName { ExprName {
range: 0..1,
id: Identifier( id: Identifier(
"x", "x",
), ),
ctx: Load, ctx: Load,
}, },
), ),
},
attr: Identifier( attr: Identifier(
"y", "y",
), ),
ctx: Store, ctx: Store,
}, },
), ),
},
], ],
value: Attributed { value: Tuple(
range: 6..15,
custom: (),
node: Tuple(
ExprTuple { ExprTuple {
range: 6..15,
elts: [ elts: [
Attributed { Constant(
range: 7..8,
custom: (),
node: Constant(
ExprConstant { ExprConstant {
range: 7..8,
value: Int( value: Int(
1, 1,
), ),
kind: None, kind: None,
}, },
), ),
}, Constant(
Attributed {
range: 10..11,
custom: (),
node: Constant(
ExprConstant { ExprConstant {
range: 10..11,
value: Int( value: Int(
2, 2,
), ),
kind: None, kind: None,
}, },
), ),
}, Constant(
Attributed {
range: 13..14,
custom: (),
node: Constant(
ExprConstant { ExprConstant {
range: 13..14,
value: Int( value: Int(
3, 3,
), ),
kind: None, kind: None,
}, },
), ),
},
], ],
ctx: Load, ctx: Load,
}, },
), ),
},
type_comment: None, type_comment: None,
}, },
), ),
},
] ]

View File

@ -3,80 +3,62 @@ source: parser/src/context.rs
expression: parse_ast expression: parse_ast
--- ---
[ [
Attributed { For(
range: 0..24,
custom: (),
node: For(
StmtFor { StmtFor {
target: Attributed { range: 0..24,
range: 4..5, target: Name(
custom: (),
node: Name(
ExprName { ExprName {
range: 4..5,
id: Identifier( id: Identifier(
"x", "x",
), ),
ctx: Store, ctx: Store,
}, },
), ),
}, iter: Tuple(
iter: Attributed {
range: 9..18,
custom: (),
node: Tuple(
ExprTuple { ExprTuple {
range: 9..18,
elts: [ elts: [
Attributed { Constant(
range: 10..11,
custom: (),
node: Constant(
ExprConstant { ExprConstant {
range: 10..11,
value: Int( value: Int(
1, 1,
), ),
kind: None, kind: None,
}, },
), ),
}, Constant(
Attributed {
range: 13..14,
custom: (),
node: Constant(
ExprConstant { ExprConstant {
range: 13..14,
value: Int( value: Int(
2, 2,
), ),
kind: None, kind: None,
}, },
), ),
}, Constant(
Attributed {
range: 16..17,
custom: (),
node: Constant(
ExprConstant { ExprConstant {
range: 16..17,
value: Int( value: Int(
3, 3,
), ),
kind: None, kind: None,
}, },
), ),
},
], ],
ctx: Load, ctx: Load,
}, },
), ),
},
body: [ body: [
Attributed { Pass(
StmtPass {
range: 20..24, range: 20..24,
custom: (),
node: Pass,
}, },
),
], ],
orelse: [], orelse: [],
type_comment: None, type_comment: None,
}, },
), ),
},
] ]

View File

@ -3,97 +3,73 @@ source: parser/src/context.rs
expression: parse_ast expression: parse_ast
--- ---
[ [
Attributed { Assign(
range: 0..18,
custom: (),
node: Assign(
StmtAssign { StmtAssign {
range: 0..18,
targets: [ targets: [
Attributed { List(
range: 0..6,
custom: (),
node: List(
ExprList { ExprList {
range: 0..6,
elts: [ elts: [
Attributed { Name(
range: 1..2,
custom: (),
node: Name(
ExprName { ExprName {
range: 1..2,
id: Identifier( id: Identifier(
"x", "x",
), ),
ctx: Store, ctx: Store,
}, },
), ),
}, Name(
Attributed {
range: 4..5,
custom: (),
node: Name(
ExprName { ExprName {
range: 4..5,
id: Identifier( id: Identifier(
"y", "y",
), ),
ctx: Store, ctx: Store,
}, },
), ),
},
], ],
ctx: Store, ctx: Store,
}, },
), ),
},
], ],
value: Attributed { value: Tuple(
range: 9..18,
custom: (),
node: Tuple(
ExprTuple { ExprTuple {
range: 9..18,
elts: [ elts: [
Attributed { Constant(
range: 10..11,
custom: (),
node: Constant(
ExprConstant { ExprConstant {
range: 10..11,
value: Int( value: Int(
1, 1,
), ),
kind: None, kind: None,
}, },
), ),
}, Constant(
Attributed {
range: 13..14,
custom: (),
node: Constant(
ExprConstant { ExprConstant {
range: 13..14,
value: Int( value: Int(
2, 2,
), ),
kind: None, kind: None,
}, },
), ),
}, Constant(
Attributed {
range: 16..17,
custom: (),
node: Constant(
ExprConstant { ExprConstant {
range: 16..17,
value: Int( value: Int(
3, 3,
), ),
kind: None, kind: None,
}, },
), ),
},
], ],
ctx: Load, ctx: Load,
}, },
), ),
},
type_comment: None, type_comment: None,
}, },
), ),
},
] ]

View File

@ -3,112 +3,86 @@ source: parser/src/context.rs
expression: parse_ast expression: parse_ast
--- ---
[ [
Attributed { Assign(
range: 0..26,
custom: (),
node: Assign(
StmtAssign { StmtAssign {
range: 0..26,
targets: [ targets: [
Attributed { Name(
range: 0..1,
custom: (),
node: Name(
ExprName { ExprName {
range: 0..1,
id: Identifier( id: Identifier(
"x", "x",
), ),
ctx: Store, ctx: Store,
}, },
), ),
},
], ],
value: Attributed { value: ListComp(
range: 4..26,
custom: (),
node: ListComp(
ExprListComp { ExprListComp {
elt: Attributed { range: 4..26,
range: 5..6, elt: Name(
custom: (),
node: Name(
ExprName { ExprName {
range: 5..6,
id: Identifier( id: Identifier(
"y", "y",
), ),
ctx: Load, ctx: Load,
}, },
), ),
},
generators: [ generators: [
Comprehension { Comprehension {
target: Attributed { target: Name(
range: 11..12,
custom: (),
node: Name(
ExprName { ExprName {
range: 11..12,
id: Identifier( id: Identifier(
"y", "y",
), ),
ctx: Store, ctx: Store,
}, },
), ),
}, iter: Tuple(
iter: Attributed {
range: 16..25,
custom: (),
node: Tuple(
ExprTuple { ExprTuple {
range: 16..25,
elts: [ elts: [
Attributed { Constant(
range: 17..18,
custom: (),
node: Constant(
ExprConstant { ExprConstant {
range: 17..18,
value: Int( value: Int(
1, 1,
), ),
kind: None, kind: None,
}, },
), ),
}, Constant(
Attributed {
range: 20..21,
custom: (),
node: Constant(
ExprConstant { ExprConstant {
range: 20..21,
value: Int( value: Int(
2, 2,
), ),
kind: None, kind: None,
}, },
), ),
}, Constant(
Attributed {
range: 23..24,
custom: (),
node: Constant(
ExprConstant { ExprConstant {
range: 23..24,
value: Int( value: Int(
3, 3,
), ),
kind: None, kind: None,
}, },
), ),
},
], ],
ctx: Load, ctx: Load,
}, },
), ),
},
ifs: [], ifs: [],
is_async: false, is_async: false,
range: (),
}, },
], ],
}, },
), ),
},
type_comment: None, type_comment: None,
}, },
), ),
},
] ]

View File

@ -3,74 +3,56 @@ source: parser/src/context.rs
expression: parse_ast expression: parse_ast
--- ---
[ [
Attributed { Assign(
range: 0..13,
custom: (),
node: Assign(
StmtAssign { StmtAssign {
range: 0..13,
targets: [ targets: [
Attributed { Name(
range: 0..1,
custom: (),
node: Name(
ExprName { ExprName {
range: 0..1,
id: Identifier( id: Identifier(
"x", "x",
), ),
ctx: Store, ctx: Store,
}, },
), ),
},
], ],
value: Attributed { value: Tuple(
range: 4..13,
custom: (),
node: Tuple(
ExprTuple { ExprTuple {
range: 4..13,
elts: [ elts: [
Attributed { Constant(
range: 5..6,
custom: (),
node: Constant(
ExprConstant { ExprConstant {
range: 5..6,
value: Int( value: Int(
1, 1,
), ),
kind: None, kind: None,
}, },
), ),
}, Constant(
Attributed {
range: 8..9,
custom: (),
node: Constant(
ExprConstant { ExprConstant {
range: 8..9,
value: Int( value: Int(
2, 2,
), ),
kind: None, kind: None,
}, },
), ),
}, Constant(
Attributed {
range: 11..12,
custom: (),
node: Constant(
ExprConstant { ExprConstant {
range: 11..12,
value: Int( value: Int(
3, 3,
), ),
kind: None, kind: None,
}, },
), ),
},
], ],
ctx: Load, ctx: Load,
}, },
), ),
},
type_comment: None, type_comment: None,
}, },
), ),
},
] ]

View File

@ -3,33 +3,24 @@ source: parser/src/context.rs
expression: parse_ast expression: parse_ast
--- ---
[ [
Attributed { If(
range: 0..14,
custom: (),
node: If(
StmtIf { StmtIf {
test: Attributed { range: 0..14,
range: 3..8, test: NamedExpr(
custom: (),
node: NamedExpr(
ExprNamedExpr { ExprNamedExpr {
target: Attributed { range: 3..8,
range: 3..4, target: Name(
custom: (),
node: Name(
ExprName { ExprName {
range: 3..4,
id: Identifier( id: Identifier(
"x", "x",
), ),
ctx: Store, ctx: Store,
}, },
), ),
}, value: Constant(
value: Attributed {
range: 7..8,
custom: (),
node: Constant(
ExprConstant { ExprConstant {
range: 7..8,
value: Int( value: Int(
1, 1,
), ),
@ -37,18 +28,15 @@ expression: parse_ast
}, },
), ),
}, },
),
body: [
Pass(
StmtPass {
range: 10..14,
}, },
), ),
},
body: [
Attributed {
range: 10..14,
custom: (),
node: Pass,
},
], ],
orelse: [], orelse: [],
}, },
), ),
},
] ]

View File

@ -3,112 +3,86 @@ source: parser/src/context.rs
expression: parse_ast expression: parse_ast
--- ---
[ [
Attributed { Assign(
range: 0..26,
custom: (),
node: Assign(
StmtAssign { StmtAssign {
range: 0..26,
targets: [ targets: [
Attributed { Name(
range: 0..1,
custom: (),
node: Name(
ExprName { ExprName {
range: 0..1,
id: Identifier( id: Identifier(
"x", "x",
), ),
ctx: Store, ctx: Store,
}, },
), ),
},
], ],
value: Attributed { value: SetComp(
range: 4..26,
custom: (),
node: SetComp(
ExprSetComp { ExprSetComp {
elt: Attributed { range: 4..26,
range: 5..6, elt: Name(
custom: (),
node: Name(
ExprName { ExprName {
range: 5..6,
id: Identifier( id: Identifier(
"y", "y",
), ),
ctx: Load, ctx: Load,
}, },
), ),
},
generators: [ generators: [
Comprehension { Comprehension {
target: Attributed { target: Name(
range: 11..12,
custom: (),
node: Name(
ExprName { ExprName {
range: 11..12,
id: Identifier( id: Identifier(
"y", "y",
), ),
ctx: Store, ctx: Store,
}, },
), ),
}, iter: Tuple(
iter: Attributed {
range: 16..25,
custom: (),
node: Tuple(
ExprTuple { ExprTuple {
range: 16..25,
elts: [ elts: [
Attributed { Constant(
range: 17..18,
custom: (),
node: Constant(
ExprConstant { ExprConstant {
range: 17..18,
value: Int( value: Int(
1, 1,
), ),
kind: None, kind: None,
}, },
), ),
}, Constant(
Attributed {
range: 20..21,
custom: (),
node: Constant(
ExprConstant { ExprConstant {
range: 20..21,
value: Int( value: Int(
2, 2,
), ),
kind: None, kind: None,
}, },
), ),
}, Constant(
Attributed {
range: 23..24,
custom: (),
node: Constant(
ExprConstant { ExprConstant {
range: 23..24,
value: Int( value: Int(
3, 3,
), ),
kind: None, kind: None,
}, },
), ),
},
], ],
ctx: Load, ctx: Load,
}, },
), ),
},
ifs: [], ifs: [],
is_async: false, is_async: false,
range: (),
}, },
], ],
}, },
), ),
},
type_comment: None, type_comment: None,
}, },
), ),
},
] ]

View File

@ -3,106 +3,79 @@ source: parser/src/context.rs
expression: parse_ast expression: parse_ast
--- ---
[ [
Attributed { Assign(
range: 0..19,
custom: (),
node: Assign(
StmtAssign { StmtAssign {
range: 0..19,
targets: [ targets: [
Attributed { Tuple(
range: 0..7,
custom: (),
node: Tuple(
ExprTuple { ExprTuple {
range: 0..7,
elts: [ elts: [
Attributed { Name(
range: 1..2,
custom: (),
node: Name(
ExprName { ExprName {
range: 1..2,
id: Identifier( id: Identifier(
"x", "x",
), ),
ctx: Store, ctx: Store,
}, },
), ),
}, Starred(
Attributed {
range: 4..6,
custom: (),
node: Starred(
ExprStarred { ExprStarred {
value: Attributed { range: 4..6,
range: 5..6, value: Name(
custom: (),
node: Name(
ExprName { ExprName {
range: 5..6,
id: Identifier( id: Identifier(
"y", "y",
), ),
ctx: Store, ctx: Store,
}, },
), ),
},
ctx: Store, ctx: Store,
}, },
), ),
},
], ],
ctx: Store, ctx: Store,
}, },
), ),
},
], ],
value: Attributed { value: Tuple(
range: 10..19,
custom: (),
node: Tuple(
ExprTuple { ExprTuple {
range: 10..19,
elts: [ elts: [
Attributed { Constant(
range: 11..12,
custom: (),
node: Constant(
ExprConstant { ExprConstant {
range: 11..12,
value: Int( value: Int(
1, 1,
), ),
kind: None, kind: None,
}, },
), ),
}, Constant(
Attributed {
range: 14..15,
custom: (),
node: Constant(
ExprConstant { ExprConstant {
range: 14..15,
value: Int( value: Int(
2, 2,
), ),
kind: None, kind: None,
}, },
), ),
}, Constant(
Attributed {
range: 17..18,
custom: (),
node: Constant(
ExprConstant { ExprConstant {
range: 17..18,
value: Int( value: Int(
3, 3,
), ),
kind: None, kind: None,
}, },
), ),
},
], ],
ctx: Load, ctx: Load,
}, },
), ),
},
type_comment: None, type_comment: None,
}, },
), ),
},
] ]

View File

@ -3,95 +3,71 @@ source: parser/src/context.rs
expression: parse_ast expression: parse_ast
--- ---
[ [
Attributed { Assign(
range: 0..16,
custom: (),
node: Assign(
StmtAssign { StmtAssign {
range: 0..16,
targets: [ targets: [
Attributed { Subscript(
range: 0..4,
custom: (),
node: Subscript(
ExprSubscript { ExprSubscript {
value: Attributed { range: 0..4,
range: 0..1, value: Name(
custom: (),
node: Name(
ExprName { ExprName {
range: 0..1,
id: Identifier( id: Identifier(
"x", "x",
), ),
ctx: Load, ctx: Load,
}, },
), ),
}, slice: Name(
slice: Attributed {
range: 2..3,
custom: (),
node: Name(
ExprName { ExprName {
range: 2..3,
id: Identifier( id: Identifier(
"y", "y",
), ),
ctx: Load, ctx: Load,
}, },
), ),
},
ctx: Store, ctx: Store,
}, },
), ),
},
], ],
value: Attributed { value: Tuple(
range: 7..16,
custom: (),
node: Tuple(
ExprTuple { ExprTuple {
range: 7..16,
elts: [ elts: [
Attributed { Constant(
range: 8..9,
custom: (),
node: Constant(
ExprConstant { ExprConstant {
range: 8..9,
value: Int( value: Int(
1, 1,
), ),
kind: None, kind: None,
}, },
), ),
}, Constant(
Attributed {
range: 11..12,
custom: (),
node: Constant(
ExprConstant { ExprConstant {
range: 11..12,
value: Int( value: Int(
2, 2,
), ),
kind: None, kind: None,
}, },
), ),
}, Constant(
Attributed {
range: 14..15,
custom: (),
node: Constant(
ExprConstant { ExprConstant {
range: 14..15,
value: Int( value: Int(
3, 3,
), ),
kind: None, kind: None,
}, },
), ),
},
], ],
ctx: Load, ctx: Load,
}, },
), ),
},
type_comment: None, type_comment: None,
}, },
), ),
},
] ]

View File

@ -3,97 +3,73 @@ source: parser/src/context.rs
expression: parse_ast expression: parse_ast
--- ---
[ [
Attributed { Assign(
range: 0..18,
custom: (),
node: Assign(
StmtAssign { StmtAssign {
range: 0..18,
targets: [ targets: [
Attributed { Tuple(
range: 0..6,
custom: (),
node: Tuple(
ExprTuple { ExprTuple {
range: 0..6,
elts: [ elts: [
Attributed { Name(
range: 1..2,
custom: (),
node: Name(
ExprName { ExprName {
range: 1..2,
id: Identifier( id: Identifier(
"x", "x",
), ),
ctx: Store, ctx: Store,
}, },
), ),
}, Name(
Attributed {
range: 4..5,
custom: (),
node: Name(
ExprName { ExprName {
range: 4..5,
id: Identifier( id: Identifier(
"y", "y",
), ),
ctx: Store, ctx: Store,
}, },
), ),
},
], ],
ctx: Store, ctx: Store,
}, },
), ),
},
], ],
value: Attributed { value: Tuple(
range: 9..18,
custom: (),
node: Tuple(
ExprTuple { ExprTuple {
range: 9..18,
elts: [ elts: [
Attributed { Constant(
range: 10..11,
custom: (),
node: Constant(
ExprConstant { ExprConstant {
range: 10..11,
value: Int( value: Int(
1, 1,
), ),
kind: None, kind: None,
}, },
), ),
}, Constant(
Attributed {
range: 13..14,
custom: (),
node: Constant(
ExprConstant { ExprConstant {
range: 13..14,
value: Int( value: Int(
2, 2,
), ),
kind: None, kind: None,
}, },
), ),
}, Constant(
Attributed {
range: 16..17,
custom: (),
node: Constant(
ExprConstant { ExprConstant {
range: 16..17,
value: Int( value: Int(
3, 3,
), ),
kind: None, kind: None,
}, },
), ),
},
], ],
ctx: Load, ctx: Load,
}, },
), ),
},
type_comment: None, type_comment: None,
}, },
), ),
},
] ]

View File

@ -3,50 +3,42 @@ source: parser/src/context.rs
expression: parse_ast expression: parse_ast
--- ---
[ [
Attributed { With(
range: 0..17,
custom: (),
node: With(
StmtWith { StmtWith {
range: 0..17,
items: [ items: [
Withitem { Withitem {
context_expr: Attributed { context_expr: Constant(
range: 5..6,
custom: (),
node: Constant(
ExprConstant { ExprConstant {
range: 5..6,
value: Int( value: Int(
1, 1,
), ),
kind: None, kind: None,
}, },
), ),
},
optional_vars: Some( optional_vars: Some(
Attributed { Name(
range: 10..11,
custom: (),
node: Name(
ExprName { ExprName {
range: 10..11,
id: Identifier( id: Identifier(
"x", "x",
), ),
ctx: Store, ctx: Store,
}, },
), ),
},
), ),
range: (),
}, },
], ],
body: [ body: [
Attributed { Pass(
StmtPass {
range: 13..17, range: 13..17,
custom: (),
node: Pass,
}, },
),
], ],
type_comment: None, type_comment: None,
}, },
), ),
},
] ]

View File

@ -3,84 +3,63 @@ source: parser/src/context.rs
expression: parse_ast expression: parse_ast
--- ---
[ [
Attributed { AugAssign(
range: 0..16,
custom: (),
node: AugAssign(
StmtAugAssign { StmtAugAssign {
target: Attributed { range: 0..16,
range: 0..3, target: Attribute(
custom: (),
node: Attribute(
ExprAttribute { ExprAttribute {
value: Attributed { range: 0..3,
range: 0..1, value: Name(
custom: (),
node: Name(
ExprName { ExprName {
range: 0..1,
id: Identifier( id: Identifier(
"x", "x",
), ),
ctx: Load, ctx: Load,
}, },
), ),
},
attr: Identifier( attr: Identifier(
"y", "y",
), ),
ctx: Store, ctx: Store,
}, },
), ),
},
op: Add, op: Add,
value: Attributed { value: Tuple(
range: 7..16,
custom: (),
node: Tuple(
ExprTuple { ExprTuple {
range: 7..16,
elts: [ elts: [
Attributed { Constant(
range: 8..9,
custom: (),
node: Constant(
ExprConstant { ExprConstant {
range: 8..9,
value: Int( value: Int(
1, 1,
), ),
kind: None, kind: None,
}, },
), ),
}, Constant(
Attributed {
range: 11..12,
custom: (),
node: Constant(
ExprConstant { ExprConstant {
range: 11..12,
value: Int( value: Int(
2, 2,
), ),
kind: None, kind: None,
}, },
), ),
}, Constant(
Attributed {
range: 14..15,
custom: (),
node: Constant(
ExprConstant { ExprConstant {
range: 14..15,
value: Int( value: Int(
3, 3,
), ),
kind: None, kind: None,
}, },
), ),
},
], ],
ctx: Load, ctx: Load,
}, },
), ),
}, },
},
), ),
},
] ]

View File

@ -3,29 +3,22 @@ source: parser/src/context.rs
expression: parse_ast expression: parse_ast
--- ---
[ [
Attributed { AugAssign(
range: 0..6,
custom: (),
node: AugAssign(
StmtAugAssign { StmtAugAssign {
target: Attributed { range: 0..6,
range: 0..1, target: Name(
custom: (),
node: Name(
ExprName { ExprName {
range: 0..1,
id: Identifier( id: Identifier(
"x", "x",
), ),
ctx: Store, ctx: Store,
}, },
), ),
},
op: Add, op: Add,
value: Attributed { value: Constant(
range: 5..6,
custom: (),
node: Constant(
ExprConstant { ExprConstant {
range: 5..6,
value: Int( value: Int(
1, 1,
), ),
@ -33,7 +26,5 @@ expression: parse_ast
}, },
), ),
}, },
},
), ),
},
] ]

View File

@ -3,93 +3,69 @@ source: parser/src/context.rs
expression: parse_ast expression: parse_ast
--- ---
[ [
Attributed { AugAssign(
range: 0..17,
custom: (),
node: AugAssign(
StmtAugAssign { StmtAugAssign {
target: Attributed { range: 0..17,
range: 0..4, target: Subscript(
custom: (),
node: Subscript(
ExprSubscript { ExprSubscript {
value: Attributed { range: 0..4,
range: 0..1, value: Name(
custom: (),
node: Name(
ExprName { ExprName {
range: 0..1,
id: Identifier( id: Identifier(
"x", "x",
), ),
ctx: Load, ctx: Load,
}, },
), ),
}, slice: Name(
slice: Attributed {
range: 2..3,
custom: (),
node: Name(
ExprName { ExprName {
range: 2..3,
id: Identifier( id: Identifier(
"y", "y",
), ),
ctx: Load, ctx: Load,
}, },
), ),
},
ctx: Store, ctx: Store,
}, },
), ),
},
op: Add, op: Add,
value: Attributed { value: Tuple(
range: 8..17,
custom: (),
node: Tuple(
ExprTuple { ExprTuple {
range: 8..17,
elts: [ elts: [
Attributed { Constant(
range: 9..10,
custom: (),
node: Constant(
ExprConstant { ExprConstant {
range: 9..10,
value: Int( value: Int(
1, 1,
), ),
kind: None, kind: None,
}, },
), ),
}, Constant(
Attributed {
range: 12..13,
custom: (),
node: Constant(
ExprConstant { ExprConstant {
range: 12..13,
value: Int( value: Int(
2, 2,
), ),
kind: None, kind: None,
}, },
), ),
}, Constant(
Attributed {
range: 15..16,
custom: (),
node: Constant(
ExprConstant { ExprConstant {
range: 15..16,
value: Int( value: Int(
3, 3,
), ),
kind: None, kind: None,
}, },
), ),
},
], ],
ctx: Load, ctx: Load,
}, },
), ),
}, },
},
), ),
},
] ]

View File

@ -3,38 +3,29 @@ source: parser/src/context.rs
expression: parse_ast expression: parse_ast
--- ---
[ [
Attributed { Delete(
range: 0..7,
custom: (),
node: Delete(
StmtDelete { StmtDelete {
range: 0..7,
targets: [ targets: [
Attributed { Attribute(
range: 4..7,
custom: (),
node: Attribute(
ExprAttribute { ExprAttribute {
value: Attributed { range: 4..7,
range: 4..5, value: Name(
custom: (),
node: Name(
ExprName { ExprName {
range: 4..5,
id: Identifier( id: Identifier(
"x", "x",
), ),
ctx: Load, ctx: Load,
}, },
), ),
},
attr: Identifier( attr: Identifier(
"y", "y",
), ),
ctx: Del, ctx: Del,
}, },
), ),
},
], ],
}, },
), ),
},
] ]

View File

@ -3,26 +3,20 @@ source: parser/src/context.rs
expression: parse_ast expression: parse_ast
--- ---
[ [
Attributed { Delete(
range: 0..5,
custom: (),
node: Delete(
StmtDelete { StmtDelete {
range: 0..5,
targets: [ targets: [
Attributed { Name(
range: 4..5,
custom: (),
node: Name(
ExprName { ExprName {
range: 4..5,
id: Identifier( id: Identifier(
"x", "x",
), ),
ctx: Del, ctx: Del,
}, },
), ),
},
], ],
}, },
), ),
},
] ]

View File

@ -3,47 +3,35 @@ source: parser/src/context.rs
expression: parse_ast expression: parse_ast
--- ---
[ [
Attributed { Delete(
range: 0..8,
custom: (),
node: Delete(
StmtDelete { StmtDelete {
range: 0..8,
targets: [ targets: [
Attributed { Subscript(
range: 4..8,
custom: (),
node: Subscript(
ExprSubscript { ExprSubscript {
value: Attributed { range: 4..8,
range: 4..5, value: Name(
custom: (),
node: Name(
ExprName { ExprName {
range: 4..5,
id: Identifier( id: Identifier(
"x", "x",
), ),
ctx: Load, ctx: Load,
}, },
), ),
}, slice: Name(
slice: Attributed {
range: 6..7,
custom: (),
node: Name(
ExprName { ExprName {
range: 6..7,
id: Identifier( id: Identifier(
"y", "y",
), ),
ctx: Load, ctx: Load,
}, },
), ),
},
ctx: Del, ctx: Del,
}, },
), ),
},
], ],
}, },
), ),
},
] ]

View File

@ -4,11 +4,9 @@ expression: parse_ast
--- ---
Ok( Ok(
[ [
Attributed { FunctionDef(
range: 0..23,
custom: (),
node: FunctionDef(
StmtFunctionDef { StmtFunctionDef {
range: 0..23,
name: Identifier( name: Identifier(
"f", "f",
), ),
@ -17,56 +15,47 @@ Ok(
args: [], args: [],
vararg: None, vararg: None,
kwonlyargs: [ kwonlyargs: [
Attributed { Arg {
range: 9..10,
custom: (),
node: ArgData {
arg: Identifier( arg: Identifier(
"a", "a",
), ),
annotation: None, annotation: None,
type_comment: None, type_comment: None,
range: 9..10,
}, },
}, Arg {
Attributed {
range: 12..13,
custom: (),
node: ArgData {
arg: Identifier( arg: Identifier(
"b", "b",
), ),
annotation: None, annotation: None,
type_comment: None, type_comment: None,
range: 12..13,
}, },
}, Arg {
Attributed {
range: 15..16,
custom: (),
node: ArgData {
arg: Identifier( arg: Identifier(
"c", "c",
), ),
annotation: None, annotation: None,
type_comment: None, type_comment: None,
}, range: 15..16,
}, },
], ],
kw_defaults: [], kw_defaults: [],
kwarg: None, kwarg: None,
defaults: [], defaults: [],
range: (),
}, },
body: [ body: [
Attributed { Pass(
StmtPass {
range: 19..23, range: 19..23,
custom: (),
node: Pass,
}, },
),
], ],
decorator_list: [], decorator_list: [],
returns: None, returns: None,
type_comment: None, type_comment: None,
}, },
), ),
},
], ],
) )

View File

@ -4,11 +4,9 @@ expression: parse_ast
--- ---
Ok( Ok(
[ [
Attributed { FunctionDef(
range: 0..29,
custom: (),
node: FunctionDef(
StmtFunctionDef { StmtFunctionDef {
range: 0..29,
name: Identifier( name: Identifier(
"f", "f",
), ),
@ -17,81 +15,66 @@ Ok(
args: [], args: [],
vararg: None, vararg: None,
kwonlyargs: [ kwonlyargs: [
Attributed { Arg {
range: 9..10,
custom: (),
node: ArgData {
arg: Identifier( arg: Identifier(
"a", "a",
), ),
annotation: None, annotation: None,
type_comment: None, type_comment: None,
range: 9..10,
}, },
}, Arg {
Attributed {
range: 12..13,
custom: (),
node: ArgData {
arg: Identifier( arg: Identifier(
"b", "b",
), ),
annotation: None, annotation: None,
type_comment: None, type_comment: None,
range: 12..13,
}, },
}, Arg {
Attributed {
range: 18..19,
custom: (),
node: ArgData {
arg: Identifier( arg: Identifier(
"c", "c",
), ),
annotation: None, annotation: None,
type_comment: None, type_comment: None,
}, range: 18..19,
}, },
], ],
kw_defaults: [ kw_defaults: [
Attributed { Constant(
range: 14..16,
custom: (),
node: Constant(
ExprConstant { ExprConstant {
range: 14..16,
value: Int( value: Int(
20, 20,
), ),
kind: None, kind: None,
}, },
), ),
}, Constant(
Attributed {
range: 20..22,
custom: (),
node: Constant(
ExprConstant { ExprConstant {
range: 20..22,
value: Int( value: Int(
30, 30,
), ),
kind: None, kind: None,
}, },
), ),
},
], ],
kwarg: None, kwarg: None,
defaults: [], defaults: [],
range: (),
}, },
body: [ body: [
Attributed { Pass(
StmtPass {
range: 25..29, range: 25..29,
custom: (),
node: Pass,
}, },
),
], ],
decorator_list: [], decorator_list: [],
returns: None, returns: None,
type_comment: None, type_comment: None,
}, },
), ),
},
], ],
) )

View File

@ -4,11 +4,9 @@ expression: parse_ast
--- ---
Ok( Ok(
[ [
Attributed { FunctionDef(
range: 0..13,
custom: (),
node: FunctionDef(
StmtFunctionDef { StmtFunctionDef {
range: 0..13,
name: Identifier( name: Identifier(
"f", "f",
), ),
@ -20,19 +18,19 @@ Ok(
kw_defaults: [], kw_defaults: [],
kwarg: None, kwarg: None,
defaults: [], defaults: [],
range: (),
}, },
body: [ body: [
Attributed { Pass(
StmtPass {
range: 9..13, range: 9..13,
custom: (),
node: Pass,
}, },
),
], ],
decorator_list: [], decorator_list: [],
returns: None, returns: None,
type_comment: None, type_comment: None,
}, },
), ),
},
], ],
) )

View File

@ -4,103 +4,83 @@ expression: parse_ast
--- ---
Ok( Ok(
[ [
Attributed { FunctionDef(
range: 0..32,
custom: (),
node: FunctionDef(
StmtFunctionDef { StmtFunctionDef {
range: 0..32,
name: Identifier( name: Identifier(
"f", "f",
), ),
args: Arguments { args: Arguments {
posonlyargs: [], posonlyargs: [],
args: [ args: [
Attributed { Arg {
range: 6..7,
custom: (),
node: ArgData {
arg: Identifier( arg: Identifier(
"a", "a",
), ),
annotation: None, annotation: None,
type_comment: None, type_comment: None,
range: 6..7,
}, },
}, Arg {
Attributed {
range: 9..10,
custom: (),
node: ArgData {
arg: Identifier( arg: Identifier(
"b", "b",
), ),
annotation: None, annotation: None,
type_comment: None, type_comment: None,
range: 9..10,
}, },
}, Arg {
Attributed {
range: 12..13,
custom: (),
node: ArgData {
arg: Identifier( arg: Identifier(
"c", "c",
), ),
annotation: None, annotation: None,
type_comment: None, type_comment: None,
}, range: 12..13,
}, },
], ],
vararg: None, vararg: None,
kwonlyargs: [ kwonlyargs: [
Attributed { Arg {
range: 18..19,
custom: (),
node: ArgData {
arg: Identifier( arg: Identifier(
"d", "d",
), ),
annotation: None, annotation: None,
type_comment: None, type_comment: None,
range: 18..19,
}, },
}, Arg {
Attributed {
range: 21..22,
custom: (),
node: ArgData {
arg: Identifier( arg: Identifier(
"e", "e",
), ),
annotation: None, annotation: None,
type_comment: None, type_comment: None,
range: 21..22,
}, },
}, Arg {
Attributed {
range: 24..25,
custom: (),
node: ArgData {
arg: Identifier( arg: Identifier(
"f", "f",
), ),
annotation: None, annotation: None,
type_comment: None, type_comment: None,
}, range: 24..25,
}, },
], ],
kw_defaults: [], kw_defaults: [],
kwarg: None, kwarg: None,
defaults: [], defaults: [],
range: (),
}, },
body: [ body: [
Attributed { Pass(
StmtPass {
range: 28..32, range: 28..32,
custom: (),
node: Pass,
}, },
),
], ],
decorator_list: [], decorator_list: [],
returns: None, returns: None,
type_comment: None, type_comment: None,
}, },
), ),
},
], ],
) )

View File

@ -4,128 +4,102 @@ expression: parse_ast
--- ---
Ok( Ok(
[ [
Attributed { FunctionDef(
range: 0..38,
custom: (),
node: FunctionDef(
StmtFunctionDef { StmtFunctionDef {
range: 0..38,
name: Identifier( name: Identifier(
"f", "f",
), ),
args: Arguments { args: Arguments {
posonlyargs: [], posonlyargs: [],
args: [ args: [
Attributed { Arg {
range: 6..7,
custom: (),
node: ArgData {
arg: Identifier( arg: Identifier(
"a", "a",
), ),
annotation: None, annotation: None,
type_comment: None, type_comment: None,
range: 6..7,
}, },
}, Arg {
Attributed {
range: 9..10,
custom: (),
node: ArgData {
arg: Identifier( arg: Identifier(
"b", "b",
), ),
annotation: None, annotation: None,
type_comment: None, type_comment: None,
range: 9..10,
}, },
}, Arg {
Attributed {
range: 12..13,
custom: (),
node: ArgData {
arg: Identifier( arg: Identifier(
"c", "c",
), ),
annotation: None, annotation: None,
type_comment: None, type_comment: None,
}, range: 12..13,
}, },
], ],
vararg: None, vararg: None,
kwonlyargs: [ kwonlyargs: [
Attributed { Arg {
range: 18..19,
custom: (),
node: ArgData {
arg: Identifier( arg: Identifier(
"d", "d",
), ),
annotation: None, annotation: None,
type_comment: None, type_comment: None,
range: 18..19,
}, },
}, Arg {
Attributed {
range: 21..22,
custom: (),
node: ArgData {
arg: Identifier( arg: Identifier(
"e", "e",
), ),
annotation: None, annotation: None,
type_comment: None, type_comment: None,
range: 21..22,
}, },
}, Arg {
Attributed {
range: 27..28,
custom: (),
node: ArgData {
arg: Identifier( arg: Identifier(
"f", "f",
), ),
annotation: None, annotation: None,
type_comment: None, type_comment: None,
}, range: 27..28,
}, },
], ],
kw_defaults: [ kw_defaults: [
Attributed { Constant(
range: 23..25,
custom: (),
node: Constant(
ExprConstant { ExprConstant {
range: 23..25,
value: Int( value: Int(
20, 20,
), ),
kind: None, kind: None,
}, },
), ),
}, Constant(
Attributed {
range: 29..31,
custom: (),
node: Constant(
ExprConstant { ExprConstant {
range: 29..31,
value: Int( value: Int(
30, 30,
), ),
kind: None, kind: None,
}, },
), ),
},
], ],
kwarg: None, kwarg: None,
defaults: [], defaults: [],
range: (),
}, },
body: [ body: [
Attributed { Pass(
StmtPass {
range: 34..38, range: 34..38,
custom: (),
node: Pass,
}, },
),
], ],
decorator_list: [], decorator_list: [],
returns: None, returns: None,
type_comment: None, type_comment: None,
}, },
), ),
},
], ],
) )

View File

@ -4,140 +4,111 @@ expression: parse_ast
--- ---
Ok( Ok(
[ [
Attributed { FunctionDef(
range: 0..42,
custom: (),
node: FunctionDef(
StmtFunctionDef { StmtFunctionDef {
range: 0..42,
name: Identifier( name: Identifier(
"f", "f",
), ),
args: Arguments { args: Arguments {
posonlyargs: [], posonlyargs: [],
args: [ args: [
Attributed { Arg {
range: 6..7,
custom: (),
node: ArgData {
arg: Identifier( arg: Identifier(
"a", "a",
), ),
annotation: None, annotation: None,
type_comment: None, type_comment: None,
range: 6..7,
}, },
}, Arg {
Attributed {
range: 9..10,
custom: (),
node: ArgData {
arg: Identifier( arg: Identifier(
"b", "b",
), ),
annotation: None, annotation: None,
type_comment: None, type_comment: None,
range: 9..10,
}, },
}, Arg {
Attributed {
range: 12..13,
custom: (),
node: ArgData {
arg: Identifier( arg: Identifier(
"c", "c",
), ),
annotation: None, annotation: None,
type_comment: None, type_comment: None,
}, range: 12..13,
}, },
], ],
vararg: Some( vararg: Some(
Attributed { Arg {
range: 16..20,
custom: (),
node: ArgData {
arg: Identifier( arg: Identifier(
"args", "args",
), ),
annotation: None, annotation: None,
type_comment: None, type_comment: None,
}, range: 16..20,
}, },
), ),
kwonlyargs: [ kwonlyargs: [
Attributed { Arg {
range: 22..23,
custom: (),
node: ArgData {
arg: Identifier( arg: Identifier(
"d", "d",
), ),
annotation: None, annotation: None,
type_comment: None, type_comment: None,
range: 22..23,
}, },
}, Arg {
Attributed {
range: 25..26,
custom: (),
node: ArgData {
arg: Identifier( arg: Identifier(
"e", "e",
), ),
annotation: None, annotation: None,
type_comment: None, type_comment: None,
range: 25..26,
}, },
}, Arg {
Attributed {
range: 31..32,
custom: (),
node: ArgData {
arg: Identifier( arg: Identifier(
"f", "f",
), ),
annotation: None, annotation: None,
type_comment: None, type_comment: None,
}, range: 31..32,
}, },
], ],
kw_defaults: [ kw_defaults: [
Attributed { Constant(
range: 27..29,
custom: (),
node: Constant(
ExprConstant { ExprConstant {
range: 27..29,
value: Int( value: Int(
20, 20,
), ),
kind: None, kind: None,
}, },
), ),
}, Constant(
Attributed {
range: 33..35,
custom: (),
node: Constant(
ExprConstant { ExprConstant {
range: 33..35,
value: Int( value: Int(
30, 30,
), ),
kind: None, kind: None,
}, },
), ),
},
], ],
kwarg: None, kwarg: None,
defaults: [], defaults: [],
range: (),
}, },
body: [ body: [
Attributed { Pass(
StmtPass {
range: 38..42, range: 38..42,
custom: (),
node: Pass,
}, },
),
], ],
decorator_list: [], decorator_list: [],
returns: None, returns: None,
type_comment: None, type_comment: None,
}, },
), ),
},
], ],
) )

View File

@ -4,152 +4,120 @@ expression: parse_ast
--- ---
Ok( Ok(
[ [
Attributed { FunctionDef(
range: 0..52,
custom: (),
node: FunctionDef(
StmtFunctionDef { StmtFunctionDef {
range: 0..52,
name: Identifier( name: Identifier(
"f", "f",
), ),
args: Arguments { args: Arguments {
posonlyargs: [], posonlyargs: [],
args: [ args: [
Attributed { Arg {
range: 6..7,
custom: (),
node: ArgData {
arg: Identifier( arg: Identifier(
"a", "a",
), ),
annotation: None, annotation: None,
type_comment: None, type_comment: None,
range: 6..7,
}, },
}, Arg {
Attributed {
range: 9..10,
custom: (),
node: ArgData {
arg: Identifier( arg: Identifier(
"b", "b",
), ),
annotation: None, annotation: None,
type_comment: None, type_comment: None,
range: 9..10,
}, },
}, Arg {
Attributed {
range: 12..13,
custom: (),
node: ArgData {
arg: Identifier( arg: Identifier(
"c", "c",
), ),
annotation: None, annotation: None,
type_comment: None, type_comment: None,
}, range: 12..13,
}, },
], ],
vararg: Some( vararg: Some(
Attributed { Arg {
range: 16..20,
custom: (),
node: ArgData {
arg: Identifier( arg: Identifier(
"args", "args",
), ),
annotation: None, annotation: None,
type_comment: None, type_comment: None,
}, range: 16..20,
}, },
), ),
kwonlyargs: [ kwonlyargs: [
Attributed { Arg {
range: 22..23,
custom: (),
node: ArgData {
arg: Identifier( arg: Identifier(
"d", "d",
), ),
annotation: None, annotation: None,
type_comment: None, type_comment: None,
range: 22..23,
}, },
}, Arg {
Attributed {
range: 25..26,
custom: (),
node: ArgData {
arg: Identifier( arg: Identifier(
"e", "e",
), ),
annotation: None, annotation: None,
type_comment: None, type_comment: None,
range: 25..26,
}, },
}, Arg {
Attributed {
range: 31..32,
custom: (),
node: ArgData {
arg: Identifier( arg: Identifier(
"f", "f",
), ),
annotation: None, annotation: None,
type_comment: None, type_comment: None,
}, range: 31..32,
}, },
], ],
kw_defaults: [ kw_defaults: [
Attributed { Constant(
range: 27..29,
custom: (),
node: Constant(
ExprConstant { ExprConstant {
range: 27..29,
value: Int( value: Int(
20, 20,
), ),
kind: None, kind: None,
}, },
), ),
}, Constant(
Attributed {
range: 33..35,
custom: (),
node: Constant(
ExprConstant { ExprConstant {
range: 33..35,
value: Int( value: Int(
30, 30,
), ),
kind: None, kind: None,
}, },
), ),
},
], ],
kwarg: Some( kwarg: Some(
Attributed { Arg {
range: 39..45,
custom: (),
node: ArgData {
arg: Identifier( arg: Identifier(
"kwargs", "kwargs",
), ),
annotation: None, annotation: None,
type_comment: None, type_comment: None,
}, range: 39..45,
}, },
), ),
defaults: [], defaults: [],
range: (),
}, },
body: [ body: [
Attributed { Pass(
StmtPass {
range: 48..52, range: 48..52,
custom: (),
node: Pass,
}, },
),
], ],
decorator_list: [], decorator_list: [],
returns: None, returns: None,
type_comment: None, type_comment: None,
}, },
), ),
},
], ],
) )

View File

@ -4,49 +4,38 @@ expression: parse_ast
--- ---
Ok( Ok(
[ [
Attributed { FunctionDef(
range: 0..20,
custom: (),
node: FunctionDef(
StmtFunctionDef { StmtFunctionDef {
range: 0..20,
name: Identifier( name: Identifier(
"f", "f",
), ),
args: Arguments { args: Arguments {
posonlyargs: [], posonlyargs: [],
args: [ args: [
Attributed { Arg {
range: 6..7,
custom: (),
node: ArgData {
arg: Identifier( arg: Identifier(
"a", "a",
), ),
annotation: None, annotation: None,
type_comment: None, type_comment: None,
range: 6..7,
}, },
}, Arg {
Attributed {
range: 9..10,
custom: (),
node: ArgData {
arg: Identifier( arg: Identifier(
"b", "b",
), ),
annotation: None, annotation: None,
type_comment: None, type_comment: None,
range: 9..10,
}, },
}, Arg {
Attributed {
range: 12..13,
custom: (),
node: ArgData {
arg: Identifier( arg: Identifier(
"c", "c",
), ),
annotation: None, annotation: None,
type_comment: None, type_comment: None,
}, range: 12..13,
}, },
], ],
vararg: None, vararg: None,
@ -54,19 +43,19 @@ Ok(
kw_defaults: [], kw_defaults: [],
kwarg: None, kwarg: None,
defaults: [], defaults: [],
range: (),
}, },
body: [ body: [
Attributed { Pass(
StmtPass {
range: 16..20, range: 16..20,
custom: (),
node: Pass,
}, },
),
], ],
decorator_list: [], decorator_list: [],
returns: None, returns: None,
type_comment: None, type_comment: None,
}, },
), ),
},
], ],
) )

View File

@ -4,49 +4,38 @@ expression: parse_ast
--- ---
Ok( Ok(
[ [
Attributed { FunctionDef(
range: 0..26,
custom: (),
node: FunctionDef(
StmtFunctionDef { StmtFunctionDef {
range: 0..26,
name: Identifier( name: Identifier(
"f", "f",
), ),
args: Arguments { args: Arguments {
posonlyargs: [], posonlyargs: [],
args: [ args: [
Attributed { Arg {
range: 6..7,
custom: (),
node: ArgData {
arg: Identifier( arg: Identifier(
"a", "a",
), ),
annotation: None, annotation: None,
type_comment: None, type_comment: None,
range: 6..7,
}, },
}, Arg {
Attributed {
range: 9..10,
custom: (),
node: ArgData {
arg: Identifier( arg: Identifier(
"b", "b",
), ),
annotation: None, annotation: None,
type_comment: None, type_comment: None,
range: 9..10,
}, },
}, Arg {
Attributed {
range: 15..16,
custom: (),
node: ArgData {
arg: Identifier( arg: Identifier(
"c", "c",
), ),
annotation: None, annotation: None,
type_comment: None, type_comment: None,
}, range: 15..16,
}, },
], ],
vararg: None, vararg: None,
@ -54,44 +43,38 @@ Ok(
kw_defaults: [], kw_defaults: [],
kwarg: None, kwarg: None,
defaults: [ defaults: [
Attributed { Constant(
range: 11..13,
custom: (),
node: Constant(
ExprConstant { ExprConstant {
range: 11..13,
value: Int( value: Int(
20, 20,
), ),
kind: None, kind: None,
}, },
), ),
}, Constant(
Attributed {
range: 17..19,
custom: (),
node: Constant(
ExprConstant { ExprConstant {
range: 17..19,
value: Int( value: Int(
30, 30,
), ),
kind: None, kind: None,
}, },
), ),
},
], ],
range: (),
}, },
body: [ body: [
Attributed { Pass(
StmtPass {
range: 22..26, range: 22..26,
custom: (),
node: Pass,
}, },
),
], ],
decorator_list: [], decorator_list: [],
returns: None, returns: None,
type_comment: None, type_comment: None,
}, },
), ),
},
], ],
) )

View File

@ -4,64 +4,50 @@ expression: parse_ast
--- ---
Ok( Ok(
[ [
Attributed { Expr(
range: 0..20,
custom: (),
node: Expr(
StmtExpr { StmtExpr {
value: Attributed {
range: 0..20, range: 0..20,
custom: (), value: Lambda(
node: Lambda(
ExprLambda { ExprLambda {
range: 0..20,
args: Arguments { args: Arguments {
posonlyargs: [], posonlyargs: [],
args: [], args: [],
vararg: None, vararg: None,
kwonlyargs: [ kwonlyargs: [
Attributed { Arg {
range: 10..11,
custom: (),
node: ArgData {
arg: Identifier( arg: Identifier(
"a", "a",
), ),
annotation: None, annotation: None,
type_comment: None, type_comment: None,
range: 10..11,
}, },
}, Arg {
Attributed {
range: 13..14,
custom: (),
node: ArgData {
arg: Identifier( arg: Identifier(
"b", "b",
), ),
annotation: None, annotation: None,
type_comment: None, type_comment: None,
range: 13..14,
}, },
}, Arg {
Attributed {
range: 16..17,
custom: (),
node: ArgData {
arg: Identifier( arg: Identifier(
"c", "c",
), ),
annotation: None, annotation: None,
type_comment: None, type_comment: None,
}, range: 16..17,
}, },
], ],
kw_defaults: [], kw_defaults: [],
kwarg: None, kwarg: None,
defaults: [], defaults: [],
range: (),
}, },
body: Attributed { body: Constant(
range: 19..20,
custom: (),
node: Constant(
ExprConstant { ExprConstant {
range: 19..20,
value: Int( value: Int(
1, 1,
), ),
@ -69,11 +55,8 @@ Ok(
}, },
), ),
}, },
},
), ),
}, },
},
), ),
},
], ],
) )

View File

@ -4,89 +4,69 @@ expression: parse_ast
--- ---
Ok( Ok(
[ [
Attributed { Expr(
range: 0..26,
custom: (),
node: Expr(
StmtExpr { StmtExpr {
value: Attributed {
range: 0..26, range: 0..26,
custom: (), value: Lambda(
node: Lambda(
ExprLambda { ExprLambda {
range: 0..26,
args: Arguments { args: Arguments {
posonlyargs: [], posonlyargs: [],
args: [], args: [],
vararg: None, vararg: None,
kwonlyargs: [ kwonlyargs: [
Attributed { Arg {
range: 10..11,
custom: (),
node: ArgData {
arg: Identifier( arg: Identifier(
"a", "a",
), ),
annotation: None, annotation: None,
type_comment: None, type_comment: None,
range: 10..11,
}, },
}, Arg {
Attributed {
range: 13..14,
custom: (),
node: ArgData {
arg: Identifier( arg: Identifier(
"b", "b",
), ),
annotation: None, annotation: None,
type_comment: None, type_comment: None,
range: 13..14,
}, },
}, Arg {
Attributed {
range: 19..20,
custom: (),
node: ArgData {
arg: Identifier( arg: Identifier(
"c", "c",
), ),
annotation: None, annotation: None,
type_comment: None, type_comment: None,
}, range: 19..20,
}, },
], ],
kw_defaults: [ kw_defaults: [
Attributed { Constant(
range: 15..17,
custom: (),
node: Constant(
ExprConstant { ExprConstant {
range: 15..17,
value: Int( value: Int(
20, 20,
), ),
kind: None, kind: None,
}, },
), ),
}, Constant(
Attributed {
range: 21..23,
custom: (),
node: Constant(
ExprConstant { ExprConstant {
range: 21..23,
value: Int( value: Int(
30, 30,
), ),
kind: None, kind: None,
}, },
), ),
},
], ],
kwarg: None, kwarg: None,
defaults: [], defaults: [],
range: (),
}, },
body: Attributed { body: Constant(
range: 25..26,
custom: (),
node: Constant(
ExprConstant { ExprConstant {
range: 25..26,
value: Int( value: Int(
1, 1,
), ),
@ -94,11 +74,8 @@ Ok(
}, },
), ),
}, },
},
), ),
}, },
},
), ),
},
], ],
) )

View File

@ -4,16 +4,12 @@ expression: parse_ast
--- ---
Ok( Ok(
[ [
Attributed { Expr(
range: 0..9,
custom: (),
node: Expr(
StmtExpr { StmtExpr {
value: Attributed {
range: 0..9, range: 0..9,
custom: (), value: Lambda(
node: Lambda(
ExprLambda { ExprLambda {
range: 0..9,
args: Arguments { args: Arguments {
posonlyargs: [], posonlyargs: [],
args: [], args: [],
@ -22,12 +18,11 @@ Ok(
kw_defaults: [], kw_defaults: [],
kwarg: None, kwarg: None,
defaults: [], defaults: [],
range: (),
}, },
body: Attributed { body: Constant(
range: 8..9,
custom: (),
node: Constant(
ExprConstant { ExprConstant {
range: 8..9,
value: Int( value: Int(
1, 1,
), ),
@ -35,11 +30,8 @@ Ok(
}, },
), ),
}, },
},
), ),
}, },
},
), ),
},
], ],
) )

View File

@ -4,87 +4,67 @@ expression: parse_ast
--- ---
Ok( Ok(
[ [
Attributed { Expr(
range: 0..26,
custom: (),
node: Expr(
StmtExpr { StmtExpr {
value: Attributed {
range: 0..26, range: 0..26,
custom: (), value: Lambda(
node: Lambda(
ExprLambda { ExprLambda {
range: 0..26,
args: Arguments { args: Arguments {
posonlyargs: [], posonlyargs: [],
args: [ args: [
Attributed { Arg {
range: 7..8,
custom: (),
node: ArgData {
arg: Identifier( arg: Identifier(
"a", "a",
), ),
annotation: None, annotation: None,
type_comment: None, type_comment: None,
range: 7..8,
}, },
}, Arg {
Attributed {
range: 10..11,
custom: (),
node: ArgData {
arg: Identifier( arg: Identifier(
"b", "b",
), ),
annotation: None, annotation: None,
type_comment: None, type_comment: None,
range: 10..11,
}, },
}, Arg {
Attributed {
range: 13..14,
custom: (),
node: ArgData {
arg: Identifier( arg: Identifier(
"c", "c",
), ),
annotation: None, annotation: None,
type_comment: None, type_comment: None,
}, range: 13..14,
}, },
], ],
vararg: None, vararg: None,
kwonlyargs: [ kwonlyargs: [
Attributed { Arg {
range: 19..20,
custom: (),
node: ArgData {
arg: Identifier( arg: Identifier(
"d", "d",
), ),
annotation: None, annotation: None,
type_comment: None, type_comment: None,
range: 19..20,
}, },
}, Arg {
Attributed {
range: 22..23,
custom: (),
node: ArgData {
arg: Identifier( arg: Identifier(
"e", "e",
), ),
annotation: None, annotation: None,
type_comment: None, type_comment: None,
}, range: 22..23,
}, },
], ],
kw_defaults: [], kw_defaults: [],
kwarg: None, kwarg: None,
defaults: [], defaults: [],
range: (),
}, },
body: Attributed { body: Constant(
range: 25..26,
custom: (),
node: Constant(
ExprConstant { ExprConstant {
range: 25..26,
value: Int( value: Int(
0, 0,
), ),
@ -92,11 +72,8 @@ Ok(
}, },
), ),
}, },
},
), ),
}, },
},
), ),
},
], ],
) )

View File

@ -4,51 +4,38 @@ expression: parse_ast
--- ---
Ok( Ok(
[ [
Attributed { Expr(
range: 0..17,
custom: (),
node: Expr(
StmtExpr { StmtExpr {
value: Attributed {
range: 0..17, range: 0..17,
custom: (), value: Lambda(
node: Lambda(
ExprLambda { ExprLambda {
range: 0..17,
args: Arguments { args: Arguments {
posonlyargs: [], posonlyargs: [],
args: [ args: [
Attributed { Arg {
range: 7..8,
custom: (),
node: ArgData {
arg: Identifier( arg: Identifier(
"a", "a",
), ),
annotation: None, annotation: None,
type_comment: None, type_comment: None,
range: 7..8,
}, },
}, Arg {
Attributed {
range: 10..11,
custom: (),
node: ArgData {
arg: Identifier( arg: Identifier(
"b", "b",
), ),
annotation: None, annotation: None,
type_comment: None, type_comment: None,
range: 10..11,
}, },
}, Arg {
Attributed {
range: 13..14,
custom: (),
node: ArgData {
arg: Identifier( arg: Identifier(
"c", "c",
), ),
annotation: None, annotation: None,
type_comment: None, type_comment: None,
}, range: 13..14,
}, },
], ],
vararg: None, vararg: None,
@ -56,12 +43,11 @@ Ok(
kw_defaults: [], kw_defaults: [],
kwarg: None, kwarg: None,
defaults: [], defaults: [],
range: (),
}, },
body: Attributed { body: Constant(
range: 16..17,
custom: (),
node: Constant(
ExprConstant { ExprConstant {
range: 16..17,
value: Int( value: Int(
1, 1,
), ),
@ -69,11 +55,8 @@ Ok(
}, },
), ),
}, },
},
), ),
}, },
},
), ),
},
], ],
) )

View File

@ -4,51 +4,38 @@ expression: parse_ast
--- ---
Ok( Ok(
[ [
Attributed { Expr(
range: 0..23,
custom: (),
node: Expr(
StmtExpr { StmtExpr {
value: Attributed {
range: 0..23, range: 0..23,
custom: (), value: Lambda(
node: Lambda(
ExprLambda { ExprLambda {
range: 0..23,
args: Arguments { args: Arguments {
posonlyargs: [], posonlyargs: [],
args: [ args: [
Attributed { Arg {
range: 7..8,
custom: (),
node: ArgData {
arg: Identifier( arg: Identifier(
"a", "a",
), ),
annotation: None, annotation: None,
type_comment: None, type_comment: None,
range: 7..8,
}, },
}, Arg {
Attributed {
range: 10..11,
custom: (),
node: ArgData {
arg: Identifier( arg: Identifier(
"b", "b",
), ),
annotation: None, annotation: None,
type_comment: None, type_comment: None,
range: 10..11,
}, },
}, Arg {
Attributed {
range: 16..17,
custom: (),
node: ArgData {
arg: Identifier( arg: Identifier(
"c", "c",
), ),
annotation: None, annotation: None,
type_comment: None, type_comment: None,
}, range: 16..17,
}, },
], ],
vararg: None, vararg: None,
@ -56,37 +43,30 @@ Ok(
kw_defaults: [], kw_defaults: [],
kwarg: None, kwarg: None,
defaults: [ defaults: [
Attributed { Constant(
range: 12..14,
custom: (),
node: Constant(
ExprConstant { ExprConstant {
range: 12..14,
value: Int( value: Int(
20, 20,
), ),
kind: None, kind: None,
}, },
), ),
}, Constant(
Attributed {
range: 18..20,
custom: (),
node: Constant(
ExprConstant { ExprConstant {
range: 18..20,
value: Int( value: Int(
30, 30,
), ),
kind: None, kind: None,
}, },
), ),
},
], ],
range: (),
}, },
body: Attributed { body: Constant(
range: 22..23,
custom: (),
node: Constant(
ExprConstant { ExprConstant {
range: 22..23,
value: Int( value: Int(
1, 1,
), ),
@ -94,11 +74,8 @@ Ok(
}, },
), ),
}, },
},
), ),
}, },
},
), ),
},
], ],
) )

View File

@ -2,80 +2,62 @@
source: parser/src/parser.rs source: parser/src/parser.rs
expression: parse_ast expression: parse_ast
--- ---
Attributed { Dict(
range: 0..25,
custom: (),
node: Dict(
ExprDict { ExprDict {
range: 0..25,
keys: [ keys: [
Some( Some(
Attributed { Constant(
range: 1..4,
custom: (),
node: Constant(
ExprConstant { ExprConstant {
range: 1..4,
value: Str( value: Str(
"a", "a",
), ),
kind: None, kind: None,
}, },
), ),
},
), ),
None, None,
Some( Some(
Attributed { Constant(
range: 16..19,
custom: (),
node: Constant(
ExprConstant { ExprConstant {
range: 16..19,
value: Str( value: Str(
"d", "d",
), ),
kind: None, kind: None,
}, },
), ),
},
), ),
], ],
values: [ values: [
Attributed { Constant(
range: 6..9,
custom: (),
node: Constant(
ExprConstant { ExprConstant {
range: 6..9,
value: Str( value: Str(
"b", "b",
), ),
kind: None, kind: None,
}, },
), ),
}, Name(
Attributed {
range: 13..14,
custom: (),
node: Name(
ExprName { ExprName {
range: 13..14,
id: Identifier( id: Identifier(
"c", "c",
), ),
ctx: Load, ctx: Load,
}, },
), ),
}, Constant(
Attributed {
range: 21..24,
custom: (),
node: Constant(
ExprConstant { ExprConstant {
range: 21..24,
value: Str( value: Str(
"e", "e",
), ),
kind: None, kind: None,
}, },
), ),
},
], ],
}, },
), )
}

View File

@ -2,113 +2,83 @@
source: parser/src/parser.rs source: parser/src/parser.rs
expression: parse_ast expression: parse_ast
--- ---
Attributed { Call(
range: 0..141,
custom: (),
node: Call(
ExprCall { ExprCall {
func: Attributed { range: 0..141,
range: 0..8, func: Attribute(
custom: (),
node: Attribute(
ExprAttribute { ExprAttribute {
value: Attributed { range: 0..8,
range: 0..3, value: Constant(
custom: (),
node: Constant(
ExprConstant { ExprConstant {
range: 0..3,
value: Str( value: Str(
" ", " ",
), ),
kind: None, kind: None,
}, },
), ),
},
attr: Identifier( attr: Identifier(
"join", "join",
), ),
ctx: Load, ctx: Load,
}, },
), ),
},
args: [ args: [
Attributed { GeneratorExp(
range: 14..139,
custom: (),
node: GeneratorExp(
ExprGeneratorExp { ExprGeneratorExp {
elt: Attributed { range: 14..139,
range: 14..17, elt: Name(
custom: (),
node: Name(
ExprName { ExprName {
range: 14..17,
id: Identifier( id: Identifier(
"sql", "sql",
), ),
ctx: Load, ctx: Load,
}, },
), ),
},
generators: [ generators: [
Comprehension { Comprehension {
target: Attributed { target: Name(
range: 26..29,
custom: (),
node: Name(
ExprName { ExprName {
range: 26..29,
id: Identifier( id: Identifier(
"sql", "sql",
), ),
ctx: Store, ctx: Store,
}, },
), ),
}, iter: Tuple(
iter: Attributed {
range: 33..139,
custom: (),
node: Tuple(
ExprTuple { ExprTuple {
range: 33..139,
elts: [ elts: [
Attributed { IfExp(
range: 43..80,
custom: (),
node: IfExp(
ExprIfExp { ExprIfExp {
test: Attributed { range: 43..80,
range: 65..70, test: Name(
custom: (),
node: Name(
ExprName { ExprName {
range: 65..70,
id: Identifier( id: Identifier(
"limit", "limit",
), ),
ctx: Load, ctx: Load,
}, },
), ),
}, body: BinOp(
body: Attributed {
range: 43..61,
custom: (),
node: BinOp(
ExprBinOp { ExprBinOp {
left: Attributed { range: 43..61,
range: 43..53, left: Constant(
custom: (),
node: Constant(
ExprConstant { ExprConstant {
range: 43..53,
value: Str( value: Str(
"LIMIT %d", "LIMIT %d",
), ),
kind: None, kind: None,
}, },
), ),
},
op: Mod, op: Mod,
right: Attributed { right: Name(
range: 56..61,
custom: (),
node: Name(
ExprName { ExprName {
range: 56..61,
id: Identifier( id: Identifier(
"limit", "limit",
), ),
@ -116,62 +86,44 @@ Attributed {
}, },
), ),
}, },
},
), ),
}, orelse: Constant(
orelse: Attributed {
range: 76..80,
custom: (),
node: Constant(
ExprConstant { ExprConstant {
range: 76..80,
value: None, value: None,
kind: None, kind: None,
}, },
), ),
}, },
},
), ),
}, IfExp(
Attributed {
range: 90..132,
custom: (),
node: IfExp(
ExprIfExp { ExprIfExp {
test: Attributed { range: 90..132,
range: 116..122, test: Name(
custom: (),
node: Name(
ExprName { ExprName {
range: 116..122,
id: Identifier( id: Identifier(
"offset", "offset",
), ),
ctx: Load, ctx: Load,
}, },
), ),
}, body: BinOp(
body: Attributed {
range: 91..111,
custom: (),
node: BinOp(
ExprBinOp { ExprBinOp {
left: Attributed { range: 91..111,
range: 91..102, left: Constant(
custom: (),
node: Constant(
ExprConstant { ExprConstant {
range: 91..102,
value: Str( value: Str(
"OFFSET %d", "OFFSET %d",
), ),
kind: None, kind: None,
}, },
), ),
},
op: Mod, op: Mod,
right: Attributed { right: Name(
range: 105..111,
custom: (),
node: Name(
ExprName { ExprName {
range: 105..111,
id: Identifier( id: Identifier(
"offset", "offset",
), ),
@ -179,36 +131,28 @@ Attributed {
}, },
), ),
}, },
},
), ),
}, orelse: Constant(
orelse: Attributed {
range: 128..132,
custom: (),
node: Constant(
ExprConstant { ExprConstant {
range: 128..132,
value: None, value: None,
kind: None, kind: None,
}, },
), ),
}, },
},
), ),
},
], ],
ctx: Load, ctx: Load,
}, },
), ),
},
ifs: [], ifs: [],
is_async: false, is_async: false,
range: (),
}, },
], ],
}, },
), ),
},
], ],
keywords: [], keywords: [],
}, },
), )
}

View File

@ -3,56 +3,43 @@ source: parser/src/parser.rs
expression: parse_ast expression: parse_ast
--- ---
[ [
Attributed { Match(
range: 1..73,
custom: (),
node: Match(
StmtMatch { StmtMatch {
subject: Attributed { range: 1..73,
range: 7..18, subject: Dict(
custom: (),
node: Dict(
ExprDict { ExprDict {
range: 7..18,
keys: [ keys: [
Some( Some(
Attributed { Constant(
range: 8..14,
custom: (),
node: Constant(
ExprConstant { ExprConstant {
range: 8..14,
value: Str( value: Str(
"test", "test",
), ),
kind: None, kind: None,
}, },
), ),
},
), ),
], ],
values: [ values: [
Attributed { Constant(
range: 16..17,
custom: (),
node: Constant(
ExprConstant { ExprConstant {
range: 16..17,
value: Int( value: Int(
1, 1,
), ),
kind: None, kind: None,
}, },
), ),
},
], ],
}, },
), ),
},
cases: [ cases: [
MatchCase { MatchCase {
pattern: Attributed { pattern: MatchMapping(
range: 29..52,
custom: (),
node: MatchMapping(
PatternMatchMapping { PatternMatchMapping {
range: 29..52,
keys: [], keys: [],
patterns: [], patterns: [],
rest: Some( rest: Some(
@ -62,171 +49,128 @@ expression: parse_ast
), ),
}, },
), ),
},
guard: None, guard: None,
body: [ body: [
Attributed { Expr(
range: 62..73,
custom: (),
node: Expr(
StmtExpr { StmtExpr {
value: Attributed {
range: 62..73, range: 62..73,
custom: (), value: Call(
node: Call(
ExprCall { ExprCall {
func: Attributed { range: 62..73,
range: 62..67, func: Name(
custom: (),
node: Name(
ExprName { ExprName {
range: 62..67,
id: Identifier( id: Identifier(
"print", "print",
), ),
ctx: Load, ctx: Load,
}, },
), ),
},
args: [ args: [
Attributed { Name(
range: 68..72,
custom: (),
node: Name(
ExprName { ExprName {
range: 68..72,
id: Identifier( id: Identifier(
"rest", "rest",
), ),
ctx: Load, ctx: Load,
}, },
), ),
},
], ],
keywords: [], keywords: [],
}, },
), ),
}, },
},
), ),
},
], ],
range: (),
}, },
], ],
}, },
), ),
}, Match(
Attributed {
range: 74..177,
custom: (),
node: Match(
StmtMatch { StmtMatch {
subject: Attributed { range: 74..177,
range: 80..97, subject: Dict(
custom: (),
node: Dict(
ExprDict { ExprDict {
range: 80..97,
keys: [ keys: [
Some( Some(
Attributed { Constant(
range: 81..88,
custom: (),
node: Constant(
ExprConstant { ExprConstant {
range: 81..88,
value: Str( value: Str(
"label", "label",
), ),
kind: None, kind: None,
}, },
), ),
},
), ),
], ],
values: [ values: [
Attributed { Constant(
range: 90..96,
custom: (),
node: Constant(
ExprConstant { ExprConstant {
range: 90..96,
value: Str( value: Str(
"test", "test",
), ),
kind: None, kind: None,
}, },
), ),
},
], ],
}, },
), ),
},
cases: [ cases: [
MatchCase { MatchCase {
pattern: Attributed { pattern: MatchMapping(
range: 108..155,
custom: (),
node: MatchMapping(
PatternMatchMapping { PatternMatchMapping {
range: 108..155,
keys: [ keys: [
Attributed { Constant(
range: 118..125,
custom: (),
node: Constant(
ExprConstant { ExprConstant {
range: 118..125,
value: Str( value: Str(
"label", "label",
), ),
kind: None, kind: None,
}, },
), ),
},
], ],
patterns: [ patterns: [
Attributed { MatchAs(
range: 127..148,
custom: (),
node: MatchAs(
PatternMatchAs { PatternMatchAs {
range: 127..148,
pattern: Some( pattern: Some(
Attributed { MatchOr(
range: 127..139,
custom: (),
node: MatchOr(
PatternMatchOr { PatternMatchOr {
range: 127..139,
patterns: [ patterns: [
Attributed { MatchClass(
range: 127..132,
custom: (),
node: MatchClass(
PatternMatchClass { PatternMatchClass {
cls: Attributed { range: 127..132,
range: 127..130, cls: Name(
custom: (),
node: Name(
ExprName { ExprName {
range: 127..130,
id: Identifier( id: Identifier(
"str", "str",
), ),
ctx: Load, ctx: Load,
}, },
), ),
},
patterns: [], patterns: [],
kwd_attrs: [], kwd_attrs: [],
kwd_patterns: [], kwd_patterns: [],
}, },
), ),
}, MatchSingleton(
Attributed {
range: 135..139,
custom: (),
node: MatchSingleton(
PatternMatchSingleton { PatternMatchSingleton {
range: 135..139,
value: None, value: None,
}, },
), ),
},
], ],
}, },
), ),
},
), ),
name: Some( name: Some(
Identifier( Identifier(
@ -235,98 +179,73 @@ expression: parse_ast
), ),
}, },
), ),
},
], ],
rest: None, rest: None,
}, },
), ),
},
guard: None, guard: None,
body: [ body: [
Attributed { Expr(
range: 165..177,
custom: (),
node: Expr(
StmtExpr { StmtExpr {
value: Attributed {
range: 165..177, range: 165..177,
custom: (), value: Call(
node: Call(
ExprCall { ExprCall {
func: Attributed { range: 165..177,
range: 165..170, func: Name(
custom: (),
node: Name(
ExprName { ExprName {
range: 165..170,
id: Identifier( id: Identifier(
"print", "print",
), ),
ctx: Load, ctx: Load,
}, },
), ),
},
args: [ args: [
Attributed { Name(
range: 171..176,
custom: (),
node: Name(
ExprName { ExprName {
range: 171..176,
id: Identifier( id: Identifier(
"label", "label",
), ),
ctx: Load, ctx: Load,
}, },
), ),
},
], ],
keywords: [], keywords: [],
}, },
), ),
}, },
},
), ),
},
], ],
range: (),
}, },
], ],
}, },
), ),
}, Match(
Attributed { StmtMatch {
range: 178..218, range: 178..218,
custom: (), subject: Name(
node: Match( ExprName {
StmtMatch {
subject: Attributed {
range: 184..185, range: 184..185,
custom: (),
node: Name(
ExprName {
id: Identifier( id: Identifier(
"x", "x",
), ),
ctx: Load, ctx: Load,
}, },
), ),
},
cases: [ cases: [
MatchCase { MatchCase {
pattern: Attributed { pattern: MatchSequence(
PatternMatchSequence {
range: 196..203, range: 196..203,
custom: (),
node: MatchSequence(
PatternMatchSequence {
patterns: [ patterns: [
Attributed { MatchValue(
range: 197..198,
custom: (),
node: MatchValue(
PatternMatchValue { PatternMatchValue {
value: Attributed {
range: 197..198, range: 197..198,
custom: (), value: Constant(
node: Constant(
ExprConstant { ExprConstant {
range: 197..198,
value: Int( value: Int(
0, 0,
), ),
@ -334,19 +253,13 @@ expression: parse_ast
}, },
), ),
}, },
},
), ),
}, MatchValue(
Attributed {
range: 200..201,
custom: (),
node: MatchValue(
PatternMatchValue { PatternMatchValue {
value: Attributed {
range: 200..201, range: 200..201,
custom: (), value: Constant(
node: Constant(
ExprConstant { ExprConstant {
range: 200..201,
value: Int( value: Int(
1, 1,
), ),
@ -354,91 +267,68 @@ expression: parse_ast
}, },
), ),
}, },
},
), ),
},
], ],
}, },
), ),
},
guard: None, guard: None,
body: [ body: [
Attributed { Assign(
StmtAssign {
range: 213..218, range: 213..218,
custom: (),
node: Assign(
StmtAssign {
targets: [ targets: [
Attributed { Name(
range: 213..214,
custom: (),
node: Name(
ExprName { ExprName {
range: 213..214,
id: Identifier( id: Identifier(
"y", "y",
), ),
ctx: Store, ctx: Store,
}, },
), ),
},
], ],
value: Attributed { value: Constant(
range: 217..218,
custom: (),
node: Constant(
ExprConstant { ExprConstant {
range: 217..218,
value: Int( value: Int(
0, 0,
), ),
kind: None, kind: None,
}, },
), ),
},
type_comment: None, type_comment: None,
}, },
), ),
},
], ],
range: (),
}, },
], ],
}, },
), ),
}, Match(
Attributed {
range: 219..259,
custom: (),
node: Match(
StmtMatch { StmtMatch {
subject: Attributed { range: 219..259,
range: 225..226, subject: Name(
custom: (),
node: Name(
ExprName { ExprName {
range: 225..226,
id: Identifier( id: Identifier(
"x", "x",
), ),
ctx: Load, ctx: Load,
}, },
), ),
},
cases: [ cases: [
MatchCase { MatchCase {
pattern: Attributed { pattern: MatchSequence(
range: 237..244,
custom: (),
node: MatchSequence(
PatternMatchSequence { PatternMatchSequence {
range: 237..244,
patterns: [ patterns: [
Attributed { MatchValue(
range: 238..239,
custom: (),
node: MatchValue(
PatternMatchValue { PatternMatchValue {
value: Attributed {
range: 238..239, range: 238..239,
custom: (), value: Constant(
node: Constant(
ExprConstant { ExprConstant {
range: 238..239,
value: Int( value: Int(
0, 0,
), ),
@ -446,19 +336,13 @@ expression: parse_ast
}, },
), ),
}, },
},
), ),
}, MatchValue(
Attributed {
range: 241..242,
custom: (),
node: MatchValue(
PatternMatchValue { PatternMatchValue {
value: Attributed {
range: 241..242, range: 241..242,
custom: (), value: Constant(
node: Constant(
ExprConstant { ExprConstant {
range: 241..242,
value: Int( value: Int(
1, 1,
), ),
@ -466,91 +350,68 @@ expression: parse_ast
}, },
), ),
}, },
},
), ),
},
], ],
}, },
), ),
},
guard: None, guard: None,
body: [ body: [
Attributed { Assign(
range: 254..259,
custom: (),
node: Assign(
StmtAssign { StmtAssign {
range: 254..259,
targets: [ targets: [
Attributed { Name(
range: 254..255,
custom: (),
node: Name(
ExprName { ExprName {
range: 254..255,
id: Identifier( id: Identifier(
"y", "y",
), ),
ctx: Store, ctx: Store,
}, },
), ),
},
], ],
value: Attributed { value: Constant(
range: 258..259,
custom: (),
node: Constant(
ExprConstant { ExprConstant {
range: 258..259,
value: Int( value: Int(
0, 0,
), ),
kind: None, kind: None,
}, },
), ),
},
type_comment: None, type_comment: None,
}, },
), ),
},
], ],
range: (),
}, },
], ],
}, },
), ),
}, Match(
Attributed {
range: 260..297,
custom: (),
node: Match(
StmtMatch { StmtMatch {
subject: Attributed { range: 260..297,
range: 266..267, subject: Name(
custom: (),
node: Name(
ExprName { ExprName {
range: 266..267,
id: Identifier( id: Identifier(
"x", "x",
), ),
ctx: Load, ctx: Load,
}, },
), ),
},
cases: [ cases: [
MatchCase { MatchCase {
pattern: Attributed { pattern: MatchSequence(
range: 278..282,
custom: (),
node: MatchSequence(
PatternMatchSequence { PatternMatchSequence {
range: 278..282,
patterns: [ patterns: [
Attributed { MatchValue(
range: 279..280,
custom: (),
node: MatchValue(
PatternMatchValue { PatternMatchValue {
value: Attributed {
range: 279..280, range: 279..280,
custom: (), value: Constant(
node: Constant(
ExprConstant { ExprConstant {
range: 279..280,
value: Int( value: Int(
0, 0,
), ),
@ -558,54 +419,42 @@ expression: parse_ast
}, },
), ),
}, },
},
), ),
},
], ],
}, },
), ),
},
guard: None, guard: None,
body: [ body: [
Attributed { Assign(
range: 292..297,
custom: (),
node: Assign(
StmtAssign { StmtAssign {
range: 292..297,
targets: [ targets: [
Attributed { Name(
range: 292..293,
custom: (),
node: Name(
ExprName { ExprName {
range: 292..293,
id: Identifier( id: Identifier(
"y", "y",
), ),
ctx: Store, ctx: Store,
}, },
), ),
},
], ],
value: Attributed { value: Constant(
range: 296..297,
custom: (),
node: Constant(
ExprConstant { ExprConstant {
range: 296..297,
value: Int( value: Int(
0, 0,
), ),
kind: None, kind: None,
}, },
), ),
},
type_comment: None, type_comment: None,
}, },
), ),
},
], ],
range: (),
}, },
], ],
}, },
), ),
},
] ]

View File

@ -2,38 +2,29 @@
source: parser/src/parser.rs source: parser/src/parser.rs
expression: parse_ast expression: parse_ast
--- ---
Attributed { BoolOp(
range: 0..7,
custom: (),
node: BoolOp(
ExprBoolOp { ExprBoolOp {
range: 0..7,
op: And, op: And,
values: [ values: [
Attributed { Name(
range: 0..1,
custom: (),
node: Name(
ExprName { ExprName {
range: 0..1,
id: Identifier( id: Identifier(
"x", "x",
), ),
ctx: Load, ctx: Load,
}, },
), ),
}, Name(
Attributed {
range: 6..7,
custom: (),
node: Name(
ExprName { ExprName {
range: 6..7,
id: Identifier( id: Identifier(
"y", "y",
), ),
ctx: Load, ctx: Load,
}, },
), ),
},
], ],
}, },
), )
}

View File

@ -2,38 +2,29 @@
source: parser/src/parser.rs source: parser/src/parser.rs
expression: parse_ast expression: parse_ast
--- ---
Attributed { BoolOp(
range: 0..6,
custom: (),
node: BoolOp(
ExprBoolOp { ExprBoolOp {
range: 0..6,
op: Or, op: Or,
values: [ values: [
Attributed { Name(
range: 0..1,
custom: (),
node: Name(
ExprName { ExprName {
range: 0..1,
id: Identifier( id: Identifier(
"x", "x",
), ),
ctx: Load, ctx: Load,
}, },
), ),
}, Name(
Attributed {
range: 5..6,
custom: (),
node: Name(
ExprName { ExprName {
range: 5..6,
id: Identifier( id: Identifier(
"y", "y",
), ),
ctx: Load, ctx: Load,
}, },
), ),
},
], ],
}, },
), )
}

View File

@ -3,63 +3,50 @@ source: parser/src/parser.rs
expression: "parse_program(source, \"<test>\").unwrap()" expression: "parse_program(source, \"<test>\").unwrap()"
--- ---
[ [
Attributed { ClassDef(
range: 0..98,
custom: (),
node: ClassDef(
StmtClassDef { StmtClassDef {
range: 0..98,
name: Identifier( name: Identifier(
"Foo", "Foo",
), ),
bases: [ bases: [
Attributed { Name(
range: 10..11,
custom: (),
node: Name(
ExprName { ExprName {
range: 10..11,
id: Identifier( id: Identifier(
"A", "A",
), ),
ctx: Load, ctx: Load,
}, },
), ),
}, Name(
Attributed {
range: 13..14,
custom: (),
node: Name(
ExprName { ExprName {
range: 13..14,
id: Identifier( id: Identifier(
"B", "B",
), ),
ctx: Load, ctx: Load,
}, },
), ),
},
], ],
keywords: [], keywords: [],
body: [ body: [
Attributed { FunctionDef(
range: 18..44,
custom: (),
node: FunctionDef(
StmtFunctionDef { StmtFunctionDef {
range: 18..44,
name: Identifier( name: Identifier(
"__init__", "__init__",
), ),
args: Arguments { args: Arguments {
posonlyargs: [], posonlyargs: [],
args: [ args: [
Attributed { Arg {
range: 31..35,
custom: (),
node: ArgData {
arg: Identifier( arg: Identifier(
"self", "self",
), ),
annotation: None, annotation: None,
type_comment: None, type_comment: None,
}, range: 31..35,
}, },
], ],
vararg: None, vararg: None,
@ -67,52 +54,44 @@ expression: "parse_program(source, \"<test>\").unwrap()"
kw_defaults: [], kw_defaults: [],
kwarg: None, kwarg: None,
defaults: [], defaults: [],
range: (),
}, },
body: [ body: [
Attributed { Pass(
StmtPass {
range: 40..44, range: 40..44,
custom: (),
node: Pass,
}, },
),
], ],
decorator_list: [], decorator_list: [],
returns: None, returns: None,
type_comment: None, type_comment: None,
}, },
), ),
}, FunctionDef(
Attributed {
range: 46..98,
custom: (),
node: FunctionDef(
StmtFunctionDef { StmtFunctionDef {
range: 46..98,
name: Identifier( name: Identifier(
"method_with_default", "method_with_default",
), ),
args: Arguments { args: Arguments {
posonlyargs: [], posonlyargs: [],
args: [ args: [
Attributed { Arg {
range: 70..74,
custom: (),
node: ArgData {
arg: Identifier( arg: Identifier(
"self", "self",
), ),
annotation: None, annotation: None,
type_comment: None, type_comment: None,
range: 70..74,
}, },
}, Arg {
Attributed {
range: 76..79,
custom: (),
node: ArgData {
arg: Identifier( arg: Identifier(
"arg", "arg",
), ),
annotation: None, annotation: None,
type_comment: None, type_comment: None,
}, range: 76..79,
}, },
], ],
vararg: None, vararg: None,
@ -120,36 +99,32 @@ expression: "parse_program(source, \"<test>\").unwrap()"
kw_defaults: [], kw_defaults: [],
kwarg: None, kwarg: None,
defaults: [ defaults: [
Attributed { Constant(
range: 80..89,
custom: (),
node: Constant(
ExprConstant { ExprConstant {
range: 80..89,
value: Str( value: Str(
"default", "default",
), ),
kind: None, kind: None,
}, },
), ),
},
], ],
range: (),
}, },
body: [ body: [
Attributed { Pass(
StmtPass {
range: 94..98, range: 94..98,
custom: (),
node: Pass,
}, },
),
], ],
decorator_list: [], decorator_list: [],
returns: None, returns: None,
type_comment: None, type_comment: None,
}, },
), ),
},
], ],
decorator_list: [], decorator_list: [],
}, },
), ),
},
] ]

View File

@ -2,65 +2,51 @@
source: parser/src/parser.rs source: parser/src/parser.rs
expression: parse_ast expression: parse_ast
--- ---
Attributed { DictComp(
range: 0..19,
custom: (),
node: DictComp(
ExprDictComp { ExprDictComp {
key: Attributed { range: 0..19,
range: 1..3, key: Name(
custom: (),
node: Name(
ExprName { ExprName {
range: 1..3,
id: Identifier( id: Identifier(
"x1", "x1",
), ),
ctx: Load, ctx: Load,
}, },
), ),
}, value: Name(
value: Attributed {
range: 5..7,
custom: (),
node: Name(
ExprName { ExprName {
range: 5..7,
id: Identifier( id: Identifier(
"x2", "x2",
), ),
ctx: Load, ctx: Load,
}, },
), ),
},
generators: [ generators: [
Comprehension { Comprehension {
target: Attributed { target: Name(
range: 12..13,
custom: (),
node: Name(
ExprName { ExprName {
range: 12..13,
id: Identifier( id: Identifier(
"y", "y",
), ),
ctx: Store, ctx: Store,
}, },
), ),
}, iter: Name(
iter: Attributed {
range: 17..18,
custom: (),
node: Name(
ExprName { ExprName {
range: 17..18,
id: Identifier( id: Identifier(
"z", "z",
), ),
ctx: Load, ctx: Load,
}, },
), ),
},
ifs: [], ifs: [],
is_async: false, is_async: false,
range: (),
}, },
], ],
}, },
), )
}

View File

@ -2,179 +2,139 @@
source: parser/src/parser.rs source: parser/src/parser.rs
expression: parse_ast expression: parse_ast
--- ---
Attributed { ListComp(
range: 0..48,
custom: (),
node: ListComp(
ExprListComp { ExprListComp {
elt: Attributed { range: 0..48,
range: 1..2, elt: Name(
custom: (),
node: Name(
ExprName { ExprName {
range: 1..2,
id: Identifier( id: Identifier(
"x", "x",
), ),
ctx: Load, ctx: Load,
}, },
), ),
},
generators: [ generators: [
Comprehension { Comprehension {
target: Attributed { target: Tuple(
range: 7..12,
custom: (),
node: Tuple(
ExprTuple { ExprTuple {
range: 7..12,
elts: [ elts: [
Attributed { Name(
range: 7..8,
custom: (),
node: Name(
ExprName { ExprName {
range: 7..8,
id: Identifier( id: Identifier(
"y", "y",
), ),
ctx: Store, ctx: Store,
}, },
), ),
}, Name(
Attributed {
range: 10..12,
custom: (),
node: Name(
ExprName { ExprName {
range: 10..12,
id: Identifier( id: Identifier(
"y2", "y2",
), ),
ctx: Store, ctx: Store,
}, },
), ),
},
], ],
ctx: Store, ctx: Store,
}, },
), ),
}, iter: Name(
iter: Attributed {
range: 16..17,
custom: (),
node: Name(
ExprName { ExprName {
range: 16..17,
id: Identifier( id: Identifier(
"z", "z",
), ),
ctx: Load, ctx: Load,
}, },
), ),
},
ifs: [], ifs: [],
is_async: false, is_async: false,
range: (),
}, },
Comprehension { Comprehension {
target: Attributed { target: Name(
range: 22..23,
custom: (),
node: Name(
ExprName { ExprName {
range: 22..23,
id: Identifier( id: Identifier(
"a", "a",
), ),
ctx: Store, ctx: Store,
}, },
), ),
}, iter: Name(
iter: Attributed {
range: 27..28,
custom: (),
node: Name(
ExprName { ExprName {
range: 27..28,
id: Identifier( id: Identifier(
"b", "b",
), ),
ctx: Load, ctx: Load,
}, },
), ),
},
ifs: [ ifs: [
Attributed { Compare(
range: 32..37,
custom: (),
node: Compare(
ExprCompare { ExprCompare {
left: Attributed { range: 32..37,
range: 32..33, left: Name(
custom: (),
node: Name(
ExprName { ExprName {
range: 32..33,
id: Identifier( id: Identifier(
"a", "a",
), ),
ctx: Load, ctx: Load,
}, },
), ),
},
ops: [ ops: [
Lt, Lt,
], ],
comparators: [ comparators: [
Attributed { Constant(
range: 36..37,
custom: (),
node: Constant(
ExprConstant { ExprConstant {
range: 36..37,
value: Int( value: Int(
5, 5,
), ),
kind: None, kind: None,
}, },
), ),
},
], ],
}, },
), ),
}, Compare(
Attributed {
range: 41..47,
custom: (),
node: Compare(
ExprCompare { ExprCompare {
left: Attributed { range: 41..47,
range: 41..42, left: Name(
custom: (),
node: Name(
ExprName { ExprName {
range: 41..42,
id: Identifier( id: Identifier(
"a", "a",
), ),
ctx: Load, ctx: Load,
}, },
), ),
},
ops: [ ops: [
Gt, Gt,
], ],
comparators: [ comparators: [
Attributed { Constant(
range: 45..47,
custom: (),
node: Constant(
ExprConstant { ExprConstant {
range: 45..47,
value: Int( value: Int(
10, 10,
), ),
kind: None, kind: None,
}, },
), ),
},
], ],
}, },
), ),
},
], ],
is_async: false, is_async: false,
range: (),
}, },
], ],
}, },
), )
}

View File

@ -3,34 +3,25 @@ source: parser/src/parser.rs
expression: parse_ast expression: parse_ast
--- ---
[ [
Attributed { Expr(
range: 0..14,
custom: (),
node: Expr(
StmtExpr { StmtExpr {
value: Attributed {
range: 0..14, range: 0..14,
custom: (), value: JoinedStr(
node: JoinedStr(
ExprJoinedStr { ExprJoinedStr {
values: [
Attributed {
range: 0..14, range: 0..14,
custom: (), values: [
node: Constant( Constant(
ExprConstant { ExprConstant {
range: 0..14,
value: Str( value: Str(
"Hello world", "Hello world",
), ),
kind: None, kind: None,
}, },
), ),
},
], ],
}, },
), ),
}, },
},
), ),
},
] ]

View File

@ -2,53 +2,42 @@
source: parser/src/parser.rs source: parser/src/parser.rs
expression: parse_ast expression: parse_ast
--- ---
Attributed { GeneratorExp(
range: 0..14,
custom: (),
node: GeneratorExp(
ExprGeneratorExp { ExprGeneratorExp {
elt: Attributed { range: 0..14,
range: 1..2, elt: Name(
custom: (),
node: Name(
ExprName { ExprName {
range: 1..2,
id: Identifier( id: Identifier(
"x", "x",
), ),
ctx: Load, ctx: Load,
}, },
), ),
},
generators: [ generators: [
Comprehension { Comprehension {
target: Attributed { target: Name(
range: 7..8,
custom: (),
node: Name(
ExprName { ExprName {
range: 7..8,
id: Identifier( id: Identifier(
"y", "y",
), ),
ctx: Store, ctx: Store,
}, },
), ),
}, iter: Name(
iter: Attributed {
range: 12..13,
custom: (),
node: Name(
ExprName { ExprName {
range: 12..13,
id: Identifier( id: Identifier(
"z", "z",
), ),
ctx: Load, ctx: Load,
}, },
), ),
},
ifs: [], ifs: [],
is_async: false, is_async: false,
range: (),
}, },
], ],
}, },
), )
}

View File

@ -3,34 +3,25 @@ source: parser/src/parser.rs
expression: parse_ast expression: parse_ast
--- ---
[ [
Attributed { If(
range: 0..28,
custom: (),
node: If(
StmtIf { StmtIf {
test: Attributed { range: 0..28,
range: 3..4, test: Constant(
custom: (),
node: Constant(
ExprConstant { ExprConstant {
range: 3..4,
value: Int( value: Int(
1, 1,
), ),
kind: None, kind: None,
}, },
), ),
},
body: [ body: [
Attributed { Expr(
range: 6..8,
custom: (),
node: Expr(
StmtExpr { StmtExpr {
value: Attributed {
range: 6..8, range: 6..8,
custom: (), value: Constant(
node: Constant(
ExprConstant { ExprConstant {
range: 6..8,
value: Int( value: Int(
10, 10,
), ),
@ -38,39 +29,28 @@ expression: parse_ast
}, },
), ),
}, },
},
), ),
},
], ],
orelse: [ orelse: [
Attributed { If(
range: 9..28,
custom: (),
node: If(
StmtIf { StmtIf {
test: Attributed { range: 9..28,
range: 14..15, test: Constant(
custom: (),
node: Constant(
ExprConstant { ExprConstant {
range: 14..15,
value: Int( value: Int(
2, 2,
), ),
kind: None, kind: None,
}, },
), ),
},
body: [ body: [
Attributed { Expr(
range: 17..19,
custom: (),
node: Expr(
StmtExpr { StmtExpr {
value: Attributed {
range: 17..19, range: 17..19,
custom: (), value: Constant(
node: Constant(
ExprConstant { ExprConstant {
range: 17..19,
value: Int( value: Int(
20, 20,
), ),
@ -78,21 +58,15 @@ expression: parse_ast
}, },
), ),
}, },
},
), ),
},
], ],
orelse: [ orelse: [
Attributed { Expr(
range: 26..28,
custom: (),
node: Expr(
StmtExpr { StmtExpr {
value: Attributed {
range: 26..28, range: 26..28,
custom: (), value: Constant(
node: Constant(
ExprConstant { ExprConstant {
range: 26..28,
value: Int( value: Int(
30, 30,
), ),
@ -100,15 +74,11 @@ expression: parse_ast
}, },
), ),
}, },
},
), ),
},
], ],
}, },
), ),
},
], ],
}, },
), ),
},
] ]

View File

@ -2,45 +2,33 @@
source: parser/src/parser.rs source: parser/src/parser.rs
expression: parse_ast expression: parse_ast
--- ---
Attributed { GeneratorExp(
range: 0..26,
custom: (),
node: GeneratorExp(
ExprGeneratorExp { ExprGeneratorExp {
elt: Attributed { range: 0..26,
range: 1..14, elt: IfExp(
custom: (),
node: IfExp(
ExprIfExp { ExprIfExp {
test: Attributed { range: 1..14,
range: 6..7, test: Name(
custom: (),
node: Name(
ExprName { ExprName {
range: 6..7,
id: Identifier( id: Identifier(
"y", "y",
), ),
ctx: Load, ctx: Load,
}, },
), ),
}, body: Name(
body: Attributed {
range: 1..2,
custom: (),
node: Name(
ExprName { ExprName {
range: 1..2,
id: Identifier( id: Identifier(
"x", "x",
), ),
ctx: Load, ctx: Load,
}, },
), ),
}, orelse: Name(
orelse: Attributed {
range: 13..14,
custom: (),
node: Name(
ExprName { ExprName {
range: 13..14,
id: Identifier( id: Identifier(
"y", "y",
), ),
@ -48,39 +36,31 @@ Attributed {
}, },
), ),
}, },
},
), ),
},
generators: [ generators: [
Comprehension { Comprehension {
target: Attributed { target: Name(
range: 19..20,
custom: (),
node: Name(
ExprName { ExprName {
range: 19..20,
id: Identifier( id: Identifier(
"y", "y",
), ),
ctx: Store, ctx: Store,
}, },
), ),
}, iter: Name(
iter: Attributed {
range: 24..25,
custom: (),
node: Name(
ExprName { ExprName {
range: 24..25,
id: Identifier( id: Identifier(
"z", "z",
), ),
ctx: Load, ctx: Load,
}, },
), ),
},
ifs: [], ifs: [],
is_async: false, is_async: false,
range: (),
}, },
], ],
}, },
), )
}

View File

@ -3,71 +3,53 @@ source: parser/src/parser.rs
expression: parse_ast expression: parse_ast
--- ---
[ [
Attributed { Expr(
range: 0..32,
custom: (),
node: Expr(
StmtExpr { StmtExpr {
value: Attributed {
range: 0..32, range: 0..32,
custom: (), value: Call(
node: Call(
ExprCall { ExprCall {
func: Attributed { range: 0..32,
range: 0..7, func: Name(
custom: (),
node: Name(
ExprName { ExprName {
range: 0..7,
id: Identifier( id: Identifier(
"my_func", "my_func",
), ),
ctx: Load, ctx: Load,
}, },
), ),
},
args: [ args: [
Attributed { Constant(
range: 8..20,
custom: (),
node: Constant(
ExprConstant { ExprConstant {
range: 8..20,
value: Str( value: Str(
"positional", "positional",
), ),
kind: None, kind: None,
}, },
), ),
},
], ],
keywords: [ keywords: [
Attributed { Keyword {
range: 22..31,
custom: (),
node: KeywordData {
arg: Some( arg: Some(
Identifier( Identifier(
"keyword", "keyword",
), ),
), ),
value: Attributed { value: Constant(
range: 30..31,
custom: (),
node: Constant(
ExprConstant { ExprConstant {
range: 30..31,
value: Int( value: Int(
2, 2,
), ),
kind: None, kind: None,
}, },
), ),
}, range: 22..31,
},
}, },
], ],
}, },
), ),
}, },
},
), ),
},
] ]

View File

@ -3,40 +3,30 @@ source: parser/src/parser.rs
expression: parse_ast expression: parse_ast
--- ---
[ [
Attributed { Expr(
range: 0..18,
custom: (),
node: Expr(
StmtExpr { StmtExpr {
value: Attributed {
range: 0..18, range: 0..18,
custom: (), value: Lambda(
node: Lambda(
ExprLambda { ExprLambda {
range: 0..18,
args: Arguments { args: Arguments {
posonlyargs: [], posonlyargs: [],
args: [ args: [
Attributed { Arg {
range: 7..8,
custom: (),
node: ArgData {
arg: Identifier( arg: Identifier(
"x", "x",
), ),
annotation: None, annotation: None,
type_comment: None, type_comment: None,
range: 7..8,
}, },
}, Arg {
Attributed {
range: 10..11,
custom: (),
node: ArgData {
arg: Identifier( arg: Identifier(
"y", "y",
), ),
annotation: None, annotation: None,
type_comment: None, type_comment: None,
}, range: 10..11,
}, },
], ],
vararg: None, vararg: None,
@ -44,30 +34,24 @@ expression: parse_ast
kw_defaults: [], kw_defaults: [],
kwarg: None, kwarg: None,
defaults: [], defaults: [],
range: (),
}, },
body: Attributed { body: BinOp(
range: 13..18,
custom: (),
node: BinOp(
ExprBinOp { ExprBinOp {
left: Attributed { range: 13..18,
range: 13..14, left: Name(
custom: (),
node: Name(
ExprName { ExprName {
range: 13..14,
id: Identifier( id: Identifier(
"x", "x",
), ),
ctx: Load, ctx: Load,
}, },
), ),
},
op: Mult, op: Mult,
right: Attributed { right: Name(
range: 17..18,
custom: (),
node: Name(
ExprName { ExprName {
range: 17..18,
id: Identifier( id: Identifier(
"y", "y",
), ),
@ -75,13 +59,9 @@ expression: parse_ast
}, },
), ),
}, },
),
}, },
), ),
}, },
},
), ),
},
},
),
},
] ]

View File

@ -2,53 +2,42 @@
source: parser/src/parser.rs source: parser/src/parser.rs
expression: parse_ast expression: parse_ast
--- ---
Attributed { ListComp(
range: 0..14,
custom: (),
node: ListComp(
ExprListComp { ExprListComp {
elt: Attributed { range: 0..14,
range: 1..2, elt: Name(
custom: (),
node: Name(
ExprName { ExprName {
range: 1..2,
id: Identifier( id: Identifier(
"x", "x",
), ),
ctx: Load, ctx: Load,
}, },
), ),
},
generators: [ generators: [
Comprehension { Comprehension {
target: Attributed { target: Name(
range: 7..8,
custom: (),
node: Name(
ExprName { ExprName {
range: 7..8,
id: Identifier( id: Identifier(
"y", "y",
), ),
ctx: Store, ctx: Store,
}, },
), ),
}, iter: Name(
iter: Attributed {
range: 12..13,
custom: (),
node: Name(
ExprName { ExprName {
range: 12..13,
id: Identifier( id: Identifier(
"z", "z",
), ),
ctx: Load, ctx: Load,
}, },
), ),
},
ifs: [], ifs: [],
is_async: false, is_async: false,
range: (),
}, },
], ],
}, },
), )
}

View File

@ -2,51 +2,37 @@
source: parser/src/parser.rs source: parser/src/parser.rs
expression: parse_ast expression: parse_ast
--- ---
Attributed { GeneratorExp(
range: 0..23,
custom: (),
node: GeneratorExp(
ExprGeneratorExp { ExprGeneratorExp {
elt: Attributed { range: 0..23,
range: 1..11, elt: NamedExpr(
custom: (),
node: NamedExpr(
ExprNamedExpr { ExprNamedExpr {
target: Attributed { range: 1..11,
range: 1..2, target: Name(
custom: (),
node: Name(
ExprName { ExprName {
range: 1..2,
id: Identifier( id: Identifier(
"x", "x",
), ),
ctx: Store, ctx: Store,
}, },
), ),
}, value: BinOp(
value: Attributed {
range: 6..11,
custom: (),
node: BinOp(
ExprBinOp { ExprBinOp {
left: Attributed { range: 6..11,
range: 6..7, left: Name(
custom: (),
node: Name(
ExprName { ExprName {
range: 6..7,
id: Identifier( id: Identifier(
"y", "y",
), ),
ctx: Load, ctx: Load,
}, },
), ),
},
op: Add, op: Add,
right: Attributed { right: Constant(
range: 10..11,
custom: (),
node: Constant(
ExprConstant { ExprConstant {
range: 10..11,
value: Int( value: Int(
1, 1,
), ),
@ -54,42 +40,33 @@ Attributed {
}, },
), ),
}, },
},
), ),
}, },
},
), ),
},
generators: [ generators: [
Comprehension { Comprehension {
target: Attributed { target: Name(
range: 16..17,
custom: (),
node: Name(
ExprName { ExprName {
range: 16..17,
id: Identifier( id: Identifier(
"y", "y",
), ),
ctx: Store, ctx: Store,
}, },
), ),
}, iter: Name(
iter: Attributed {
range: 21..22,
custom: (),
node: Name(
ExprName { ExprName {
range: 21..22,
id: Identifier( id: Identifier(
"z", "z",
), ),
ctx: Load, ctx: Load,
}, },
), ),
},
ifs: [], ifs: [],
is_async: false, is_async: false,
range: (),
}, },
], ],
}, },
), )
}

View File

@ -3,59 +3,44 @@ source: parser/src/parser.rs
expression: parse_ast expression: parse_ast
--- ---
[ [
Attributed { Expr(
range: 0..23,
custom: (),
node: Expr(
StmtExpr { StmtExpr {
value: Attributed {
range: 0..23, range: 0..23,
custom: (), value: Call(
node: Call(
ExprCall { ExprCall {
func: Attributed { range: 0..23,
range: 0..5, func: Name(
custom: (),
node: Name(
ExprName { ExprName {
range: 0..5,
id: Identifier( id: Identifier(
"print", "print",
), ),
ctx: Load, ctx: Load,
}, },
), ),
},
args: [ args: [
Attributed { Constant(
range: 6..19,
custom: (),
node: Constant(
ExprConstant { ExprConstant {
range: 6..19,
value: Str( value: Str(
"Hello world", "Hello world",
), ),
kind: None, kind: None,
}, },
), ),
}, Constant(
Attributed {
range: 21..22,
custom: (),
node: Constant(
ExprConstant { ExprConstant {
range: 21..22,
value: Int( value: Int(
2, 2,
), ),
kind: None, kind: None,
}, },
), ),
},
], ],
keywords: [], keywords: [],
}, },
), ),
}, },
},
), ),
},
] ]

View File

@ -3,47 +3,35 @@ source: parser/src/parser.rs
expression: parse_ast expression: parse_ast
--- ---
[ [
Attributed { Expr(
range: 0..20,
custom: (),
node: Expr(
StmtExpr { StmtExpr {
value: Attributed {
range: 0..20, range: 0..20,
custom: (), value: Call(
node: Call(
ExprCall { ExprCall {
func: Attributed { range: 0..20,
range: 0..5, func: Name(
custom: (),
node: Name(
ExprName { ExprName {
range: 0..5,
id: Identifier( id: Identifier(
"print", "print",
), ),
ctx: Load, ctx: Load,
}, },
), ),
},
args: [ args: [
Attributed { Constant(
range: 6..19,
custom: (),
node: Constant(
ExprConstant { ExprConstant {
range: 6..19,
value: Str( value: Str(
"Hello world", "Hello world",
), ),
kind: None, kind: None,
}, },
), ),
},
], ],
keywords: [], keywords: [],
}, },
), ),
}, },
},
), ),
},
] ]

View File

@ -3,16 +3,12 @@ source: parser/src/parser.rs
expression: parse_ast expression: parse_ast
--- ---
[ [
Attributed { Expr(
range: 0..13,
custom: (),
node: Expr(
StmtExpr { StmtExpr {
value: Attributed {
range: 0..13, range: 0..13,
custom: (), value: Constant(
node: Constant(
ExprConstant { ExprConstant {
range: 0..13,
value: Str( value: Str(
"Hello world", "Hello world",
), ),
@ -20,7 +16,5 @@ expression: parse_ast
}, },
), ),
}, },
},
), ),
},
] ]

View File

@ -3,85 +3,64 @@ source: parser/src/parser.rs
expression: "parse_program(source, \"<test>\").unwrap()" expression: "parse_program(source, \"<test>\").unwrap()"
--- ---
[ [
Attributed { Assign(
range: 0..11,
custom: (),
node: Assign(
StmtAssign { StmtAssign {
range: 0..11,
targets: [ targets: [
Attributed { Tuple(
range: 0..4,
custom: (),
node: Tuple(
ExprTuple { ExprTuple {
range: 0..4,
elts: [ elts: [
Attributed { Name(
range: 0..1,
custom: (),
node: Name(
ExprName { ExprName {
range: 0..1,
id: Identifier( id: Identifier(
"a", "a",
), ),
ctx: Store, ctx: Store,
}, },
), ),
}, Name(
Attributed {
range: 3..4,
custom: (),
node: Name(
ExprName { ExprName {
range: 3..4,
id: Identifier( id: Identifier(
"b", "b",
), ),
ctx: Store, ctx: Store,
}, },
), ),
},
], ],
ctx: Store, ctx: Store,
}, },
), ),
},
], ],
value: Attributed { value: Tuple(
range: 7..11,
custom: (),
node: Tuple(
ExprTuple { ExprTuple {
range: 7..11,
elts: [ elts: [
Attributed { Constant(
range: 7..8,
custom: (),
node: Constant(
ExprConstant { ExprConstant {
range: 7..8,
value: Int( value: Int(
4, 4,
), ),
kind: None, kind: None,
}, },
), ),
}, Constant(
Attributed {
range: 10..11,
custom: (),
node: Constant(
ExprConstant { ExprConstant {
range: 10..11,
value: Int( value: Int(
5, 5,
), ),
kind: None, kind: None,
}, },
), ),
},
], ],
ctx: Load, ctx: Load,
}, },
), ),
},
type_comment: None, type_comment: None,
}, },
), ),
},
] ]

File diff suppressed because it is too large Load Diff

View File

@ -2,74 +2,56 @@
source: parser/src/parser.rs source: parser/src/parser.rs
expression: parse_ast expression: parse_ast
--- ---
Attributed { Subscript(
range: 0..8,
custom: (),
node: Subscript(
ExprSubscript { ExprSubscript {
value: Attributed { range: 0..8,
range: 0..1, value: Name(
custom: (),
node: Name(
ExprName { ExprName {
range: 0..1,
id: Identifier( id: Identifier(
"x", "x",
), ),
ctx: Load, ctx: Load,
}, },
), ),
}, slice: Slice(
slice: Attributed {
range: 2..7,
custom: (),
node: Slice(
ExprSlice { ExprSlice {
range: 2..7,
lower: Some( lower: Some(
Attributed { Constant(
range: 2..3,
custom: (),
node: Constant(
ExprConstant { ExprConstant {
range: 2..3,
value: Int( value: Int(
1, 1,
), ),
kind: None, kind: None,
}, },
), ),
},
), ),
upper: Some( upper: Some(
Attributed { Constant(
range: 4..5,
custom: (),
node: Constant(
ExprConstant { ExprConstant {
range: 4..5,
value: Int( value: Int(
2, 2,
), ),
kind: None, kind: None,
}, },
), ),
},
), ),
step: Some( step: Some(
Attributed { Constant(
range: 6..7,
custom: (),
node: Constant(
ExprConstant { ExprConstant {
range: 6..7,
value: Int( value: Int(
3, 3,
), ),
kind: None, kind: None,
}, },
), ),
},
), ),
}, },
), ),
},
ctx: Load, ctx: Load,
}, },
), )
}

View File

@ -3,92 +3,67 @@ source: parser/src/parser.rs
expression: parse_ast expression: parse_ast
--- ---
[ [
Attributed { Assign(
StmtAssign {
range: 0..36, range: 0..36,
custom: (),
node: Assign(
StmtAssign {
targets: [ targets: [
Attributed { Name(
ExprName {
range: 0..11, range: 0..11,
custom: (),
node: Name(
ExprName {
id: Identifier( id: Identifier(
"array_slice", "array_slice",
), ),
ctx: Store, ctx: Store,
}, },
), ),
},
], ],
value: Attributed { value: Subscript(
ExprSubscript {
range: 14..36, range: 14..36,
custom: (), value: Name(
node: Subscript(
ExprSubscript {
value: Attributed {
range: 14..19,
custom: (),
node: Name(
ExprName { ExprName {
range: 14..19,
id: Identifier( id: Identifier(
"array", "array",
), ),
ctx: Load, ctx: Load,
}, },
), ),
}, slice: Tuple(
slice: Attributed {
range: 20..35,
custom: (),
node: Tuple(
ExprTuple { ExprTuple {
range: 20..35,
elts: [ elts: [
Attributed { Constant(
range: 20..21,
custom: (),
node: Constant(
ExprConstant { ExprConstant {
range: 20..21,
value: Int( value: Int(
0, 0,
), ),
kind: None, kind: None,
}, },
), ),
}, Starred(
Attributed {
range: 23..31,
custom: (),
node: Starred(
ExprStarred { ExprStarred {
value: Attributed { range: 23..31,
range: 24..31, value: Name(
custom: (),
node: Name(
ExprName { ExprName {
range: 24..31,
id: Identifier( id: Identifier(
"indexes", "indexes",
), ),
ctx: Load, ctx: Load,
}, },
), ),
},
ctx: Load, ctx: Load,
}, },
), ),
}, UnaryOp(
Attributed {
range: 33..35,
custom: (),
node: UnaryOp(
ExprUnaryOp { ExprUnaryOp {
range: 33..35,
op: USub, op: USub,
operand: Attributed { operand: Constant(
range: 34..35,
custom: (),
node: Constant(
ExprConstant { ExprConstant {
range: 34..35,
value: Int( value: Int(
1, 1,
), ),
@ -96,95 +71,68 @@ expression: parse_ast
}, },
), ),
}, },
},
), ),
},
], ],
ctx: Load, ctx: Load,
}, },
), ),
},
ctx: Load, ctx: Load,
}, },
), ),
},
type_comment: None, type_comment: None,
}, },
), ),
}, Assign(
Attributed {
range: 37..73,
custom: (),
node: Assign(
StmtAssign { StmtAssign {
range: 37..73,
targets: [ targets: [
Attributed { Subscript(
range: 37..59,
custom: (),
node: Subscript(
ExprSubscript { ExprSubscript {
value: Attributed { range: 37..59,
range: 37..42, value: Name(
custom: (),
node: Name(
ExprName { ExprName {
range: 37..42,
id: Identifier( id: Identifier(
"array", "array",
), ),
ctx: Load, ctx: Load,
}, },
), ),
}, slice: Tuple(
slice: Attributed {
range: 43..58,
custom: (),
node: Tuple(
ExprTuple { ExprTuple {
range: 43..58,
elts: [ elts: [
Attributed { Constant(
range: 43..44,
custom: (),
node: Constant(
ExprConstant { ExprConstant {
range: 43..44,
value: Int( value: Int(
0, 0,
), ),
kind: None, kind: None,
}, },
), ),
}, Starred(
Attributed {
range: 46..54,
custom: (),
node: Starred(
ExprStarred { ExprStarred {
value: Attributed { range: 46..54,
range: 47..54, value: Name(
custom: (),
node: Name(
ExprName { ExprName {
range: 47..54,
id: Identifier( id: Identifier(
"indexes", "indexes",
), ),
ctx: Load, ctx: Load,
}, },
), ),
},
ctx: Load, ctx: Load,
}, },
), ),
}, UnaryOp(
Attributed {
range: 56..58,
custom: (),
node: UnaryOp(
ExprUnaryOp { ExprUnaryOp {
range: 56..58,
op: USub, op: USub,
operand: Attributed { operand: Constant(
range: 57..58,
custom: (),
node: Constant(
ExprConstant { ExprConstant {
range: 57..58,
value: Int( value: Int(
1, 1,
), ),
@ -192,213 +140,154 @@ expression: parse_ast
}, },
), ),
}, },
},
), ),
},
], ],
ctx: Load, ctx: Load,
}, },
), ),
},
ctx: Store, ctx: Store,
}, },
), ),
},
], ],
value: Attributed { value: Name(
range: 62..73,
custom: (),
node: Name(
ExprName { ExprName {
range: 62..73,
id: Identifier( id: Identifier(
"array_slice", "array_slice",
), ),
ctx: Load, ctx: Load,
}, },
), ),
},
type_comment: None, type_comment: None,
}, },
), ),
}, Expr(
Attributed {
range: 74..119,
custom: (),
node: Expr(
StmtExpr { StmtExpr {
value: Attributed {
range: 74..119, range: 74..119,
custom: (), value: Subscript(
node: Subscript(
ExprSubscript { ExprSubscript {
value: Attributed { range: 74..119,
range: 74..79, value: Name(
custom: (),
node: Name(
ExprName { ExprName {
range: 74..79,
id: Identifier( id: Identifier(
"array", "array",
), ),
ctx: Load, ctx: Load,
}, },
), ),
}, slice: Tuple(
slice: Attributed {
range: 80..118,
custom: (),
node: Tuple(
ExprTuple { ExprTuple {
range: 80..118,
elts: [ elts: [
Attributed { Starred(
ExprStarred {
range: 80..98, range: 80..98,
custom: (), value: Name(
node: Starred( ExprName {
ExprStarred {
value: Attributed {
range: 81..98, range: 81..98,
custom: (),
node: Name(
ExprName {
id: Identifier( id: Identifier(
"indexes_to_select", "indexes_to_select",
), ),
ctx: Load, ctx: Load,
}, },
), ),
},
ctx: Load, ctx: Load,
}, },
), ),
}, Starred(
Attributed {
range: 100..118,
custom: (),
node: Starred(
ExprStarred { ExprStarred {
value: Attributed { range: 100..118,
range: 101..118, value: Name(
custom: (),
node: Name(
ExprName { ExprName {
range: 101..118,
id: Identifier( id: Identifier(
"indexes_to_select", "indexes_to_select",
), ),
ctx: Load, ctx: Load,
}, },
), ),
},
ctx: Load, ctx: Load,
}, },
), ),
},
], ],
ctx: Load, ctx: Load,
}, },
), ),
},
ctx: Load, ctx: Load,
}, },
), ),
}, },
},
), ),
}, Expr(
Attributed {
range: 120..150,
custom: (),
node: Expr(
StmtExpr { StmtExpr {
value: Attributed {
range: 120..150, range: 120..150,
custom: (), value: Subscript(
node: Subscript(
ExprSubscript { ExprSubscript {
value: Attributed { range: 120..150,
range: 120..125, value: Name(
custom: (),
node: Name(
ExprName { ExprName {
range: 120..125,
id: Identifier( id: Identifier(
"array", "array",
), ),
ctx: Load, ctx: Load,
}, },
), ),
}, slice: Tuple(
slice: Attributed {
range: 126..149,
custom: (),
node: Tuple(
ExprTuple { ExprTuple {
range: 126..149,
elts: [ elts: [
Attributed { Slice(
range: 126..129,
custom: (),
node: Slice(
ExprSlice { ExprSlice {
range: 126..129,
lower: Some( lower: Some(
Attributed { Constant(
range: 126..127,
custom: (),
node: Constant(
ExprConstant { ExprConstant {
range: 126..127,
value: Int( value: Int(
3, 3,
), ),
kind: None, kind: None,
}, },
), ),
},
), ),
upper: Some( upper: Some(
Attributed { Constant(
range: 128..129,
custom: (),
node: Constant(
ExprConstant { ExprConstant {
range: 128..129,
value: Int( value: Int(
5, 5,
), ),
kind: None, kind: None,
}, },
), ),
},
), ),
step: None, step: None,
}, },
), ),
}, Starred(
Attributed {
range: 131..149,
custom: (),
node: Starred(
ExprStarred { ExprStarred {
value: Attributed { range: 131..149,
range: 132..149, value: Name(
custom: (),
node: Name(
ExprName { ExprName {
range: 132..149,
id: Identifier( id: Identifier(
"indexes_to_select", "indexes_to_select",
), ),
ctx: Load, ctx: Load,
}, },
), ),
},
ctx: Load, ctx: Load,
}, },
), ),
},
], ],
ctx: Load, ctx: Load,
}, },
), ),
},
ctx: Load, ctx: Load,
}, },
), ),
}, },
},
), ),
},
] ]

View File

@ -3,78 +3,59 @@ source: parser/src/parser.rs
expression: parse_ast expression: parse_ast
--- ---
[ [
Attributed { Try(
range: 0..134,
custom: (),
node: Try(
StmtTry { StmtTry {
range: 0..134,
body: [ body: [
Attributed { Raise(
range: 9..28,
custom: (),
node: Raise(
StmtRaise { StmtRaise {
range: 9..28,
exc: Some( exc: Some(
Attributed { Call(
range: 15..28,
custom: (),
node: Call(
ExprCall { ExprCall {
func: Attributed { range: 15..28,
range: 15..25, func: Name(
custom: (),
node: Name(
ExprName { ExprName {
range: 15..25,
id: Identifier( id: Identifier(
"ValueError", "ValueError",
), ),
ctx: Load, ctx: Load,
}, },
), ),
},
args: [ args: [
Attributed { Constant(
range: 26..27,
custom: (),
node: Constant(
ExprConstant { ExprConstant {
range: 26..27,
value: Int( value: Int(
1, 1,
), ),
kind: None, kind: None,
}, },
), ),
},
], ],
keywords: [], keywords: [],
}, },
), ),
},
), ),
cause: None, cause: None,
}, },
), ),
},
], ],
handlers: [ handlers: [
Attributed { ExceptHandler(
range: 29..82,
custom: (),
node: ExceptHandler(
ExcepthandlerExceptHandler { ExcepthandlerExceptHandler {
range: 29..82,
type_: Some( type_: Some(
Attributed { Name(
range: 36..45,
custom: (),
node: Name(
ExprName { ExprName {
range: 36..45,
id: Identifier( id: Identifier(
"TypeError", "TypeError",
), ),
ctx: Load, ctx: Load,
}, },
), ),
},
), ),
name: Some( name: Some(
Identifier( Identifier(
@ -82,128 +63,95 @@ expression: parse_ast
), ),
), ),
body: [ body: [
Attributed { Expr(
range: 56..82,
custom: (),
node: Expr(
StmtExpr { StmtExpr {
value: Attributed {
range: 56..82, range: 56..82,
custom: (), value: Call(
node: Call(
ExprCall { ExprCall {
func: Attributed { range: 56..82,
range: 56..61, func: Name(
custom: (),
node: Name(
ExprName { ExprName {
range: 56..61,
id: Identifier( id: Identifier(
"print", "print",
), ),
ctx: Load, ctx: Load,
}, },
), ),
},
args: [ args: [
Attributed { JoinedStr(
range: 62..81,
custom: (),
node: JoinedStr(
ExprJoinedStr { ExprJoinedStr {
values: [
Attributed {
range: 62..81, range: 62..81,
custom: (), values: [
node: Constant( Constant(
ExprConstant { ExprConstant {
range: 62..81,
value: Str( value: Str(
"caught ", "caught ",
), ),
kind: None, kind: None,
}, },
), ),
}, FormattedValue(
Attributed {
range: 62..81,
custom: (),
node: FormattedValue(
ExprFormattedValue { ExprFormattedValue {
value: Attributed { range: 62..81,
range: 72..79, value: Call(
custom: (),
node: Call(
ExprCall { ExprCall {
func: Attributed { range: 72..79,
range: 72..76, func: Name(
custom: (),
node: Name(
ExprName { ExprName {
range: 72..76,
id: Identifier( id: Identifier(
"type", "type",
), ),
ctx: Load, ctx: Load,
}, },
), ),
},
args: [ args: [
Attributed { Name(
range: 77..78,
custom: (),
node: Name(
ExprName { ExprName {
range: 77..78,
id: Identifier( id: Identifier(
"e", "e",
), ),
ctx: Load, ctx: Load,
}, },
), ),
},
], ],
keywords: [], keywords: [],
}, },
), ),
},
conversion: Int( conversion: Int(
0, 0,
), ),
format_spec: None, format_spec: None,
}, },
), ),
},
], ],
}, },
), ),
},
], ],
keywords: [], keywords: [],
}, },
), ),
}, },
},
), ),
},
], ],
}, },
), ),
}, ExceptHandler(
Attributed {
range: 83..134,
custom: (),
node: ExceptHandler(
ExcepthandlerExceptHandler { ExcepthandlerExceptHandler {
range: 83..134,
type_: Some( type_: Some(
Attributed { Name(
range: 90..97,
custom: (),
node: Name(
ExprName { ExprName {
range: 90..97,
id: Identifier( id: Identifier(
"OSError", "OSError",
), ),
ctx: Load, ctx: Load,
}, },
), ),
},
), ),
name: Some( name: Some(
Identifier( Identifier(
@ -211,114 +159,85 @@ expression: parse_ast
), ),
), ),
body: [ body: [
Attributed { Expr(
range: 108..134,
custom: (),
node: Expr(
StmtExpr { StmtExpr {
value: Attributed {
range: 108..134, range: 108..134,
custom: (), value: Call(
node: Call(
ExprCall { ExprCall {
func: Attributed { range: 108..134,
range: 108..113, func: Name(
custom: (),
node: Name(
ExprName { ExprName {
range: 108..113,
id: Identifier( id: Identifier(
"print", "print",
), ),
ctx: Load, ctx: Load,
}, },
), ),
},
args: [ args: [
Attributed { JoinedStr(
range: 114..133,
custom: (),
node: JoinedStr(
ExprJoinedStr { ExprJoinedStr {
values: [
Attributed {
range: 114..133, range: 114..133,
custom: (), values: [
node: Constant( Constant(
ExprConstant { ExprConstant {
range: 114..133,
value: Str( value: Str(
"caught ", "caught ",
), ),
kind: None, kind: None,
}, },
), ),
}, FormattedValue(
Attributed {
range: 114..133,
custom: (),
node: FormattedValue(
ExprFormattedValue { ExprFormattedValue {
value: Attributed { range: 114..133,
range: 124..131, value: Call(
custom: (),
node: Call(
ExprCall { ExprCall {
func: Attributed { range: 124..131,
range: 124..128, func: Name(
custom: (),
node: Name(
ExprName { ExprName {
range: 124..128,
id: Identifier( id: Identifier(
"type", "type",
), ),
ctx: Load, ctx: Load,
}, },
), ),
},
args: [ args: [
Attributed { Name(
range: 129..130,
custom: (),
node: Name(
ExprName { ExprName {
range: 129..130,
id: Identifier( id: Identifier(
"e", "e",
), ),
ctx: Load, ctx: Load,
}, },
), ),
},
], ],
keywords: [], keywords: [],
}, },
), ),
},
conversion: Int( conversion: Int(
0, 0,
), ),
format_spec: None, format_spec: None,
}, },
), ),
},
], ],
}, },
), ),
},
], ],
keywords: [], keywords: [],
}, },
), ),
}, },
},
), ),
},
], ],
}, },
), ),
},
], ],
orelse: [], orelse: [],
finalbody: [], finalbody: [],
}, },
), ),
},
] ]

View File

@ -3,229 +3,171 @@ source: parser/src/parser.rs
expression: parse_ast expression: parse_ast
--- ---
[ [
Attributed { TryStar(
range: 0..260,
custom: (),
node: TryStar(
StmtTryStar { StmtTryStar {
range: 0..260,
body: [ body: [
Attributed { Raise(
range: 9..98,
custom: (),
node: Raise(
StmtRaise { StmtRaise {
range: 9..98,
exc: Some( exc: Some(
Attributed { Call(
range: 15..98,
custom: (),
node: Call(
ExprCall { ExprCall {
func: Attributed { range: 15..98,
range: 15..29, func: Name(
custom: (),
node: Name(
ExprName { ExprName {
range: 15..29,
id: Identifier( id: Identifier(
"ExceptionGroup", "ExceptionGroup",
), ),
ctx: Load, ctx: Load,
}, },
), ),
},
args: [ args: [
Attributed { Constant(
range: 30..34,
custom: (),
node: Constant(
ExprConstant { ExprConstant {
range: 30..34,
value: Str( value: Str(
"eg", "eg",
), ),
kind: None, kind: None,
}, },
), ),
}, List(
Attributed {
range: 44..97,
custom: (),
node: List(
ExprList { ExprList {
range: 44..97,
elts: [ elts: [
Attributed { Call(
range: 45..58,
custom: (),
node: Call(
ExprCall { ExprCall {
func: Attributed { range: 45..58,
range: 45..55, func: Name(
custom: (),
node: Name(
ExprName { ExprName {
range: 45..55,
id: Identifier( id: Identifier(
"ValueError", "ValueError",
), ),
ctx: Load, ctx: Load,
}, },
), ),
},
args: [ args: [
Attributed { Constant(
range: 56..57,
custom: (),
node: Constant(
ExprConstant { ExprConstant {
range: 56..57,
value: Int( value: Int(
1, 1,
), ),
kind: None, kind: None,
}, },
), ),
},
], ],
keywords: [], keywords: [],
}, },
), ),
}, Call(
Attributed {
range: 60..72,
custom: (),
node: Call(
ExprCall { ExprCall {
func: Attributed { range: 60..72,
range: 60..69, func: Name(
custom: (),
node: Name(
ExprName { ExprName {
range: 60..69,
id: Identifier( id: Identifier(
"TypeError", "TypeError",
), ),
ctx: Load, ctx: Load,
}, },
), ),
},
args: [ args: [
Attributed { Constant(
range: 70..71,
custom: (),
node: Constant(
ExprConstant { ExprConstant {
range: 70..71,
value: Int( value: Int(
2, 2,
), ),
kind: None, kind: None,
}, },
), ),
},
], ],
keywords: [], keywords: [],
}, },
), ),
}, Call(
Attributed {
range: 74..84,
custom: (),
node: Call(
ExprCall { ExprCall {
func: Attributed { range: 74..84,
range: 74..81, func: Name(
custom: (),
node: Name(
ExprName { ExprName {
range: 74..81,
id: Identifier( id: Identifier(
"OSError", "OSError",
), ),
ctx: Load, ctx: Load,
}, },
), ),
},
args: [ args: [
Attributed { Constant(
range: 82..83,
custom: (),
node: Constant(
ExprConstant { ExprConstant {
range: 82..83,
value: Int( value: Int(
3, 3,
), ),
kind: None, kind: None,
}, },
), ),
},
], ],
keywords: [], keywords: [],
}, },
), ),
}, Call(
Attributed {
range: 86..96,
custom: (),
node: Call(
ExprCall { ExprCall {
func: Attributed { range: 86..96,
range: 86..93, func: Name(
custom: (),
node: Name(
ExprName { ExprName {
range: 86..93,
id: Identifier( id: Identifier(
"OSError", "OSError",
), ),
ctx: Load, ctx: Load,
}, },
), ),
},
args: [ args: [
Attributed { Constant(
range: 94..95,
custom: (),
node: Constant(
ExprConstant { ExprConstant {
range: 94..95,
value: Int( value: Int(
4, 4,
), ),
kind: None, kind: None,
}, },
), ),
},
], ],
keywords: [], keywords: [],
}, },
), ),
},
], ],
ctx: Load, ctx: Load,
}, },
), ),
},
], ],
keywords: [], keywords: [],
}, },
), ),
},
), ),
cause: None, cause: None,
}, },
), ),
},
], ],
handlers: [ handlers: [
Attributed { ExceptHandler(
range: 99..180,
custom: (),
node: ExceptHandler(
ExcepthandlerExceptHandler { ExcepthandlerExceptHandler {
range: 99..180,
type_: Some( type_: Some(
Attributed { Name(
range: 107..116,
custom: (),
node: Name(
ExprName { ExprName {
range: 107..116,
id: Identifier( id: Identifier(
"TypeError", "TypeError",
), ),
ctx: Load, ctx: Load,
}, },
), ),
},
), ),
name: Some( name: Some(
Identifier( Identifier(
@ -233,176 +175,131 @@ expression: parse_ast
), ),
), ),
body: [ body: [
Attributed { Expr(
range: 127..180,
custom: (),
node: Expr(
StmtExpr { StmtExpr {
value: Attributed {
range: 127..180, range: 127..180,
custom: (), value: Call(
node: Call(
ExprCall { ExprCall {
func: Attributed { range: 127..180,
range: 127..132, func: Name(
custom: (),
node: Name(
ExprName { ExprName {
range: 127..132,
id: Identifier( id: Identifier(
"print", "print",
), ),
ctx: Load, ctx: Load,
}, },
), ),
},
args: [ args: [
Attributed { JoinedStr(
range: 133..179,
custom: (),
node: JoinedStr(
ExprJoinedStr { ExprJoinedStr {
values: [
Attributed {
range: 133..179, range: 133..179,
custom: (), values: [
node: Constant( Constant(
ExprConstant { ExprConstant {
range: 133..179,
value: Str( value: Str(
"caught ", "caught ",
), ),
kind: None, kind: None,
}, },
), ),
}, FormattedValue(
Attributed {
range: 133..179,
custom: (),
node: FormattedValue(
ExprFormattedValue { ExprFormattedValue {
value: Attributed { range: 133..179,
range: 143..150, value: Call(
custom: (),
node: Call(
ExprCall { ExprCall {
func: Attributed { range: 143..150,
range: 143..147, func: Name(
custom: (),
node: Name(
ExprName { ExprName {
range: 143..147,
id: Identifier( id: Identifier(
"type", "type",
), ),
ctx: Load, ctx: Load,
}, },
), ),
},
args: [ args: [
Attributed { Name(
range: 148..149,
custom: (),
node: Name(
ExprName { ExprName {
range: 148..149,
id: Identifier( id: Identifier(
"e", "e",
), ),
ctx: Load, ctx: Load,
}, },
), ),
},
], ],
keywords: [], keywords: [],
}, },
), ),
},
conversion: Int( conversion: Int(
0, 0,
), ),
format_spec: None, format_spec: None,
}, },
), ),
}, Constant(
Attributed {
range: 133..179,
custom: (),
node: Constant(
ExprConstant { ExprConstant {
range: 133..179,
value: Str( value: Str(
" with nested ", " with nested ",
), ),
kind: None, kind: None,
}, },
), ),
}, FormattedValue(
Attributed {
range: 133..179,
custom: (),
node: FormattedValue(
ExprFormattedValue { ExprFormattedValue {
value: Attributed { range: 133..179,
range: 165..177, value: Attribute(
custom: (),
node: Attribute(
ExprAttribute { ExprAttribute {
value: Attributed { range: 165..177,
range: 165..166, value: Name(
custom: (),
node: Name(
ExprName { ExprName {
range: 165..166,
id: Identifier( id: Identifier(
"e", "e",
), ),
ctx: Load, ctx: Load,
}, },
), ),
},
attr: Identifier( attr: Identifier(
"exceptions", "exceptions",
), ),
ctx: Load, ctx: Load,
}, },
), ),
},
conversion: Int( conversion: Int(
0, 0,
), ),
format_spec: None, format_spec: None,
}, },
), ),
},
], ],
}, },
), ),
},
], ],
keywords: [], keywords: [],
}, },
), ),
}, },
},
), ),
},
], ],
}, },
), ),
}, ExceptHandler(
Attributed {
range: 181..260,
custom: (),
node: ExceptHandler(
ExcepthandlerExceptHandler { ExcepthandlerExceptHandler {
range: 181..260,
type_: Some( type_: Some(
Attributed { Name(
range: 189..196,
custom: (),
node: Name(
ExprName { ExprName {
range: 189..196,
id: Identifier( id: Identifier(
"OSError", "OSError",
), ),
ctx: Load, ctx: Load,
}, },
), ),
},
), ),
name: Some( name: Some(
Identifier( Identifier(
@ -410,162 +307,121 @@ expression: parse_ast
), ),
), ),
body: [ body: [
Attributed { Expr(
range: 207..260,
custom: (),
node: Expr(
StmtExpr { StmtExpr {
value: Attributed {
range: 207..260, range: 207..260,
custom: (), value: Call(
node: Call(
ExprCall { ExprCall {
func: Attributed { range: 207..260,
range: 207..212, func: Name(
custom: (),
node: Name(
ExprName { ExprName {
range: 207..212,
id: Identifier( id: Identifier(
"print", "print",
), ),
ctx: Load, ctx: Load,
}, },
), ),
},
args: [ args: [
Attributed { JoinedStr(
range: 213..259,
custom: (),
node: JoinedStr(
ExprJoinedStr { ExprJoinedStr {
values: [
Attributed {
range: 213..259, range: 213..259,
custom: (), values: [
node: Constant( Constant(
ExprConstant { ExprConstant {
range: 213..259,
value: Str( value: Str(
"caught ", "caught ",
), ),
kind: None, kind: None,
}, },
), ),
}, FormattedValue(
Attributed {
range: 213..259,
custom: (),
node: FormattedValue(
ExprFormattedValue { ExprFormattedValue {
value: Attributed { range: 213..259,
range: 223..230, value: Call(
custom: (),
node: Call(
ExprCall { ExprCall {
func: Attributed { range: 223..230,
range: 223..227, func: Name(
custom: (),
node: Name(
ExprName { ExprName {
range: 223..227,
id: Identifier( id: Identifier(
"type", "type",
), ),
ctx: Load, ctx: Load,
}, },
), ),
},
args: [ args: [
Attributed { Name(
range: 228..229,
custom: (),
node: Name(
ExprName { ExprName {
range: 228..229,
id: Identifier( id: Identifier(
"e", "e",
), ),
ctx: Load, ctx: Load,
}, },
), ),
},
], ],
keywords: [], keywords: [],
}, },
), ),
},
conversion: Int( conversion: Int(
0, 0,
), ),
format_spec: None, format_spec: None,
}, },
), ),
}, Constant(
Attributed {
range: 213..259,
custom: (),
node: Constant(
ExprConstant { ExprConstant {
range: 213..259,
value: Str( value: Str(
" with nested ", " with nested ",
), ),
kind: None, kind: None,
}, },
), ),
}, FormattedValue(
Attributed {
range: 213..259,
custom: (),
node: FormattedValue(
ExprFormattedValue { ExprFormattedValue {
value: Attributed { range: 213..259,
range: 245..257, value: Attribute(
custom: (),
node: Attribute(
ExprAttribute { ExprAttribute {
value: Attributed { range: 245..257,
range: 245..246, value: Name(
custom: (),
node: Name(
ExprName { ExprName {
range: 245..246,
id: Identifier( id: Identifier(
"e", "e",
), ),
ctx: Load, ctx: Load,
}, },
), ),
},
attr: Identifier( attr: Identifier(
"exceptions", "exceptions",
), ),
ctx: Load, ctx: Load,
}, },
), ),
},
conversion: Int( conversion: Int(
0, 0,
), ),
format_spec: None, format_spec: None,
}, },
), ),
},
], ],
}, },
), ),
},
], ],
keywords: [], keywords: [],
}, },
), ),
}, },
},
), ),
},
], ],
}, },
), ),
},
], ],
orelse: [], orelse: [],
finalbody: [], finalbody: [],
}, },
), ),
},
] ]

View File

@ -3,11 +3,9 @@ source: parser/src/parser.rs
expression: parse_ast expression: parse_ast
--- ---
[ [
Attributed { FunctionDef(
range: 1..49,
custom: (),
node: FunctionDef(
StmtFunctionDef { StmtFunctionDef {
range: 1..49,
name: Identifier( name: Identifier(
"args_to_tuple", "args_to_tuple",
), ),
@ -15,112 +13,85 @@ expression: parse_ast
posonlyargs: [], posonlyargs: [],
args: [], args: [],
vararg: Some( vararg: Some(
Attributed { Arg {
range: 20..29,
custom: (),
node: ArgData {
arg: Identifier( arg: Identifier(
"args", "args",
), ),
annotation: Some( annotation: Some(
Attributed { Starred(
range: 26..29,
custom: (),
node: Starred(
ExprStarred { ExprStarred {
value: Attributed { range: 26..29,
range: 27..29, value: Name(
custom: (),
node: Name(
ExprName { ExprName {
range: 27..29,
id: Identifier( id: Identifier(
"Ts", "Ts",
), ),
ctx: Load, ctx: Load,
}, },
), ),
},
ctx: Load, ctx: Load,
}, },
), ),
},
), ),
type_comment: None, type_comment: None,
}, range: 20..29,
}, },
), ),
kwonlyargs: [], kwonlyargs: [],
kw_defaults: [], kw_defaults: [],
kwarg: None, kwarg: None,
defaults: [], defaults: [],
range: (),
}, },
body: [ body: [
Attributed { Expr(
range: 46..49,
custom: (),
node: Expr(
StmtExpr { StmtExpr {
value: Attributed {
range: 46..49, range: 46..49,
custom: (), value: Constant(
node: Constant(
ExprConstant { ExprConstant {
range: 46..49,
value: Ellipsis, value: Ellipsis,
kind: None, kind: None,
}, },
), ),
}, },
},
), ),
},
], ],
decorator_list: [], decorator_list: [],
returns: Some( returns: Some(
Attributed { Subscript(
range: 34..44,
custom: (),
node: Subscript(
ExprSubscript { ExprSubscript {
value: Attributed { range: 34..44,
range: 34..39, value: Name(
custom: (),
node: Name(
ExprName { ExprName {
range: 34..39,
id: Identifier( id: Identifier(
"Tuple", "Tuple",
), ),
ctx: Load, ctx: Load,
}, },
), ),
}, slice: Starred(
slice: Attributed {
range: 40..43,
custom: (),
node: Starred(
ExprStarred { ExprStarred {
value: Attributed { range: 40..43,
range: 41..43, value: Name(
custom: (),
node: Name(
ExprName { ExprName {
range: 41..43,
id: Identifier( id: Identifier(
"Ts", "Ts",
), ),
ctx: Load, ctx: Load,
}, },
), ),
},
ctx: Load, ctx: Load,
}, },
), ),
},
ctx: Load, ctx: Load,
}, },
), ),
},
), ),
type_comment: None, type_comment: None,
}, },
), ),
},
] ]

File diff suppressed because it is too large Load Diff

View File

@ -3,16 +3,12 @@ source: parser/src/string.rs
expression: parse_ast expression: parse_ast
--- ---
[ [
Attributed { Expr(
range: 0..15,
custom: (),
node: Expr(
StmtExpr { StmtExpr {
value: Attributed {
range: 0..15, range: 0..15,
custom: (), value: Constant(
node: Constant(
ExprConstant { ExprConstant {
range: 0..15,
value: Str( value: Str(
"\u{8}", "\u{8}",
), ),
@ -20,7 +16,5 @@ expression: parse_ast
}, },
), ),
}, },
},
), ),
},
] ]

View File

@ -3,16 +3,12 @@ source: parser/src/string.rs
expression: parse_ast expression: parse_ast
--- ---
[ [
Attributed { Expr(
range: 0..9,
custom: (),
node: Expr(
StmtExpr { StmtExpr {
value: Attributed {
range: 0..9, range: 0..9,
custom: (), value: Constant(
node: Constant(
ExprConstant { ExprConstant {
range: 0..9,
value: Str( value: Str(
"\u{7}", "\u{7}",
), ),
@ -20,7 +16,5 @@ expression: parse_ast
}, },
), ),
}, },
},
), ),
},
] ]

View File

@ -3,16 +3,12 @@ source: parser/src/string.rs
expression: parse_ast expression: parse_ast
--- ---
[ [
Attributed { Expr(
range: 0..21,
custom: (),
node: Expr(
StmtExpr { StmtExpr {
value: Attributed {
range: 0..21, range: 0..21,
custom: (), value: Constant(
node: Constant(
ExprConstant { ExprConstant {
range: 0..21,
value: Str( value: Str(
"\r", "\r",
), ),
@ -20,7 +16,5 @@ expression: parse_ast
}, },
), ),
}, },
},
), ),
},
] ]

View File

@ -3,16 +3,12 @@ source: parser/src/string.rs
expression: parse_ast expression: parse_ast
--- ---
[ [
Attributed { Expr(
range: 0..45,
custom: (),
node: Expr(
StmtExpr { StmtExpr {
value: Attributed {
range: 0..45, range: 0..45,
custom: (), value: Constant(
node: Constant(
ExprConstant { ExprConstant {
range: 0..45,
value: Str( value: Str(
"\u{89}", "\u{89}",
), ),
@ -20,7 +16,5 @@ expression: parse_ast
}, },
), ),
}, },
},
), ),
},
] ]

View File

@ -3,16 +3,12 @@ source: parser/src/string.rs
expression: parse_ast expression: parse_ast
--- ---
[ [
Attributed { Expr(
range: 0..12,
custom: (),
node: Expr(
StmtExpr { StmtExpr {
value: Attributed {
range: 0..12, range: 0..12,
custom: (), value: Constant(
node: Constant(
ExprConstant { ExprConstant {
range: 0..12,
value: Str( value: Str(
"\u{7f}", "\u{7f}",
), ),
@ -20,7 +16,5 @@ expression: parse_ast
}, },
), ),
}, },
},
), ),
},
] ]

View File

@ -3,16 +3,12 @@ source: parser/src/string.rs
expression: parse_ast expression: parse_ast
--- ---
[ [
Attributed { Expr(
range: 0..738,
custom: (),
node: Expr(
StmtExpr { StmtExpr {
value: Attributed {
range: 0..738, range: 0..738,
custom: (), value: Constant(
node: Constant(
ExprConstant { ExprConstant {
range: 0..738,
value: Bytes( value: Bytes(
[ [
0, 0,
@ -277,7 +273,5 @@ expression: parse_ast
}, },
), ),
}, },
},
), ),
},
] ]

View File

@ -3,16 +3,12 @@ source: parser/src/string.rs
expression: parse_ast expression: parse_ast
--- ---
[ [
Attributed { Expr(
range: 0..12,
custom: (),
node: Expr(
StmtExpr { StmtExpr {
value: Attributed {
range: 0..12, range: 0..12,
custom: (), value: Constant(
node: Constant(
ExprConstant { ExprConstant {
range: 0..12,
value: Str( value: Str(
"\u{1b}", "\u{1b}",
), ),
@ -20,7 +16,5 @@ expression: parse_ast
}, },
), ),
}, },
},
), ),
},
] ]

View File

@ -3,16 +3,12 @@ source: parser/src/string.rs
expression: parse_ast expression: parse_ast
--- ---
[ [
Attributed { Expr(
range: 0..13,
custom: (),
node: Expr(
StmtExpr { StmtExpr {
value: Attributed {
range: 0..13, range: 0..13,
custom: (), value: Constant(
node: Constant(
ExprConstant { ExprConstant {
range: 0..13,
value: Bytes( value: Bytes(
[ [
111, 111,
@ -31,7 +27,5 @@ expression: parse_ast
}, },
), ),
}, },
},
), ),
},
] ]

View File

@ -3,16 +3,12 @@ source: parser/src/string.rs
expression: parse_ast expression: parse_ast
--- ---
[ [
Attributed { Expr(
range: 0..14,
custom: (),
node: Expr(
StmtExpr { StmtExpr {
value: Attributed {
range: 0..14, range: 0..14,
custom: (), value: Constant(
node: Constant(
ExprConstant { ExprConstant {
range: 0..14,
value: Bytes( value: Bytes(
[ [
35, 35,
@ -26,7 +22,5 @@ expression: parse_ast
}, },
), ),
}, },
},
), ),
},
] ]

View File

@ -3,16 +3,12 @@ source: parser/src/string.rs
expression: parse_ast expression: parse_ast
--- ---
[ [
Attributed { Expr(
range: 0..15,
custom: (),
node: Expr(
StmtExpr { StmtExpr {
value: Attributed {
range: 0..15, range: 0..15,
custom: (), value: Constant(
node: Constant(
ExprConstant { ExprConstant {
range: 0..15,
value: Str( value: Str(
"\u{c}", "\u{c}",
), ),
@ -20,7 +16,5 @@ expression: parse_ast
}, },
), ),
}, },
},
), ),
},
] ]

View File

@ -3,58 +3,43 @@ source: parser/src/string.rs
expression: parse_ast expression: parse_ast
--- ---
[ [
Attributed { Expr(
range: 0..8,
custom: (),
node: Expr(
StmtExpr { StmtExpr {
value: Attributed {
range: 0..8, range: 0..8,
custom: (), value: JoinedStr(
node: JoinedStr(
ExprJoinedStr { ExprJoinedStr {
values: [
Attributed {
range: 0..8, range: 0..8,
custom: (), values: [
node: Constant( Constant(
ExprConstant { ExprConstant {
range: 0..8,
value: Str( value: Str(
"\\", "\\",
), ),
kind: None, kind: None,
}, },
), ),
}, FormattedValue(
Attributed {
range: 0..8,
custom: (),
node: FormattedValue(
ExprFormattedValue { ExprFormattedValue {
value: Attributed { range: 0..8,
range: 5..6, value: Name(
custom: (),
node: Name(
ExprName { ExprName {
range: 5..6,
id: Identifier( id: Identifier(
"x", "x",
), ),
ctx: Load, ctx: Load,
}, },
), ),
},
conversion: Int( conversion: Int(
0, 0,
), ),
format_spec: None, format_spec: None,
}, },
), ),
},
], ],
}, },
), ),
}, },
},
), ),
},
] ]

View File

@ -3,58 +3,43 @@ source: parser/src/string.rs
expression: parse_ast expression: parse_ast
--- ---
[ [
Attributed { Expr(
range: 0..8,
custom: (),
node: Expr(
StmtExpr { StmtExpr {
value: Attributed {
range: 0..8, range: 0..8,
custom: (), value: JoinedStr(
node: JoinedStr(
ExprJoinedStr { ExprJoinedStr {
values: [
Attributed {
range: 0..8, range: 0..8,
custom: (), values: [
node: Constant( Constant(
ExprConstant { ExprConstant {
range: 0..8,
value: Str( value: Str(
"\n", "\n",
), ),
kind: None, kind: None,
}, },
), ),
}, FormattedValue(
Attributed {
range: 0..8,
custom: (),
node: FormattedValue(
ExprFormattedValue { ExprFormattedValue {
value: Attributed { range: 0..8,
range: 5..6, value: Name(
custom: (),
node: Name(
ExprName { ExprName {
range: 5..6,
id: Identifier( id: Identifier(
"x", "x",
), ),
ctx: Load, ctx: Load,
}, },
), ),
},
conversion: Int( conversion: Int(
0, 0,
), ),
format_spec: None, format_spec: None,
}, },
), ),
},
], ],
}, },
), ),
}, },
},
), ),
},
] ]

View File

@ -3,58 +3,43 @@ source: parser/src/string.rs
expression: parse_ast expression: parse_ast
--- ---
[ [
Attributed { Expr(
range: 0..9,
custom: (),
node: Expr(
StmtExpr { StmtExpr {
value: Attributed {
range: 0..9, range: 0..9,
custom: (), value: JoinedStr(
node: JoinedStr(
ExprJoinedStr { ExprJoinedStr {
values: [
Attributed {
range: 0..9, range: 0..9,
custom: (), values: [
node: Constant( Constant(
ExprConstant { ExprConstant {
range: 0..9,
value: Str( value: Str(
"\\\n", "\\\n",
), ),
kind: None, kind: None,
}, },
), ),
}, FormattedValue(
Attributed {
range: 0..9,
custom: (),
node: FormattedValue(
ExprFormattedValue { ExprFormattedValue {
value: Attributed { range: 0..9,
range: 6..7, value: Name(
custom: (),
node: Name(
ExprName { ExprName {
range: 6..7,
id: Identifier( id: Identifier(
"x", "x",
), ),
ctx: Load, ctx: Load,
}, },
), ),
},
conversion: Int( conversion: Int(
0, 0,
), ),
format_spec: None, format_spec: None,
}, },
), ),
},
], ],
}, },
), ),
}, },
},
), ),
},
] ]

View File

@ -3,52 +3,40 @@ source: parser/src/string.rs
expression: parse_ast expression: parse_ast
--- ---
[ [
Attributed { Constant(
range: 0..10,
custom: (),
node: Constant(
ExprConstant { ExprConstant {
range: 0..10,
value: Str( value: Str(
"user=", "user=",
), ),
kind: None, kind: None,
}, },
), ),
}, Constant(
Attributed {
range: 0..10,
custom: (),
node: Constant(
ExprConstant { ExprConstant {
range: 0..10,
value: Str( value: Str(
"", "",
), ),
kind: None, kind: None,
}, },
), ),
}, FormattedValue(
Attributed {
range: 0..10,
custom: (),
node: FormattedValue(
ExprFormattedValue { ExprFormattedValue {
value: Attributed { range: 0..10,
range: 3..7, value: Name(
custom: (),
node: Name(
ExprName { ExprName {
range: 3..7,
id: Identifier( id: Identifier(
"user", "user",
), ),
ctx: Load, ctx: Load,
}, },
), ),
},
conversion: Int( conversion: Int(
114, 114,
), ),
format_spec: None, format_spec: None,
}, },
), ),
},
] ]

View File

@ -3,124 +3,94 @@ source: parser/src/string.rs
expression: parse_ast expression: parse_ast
--- ---
[ [
Attributed { Constant(
range: 0..38,
custom: (),
node: Constant(
ExprConstant { ExprConstant {
range: 0..38,
value: Str( value: Str(
"mix ", "mix ",
), ),
kind: None, kind: None,
}, },
), ),
}, Constant(
Attributed {
range: 0..38,
custom: (),
node: Constant(
ExprConstant { ExprConstant {
range: 0..38,
value: Str( value: Str(
"user=", "user=",
), ),
kind: None, kind: None,
}, },
), ),
}, Constant(
Attributed {
range: 0..38,
custom: (),
node: Constant(
ExprConstant { ExprConstant {
range: 0..38,
value: Str( value: Str(
"", "",
), ),
kind: None, kind: None,
}, },
), ),
}, FormattedValue(
Attributed {
range: 0..38,
custom: (),
node: FormattedValue(
ExprFormattedValue { ExprFormattedValue {
value: Attributed { range: 0..38,
range: 7..11, value: Name(
custom: (),
node: Name(
ExprName { ExprName {
range: 7..11,
id: Identifier( id: Identifier(
"user", "user",
), ),
ctx: Load, ctx: Load,
}, },
), ),
},
conversion: Int( conversion: Int(
114, 114,
), ),
format_spec: None, format_spec: None,
}, },
), ),
}, Constant(
Attributed {
range: 0..38,
custom: (),
node: Constant(
ExprConstant { ExprConstant {
range: 0..38,
value: Str( value: Str(
" with text and ", " with text and ",
), ),
kind: None, kind: None,
}, },
), ),
}, Constant(
Attributed {
range: 0..38,
custom: (),
node: Constant(
ExprConstant { ExprConstant {
range: 0..38,
value: Str( value: Str(
"second=", "second=",
), ),
kind: None, kind: None,
}, },
), ),
}, Constant(
Attributed {
range: 0..38,
custom: (),
node: Constant(
ExprConstant { ExprConstant {
range: 0..38,
value: Str( value: Str(
"", "",
), ),
kind: None, kind: None,
}, },
), ),
}, FormattedValue(
Attributed {
range: 0..38,
custom: (),
node: FormattedValue(
ExprFormattedValue { ExprFormattedValue {
value: Attributed { range: 0..38,
range: 29..35, value: Name(
custom: (),
node: Name(
ExprName { ExprName {
range: 29..35,
id: Identifier( id: Identifier(
"second", "second",
), ),
ctx: Load, ctx: Load,
}, },
), ),
},
conversion: Int( conversion: Int(
114, 114,
), ),
format_spec: None, format_spec: None,
}, },
), ),
},
] ]

Some files were not shown because too many files have changed in this diff Show More