mirror of
https://github.com/RustPython/Parser.git
synced 2025-08-04 02:39:22 +00:00
No Attributed + custom for Range PoC
This commit is contained in:
parent
ba0ae51e82
commit
904f5c8b37
10 changed files with 1732 additions and 1184 deletions
184
ast/asdl_rs.py
184
ast/asdl_rs.py
|
@ -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 needs_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
|
||||||
|
@ -208,6 +205,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)
|
||||||
|
@ -277,6 +275,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_custom(self, has_attributes, depth):
|
||||||
|
if has_attributes:
|
||||||
|
self.emit("pub custom: U,", depth + 1)
|
||||||
|
else:
|
||||||
|
self.emit('#[cfg(feature = "more-attributes")]', depth + 1)
|
||||||
|
self.emit("pub custom: U,", depth + 1)
|
||||||
|
self.emit('#[cfg(not(feature = "more-attributes"))]', depth + 1)
|
||||||
|
self.emit("pub custom: std::marker::PhantomData<U>,", 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)
|
||||||
|
@ -289,7 +297,6 @@ 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<>
|
||||||
|
@ -297,10 +304,9 @@ class StructVisitor(EmitVisitor):
|
||||||
for t in sum.types:
|
for t in sum.types:
|
||||||
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}<U> {{", 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:
|
||||||
|
@ -308,33 +314,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,
|
||||||
)
|
)
|
||||||
(t_generics_applied,) = self.apply_generics(t.name, "U")
|
|
||||||
self.emit(
|
self.emit(
|
||||||
f"{t.name}({rust_name}{t.name}{t_generics_applied}),", depth + 1
|
f"{t.name}({rust_name}{t.name}<U>),", 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}<U> {{", 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)
|
||||||
self.emit("pub range: TextRange", depth + 1)
|
|
||||||
|
assert sum_type_info.has_attributes == self.type_info[t.name].needs_cfg(self.type_info)
|
||||||
|
self.emit_custom(sum_type_info.has_attributes, depth)
|
||||||
|
|
||||||
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<U> From<{payload_name}<U>> for {rust_name}<U> {{
|
||||||
fn from(payload: {payload_name}{generics_applied}) -> Self {{
|
fn from(payload: {payload_name}<U>) -> Self {{
|
||||||
{rust_name}{sum_type_info.rust_suffix}::{t.name}(payload)
|
{rust_name}::{t.name}(payload)
|
||||||
}}
|
}}
|
||||||
}}
|
}}
|
||||||
"""
|
"""
|
||||||
|
@ -342,12 +344,14 @@ class StructVisitor(EmitVisitor):
|
||||||
depth,
|
depth,
|
||||||
)
|
)
|
||||||
|
|
||||||
self.emit(f"impl{generics_applied} Ranged for {payload_name}{generics_applied} {{", depth)
|
# if not sum_type_info.has_attributes:
|
||||||
self.emit("#[inline]", depth + 1)
|
# self.emit('#[cfg(feature = "more-attributes")]', depth)
|
||||||
self.emit("fn range(&self) -> TextRange {", depth + 1)
|
# self.emit(f"impl Ranged for {payload_name}<TextRange> {{", depth)
|
||||||
self.emit("self.range", depth + 2)
|
# self.emit("#[inline]", depth + 1)
|
||||||
self.emit("}", depth + 1)
|
# self.emit("fn range(&self) -> TextRange {", depth + 1)
|
||||||
self.emit("}", depth)
|
# self.emit("self.custom", depth + 2)
|
||||||
|
# self.emit("}", depth + 1)
|
||||||
|
# self.emit("}", depth)
|
||||||
self.emit("", depth)
|
self.emit("", depth)
|
||||||
|
|
||||||
def visitConstructor(self, cons, parent, depth):
|
def visitConstructor(self, cons, parent, depth):
|
||||||
|
@ -362,7 +366,7 @@ 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}<U>"
|
||||||
# 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 (
|
||||||
|
@ -388,41 +392,23 @@ 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:
|
|
||||||
data_def = f"{data_name}{generics}"
|
|
||||||
else:
|
|
||||||
data_def = data_name
|
|
||||||
generics_applied = ""
|
|
||||||
|
|
||||||
self.emit(f"pub struct {data_def} {{", depth)
|
self.emit(f"pub struct {product_name}<U> {{", 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)
|
||||||
self.emit("pub range: TextRange", depth + 1)
|
assert bool(product.attributes) == type_info.needs_cfg(self.type_info)
|
||||||
|
self.emit_custom(product.attributes, depth + 1)
|
||||||
self.emit("}", depth)
|
self.emit("}", depth)
|
||||||
|
|
||||||
self.emit(f"impl{generics_applied} Ranged for {data_name}{generics_applied} {{", depth)
|
# self.emit('#[cfg(feature = "more-attributes")]', depth)
|
||||||
self.emit("#[inline]", depth + 1)
|
# self.emit(f"impl Ranged for {product_name}<TextRange> {{", depth)
|
||||||
self.emit("fn range(&self) -> TextRange {", depth + 1)
|
# self.emit("#[inline]", depth + 1)
|
||||||
self.emit("self.range", depth + 2)
|
# self.emit("fn range(&self) -> TextRange {", depth + 1)
|
||||||
self.emit("}", depth + 1)
|
# self.emit("self.custom", depth + 2)
|
||||||
self.emit("}", depth)
|
# self.emit("}", 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)
|
||||||
|
|
||||||
|
|
||||||
|
@ -511,7 +497,7 @@ class FoldImplVisitor(EmitVisitor):
|
||||||
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, type_info.rust_suffix, cons.name, cons.fields, simple
|
enum_name, cons.name, cons.fields, simple
|
||||||
)
|
)
|
||||||
self.emit(
|
self.emit(
|
||||||
f"{fields_pattern[0]} {{ {fields_pattern[1]}}} {fields_pattern[2]} => {{",
|
f"{fields_pattern[0]} {{ {fields_pattern[1]}}} {fields_pattern[2]} => {{",
|
||||||
|
@ -552,19 +538,19 @@ class FoldImplVisitor(EmitVisitor):
|
||||||
rust_name = struct_name + "Data"
|
rust_name = struct_name + "Data"
|
||||||
else:
|
else:
|
||||||
rust_name = struct_name
|
rust_name = struct_name
|
||||||
fields_pattern = self.make_pattern(rust_name, struct_name, None, product.fields, False)
|
fields_pattern = self.make_pattern(rust_name, struct_name, product.fields, False)
|
||||||
self.emit(f"let {rust_name} {{ {fields_pattern[1]} }} = node;", depth + 1)
|
self.emit(f"let {rust_name} {{ {fields_pattern[1]} }} = node;", depth + 1)
|
||||||
self.gen_construction(rust_name, product.fields, "", depth + 1, False)
|
self.gen_construction(rust_name, product.fields, "", depth + 1, False)
|
||||||
if has_attributes:
|
if has_attributes:
|
||||||
self.emit("})", depth)
|
self.emit("})", depth)
|
||||||
self.emit("}", depth)
|
self.emit("}", depth)
|
||||||
|
|
||||||
def make_pattern(self, rust_name, suffix, fieldname: str, fields, simple_sum: bool):
|
def make_pattern(self, rust_name, fieldname: str, fields, simple_sum: bool):
|
||||||
if fields or not simple_sum:
|
if fields or not simple_sum:
|
||||||
header = f"{rust_name}{suffix}::{fieldname}({rust_name}{fieldname}"
|
header = f"{rust_name}::{fieldname}({rust_name}{fieldname}"
|
||||||
footer = ")"
|
footer = ")"
|
||||||
else:
|
else:
|
||||||
header = f"{rust_name}{suffix}::{fieldname}"
|
header = f"{rust_name}::{fieldname}"
|
||||||
footer = ""
|
footer = ""
|
||||||
|
|
||||||
body = ",".join(rust_field(f.name) for f in fields)
|
body = ",".join(rust_field(f.name) for f in fields)
|
||||||
|
@ -977,11 +963,6 @@ 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};
|
|
||||||
use crate::Ranged;
|
|
||||||
""")
|
|
||||||
|
|
||||||
StructVisitor(f, type_info).visit(mod)
|
StructVisitor(f, type_info).visit(mod)
|
||||||
|
|
||||||
|
|
||||||
|
@ -996,33 +977,43 @@ 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(
|
|
||||||
textwrap.dedent(
|
|
||||||
"""
|
|
||||||
use rustpython_parser_core::source_code::SourceRange;
|
|
||||||
|
|
||||||
pub type Located<T> = super::generic::Attributed<T, SourceRange>;
|
|
||||||
"""
|
|
||||||
)
|
|
||||||
)
|
|
||||||
for info in type_info.values():
|
for info in type_info.values():
|
||||||
if info.empty_field:
|
if not info.is_simple:
|
||||||
continue
|
if info.needs_cfg:
|
||||||
if info.has_user_data:
|
f.write('#[cfg(feature = "more-attributes")]')
|
||||||
|
f.write(f"""
|
||||||
|
impl Ranged for {info.rust_sum_name} {{
|
||||||
|
fn range(&self) -> TextRange {{
|
||||||
|
self.custom
|
||||||
|
}}
|
||||||
|
}}
|
||||||
|
""")
|
||||||
|
generics = "::<TextRange>"
|
||||||
|
else:
|
||||||
|
generics = ""
|
||||||
|
f.write(
|
||||||
|
f"pub type {info.rust_sum_name} = crate::generic::{info.rust_sum_name}{generics};\n"
|
||||||
|
)
|
||||||
|
|
||||||
|
def write_located_def(mod, type_info, f):
|
||||||
|
for info in type_info.values():
|
||||||
|
if not info.is_simple:
|
||||||
|
if info.needs_cfg:
|
||||||
|
f.write('#[cfg(feature = "more-attributes")]')
|
||||||
|
f.write(f"""
|
||||||
|
impl Located for {info.rust_sum_name} {{
|
||||||
|
fn range(&self) -> SourceRange {{
|
||||||
|
self.custom
|
||||||
|
}}
|
||||||
|
}}
|
||||||
|
""")
|
||||||
generics = "::<SourceRange>"
|
generics = "::<SourceRange>"
|
||||||
else:
|
else:
|
||||||
generics = ""
|
generics = ""
|
||||||
f.write(
|
f.write(
|
||||||
f"pub type {info.rust_sum_name} = super::generic::{info.rust_sum_name}{generics};\n"
|
f"pub type {info.rust_sum_name} = crate::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):
|
||||||
f.write(
|
f.write(
|
||||||
|
@ -1064,6 +1055,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),
|
||||||
]:
|
]:
|
||||||
|
|
|
@ -161,7 +161,7 @@ pub fn fold_stmt<U, F: Fold<U> + ?Sized>(
|
||||||
node: Stmt<U>,
|
node: Stmt<U>,
|
||||||
) -> Result<Stmt<F::TargetU>, F::Error> {
|
) -> Result<Stmt<F::TargetU>, F::Error> {
|
||||||
fold_attributed(folder, node, |folder, node| match node {
|
fold_attributed(folder, node, |folder, node| match node {
|
||||||
StmtKind::FunctionDef(StmtFunctionDef {
|
Stmt::FunctionDef(StmtFunctionDef {
|
||||||
range,
|
range,
|
||||||
name,
|
name,
|
||||||
args,
|
args,
|
||||||
|
@ -169,7 +169,7 @@ pub fn fold_stmt<U, F: Fold<U> + ?Sized>(
|
||||||
decorator_list,
|
decorator_list,
|
||||||
returns,
|
returns,
|
||||||
type_comment,
|
type_comment,
|
||||||
}) => Ok(StmtKind::FunctionDef(StmtFunctionDef {
|
}) => Ok(Stmt::FunctionDef(StmtFunctionDef {
|
||||||
name: Foldable::fold(name, folder)?,
|
name: Foldable::fold(name, folder)?,
|
||||||
args: Foldable::fold(args, folder)?,
|
args: Foldable::fold(args, folder)?,
|
||||||
body: Foldable::fold(body, folder)?,
|
body: Foldable::fold(body, folder)?,
|
||||||
|
@ -178,7 +178,7 @@ pub fn fold_stmt<U, F: Fold<U> + ?Sized>(
|
||||||
type_comment: Foldable::fold(type_comment, folder)?,
|
type_comment: Foldable::fold(type_comment, folder)?,
|
||||||
range,
|
range,
|
||||||
})),
|
})),
|
||||||
StmtKind::AsyncFunctionDef(StmtAsyncFunctionDef {
|
Stmt::AsyncFunctionDef(StmtAsyncFunctionDef {
|
||||||
range,
|
range,
|
||||||
name,
|
name,
|
||||||
args,
|
args,
|
||||||
|
@ -186,7 +186,7 @@ pub fn fold_stmt<U, F: Fold<U> + ?Sized>(
|
||||||
decorator_list,
|
decorator_list,
|
||||||
returns,
|
returns,
|
||||||
type_comment,
|
type_comment,
|
||||||
}) => Ok(StmtKind::AsyncFunctionDef(StmtAsyncFunctionDef {
|
}) => Ok(Stmt::AsyncFunctionDef(StmtAsyncFunctionDef {
|
||||||
name: Foldable::fold(name, folder)?,
|
name: Foldable::fold(name, folder)?,
|
||||||
args: Foldable::fold(args, folder)?,
|
args: Foldable::fold(args, folder)?,
|
||||||
body: Foldable::fold(body, folder)?,
|
body: Foldable::fold(body, folder)?,
|
||||||
|
@ -195,14 +195,14 @@ pub fn fold_stmt<U, F: Fold<U> + ?Sized>(
|
||||||
type_comment: Foldable::fold(type_comment, folder)?,
|
type_comment: Foldable::fold(type_comment, folder)?,
|
||||||
range,
|
range,
|
||||||
})),
|
})),
|
||||||
StmtKind::ClassDef(StmtClassDef {
|
Stmt::ClassDef(StmtClassDef {
|
||||||
range,
|
range,
|
||||||
name,
|
name,
|
||||||
bases,
|
bases,
|
||||||
keywords,
|
keywords,
|
||||||
body,
|
body,
|
||||||
decorator_list,
|
decorator_list,
|
||||||
}) => Ok(StmtKind::ClassDef(StmtClassDef {
|
}) => Ok(Stmt::ClassDef(StmtClassDef {
|
||||||
name: Foldable::fold(name, folder)?,
|
name: Foldable::fold(name, folder)?,
|
||||||
bases: Foldable::fold(bases, folder)?,
|
bases: Foldable::fold(bases, folder)?,
|
||||||
keywords: Foldable::fold(keywords, folder)?,
|
keywords: Foldable::fold(keywords, folder)?,
|
||||||
|
@ -210,57 +210,57 @@ pub fn fold_stmt<U, F: Fold<U> + ?Sized>(
|
||||||
decorator_list: Foldable::fold(decorator_list, folder)?,
|
decorator_list: Foldable::fold(decorator_list, folder)?,
|
||||||
range,
|
range,
|
||||||
})),
|
})),
|
||||||
StmtKind::Return(StmtReturn { range, value }) => Ok(StmtKind::Return(StmtReturn {
|
Stmt::Return(StmtReturn { range, value }) => Ok(Stmt::Return(StmtReturn {
|
||||||
value: Foldable::fold(value, folder)?,
|
value: Foldable::fold(value, folder)?,
|
||||||
range,
|
range,
|
||||||
})),
|
})),
|
||||||
StmtKind::Delete(StmtDelete { range, targets }) => Ok(StmtKind::Delete(StmtDelete {
|
Stmt::Delete(StmtDelete { range, targets }) => Ok(Stmt::Delete(StmtDelete {
|
||||||
targets: Foldable::fold(targets, folder)?,
|
targets: Foldable::fold(targets, folder)?,
|
||||||
range,
|
range,
|
||||||
})),
|
})),
|
||||||
StmtKind::Assign(StmtAssign {
|
Stmt::Assign(StmtAssign {
|
||||||
range,
|
range,
|
||||||
targets,
|
targets,
|
||||||
value,
|
value,
|
||||||
type_comment,
|
type_comment,
|
||||||
}) => Ok(StmtKind::Assign(StmtAssign {
|
}) => Ok(Stmt::Assign(StmtAssign {
|
||||||
targets: Foldable::fold(targets, folder)?,
|
targets: Foldable::fold(targets, folder)?,
|
||||||
value: Foldable::fold(value, folder)?,
|
value: Foldable::fold(value, folder)?,
|
||||||
type_comment: Foldable::fold(type_comment, folder)?,
|
type_comment: Foldable::fold(type_comment, folder)?,
|
||||||
range,
|
range,
|
||||||
})),
|
})),
|
||||||
StmtKind::AugAssign(StmtAugAssign {
|
Stmt::AugAssign(StmtAugAssign {
|
||||||
range,
|
range,
|
||||||
target,
|
target,
|
||||||
op,
|
op,
|
||||||
value,
|
value,
|
||||||
}) => Ok(StmtKind::AugAssign(StmtAugAssign {
|
}) => Ok(Stmt::AugAssign(StmtAugAssign {
|
||||||
target: Foldable::fold(target, folder)?,
|
target: Foldable::fold(target, folder)?,
|
||||||
op: Foldable::fold(op, folder)?,
|
op: Foldable::fold(op, folder)?,
|
||||||
value: Foldable::fold(value, folder)?,
|
value: Foldable::fold(value, folder)?,
|
||||||
range,
|
range,
|
||||||
})),
|
})),
|
||||||
StmtKind::AnnAssign(StmtAnnAssign {
|
Stmt::AnnAssign(StmtAnnAssign {
|
||||||
range,
|
range,
|
||||||
target,
|
target,
|
||||||
annotation,
|
annotation,
|
||||||
value,
|
value,
|
||||||
simple,
|
simple,
|
||||||
}) => Ok(StmtKind::AnnAssign(StmtAnnAssign {
|
}) => Ok(Stmt::AnnAssign(StmtAnnAssign {
|
||||||
target: Foldable::fold(target, folder)?,
|
target: Foldable::fold(target, folder)?,
|
||||||
annotation: Foldable::fold(annotation, folder)?,
|
annotation: Foldable::fold(annotation, folder)?,
|
||||||
value: Foldable::fold(value, folder)?,
|
value: Foldable::fold(value, folder)?,
|
||||||
simple: Foldable::fold(simple, folder)?,
|
simple: Foldable::fold(simple, folder)?,
|
||||||
range,
|
range,
|
||||||
})),
|
})),
|
||||||
StmtKind::For(StmtFor {
|
Stmt::For(StmtFor {
|
||||||
range,
|
range,
|
||||||
target,
|
target,
|
||||||
iter,
|
iter,
|
||||||
body,
|
body,
|
||||||
orelse,
|
orelse,
|
||||||
type_comment,
|
type_comment,
|
||||||
}) => Ok(StmtKind::For(StmtFor {
|
}) => Ok(Stmt::For(StmtFor {
|
||||||
target: Foldable::fold(target, folder)?,
|
target: Foldable::fold(target, folder)?,
|
||||||
iter: Foldable::fold(iter, folder)?,
|
iter: Foldable::fold(iter, folder)?,
|
||||||
body: Foldable::fold(body, folder)?,
|
body: Foldable::fold(body, folder)?,
|
||||||
|
@ -268,14 +268,14 @@ pub fn fold_stmt<U, F: Fold<U> + ?Sized>(
|
||||||
type_comment: Foldable::fold(type_comment, folder)?,
|
type_comment: Foldable::fold(type_comment, folder)?,
|
||||||
range,
|
range,
|
||||||
})),
|
})),
|
||||||
StmtKind::AsyncFor(StmtAsyncFor {
|
Stmt::AsyncFor(StmtAsyncFor {
|
||||||
range,
|
range,
|
||||||
target,
|
target,
|
||||||
iter,
|
iter,
|
||||||
body,
|
body,
|
||||||
orelse,
|
orelse,
|
||||||
type_comment,
|
type_comment,
|
||||||
}) => Ok(StmtKind::AsyncFor(StmtAsyncFor {
|
}) => Ok(Stmt::AsyncFor(StmtAsyncFor {
|
||||||
target: Foldable::fold(target, folder)?,
|
target: Foldable::fold(target, folder)?,
|
||||||
iter: Foldable::fold(iter, folder)?,
|
iter: Foldable::fold(iter, folder)?,
|
||||||
body: Foldable::fold(body, folder)?,
|
body: Foldable::fold(body, folder)?,
|
||||||
|
@ -283,127 +283,125 @@ pub fn fold_stmt<U, F: Fold<U> + ?Sized>(
|
||||||
type_comment: Foldable::fold(type_comment, folder)?,
|
type_comment: Foldable::fold(type_comment, folder)?,
|
||||||
range,
|
range,
|
||||||
})),
|
})),
|
||||||
StmtKind::While(StmtWhile {
|
Stmt::While(StmtWhile {
|
||||||
range,
|
range,
|
||||||
test,
|
test,
|
||||||
body,
|
body,
|
||||||
orelse,
|
orelse,
|
||||||
}) => Ok(StmtKind::While(StmtWhile {
|
}) => Ok(Stmt::While(StmtWhile {
|
||||||
test: Foldable::fold(test, folder)?,
|
test: Foldable::fold(test, folder)?,
|
||||||
body: Foldable::fold(body, folder)?,
|
body: Foldable::fold(body, folder)?,
|
||||||
orelse: Foldable::fold(orelse, folder)?,
|
orelse: Foldable::fold(orelse, folder)?,
|
||||||
range,
|
range,
|
||||||
})),
|
})),
|
||||||
StmtKind::If(StmtIf {
|
Stmt::If(StmtIf {
|
||||||
range,
|
range,
|
||||||
test,
|
test,
|
||||||
body,
|
body,
|
||||||
orelse,
|
orelse,
|
||||||
}) => Ok(StmtKind::If(StmtIf {
|
}) => Ok(Stmt::If(StmtIf {
|
||||||
test: Foldable::fold(test, folder)?,
|
test: Foldable::fold(test, folder)?,
|
||||||
body: Foldable::fold(body, folder)?,
|
body: Foldable::fold(body, folder)?,
|
||||||
orelse: Foldable::fold(orelse, folder)?,
|
orelse: Foldable::fold(orelse, folder)?,
|
||||||
range,
|
range,
|
||||||
})),
|
})),
|
||||||
StmtKind::With(StmtWith {
|
Stmt::With(StmtWith {
|
||||||
range,
|
range,
|
||||||
items,
|
items,
|
||||||
body,
|
body,
|
||||||
type_comment,
|
type_comment,
|
||||||
}) => Ok(StmtKind::With(StmtWith {
|
}) => Ok(Stmt::With(StmtWith {
|
||||||
items: Foldable::fold(items, folder)?,
|
items: Foldable::fold(items, folder)?,
|
||||||
body: Foldable::fold(body, folder)?,
|
body: Foldable::fold(body, folder)?,
|
||||||
type_comment: Foldable::fold(type_comment, folder)?,
|
type_comment: Foldable::fold(type_comment, folder)?,
|
||||||
range,
|
range,
|
||||||
})),
|
})),
|
||||||
StmtKind::AsyncWith(StmtAsyncWith {
|
Stmt::AsyncWith(StmtAsyncWith {
|
||||||
range,
|
range,
|
||||||
items,
|
items,
|
||||||
body,
|
body,
|
||||||
type_comment,
|
type_comment,
|
||||||
}) => Ok(StmtKind::AsyncWith(StmtAsyncWith {
|
}) => Ok(Stmt::AsyncWith(StmtAsyncWith {
|
||||||
items: Foldable::fold(items, folder)?,
|
items: Foldable::fold(items, folder)?,
|
||||||
body: Foldable::fold(body, folder)?,
|
body: Foldable::fold(body, folder)?,
|
||||||
type_comment: Foldable::fold(type_comment, folder)?,
|
type_comment: Foldable::fold(type_comment, folder)?,
|
||||||
range,
|
range,
|
||||||
})),
|
})),
|
||||||
StmtKind::Match(StmtMatch {
|
Stmt::Match(StmtMatch {
|
||||||
range,
|
range,
|
||||||
subject,
|
subject,
|
||||||
cases,
|
cases,
|
||||||
}) => Ok(StmtKind::Match(StmtMatch {
|
}) => Ok(Stmt::Match(StmtMatch {
|
||||||
subject: Foldable::fold(subject, folder)?,
|
subject: Foldable::fold(subject, folder)?,
|
||||||
cases: Foldable::fold(cases, folder)?,
|
cases: Foldable::fold(cases, folder)?,
|
||||||
range,
|
range,
|
||||||
})),
|
})),
|
||||||
StmtKind::Raise(StmtRaise { range, exc, cause }) => Ok(StmtKind::Raise(StmtRaise {
|
Stmt::Raise(StmtRaise { range, exc, cause }) => Ok(Stmt::Raise(StmtRaise {
|
||||||
exc: Foldable::fold(exc, folder)?,
|
exc: Foldable::fold(exc, folder)?,
|
||||||
cause: Foldable::fold(cause, folder)?,
|
cause: Foldable::fold(cause, folder)?,
|
||||||
range,
|
range,
|
||||||
})),
|
})),
|
||||||
StmtKind::Try(StmtTry {
|
Stmt::Try(StmtTry {
|
||||||
range,
|
range,
|
||||||
body,
|
body,
|
||||||
handlers,
|
handlers,
|
||||||
orelse,
|
orelse,
|
||||||
finalbody,
|
finalbody,
|
||||||
}) => Ok(StmtKind::Try(StmtTry {
|
}) => Ok(Stmt::Try(StmtTry {
|
||||||
body: Foldable::fold(body, folder)?,
|
body: Foldable::fold(body, folder)?,
|
||||||
handlers: Foldable::fold(handlers, folder)?,
|
handlers: Foldable::fold(handlers, folder)?,
|
||||||
orelse: Foldable::fold(orelse, folder)?,
|
orelse: Foldable::fold(orelse, folder)?,
|
||||||
finalbody: Foldable::fold(finalbody, folder)?,
|
finalbody: Foldable::fold(finalbody, folder)?,
|
||||||
range,
|
range,
|
||||||
})),
|
})),
|
||||||
StmtKind::TryStar(StmtTryStar {
|
Stmt::TryStar(StmtTryStar {
|
||||||
range,
|
range,
|
||||||
body,
|
body,
|
||||||
handlers,
|
handlers,
|
||||||
orelse,
|
orelse,
|
||||||
finalbody,
|
finalbody,
|
||||||
}) => Ok(StmtKind::TryStar(StmtTryStar {
|
}) => Ok(Stmt::TryStar(StmtTryStar {
|
||||||
body: Foldable::fold(body, folder)?,
|
body: Foldable::fold(body, folder)?,
|
||||||
handlers: Foldable::fold(handlers, folder)?,
|
handlers: Foldable::fold(handlers, folder)?,
|
||||||
orelse: Foldable::fold(orelse, folder)?,
|
orelse: Foldable::fold(orelse, folder)?,
|
||||||
finalbody: Foldable::fold(finalbody, folder)?,
|
finalbody: Foldable::fold(finalbody, folder)?,
|
||||||
range,
|
range,
|
||||||
})),
|
})),
|
||||||
StmtKind::Assert(StmtAssert { range, test, msg }) => Ok(StmtKind::Assert(StmtAssert {
|
Stmt::Assert(StmtAssert { range, test, msg }) => Ok(Stmt::Assert(StmtAssert {
|
||||||
test: Foldable::fold(test, folder)?,
|
test: Foldable::fold(test, folder)?,
|
||||||
msg: Foldable::fold(msg, folder)?,
|
msg: Foldable::fold(msg, folder)?,
|
||||||
range,
|
range,
|
||||||
})),
|
})),
|
||||||
StmtKind::Import(StmtImport { range, names }) => Ok(StmtKind::Import(StmtImport {
|
Stmt::Import(StmtImport { range, names }) => Ok(Stmt::Import(StmtImport {
|
||||||
names: Foldable::fold(names, folder)?,
|
names: Foldable::fold(names, folder)?,
|
||||||
range,
|
range,
|
||||||
})),
|
})),
|
||||||
StmtKind::ImportFrom(StmtImportFrom {
|
Stmt::ImportFrom(StmtImportFrom {
|
||||||
range,
|
range,
|
||||||
module,
|
module,
|
||||||
names,
|
names,
|
||||||
level,
|
level,
|
||||||
}) => Ok(StmtKind::ImportFrom(StmtImportFrom {
|
}) => Ok(Stmt::ImportFrom(StmtImportFrom {
|
||||||
module: Foldable::fold(module, folder)?,
|
module: Foldable::fold(module, folder)?,
|
||||||
names: Foldable::fold(names, folder)?,
|
names: Foldable::fold(names, folder)?,
|
||||||
level: Foldable::fold(level, folder)?,
|
level: Foldable::fold(level, folder)?,
|
||||||
range,
|
range,
|
||||||
})),
|
})),
|
||||||
StmtKind::Global(StmtGlobal { range, names }) => Ok(StmtKind::Global(StmtGlobal {
|
Stmt::Global(StmtGlobal { range, names }) => Ok(Stmt::Global(StmtGlobal {
|
||||||
names: Foldable::fold(names, folder)?,
|
names: Foldable::fold(names, folder)?,
|
||||||
range,
|
range,
|
||||||
})),
|
})),
|
||||||
StmtKind::Nonlocal(StmtNonlocal { range, names }) => Ok(StmtKind::Nonlocal(StmtNonlocal {
|
Stmt::Nonlocal(StmtNonlocal { range, names }) => Ok(Stmt::Nonlocal(StmtNonlocal {
|
||||||
names: Foldable::fold(names, folder)?,
|
names: Foldable::fold(names, folder)?,
|
||||||
range,
|
range,
|
||||||
})),
|
})),
|
||||||
StmtKind::Expr(StmtExpr { range, value }) => Ok(StmtKind::Expr(StmtExpr {
|
Stmt::Expr(StmtExpr { range, value }) => Ok(Stmt::Expr(StmtExpr {
|
||||||
value: Foldable::fold(value, folder)?,
|
value: Foldable::fold(value, folder)?,
|
||||||
range,
|
range,
|
||||||
})),
|
})),
|
||||||
StmtKind::Pass(StmtPass { range }) => Ok(StmtKind::Pass(StmtPass { range })),
|
Stmt::Pass(StmtPass { range }) => Ok(Stmt::Pass(StmtPass { range })),
|
||||||
StmtKind::Break(StmtBreak { range }) => Ok(StmtKind::Break(StmtBreak { range })),
|
Stmt::Break(StmtBreak { range }) => Ok(Stmt::Break(StmtBreak { range })),
|
||||||
StmtKind::Continue(StmtContinue { range }) => {
|
Stmt::Continue(StmtContinue { range }) => Ok(Stmt::Continue(StmtContinue { range })),
|
||||||
Ok(StmtKind::Continue(StmtContinue { range }))
|
|
||||||
}
|
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
impl<T, U> Foldable<T, U> for Expr<T> {
|
impl<T, U> Foldable<T, U> for Expr<T> {
|
||||||
|
@ -420,215 +418,205 @@ pub fn fold_expr<U, F: Fold<U> + ?Sized>(
|
||||||
node: Expr<U>,
|
node: Expr<U>,
|
||||||
) -> Result<Expr<F::TargetU>, F::Error> {
|
) -> Result<Expr<F::TargetU>, F::Error> {
|
||||||
fold_attributed(folder, node, |folder, node| match node {
|
fold_attributed(folder, node, |folder, node| match node {
|
||||||
ExprKind::BoolOp(ExprBoolOp { range, op, values }) => Ok(ExprKind::BoolOp(ExprBoolOp {
|
Expr::BoolOp(ExprBoolOp { range, op, values }) => Ok(Expr::BoolOp(ExprBoolOp {
|
||||||
op: Foldable::fold(op, folder)?,
|
op: Foldable::fold(op, folder)?,
|
||||||
values: Foldable::fold(values, folder)?,
|
values: Foldable::fold(values, folder)?,
|
||||||
range,
|
range,
|
||||||
})),
|
})),
|
||||||
ExprKind::NamedExpr(ExprNamedExpr {
|
Expr::NamedExpr(ExprNamedExpr {
|
||||||
range,
|
range,
|
||||||
target,
|
target,
|
||||||
value,
|
value,
|
||||||
}) => Ok(ExprKind::NamedExpr(ExprNamedExpr {
|
}) => Ok(Expr::NamedExpr(ExprNamedExpr {
|
||||||
target: Foldable::fold(target, folder)?,
|
target: Foldable::fold(target, folder)?,
|
||||||
value: Foldable::fold(value, folder)?,
|
value: Foldable::fold(value, folder)?,
|
||||||
range,
|
range,
|
||||||
})),
|
})),
|
||||||
ExprKind::BinOp(ExprBinOp {
|
Expr::BinOp(ExprBinOp {
|
||||||
range,
|
range,
|
||||||
left,
|
left,
|
||||||
op,
|
op,
|
||||||
right,
|
right,
|
||||||
}) => Ok(ExprKind::BinOp(ExprBinOp {
|
}) => Ok(Expr::BinOp(ExprBinOp {
|
||||||
left: Foldable::fold(left, folder)?,
|
left: Foldable::fold(left, folder)?,
|
||||||
op: Foldable::fold(op, folder)?,
|
op: Foldable::fold(op, folder)?,
|
||||||
right: Foldable::fold(right, folder)?,
|
right: Foldable::fold(right, folder)?,
|
||||||
range,
|
range,
|
||||||
})),
|
})),
|
||||||
ExprKind::UnaryOp(ExprUnaryOp { range, op, operand }) => {
|
Expr::UnaryOp(ExprUnaryOp { range, op, operand }) => Ok(Expr::UnaryOp(ExprUnaryOp {
|
||||||
Ok(ExprKind::UnaryOp(ExprUnaryOp {
|
op: Foldable::fold(op, folder)?,
|
||||||
op: Foldable::fold(op, folder)?,
|
operand: Foldable::fold(operand, folder)?,
|
||||||
operand: Foldable::fold(operand, folder)?,
|
range,
|
||||||
range,
|
})),
|
||||||
}))
|
Expr::Lambda(ExprLambda { range, args, body }) => Ok(Expr::Lambda(ExprLambda {
|
||||||
}
|
|
||||||
ExprKind::Lambda(ExprLambda { range, args, body }) => Ok(ExprKind::Lambda(ExprLambda {
|
|
||||||
args: Foldable::fold(args, folder)?,
|
args: Foldable::fold(args, folder)?,
|
||||||
body: Foldable::fold(body, folder)?,
|
body: Foldable::fold(body, folder)?,
|
||||||
range,
|
range,
|
||||||
})),
|
})),
|
||||||
ExprKind::IfExp(ExprIfExp {
|
Expr::IfExp(ExprIfExp {
|
||||||
range,
|
range,
|
||||||
test,
|
test,
|
||||||
body,
|
body,
|
||||||
orelse,
|
orelse,
|
||||||
}) => Ok(ExprKind::IfExp(ExprIfExp {
|
}) => Ok(Expr::IfExp(ExprIfExp {
|
||||||
test: Foldable::fold(test, folder)?,
|
test: Foldable::fold(test, folder)?,
|
||||||
body: Foldable::fold(body, folder)?,
|
body: Foldable::fold(body, folder)?,
|
||||||
orelse: Foldable::fold(orelse, folder)?,
|
orelse: Foldable::fold(orelse, folder)?,
|
||||||
range,
|
range,
|
||||||
})),
|
})),
|
||||||
ExprKind::Dict(ExprDict {
|
Expr::Dict(ExprDict {
|
||||||
range,
|
range,
|
||||||
keys,
|
keys,
|
||||||
values,
|
values,
|
||||||
}) => Ok(ExprKind::Dict(ExprDict {
|
}) => Ok(Expr::Dict(ExprDict {
|
||||||
keys: Foldable::fold(keys, folder)?,
|
keys: Foldable::fold(keys, folder)?,
|
||||||
values: Foldable::fold(values, folder)?,
|
values: Foldable::fold(values, folder)?,
|
||||||
range,
|
range,
|
||||||
})),
|
})),
|
||||||
ExprKind::Set(ExprSet { range, elts }) => Ok(ExprKind::Set(ExprSet {
|
Expr::Set(ExprSet { range, elts }) => Ok(Expr::Set(ExprSet {
|
||||||
elts: Foldable::fold(elts, folder)?,
|
elts: Foldable::fold(elts, folder)?,
|
||||||
range,
|
range,
|
||||||
})),
|
})),
|
||||||
ExprKind::ListComp(ExprListComp {
|
Expr::ListComp(ExprListComp {
|
||||||
range,
|
range,
|
||||||
elt,
|
elt,
|
||||||
generators,
|
generators,
|
||||||
}) => Ok(ExprKind::ListComp(ExprListComp {
|
}) => Ok(Expr::ListComp(ExprListComp {
|
||||||
elt: Foldable::fold(elt, folder)?,
|
elt: Foldable::fold(elt, folder)?,
|
||||||
generators: Foldable::fold(generators, folder)?,
|
generators: Foldable::fold(generators, folder)?,
|
||||||
range,
|
range,
|
||||||
})),
|
})),
|
||||||
ExprKind::SetComp(ExprSetComp {
|
Expr::SetComp(ExprSetComp {
|
||||||
range,
|
range,
|
||||||
elt,
|
elt,
|
||||||
generators,
|
generators,
|
||||||
}) => Ok(ExprKind::SetComp(ExprSetComp {
|
}) => Ok(Expr::SetComp(ExprSetComp {
|
||||||
elt: Foldable::fold(elt, folder)?,
|
elt: Foldable::fold(elt, folder)?,
|
||||||
generators: Foldable::fold(generators, folder)?,
|
generators: Foldable::fold(generators, folder)?,
|
||||||
range,
|
range,
|
||||||
})),
|
})),
|
||||||
ExprKind::DictComp(ExprDictComp {
|
Expr::DictComp(ExprDictComp {
|
||||||
range,
|
range,
|
||||||
key,
|
key,
|
||||||
value,
|
value,
|
||||||
generators,
|
generators,
|
||||||
}) => Ok(ExprKind::DictComp(ExprDictComp {
|
}) => Ok(Expr::DictComp(ExprDictComp {
|
||||||
key: Foldable::fold(key, folder)?,
|
key: Foldable::fold(key, folder)?,
|
||||||
value: Foldable::fold(value, folder)?,
|
value: Foldable::fold(value, folder)?,
|
||||||
generators: Foldable::fold(generators, folder)?,
|
generators: Foldable::fold(generators, folder)?,
|
||||||
range,
|
range,
|
||||||
})),
|
})),
|
||||||
ExprKind::GeneratorExp(ExprGeneratorExp {
|
Expr::GeneratorExp(ExprGeneratorExp {
|
||||||
range,
|
range,
|
||||||
elt,
|
elt,
|
||||||
generators,
|
generators,
|
||||||
}) => Ok(ExprKind::GeneratorExp(ExprGeneratorExp {
|
}) => Ok(Expr::GeneratorExp(ExprGeneratorExp {
|
||||||
elt: Foldable::fold(elt, folder)?,
|
elt: Foldable::fold(elt, folder)?,
|
||||||
generators: Foldable::fold(generators, folder)?,
|
generators: Foldable::fold(generators, folder)?,
|
||||||
range,
|
range,
|
||||||
})),
|
})),
|
||||||
ExprKind::Await(ExprAwait { range, value }) => Ok(ExprKind::Await(ExprAwait {
|
Expr::Await(ExprAwait { range, value }) => Ok(Expr::Await(ExprAwait {
|
||||||
value: Foldable::fold(value, folder)?,
|
value: Foldable::fold(value, folder)?,
|
||||||
range,
|
range,
|
||||||
})),
|
})),
|
||||||
ExprKind::Yield(ExprYield { range, value }) => Ok(ExprKind::Yield(ExprYield {
|
Expr::Yield(ExprYield { range, value }) => Ok(Expr::Yield(ExprYield {
|
||||||
value: Foldable::fold(value, folder)?,
|
value: Foldable::fold(value, folder)?,
|
||||||
range,
|
range,
|
||||||
})),
|
})),
|
||||||
ExprKind::YieldFrom(ExprYieldFrom { range, value }) => {
|
Expr::YieldFrom(ExprYieldFrom { range, value }) => Ok(Expr::YieldFrom(ExprYieldFrom {
|
||||||
Ok(ExprKind::YieldFrom(ExprYieldFrom {
|
value: Foldable::fold(value, folder)?,
|
||||||
value: Foldable::fold(value, folder)?,
|
range,
|
||||||
range,
|
})),
|
||||||
}))
|
Expr::Compare(ExprCompare {
|
||||||
}
|
|
||||||
ExprKind::Compare(ExprCompare {
|
|
||||||
range,
|
range,
|
||||||
left,
|
left,
|
||||||
ops,
|
ops,
|
||||||
comparators,
|
comparators,
|
||||||
}) => Ok(ExprKind::Compare(ExprCompare {
|
}) => Ok(Expr::Compare(ExprCompare {
|
||||||
left: Foldable::fold(left, folder)?,
|
left: Foldable::fold(left, folder)?,
|
||||||
ops: Foldable::fold(ops, folder)?,
|
ops: Foldable::fold(ops, folder)?,
|
||||||
comparators: Foldable::fold(comparators, folder)?,
|
comparators: Foldable::fold(comparators, folder)?,
|
||||||
range,
|
range,
|
||||||
})),
|
})),
|
||||||
ExprKind::Call(ExprCall {
|
Expr::Call(ExprCall {
|
||||||
range,
|
range,
|
||||||
func,
|
func,
|
||||||
args,
|
args,
|
||||||
keywords,
|
keywords,
|
||||||
}) => Ok(ExprKind::Call(ExprCall {
|
}) => Ok(Expr::Call(ExprCall {
|
||||||
func: Foldable::fold(func, folder)?,
|
func: Foldable::fold(func, folder)?,
|
||||||
args: Foldable::fold(args, folder)?,
|
args: Foldable::fold(args, folder)?,
|
||||||
keywords: Foldable::fold(keywords, folder)?,
|
keywords: Foldable::fold(keywords, folder)?,
|
||||||
range,
|
range,
|
||||||
})),
|
})),
|
||||||
ExprKind::FormattedValue(ExprFormattedValue {
|
Expr::FormattedValue(ExprFormattedValue {
|
||||||
range,
|
range,
|
||||||
value,
|
value,
|
||||||
conversion,
|
conversion,
|
||||||
format_spec,
|
format_spec,
|
||||||
}) => Ok(ExprKind::FormattedValue(ExprFormattedValue {
|
}) => Ok(Expr::FormattedValue(ExprFormattedValue {
|
||||||
value: Foldable::fold(value, folder)?,
|
value: Foldable::fold(value, folder)?,
|
||||||
conversion: Foldable::fold(conversion, folder)?,
|
conversion: Foldable::fold(conversion, folder)?,
|
||||||
format_spec: Foldable::fold(format_spec, folder)?,
|
format_spec: Foldable::fold(format_spec, folder)?,
|
||||||
range,
|
range,
|
||||||
})),
|
})),
|
||||||
ExprKind::JoinedStr(ExprJoinedStr { range, values }) => {
|
Expr::JoinedStr(ExprJoinedStr { range, values }) => Ok(Expr::JoinedStr(ExprJoinedStr {
|
||||||
Ok(ExprKind::JoinedStr(ExprJoinedStr {
|
values: Foldable::fold(values, folder)?,
|
||||||
values: Foldable::fold(values, folder)?,
|
range,
|
||||||
range,
|
})),
|
||||||
}))
|
Expr::Constant(ExprConstant { range, value, kind }) => Ok(Expr::Constant(ExprConstant {
|
||||||
}
|
value: Foldable::fold(value, folder)?,
|
||||||
ExprKind::Constant(ExprConstant { range, value, kind }) => {
|
kind: Foldable::fold(kind, folder)?,
|
||||||
Ok(ExprKind::Constant(ExprConstant {
|
range,
|
||||||
value: Foldable::fold(value, folder)?,
|
})),
|
||||||
kind: Foldable::fold(kind, folder)?,
|
Expr::Attribute(ExprAttribute {
|
||||||
range,
|
|
||||||
}))
|
|
||||||
}
|
|
||||||
ExprKind::Attribute(ExprAttribute {
|
|
||||||
range,
|
range,
|
||||||
value,
|
value,
|
||||||
attr,
|
attr,
|
||||||
ctx,
|
ctx,
|
||||||
}) => Ok(ExprKind::Attribute(ExprAttribute {
|
}) => Ok(Expr::Attribute(ExprAttribute {
|
||||||
value: Foldable::fold(value, folder)?,
|
value: Foldable::fold(value, folder)?,
|
||||||
attr: Foldable::fold(attr, folder)?,
|
attr: Foldable::fold(attr, folder)?,
|
||||||
ctx: Foldable::fold(ctx, folder)?,
|
ctx: Foldable::fold(ctx, folder)?,
|
||||||
range,
|
range,
|
||||||
})),
|
})),
|
||||||
ExprKind::Subscript(ExprSubscript {
|
Expr::Subscript(ExprSubscript {
|
||||||
range,
|
range,
|
||||||
value,
|
value,
|
||||||
slice,
|
slice,
|
||||||
ctx,
|
ctx,
|
||||||
}) => Ok(ExprKind::Subscript(ExprSubscript {
|
}) => Ok(Expr::Subscript(ExprSubscript {
|
||||||
value: Foldable::fold(value, folder)?,
|
value: Foldable::fold(value, folder)?,
|
||||||
slice: Foldable::fold(slice, folder)?,
|
slice: Foldable::fold(slice, folder)?,
|
||||||
ctx: Foldable::fold(ctx, folder)?,
|
ctx: Foldable::fold(ctx, folder)?,
|
||||||
range,
|
range,
|
||||||
})),
|
})),
|
||||||
ExprKind::Starred(ExprStarred { range, value, ctx }) => {
|
Expr::Starred(ExprStarred { range, value, ctx }) => Ok(Expr::Starred(ExprStarred {
|
||||||
Ok(ExprKind::Starred(ExprStarred {
|
value: Foldable::fold(value, folder)?,
|
||||||
value: Foldable::fold(value, folder)?,
|
ctx: Foldable::fold(ctx, folder)?,
|
||||||
ctx: Foldable::fold(ctx, folder)?,
|
range,
|
||||||
range,
|
})),
|
||||||
}))
|
Expr::Name(ExprName { range, id, ctx }) => Ok(Expr::Name(ExprName {
|
||||||
}
|
|
||||||
ExprKind::Name(ExprName { range, id, ctx }) => Ok(ExprKind::Name(ExprName {
|
|
||||||
id: Foldable::fold(id, folder)?,
|
id: Foldable::fold(id, folder)?,
|
||||||
ctx: Foldable::fold(ctx, folder)?,
|
ctx: Foldable::fold(ctx, folder)?,
|
||||||
range,
|
range,
|
||||||
})),
|
})),
|
||||||
ExprKind::List(ExprList { range, elts, ctx }) => Ok(ExprKind::List(ExprList {
|
Expr::List(ExprList { range, elts, ctx }) => Ok(Expr::List(ExprList {
|
||||||
elts: Foldable::fold(elts, folder)?,
|
elts: Foldable::fold(elts, folder)?,
|
||||||
ctx: Foldable::fold(ctx, folder)?,
|
ctx: Foldable::fold(ctx, folder)?,
|
||||||
range,
|
range,
|
||||||
})),
|
})),
|
||||||
ExprKind::Tuple(ExprTuple { range, elts, ctx }) => Ok(ExprKind::Tuple(ExprTuple {
|
Expr::Tuple(ExprTuple { range, elts, ctx }) => Ok(Expr::Tuple(ExprTuple {
|
||||||
elts: Foldable::fold(elts, folder)?,
|
elts: Foldable::fold(elts, folder)?,
|
||||||
ctx: Foldable::fold(ctx, folder)?,
|
ctx: Foldable::fold(ctx, folder)?,
|
||||||
range,
|
range,
|
||||||
})),
|
})),
|
||||||
ExprKind::Slice(ExprSlice {
|
Expr::Slice(ExprSlice {
|
||||||
range,
|
range,
|
||||||
lower,
|
lower,
|
||||||
upper,
|
upper,
|
||||||
step,
|
step,
|
||||||
}) => Ok(ExprKind::Slice(ExprSlice {
|
}) => Ok(Expr::Slice(ExprSlice {
|
||||||
lower: Foldable::fold(lower, folder)?,
|
lower: Foldable::fold(lower, folder)?,
|
||||||
upper: Foldable::fold(upper, folder)?,
|
upper: Foldable::fold(upper, folder)?,
|
||||||
step: Foldable::fold(step, folder)?,
|
step: Foldable::fold(step, folder)?,
|
||||||
|
@ -790,19 +778,17 @@ pub fn fold_excepthandler<U, F: Fold<U> + ?Sized>(
|
||||||
node: Excepthandler<U>,
|
node: Excepthandler<U>,
|
||||||
) -> Result<Excepthandler<F::TargetU>, F::Error> {
|
) -> Result<Excepthandler<F::TargetU>, F::Error> {
|
||||||
fold_attributed(folder, node, |folder, node| match node {
|
fold_attributed(folder, node, |folder, node| match node {
|
||||||
ExcepthandlerKind::ExceptHandler(ExcepthandlerExceptHandler {
|
Excepthandler::ExceptHandler(ExcepthandlerExceptHandler {
|
||||||
range,
|
range,
|
||||||
type_,
|
type_,
|
||||||
name,
|
name,
|
||||||
body,
|
body,
|
||||||
}) => Ok(ExcepthandlerKind::ExceptHandler(
|
}) => Ok(Excepthandler::ExceptHandler(ExcepthandlerExceptHandler {
|
||||||
ExcepthandlerExceptHandler {
|
type_: Foldable::fold(type_, folder)?,
|
||||||
type_: Foldable::fold(type_, folder)?,
|
name: Foldable::fold(name, folder)?,
|
||||||
name: Foldable::fold(name, folder)?,
|
body: Foldable::fold(body, folder)?,
|
||||||
body: Foldable::fold(body, folder)?,
|
range,
|
||||||
range,
|
})),
|
||||||
},
|
|
||||||
)),
|
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
impl<T, U> Foldable<T, U> for Arguments<T> {
|
impl<T, U> Foldable<T, U> for Arguments<T> {
|
||||||
|
@ -979,65 +965,65 @@ pub fn fold_pattern<U, F: Fold<U> + ?Sized>(
|
||||||
node: Pattern<U>,
|
node: Pattern<U>,
|
||||||
) -> Result<Pattern<F::TargetU>, F::Error> {
|
) -> Result<Pattern<F::TargetU>, F::Error> {
|
||||||
fold_attributed(folder, node, |folder, node| match node {
|
fold_attributed(folder, node, |folder, node| match node {
|
||||||
PatternKind::MatchValue(PatternMatchValue { range, value }) => {
|
Pattern::MatchValue(PatternMatchValue { range, value }) => {
|
||||||
Ok(PatternKind::MatchValue(PatternMatchValue {
|
Ok(Pattern::MatchValue(PatternMatchValue {
|
||||||
value: Foldable::fold(value, folder)?,
|
value: Foldable::fold(value, folder)?,
|
||||||
range,
|
range,
|
||||||
}))
|
}))
|
||||||
}
|
}
|
||||||
PatternKind::MatchSingleton(PatternMatchSingleton { range, value }) => {
|
Pattern::MatchSingleton(PatternMatchSingleton { range, value }) => {
|
||||||
Ok(PatternKind::MatchSingleton(PatternMatchSingleton {
|
Ok(Pattern::MatchSingleton(PatternMatchSingleton {
|
||||||
value: Foldable::fold(value, folder)?,
|
value: Foldable::fold(value, folder)?,
|
||||||
range,
|
range,
|
||||||
}))
|
}))
|
||||||
}
|
}
|
||||||
PatternKind::MatchSequence(PatternMatchSequence { range, patterns }) => {
|
Pattern::MatchSequence(PatternMatchSequence { range, patterns }) => {
|
||||||
Ok(PatternKind::MatchSequence(PatternMatchSequence {
|
Ok(Pattern::MatchSequence(PatternMatchSequence {
|
||||||
patterns: Foldable::fold(patterns, folder)?,
|
patterns: Foldable::fold(patterns, folder)?,
|
||||||
range,
|
range,
|
||||||
}))
|
}))
|
||||||
}
|
}
|
||||||
PatternKind::MatchMapping(PatternMatchMapping {
|
Pattern::MatchMapping(PatternMatchMapping {
|
||||||
range,
|
range,
|
||||||
keys,
|
keys,
|
||||||
patterns,
|
patterns,
|
||||||
rest,
|
rest,
|
||||||
}) => Ok(PatternKind::MatchMapping(PatternMatchMapping {
|
}) => Ok(Pattern::MatchMapping(PatternMatchMapping {
|
||||||
keys: Foldable::fold(keys, folder)?,
|
keys: Foldable::fold(keys, folder)?,
|
||||||
patterns: Foldable::fold(patterns, folder)?,
|
patterns: Foldable::fold(patterns, folder)?,
|
||||||
rest: Foldable::fold(rest, folder)?,
|
rest: Foldable::fold(rest, folder)?,
|
||||||
range,
|
range,
|
||||||
})),
|
})),
|
||||||
PatternKind::MatchClass(PatternMatchClass {
|
Pattern::MatchClass(PatternMatchClass {
|
||||||
range,
|
range,
|
||||||
cls,
|
cls,
|
||||||
patterns,
|
patterns,
|
||||||
kwd_attrs,
|
kwd_attrs,
|
||||||
kwd_patterns,
|
kwd_patterns,
|
||||||
}) => Ok(PatternKind::MatchClass(PatternMatchClass {
|
}) => Ok(Pattern::MatchClass(PatternMatchClass {
|
||||||
cls: Foldable::fold(cls, folder)?,
|
cls: Foldable::fold(cls, folder)?,
|
||||||
patterns: Foldable::fold(patterns, folder)?,
|
patterns: Foldable::fold(patterns, folder)?,
|
||||||
kwd_attrs: Foldable::fold(kwd_attrs, folder)?,
|
kwd_attrs: Foldable::fold(kwd_attrs, folder)?,
|
||||||
kwd_patterns: Foldable::fold(kwd_patterns, folder)?,
|
kwd_patterns: Foldable::fold(kwd_patterns, folder)?,
|
||||||
range,
|
range,
|
||||||
})),
|
})),
|
||||||
PatternKind::MatchStar(PatternMatchStar { range, name }) => {
|
Pattern::MatchStar(PatternMatchStar { range, name }) => {
|
||||||
Ok(PatternKind::MatchStar(PatternMatchStar {
|
Ok(Pattern::MatchStar(PatternMatchStar {
|
||||||
name: Foldable::fold(name, folder)?,
|
name: Foldable::fold(name, folder)?,
|
||||||
range,
|
range,
|
||||||
}))
|
}))
|
||||||
}
|
}
|
||||||
PatternKind::MatchAs(PatternMatchAs {
|
Pattern::MatchAs(PatternMatchAs {
|
||||||
range,
|
range,
|
||||||
pattern,
|
pattern,
|
||||||
name,
|
name,
|
||||||
}) => Ok(PatternKind::MatchAs(PatternMatchAs {
|
}) => Ok(Pattern::MatchAs(PatternMatchAs {
|
||||||
pattern: Foldable::fold(pattern, folder)?,
|
pattern: Foldable::fold(pattern, folder)?,
|
||||||
name: Foldable::fold(name, folder)?,
|
name: Foldable::fold(name, folder)?,
|
||||||
range,
|
range,
|
||||||
})),
|
})),
|
||||||
PatternKind::MatchOr(PatternMatchOr { range, patterns }) => {
|
Pattern::MatchOr(PatternMatchOr { range, patterns }) => {
|
||||||
Ok(PatternKind::MatchOr(PatternMatchOr {
|
Ok(Pattern::MatchOr(PatternMatchOr {
|
||||||
patterns: Foldable::fold(patterns, folder)?,
|
patterns: Foldable::fold(patterns, folder)?,
|
||||||
range,
|
range,
|
||||||
}))
|
}))
|
||||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -1,95 +1,574 @@
|
||||||
// File automatically generated by ast/asdl_rs.py.
|
// File automatically generated by ast/asdl_rs.py.
|
||||||
|
|
||||||
use rustpython_parser_core::source_code::SourceRange;
|
#[cfg(feature = "more-attributes")]
|
||||||
|
impl Located for Mod {
|
||||||
pub type Located<T> = super::generic::Attributed<T, SourceRange>;
|
fn range(&self) -> SourceRange {
|
||||||
pub type Mod = super::generic::Mod<SourceRange>;
|
self.custom
|
||||||
pub type ModModule = super::generic::ModModule<SourceRange>;
|
}
|
||||||
pub type ModInteractive = super::generic::ModInteractive<SourceRange>;
|
}
|
||||||
pub type ModExpression = super::generic::ModExpression<SourceRange>;
|
pub type Mod = crate::generic::Mod<SourceRange>;
|
||||||
pub type ModFunctionType = super::generic::ModFunctionType<SourceRange>;
|
#[cfg(feature = "more-attributes")]
|
||||||
pub type Stmt = super::generic::Stmt<SourceRange>;
|
impl Located for ModModule {
|
||||||
pub type StmtKind = super::generic::StmtKind<SourceRange>;
|
fn range(&self) -> SourceRange {
|
||||||
pub type StmtFunctionDef = super::generic::StmtFunctionDef<SourceRange>;
|
self.custom
|
||||||
pub type StmtAsyncFunctionDef = super::generic::StmtAsyncFunctionDef<SourceRange>;
|
}
|
||||||
pub type StmtClassDef = super::generic::StmtClassDef<SourceRange>;
|
}
|
||||||
pub type StmtReturn = super::generic::StmtReturn<SourceRange>;
|
pub type ModModule = crate::generic::ModModule<SourceRange>;
|
||||||
pub type StmtDelete = super::generic::StmtDelete<SourceRange>;
|
#[cfg(feature = "more-attributes")]
|
||||||
pub type StmtAssign = super::generic::StmtAssign<SourceRange>;
|
impl Located for ModInteractive {
|
||||||
pub type StmtAugAssign = super::generic::StmtAugAssign<SourceRange>;
|
fn range(&self) -> SourceRange {
|
||||||
pub type StmtAnnAssign = super::generic::StmtAnnAssign<SourceRange>;
|
self.custom
|
||||||
pub type StmtFor = super::generic::StmtFor<SourceRange>;
|
}
|
||||||
pub type StmtAsyncFor = super::generic::StmtAsyncFor<SourceRange>;
|
}
|
||||||
pub type StmtWhile = super::generic::StmtWhile<SourceRange>;
|
pub type ModInteractive = crate::generic::ModInteractive<SourceRange>;
|
||||||
pub type StmtIf = super::generic::StmtIf<SourceRange>;
|
#[cfg(feature = "more-attributes")]
|
||||||
pub type StmtWith = super::generic::StmtWith<SourceRange>;
|
impl Located for ModExpression {
|
||||||
pub type StmtAsyncWith = super::generic::StmtAsyncWith<SourceRange>;
|
fn range(&self) -> SourceRange {
|
||||||
pub type StmtMatch = super::generic::StmtMatch<SourceRange>;
|
self.custom
|
||||||
pub type StmtRaise = super::generic::StmtRaise<SourceRange>;
|
}
|
||||||
pub type StmtTry = super::generic::StmtTry<SourceRange>;
|
}
|
||||||
pub type StmtTryStar = super::generic::StmtTryStar<SourceRange>;
|
pub type ModExpression = crate::generic::ModExpression<SourceRange>;
|
||||||
pub type StmtAssert = super::generic::StmtAssert<SourceRange>;
|
#[cfg(feature = "more-attributes")]
|
||||||
pub type StmtImport = super::generic::StmtImport<SourceRange>;
|
impl Located for ModFunctionType {
|
||||||
pub type StmtImportFrom = super::generic::StmtImportFrom<SourceRange>;
|
fn range(&self) -> SourceRange {
|
||||||
pub type StmtGlobal = super::generic::StmtGlobal;
|
self.custom
|
||||||
pub type StmtNonlocal = super::generic::StmtNonlocal;
|
}
|
||||||
pub type StmtExpr = super::generic::StmtExpr<SourceRange>;
|
}
|
||||||
pub type Expr = super::generic::Expr<SourceRange>;
|
pub type ModFunctionType = crate::generic::ModFunctionType<SourceRange>;
|
||||||
pub type ExprKind = super::generic::ExprKind<SourceRange>;
|
#[cfg(feature = "more-attributes")]
|
||||||
pub type ExprBoolOp = super::generic::ExprBoolOp<SourceRange>;
|
impl Located for Stmt {
|
||||||
pub type ExprNamedExpr = super::generic::ExprNamedExpr<SourceRange>;
|
fn range(&self) -> SourceRange {
|
||||||
pub type ExprBinOp = super::generic::ExprBinOp<SourceRange>;
|
self.custom
|
||||||
pub type ExprUnaryOp = super::generic::ExprUnaryOp<SourceRange>;
|
}
|
||||||
pub type ExprLambda = super::generic::ExprLambda<SourceRange>;
|
}
|
||||||
pub type ExprIfExp = super::generic::ExprIfExp<SourceRange>;
|
pub type Stmt = crate::generic::Stmt<SourceRange>;
|
||||||
pub type ExprDict = super::generic::ExprDict<SourceRange>;
|
#[cfg(feature = "more-attributes")]
|
||||||
pub type ExprSet = super::generic::ExprSet<SourceRange>;
|
impl Located for StmtFunctionDef {
|
||||||
pub type ExprListComp = super::generic::ExprListComp<SourceRange>;
|
fn range(&self) -> SourceRange {
|
||||||
pub type ExprSetComp = super::generic::ExprSetComp<SourceRange>;
|
self.custom
|
||||||
pub type ExprDictComp = super::generic::ExprDictComp<SourceRange>;
|
}
|
||||||
pub type ExprGeneratorExp = super::generic::ExprGeneratorExp<SourceRange>;
|
}
|
||||||
pub type ExprAwait = super::generic::ExprAwait<SourceRange>;
|
pub type StmtFunctionDef = crate::generic::StmtFunctionDef<SourceRange>;
|
||||||
pub type ExprYield = super::generic::ExprYield<SourceRange>;
|
#[cfg(feature = "more-attributes")]
|
||||||
pub type ExprYieldFrom = super::generic::ExprYieldFrom<SourceRange>;
|
impl Located for StmtAsyncFunctionDef {
|
||||||
pub type ExprCompare = super::generic::ExprCompare<SourceRange>;
|
fn range(&self) -> SourceRange {
|
||||||
pub type ExprCall = super::generic::ExprCall<SourceRange>;
|
self.custom
|
||||||
pub type ExprFormattedValue = super::generic::ExprFormattedValue<SourceRange>;
|
}
|
||||||
pub type ExprJoinedStr = super::generic::ExprJoinedStr<SourceRange>;
|
}
|
||||||
pub type ExprConstant = super::generic::ExprConstant;
|
pub type StmtAsyncFunctionDef = crate::generic::StmtAsyncFunctionDef<SourceRange>;
|
||||||
pub type ExprAttribute = super::generic::ExprAttribute<SourceRange>;
|
#[cfg(feature = "more-attributes")]
|
||||||
pub type ExprSubscript = super::generic::ExprSubscript<SourceRange>;
|
impl Located for StmtClassDef {
|
||||||
pub type ExprStarred = super::generic::ExprStarred<SourceRange>;
|
fn range(&self) -> SourceRange {
|
||||||
pub type ExprName = super::generic::ExprName;
|
self.custom
|
||||||
pub type ExprList = super::generic::ExprList<SourceRange>;
|
}
|
||||||
pub type ExprTuple = super::generic::ExprTuple<SourceRange>;
|
}
|
||||||
pub type ExprSlice = super::generic::ExprSlice<SourceRange>;
|
pub type StmtClassDef = crate::generic::StmtClassDef<SourceRange>;
|
||||||
pub type ExprContext = super::generic::ExprContext;
|
#[cfg(feature = "more-attributes")]
|
||||||
pub type Boolop = super::generic::Boolop;
|
impl Located for StmtReturn {
|
||||||
pub type Operator = super::generic::Operator;
|
fn range(&self) -> SourceRange {
|
||||||
pub type Unaryop = super::generic::Unaryop;
|
self.custom
|
||||||
pub type Cmpop = super::generic::Cmpop;
|
}
|
||||||
pub type Comprehension = super::generic::Comprehension<SourceRange>;
|
}
|
||||||
pub type Excepthandler = super::generic::Excepthandler<SourceRange>;
|
pub type StmtReturn = crate::generic::StmtReturn<SourceRange>;
|
||||||
pub type ExcepthandlerKind = super::generic::ExcepthandlerKind<SourceRange>;
|
#[cfg(feature = "more-attributes")]
|
||||||
pub type ExcepthandlerExceptHandler = super::generic::ExcepthandlerExceptHandler<SourceRange>;
|
impl Located for StmtDelete {
|
||||||
pub type Arguments = super::generic::Arguments<SourceRange>;
|
fn range(&self) -> SourceRange {
|
||||||
pub type Arg = super::generic::Arg<SourceRange>;
|
self.custom
|
||||||
pub type ArgData = super::generic::ArgData<SourceRange>;
|
}
|
||||||
pub type Keyword = super::generic::Keyword<SourceRange>;
|
}
|
||||||
pub type KeywordData = super::generic::KeywordData<SourceRange>;
|
pub type StmtDelete = crate::generic::StmtDelete<SourceRange>;
|
||||||
pub type Alias = super::generic::Alias<SourceRange>;
|
#[cfg(feature = "more-attributes")]
|
||||||
pub type AliasData = super::generic::AliasData;
|
impl Located for StmtAssign {
|
||||||
pub type Withitem = super::generic::Withitem<SourceRange>;
|
fn range(&self) -> SourceRange {
|
||||||
pub type MatchCase = super::generic::MatchCase<SourceRange>;
|
self.custom
|
||||||
pub type Pattern = super::generic::Pattern<SourceRange>;
|
}
|
||||||
pub type PatternKind = super::generic::PatternKind<SourceRange>;
|
}
|
||||||
pub type PatternMatchValue = super::generic::PatternMatchValue<SourceRange>;
|
pub type StmtAssign = crate::generic::StmtAssign<SourceRange>;
|
||||||
pub type PatternMatchSingleton = super::generic::PatternMatchSingleton;
|
#[cfg(feature = "more-attributes")]
|
||||||
pub type PatternMatchSequence = super::generic::PatternMatchSequence<SourceRange>;
|
impl Located for StmtAugAssign {
|
||||||
pub type PatternMatchMapping = super::generic::PatternMatchMapping<SourceRange>;
|
fn range(&self) -> SourceRange {
|
||||||
pub type PatternMatchClass = super::generic::PatternMatchClass<SourceRange>;
|
self.custom
|
||||||
pub type PatternMatchStar = super::generic::PatternMatchStar;
|
}
|
||||||
pub type PatternMatchAs = super::generic::PatternMatchAs<SourceRange>;
|
}
|
||||||
pub type PatternMatchOr = super::generic::PatternMatchOr<SourceRange>;
|
pub type StmtAugAssign = crate::generic::StmtAugAssign<SourceRange>;
|
||||||
pub type TypeIgnore = super::generic::TypeIgnore;
|
#[cfg(feature = "more-attributes")]
|
||||||
pub type TypeIgnoreTypeIgnore = super::generic::TypeIgnoreTypeIgnore;
|
impl Located for StmtAnnAssign {
|
||||||
|
fn range(&self) -> SourceRange {
|
||||||
|
self.custom
|
||||||
|
}
|
||||||
|
}
|
||||||
|
pub type StmtAnnAssign = crate::generic::StmtAnnAssign<SourceRange>;
|
||||||
|
#[cfg(feature = "more-attributes")]
|
||||||
|
impl Located for StmtFor {
|
||||||
|
fn range(&self) -> SourceRange {
|
||||||
|
self.custom
|
||||||
|
}
|
||||||
|
}
|
||||||
|
pub type StmtFor = crate::generic::StmtFor<SourceRange>;
|
||||||
|
#[cfg(feature = "more-attributes")]
|
||||||
|
impl Located for StmtAsyncFor {
|
||||||
|
fn range(&self) -> SourceRange {
|
||||||
|
self.custom
|
||||||
|
}
|
||||||
|
}
|
||||||
|
pub type StmtAsyncFor = crate::generic::StmtAsyncFor<SourceRange>;
|
||||||
|
#[cfg(feature = "more-attributes")]
|
||||||
|
impl Located for StmtWhile {
|
||||||
|
fn range(&self) -> SourceRange {
|
||||||
|
self.custom
|
||||||
|
}
|
||||||
|
}
|
||||||
|
pub type StmtWhile = crate::generic::StmtWhile<SourceRange>;
|
||||||
|
#[cfg(feature = "more-attributes")]
|
||||||
|
impl Located for StmtIf {
|
||||||
|
fn range(&self) -> SourceRange {
|
||||||
|
self.custom
|
||||||
|
}
|
||||||
|
}
|
||||||
|
pub type StmtIf = crate::generic::StmtIf<SourceRange>;
|
||||||
|
#[cfg(feature = "more-attributes")]
|
||||||
|
impl Located for StmtWith {
|
||||||
|
fn range(&self) -> SourceRange {
|
||||||
|
self.custom
|
||||||
|
}
|
||||||
|
}
|
||||||
|
pub type StmtWith = crate::generic::StmtWith<SourceRange>;
|
||||||
|
#[cfg(feature = "more-attributes")]
|
||||||
|
impl Located for StmtAsyncWith {
|
||||||
|
fn range(&self) -> SourceRange {
|
||||||
|
self.custom
|
||||||
|
}
|
||||||
|
}
|
||||||
|
pub type StmtAsyncWith = crate::generic::StmtAsyncWith<SourceRange>;
|
||||||
|
#[cfg(feature = "more-attributes")]
|
||||||
|
impl Located for StmtMatch {
|
||||||
|
fn range(&self) -> SourceRange {
|
||||||
|
self.custom
|
||||||
|
}
|
||||||
|
}
|
||||||
|
pub type StmtMatch = crate::generic::StmtMatch<SourceRange>;
|
||||||
|
#[cfg(feature = "more-attributes")]
|
||||||
|
impl Located for StmtRaise {
|
||||||
|
fn range(&self) -> SourceRange {
|
||||||
|
self.custom
|
||||||
|
}
|
||||||
|
}
|
||||||
|
pub type StmtRaise = crate::generic::StmtRaise<SourceRange>;
|
||||||
|
#[cfg(feature = "more-attributes")]
|
||||||
|
impl Located for StmtTry {
|
||||||
|
fn range(&self) -> SourceRange {
|
||||||
|
self.custom
|
||||||
|
}
|
||||||
|
}
|
||||||
|
pub type StmtTry = crate::generic::StmtTry<SourceRange>;
|
||||||
|
#[cfg(feature = "more-attributes")]
|
||||||
|
impl Located for StmtTryStar {
|
||||||
|
fn range(&self) -> SourceRange {
|
||||||
|
self.custom
|
||||||
|
}
|
||||||
|
}
|
||||||
|
pub type StmtTryStar = crate::generic::StmtTryStar<SourceRange>;
|
||||||
|
#[cfg(feature = "more-attributes")]
|
||||||
|
impl Located for StmtAssert {
|
||||||
|
fn range(&self) -> SourceRange {
|
||||||
|
self.custom
|
||||||
|
}
|
||||||
|
}
|
||||||
|
pub type StmtAssert = crate::generic::StmtAssert<SourceRange>;
|
||||||
|
#[cfg(feature = "more-attributes")]
|
||||||
|
impl Located for StmtImport {
|
||||||
|
fn range(&self) -> SourceRange {
|
||||||
|
self.custom
|
||||||
|
}
|
||||||
|
}
|
||||||
|
pub type StmtImport = crate::generic::StmtImport<SourceRange>;
|
||||||
|
#[cfg(feature = "more-attributes")]
|
||||||
|
impl Located for StmtImportFrom {
|
||||||
|
fn range(&self) -> SourceRange {
|
||||||
|
self.custom
|
||||||
|
}
|
||||||
|
}
|
||||||
|
pub type StmtImportFrom = crate::generic::StmtImportFrom<SourceRange>;
|
||||||
|
#[cfg(feature = "more-attributes")]
|
||||||
|
impl Located for StmtGlobal {
|
||||||
|
fn range(&self) -> SourceRange {
|
||||||
|
self.custom
|
||||||
|
}
|
||||||
|
}
|
||||||
|
pub type StmtGlobal = crate::generic::StmtGlobal<SourceRange>;
|
||||||
|
#[cfg(feature = "more-attributes")]
|
||||||
|
impl Located for StmtNonlocal {
|
||||||
|
fn range(&self) -> SourceRange {
|
||||||
|
self.custom
|
||||||
|
}
|
||||||
|
}
|
||||||
|
pub type StmtNonlocal = crate::generic::StmtNonlocal<SourceRange>;
|
||||||
|
#[cfg(feature = "more-attributes")]
|
||||||
|
impl Located for StmtExpr {
|
||||||
|
fn range(&self) -> SourceRange {
|
||||||
|
self.custom
|
||||||
|
}
|
||||||
|
}
|
||||||
|
pub type StmtExpr = crate::generic::StmtExpr<SourceRange>;
|
||||||
|
#[cfg(feature = "more-attributes")]
|
||||||
|
impl Located for StmtPass {
|
||||||
|
fn range(&self) -> SourceRange {
|
||||||
|
self.custom
|
||||||
|
}
|
||||||
|
}
|
||||||
|
pub type StmtPass = crate::generic::StmtPass<SourceRange>;
|
||||||
|
#[cfg(feature = "more-attributes")]
|
||||||
|
impl Located for StmtBreak {
|
||||||
|
fn range(&self) -> SourceRange {
|
||||||
|
self.custom
|
||||||
|
}
|
||||||
|
}
|
||||||
|
pub type StmtBreak = crate::generic::StmtBreak<SourceRange>;
|
||||||
|
#[cfg(feature = "more-attributes")]
|
||||||
|
impl Located for StmtContinue {
|
||||||
|
fn range(&self) -> SourceRange {
|
||||||
|
self.custom
|
||||||
|
}
|
||||||
|
}
|
||||||
|
pub type StmtContinue = crate::generic::StmtContinue<SourceRange>;
|
||||||
|
#[cfg(feature = "more-attributes")]
|
||||||
|
impl Located for Expr {
|
||||||
|
fn range(&self) -> SourceRange {
|
||||||
|
self.custom
|
||||||
|
}
|
||||||
|
}
|
||||||
|
pub type Expr = crate::generic::Expr<SourceRange>;
|
||||||
|
#[cfg(feature = "more-attributes")]
|
||||||
|
impl Located for ExprBoolOp {
|
||||||
|
fn range(&self) -> SourceRange {
|
||||||
|
self.custom
|
||||||
|
}
|
||||||
|
}
|
||||||
|
pub type ExprBoolOp = crate::generic::ExprBoolOp<SourceRange>;
|
||||||
|
#[cfg(feature = "more-attributes")]
|
||||||
|
impl Located for ExprNamedExpr {
|
||||||
|
fn range(&self) -> SourceRange {
|
||||||
|
self.custom
|
||||||
|
}
|
||||||
|
}
|
||||||
|
pub type ExprNamedExpr = crate::generic::ExprNamedExpr<SourceRange>;
|
||||||
|
#[cfg(feature = "more-attributes")]
|
||||||
|
impl Located for ExprBinOp {
|
||||||
|
fn range(&self) -> SourceRange {
|
||||||
|
self.custom
|
||||||
|
}
|
||||||
|
}
|
||||||
|
pub type ExprBinOp = crate::generic::ExprBinOp<SourceRange>;
|
||||||
|
#[cfg(feature = "more-attributes")]
|
||||||
|
impl Located for ExprUnaryOp {
|
||||||
|
fn range(&self) -> SourceRange {
|
||||||
|
self.custom
|
||||||
|
}
|
||||||
|
}
|
||||||
|
pub type ExprUnaryOp = crate::generic::ExprUnaryOp<SourceRange>;
|
||||||
|
#[cfg(feature = "more-attributes")]
|
||||||
|
impl Located for ExprLambda {
|
||||||
|
fn range(&self) -> SourceRange {
|
||||||
|
self.custom
|
||||||
|
}
|
||||||
|
}
|
||||||
|
pub type ExprLambda = crate::generic::ExprLambda<SourceRange>;
|
||||||
|
#[cfg(feature = "more-attributes")]
|
||||||
|
impl Located for ExprIfExp {
|
||||||
|
fn range(&self) -> SourceRange {
|
||||||
|
self.custom
|
||||||
|
}
|
||||||
|
}
|
||||||
|
pub type ExprIfExp = crate::generic::ExprIfExp<SourceRange>;
|
||||||
|
#[cfg(feature = "more-attributes")]
|
||||||
|
impl Located for ExprDict {
|
||||||
|
fn range(&self) -> SourceRange {
|
||||||
|
self.custom
|
||||||
|
}
|
||||||
|
}
|
||||||
|
pub type ExprDict = crate::generic::ExprDict<SourceRange>;
|
||||||
|
#[cfg(feature = "more-attributes")]
|
||||||
|
impl Located for ExprSet {
|
||||||
|
fn range(&self) -> SourceRange {
|
||||||
|
self.custom
|
||||||
|
}
|
||||||
|
}
|
||||||
|
pub type ExprSet = crate::generic::ExprSet<SourceRange>;
|
||||||
|
#[cfg(feature = "more-attributes")]
|
||||||
|
impl Located for ExprListComp {
|
||||||
|
fn range(&self) -> SourceRange {
|
||||||
|
self.custom
|
||||||
|
}
|
||||||
|
}
|
||||||
|
pub type ExprListComp = crate::generic::ExprListComp<SourceRange>;
|
||||||
|
#[cfg(feature = "more-attributes")]
|
||||||
|
impl Located for ExprSetComp {
|
||||||
|
fn range(&self) -> SourceRange {
|
||||||
|
self.custom
|
||||||
|
}
|
||||||
|
}
|
||||||
|
pub type ExprSetComp = crate::generic::ExprSetComp<SourceRange>;
|
||||||
|
#[cfg(feature = "more-attributes")]
|
||||||
|
impl Located for ExprDictComp {
|
||||||
|
fn range(&self) -> SourceRange {
|
||||||
|
self.custom
|
||||||
|
}
|
||||||
|
}
|
||||||
|
pub type ExprDictComp = crate::generic::ExprDictComp<SourceRange>;
|
||||||
|
#[cfg(feature = "more-attributes")]
|
||||||
|
impl Located for ExprGeneratorExp {
|
||||||
|
fn range(&self) -> SourceRange {
|
||||||
|
self.custom
|
||||||
|
}
|
||||||
|
}
|
||||||
|
pub type ExprGeneratorExp = crate::generic::ExprGeneratorExp<SourceRange>;
|
||||||
|
#[cfg(feature = "more-attributes")]
|
||||||
|
impl Located for ExprAwait {
|
||||||
|
fn range(&self) -> SourceRange {
|
||||||
|
self.custom
|
||||||
|
}
|
||||||
|
}
|
||||||
|
pub type ExprAwait = crate::generic::ExprAwait<SourceRange>;
|
||||||
|
#[cfg(feature = "more-attributes")]
|
||||||
|
impl Located for ExprYield {
|
||||||
|
fn range(&self) -> SourceRange {
|
||||||
|
self.custom
|
||||||
|
}
|
||||||
|
}
|
||||||
|
pub type ExprYield = crate::generic::ExprYield<SourceRange>;
|
||||||
|
#[cfg(feature = "more-attributes")]
|
||||||
|
impl Located for ExprYieldFrom {
|
||||||
|
fn range(&self) -> SourceRange {
|
||||||
|
self.custom
|
||||||
|
}
|
||||||
|
}
|
||||||
|
pub type ExprYieldFrom = crate::generic::ExprYieldFrom<SourceRange>;
|
||||||
|
#[cfg(feature = "more-attributes")]
|
||||||
|
impl Located for ExprCompare {
|
||||||
|
fn range(&self) -> SourceRange {
|
||||||
|
self.custom
|
||||||
|
}
|
||||||
|
}
|
||||||
|
pub type ExprCompare = crate::generic::ExprCompare<SourceRange>;
|
||||||
|
#[cfg(feature = "more-attributes")]
|
||||||
|
impl Located for ExprCall {
|
||||||
|
fn range(&self) -> SourceRange {
|
||||||
|
self.custom
|
||||||
|
}
|
||||||
|
}
|
||||||
|
pub type ExprCall = crate::generic::ExprCall<SourceRange>;
|
||||||
|
#[cfg(feature = "more-attributes")]
|
||||||
|
impl Located for ExprFormattedValue {
|
||||||
|
fn range(&self) -> SourceRange {
|
||||||
|
self.custom
|
||||||
|
}
|
||||||
|
}
|
||||||
|
pub type ExprFormattedValue = crate::generic::ExprFormattedValue<SourceRange>;
|
||||||
|
#[cfg(feature = "more-attributes")]
|
||||||
|
impl Located for ExprJoinedStr {
|
||||||
|
fn range(&self) -> SourceRange {
|
||||||
|
self.custom
|
||||||
|
}
|
||||||
|
}
|
||||||
|
pub type ExprJoinedStr = crate::generic::ExprJoinedStr<SourceRange>;
|
||||||
|
#[cfg(feature = "more-attributes")]
|
||||||
|
impl Located for ExprConstant {
|
||||||
|
fn range(&self) -> SourceRange {
|
||||||
|
self.custom
|
||||||
|
}
|
||||||
|
}
|
||||||
|
pub type ExprConstant = crate::generic::ExprConstant<SourceRange>;
|
||||||
|
#[cfg(feature = "more-attributes")]
|
||||||
|
impl Located for ExprAttribute {
|
||||||
|
fn range(&self) -> SourceRange {
|
||||||
|
self.custom
|
||||||
|
}
|
||||||
|
}
|
||||||
|
pub type ExprAttribute = crate::generic::ExprAttribute<SourceRange>;
|
||||||
|
#[cfg(feature = "more-attributes")]
|
||||||
|
impl Located for ExprSubscript {
|
||||||
|
fn range(&self) -> SourceRange {
|
||||||
|
self.custom
|
||||||
|
}
|
||||||
|
}
|
||||||
|
pub type ExprSubscript = crate::generic::ExprSubscript<SourceRange>;
|
||||||
|
#[cfg(feature = "more-attributes")]
|
||||||
|
impl Located for ExprStarred {
|
||||||
|
fn range(&self) -> SourceRange {
|
||||||
|
self.custom
|
||||||
|
}
|
||||||
|
}
|
||||||
|
pub type ExprStarred = crate::generic::ExprStarred<SourceRange>;
|
||||||
|
#[cfg(feature = "more-attributes")]
|
||||||
|
impl Located for ExprName {
|
||||||
|
fn range(&self) -> SourceRange {
|
||||||
|
self.custom
|
||||||
|
}
|
||||||
|
}
|
||||||
|
pub type ExprName = crate::generic::ExprName<SourceRange>;
|
||||||
|
#[cfg(feature = "more-attributes")]
|
||||||
|
impl Located for ExprList {
|
||||||
|
fn range(&self) -> SourceRange {
|
||||||
|
self.custom
|
||||||
|
}
|
||||||
|
}
|
||||||
|
pub type ExprList = crate::generic::ExprList<SourceRange>;
|
||||||
|
#[cfg(feature = "more-attributes")]
|
||||||
|
impl Located for ExprTuple {
|
||||||
|
fn range(&self) -> SourceRange {
|
||||||
|
self.custom
|
||||||
|
}
|
||||||
|
}
|
||||||
|
pub type ExprTuple = crate::generic::ExprTuple<SourceRange>;
|
||||||
|
#[cfg(feature = "more-attributes")]
|
||||||
|
impl Located for ExprSlice {
|
||||||
|
fn range(&self) -> SourceRange {
|
||||||
|
self.custom
|
||||||
|
}
|
||||||
|
}
|
||||||
|
pub type ExprSlice = crate::generic::ExprSlice<SourceRange>;
|
||||||
|
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;
|
||||||
|
#[cfg(feature = "more-attributes")]
|
||||||
|
impl Located for Comprehension {
|
||||||
|
fn range(&self) -> SourceRange {
|
||||||
|
self.custom
|
||||||
|
}
|
||||||
|
}
|
||||||
|
pub type Comprehension = crate::generic::Comprehension<SourceRange>;
|
||||||
|
#[cfg(feature = "more-attributes")]
|
||||||
|
impl Located for Excepthandler {
|
||||||
|
fn range(&self) -> SourceRange {
|
||||||
|
self.custom
|
||||||
|
}
|
||||||
|
}
|
||||||
|
pub type Excepthandler = crate::generic::Excepthandler<SourceRange>;
|
||||||
|
#[cfg(feature = "more-attributes")]
|
||||||
|
impl Located for ExcepthandlerExceptHandler {
|
||||||
|
fn range(&self) -> SourceRange {
|
||||||
|
self.custom
|
||||||
|
}
|
||||||
|
}
|
||||||
|
pub type ExcepthandlerExceptHandler = crate::generic::ExcepthandlerExceptHandler<SourceRange>;
|
||||||
|
#[cfg(feature = "more-attributes")]
|
||||||
|
impl Located for Arguments {
|
||||||
|
fn range(&self) -> SourceRange {
|
||||||
|
self.custom
|
||||||
|
}
|
||||||
|
}
|
||||||
|
pub type Arguments = crate::generic::Arguments<SourceRange>;
|
||||||
|
#[cfg(feature = "more-attributes")]
|
||||||
|
impl Located for Arg {
|
||||||
|
fn range(&self) -> SourceRange {
|
||||||
|
self.custom
|
||||||
|
}
|
||||||
|
}
|
||||||
|
pub type Arg = crate::generic::Arg<SourceRange>;
|
||||||
|
#[cfg(feature = "more-attributes")]
|
||||||
|
impl Located for Keyword {
|
||||||
|
fn range(&self) -> SourceRange {
|
||||||
|
self.custom
|
||||||
|
}
|
||||||
|
}
|
||||||
|
pub type Keyword = crate::generic::Keyword<SourceRange>;
|
||||||
|
#[cfg(feature = "more-attributes")]
|
||||||
|
impl Located for Alias {
|
||||||
|
fn range(&self) -> SourceRange {
|
||||||
|
self.custom
|
||||||
|
}
|
||||||
|
}
|
||||||
|
pub type Alias = crate::generic::Alias<SourceRange>;
|
||||||
|
#[cfg(feature = "more-attributes")]
|
||||||
|
impl Located for Withitem {
|
||||||
|
fn range(&self) -> SourceRange {
|
||||||
|
self.custom
|
||||||
|
}
|
||||||
|
}
|
||||||
|
pub type Withitem = crate::generic::Withitem<SourceRange>;
|
||||||
|
#[cfg(feature = "more-attributes")]
|
||||||
|
impl Located for MatchCase {
|
||||||
|
fn range(&self) -> SourceRange {
|
||||||
|
self.custom
|
||||||
|
}
|
||||||
|
}
|
||||||
|
pub type MatchCase = crate::generic::MatchCase<SourceRange>;
|
||||||
|
#[cfg(feature = "more-attributes")]
|
||||||
|
impl Located for Pattern {
|
||||||
|
fn range(&self) -> SourceRange {
|
||||||
|
self.custom
|
||||||
|
}
|
||||||
|
}
|
||||||
|
pub type Pattern = crate::generic::Pattern<SourceRange>;
|
||||||
|
#[cfg(feature = "more-attributes")]
|
||||||
|
impl Located for PatternMatchValue {
|
||||||
|
fn range(&self) -> SourceRange {
|
||||||
|
self.custom
|
||||||
|
}
|
||||||
|
}
|
||||||
|
pub type PatternMatchValue = crate::generic::PatternMatchValue<SourceRange>;
|
||||||
|
#[cfg(feature = "more-attributes")]
|
||||||
|
impl Located for PatternMatchSingleton {
|
||||||
|
fn range(&self) -> SourceRange {
|
||||||
|
self.custom
|
||||||
|
}
|
||||||
|
}
|
||||||
|
pub type PatternMatchSingleton = crate::generic::PatternMatchSingleton<SourceRange>;
|
||||||
|
#[cfg(feature = "more-attributes")]
|
||||||
|
impl Located for PatternMatchSequence {
|
||||||
|
fn range(&self) -> SourceRange {
|
||||||
|
self.custom
|
||||||
|
}
|
||||||
|
}
|
||||||
|
pub type PatternMatchSequence = crate::generic::PatternMatchSequence<SourceRange>;
|
||||||
|
#[cfg(feature = "more-attributes")]
|
||||||
|
impl Located for PatternMatchMapping {
|
||||||
|
fn range(&self) -> SourceRange {
|
||||||
|
self.custom
|
||||||
|
}
|
||||||
|
}
|
||||||
|
pub type PatternMatchMapping = crate::generic::PatternMatchMapping<SourceRange>;
|
||||||
|
#[cfg(feature = "more-attributes")]
|
||||||
|
impl Located for PatternMatchClass {
|
||||||
|
fn range(&self) -> SourceRange {
|
||||||
|
self.custom
|
||||||
|
}
|
||||||
|
}
|
||||||
|
pub type PatternMatchClass = crate::generic::PatternMatchClass<SourceRange>;
|
||||||
|
#[cfg(feature = "more-attributes")]
|
||||||
|
impl Located for PatternMatchStar {
|
||||||
|
fn range(&self) -> SourceRange {
|
||||||
|
self.custom
|
||||||
|
}
|
||||||
|
}
|
||||||
|
pub type PatternMatchStar = crate::generic::PatternMatchStar<SourceRange>;
|
||||||
|
#[cfg(feature = "more-attributes")]
|
||||||
|
impl Located for PatternMatchAs {
|
||||||
|
fn range(&self) -> SourceRange {
|
||||||
|
self.custom
|
||||||
|
}
|
||||||
|
}
|
||||||
|
pub type PatternMatchAs = crate::generic::PatternMatchAs<SourceRange>;
|
||||||
|
#[cfg(feature = "more-attributes")]
|
||||||
|
impl Located for PatternMatchOr {
|
||||||
|
fn range(&self) -> SourceRange {
|
||||||
|
self.custom
|
||||||
|
}
|
||||||
|
}
|
||||||
|
pub type PatternMatchOr = crate::generic::PatternMatchOr<SourceRange>;
|
||||||
|
#[cfg(feature = "more-attributes")]
|
||||||
|
impl Located for TypeIgnore {
|
||||||
|
fn range(&self) -> SourceRange {
|
||||||
|
self.custom
|
||||||
|
}
|
||||||
|
}
|
||||||
|
pub type TypeIgnore = crate::generic::TypeIgnore<SourceRange>;
|
||||||
|
#[cfg(feature = "more-attributes")]
|
||||||
|
impl Located for TypeIgnoreTypeIgnore {
|
||||||
|
fn range(&self) -> SourceRange {
|
||||||
|
self.custom
|
||||||
|
}
|
||||||
|
}
|
||||||
|
pub type TypeIgnoreTypeIgnore = crate::generic::TypeIgnoreTypeIgnore<SourceRange>;
|
||||||
|
|
574
ast/src/gen/ranged.rs
Normal file
574
ast/src/gen/ranged.rs
Normal file
|
@ -0,0 +1,574 @@
|
||||||
|
// File automatically generated by ast/asdl_rs.py.
|
||||||
|
|
||||||
|
#[cfg(feature = "more-attributes")]
|
||||||
|
impl Ranged for Mod {
|
||||||
|
fn range(&self) -> TextRange {
|
||||||
|
self.custom
|
||||||
|
}
|
||||||
|
}
|
||||||
|
pub type Mod = crate::generic::Mod<TextRange>;
|
||||||
|
#[cfg(feature = "more-attributes")]
|
||||||
|
impl Ranged for ModModule {
|
||||||
|
fn range(&self) -> TextRange {
|
||||||
|
self.custom
|
||||||
|
}
|
||||||
|
}
|
||||||
|
pub type ModModule = crate::generic::ModModule<TextRange>;
|
||||||
|
#[cfg(feature = "more-attributes")]
|
||||||
|
impl Ranged for ModInteractive {
|
||||||
|
fn range(&self) -> TextRange {
|
||||||
|
self.custom
|
||||||
|
}
|
||||||
|
}
|
||||||
|
pub type ModInteractive = crate::generic::ModInteractive<TextRange>;
|
||||||
|
#[cfg(feature = "more-attributes")]
|
||||||
|
impl Ranged for ModExpression {
|
||||||
|
fn range(&self) -> TextRange {
|
||||||
|
self.custom
|
||||||
|
}
|
||||||
|
}
|
||||||
|
pub type ModExpression = crate::generic::ModExpression<TextRange>;
|
||||||
|
#[cfg(feature = "more-attributes")]
|
||||||
|
impl Ranged for ModFunctionType {
|
||||||
|
fn range(&self) -> TextRange {
|
||||||
|
self.custom
|
||||||
|
}
|
||||||
|
}
|
||||||
|
pub type ModFunctionType = crate::generic::ModFunctionType<TextRange>;
|
||||||
|
#[cfg(feature = "more-attributes")]
|
||||||
|
impl Ranged for Stmt {
|
||||||
|
fn range(&self) -> TextRange {
|
||||||
|
self.custom
|
||||||
|
}
|
||||||
|
}
|
||||||
|
pub type Stmt = crate::generic::Stmt<TextRange>;
|
||||||
|
#[cfg(feature = "more-attributes")]
|
||||||
|
impl Ranged for StmtFunctionDef {
|
||||||
|
fn range(&self) -> TextRange {
|
||||||
|
self.custom
|
||||||
|
}
|
||||||
|
}
|
||||||
|
pub type StmtFunctionDef = crate::generic::StmtFunctionDef<TextRange>;
|
||||||
|
#[cfg(feature = "more-attributes")]
|
||||||
|
impl Ranged for StmtAsyncFunctionDef {
|
||||||
|
fn range(&self) -> TextRange {
|
||||||
|
self.custom
|
||||||
|
}
|
||||||
|
}
|
||||||
|
pub type StmtAsyncFunctionDef = crate::generic::StmtAsyncFunctionDef<TextRange>;
|
||||||
|
#[cfg(feature = "more-attributes")]
|
||||||
|
impl Ranged for StmtClassDef {
|
||||||
|
fn range(&self) -> TextRange {
|
||||||
|
self.custom
|
||||||
|
}
|
||||||
|
}
|
||||||
|
pub type StmtClassDef = crate::generic::StmtClassDef<TextRange>;
|
||||||
|
#[cfg(feature = "more-attributes")]
|
||||||
|
impl Ranged for StmtReturn {
|
||||||
|
fn range(&self) -> TextRange {
|
||||||
|
self.custom
|
||||||
|
}
|
||||||
|
}
|
||||||
|
pub type StmtReturn = crate::generic::StmtReturn<TextRange>;
|
||||||
|
#[cfg(feature = "more-attributes")]
|
||||||
|
impl Ranged for StmtDelete {
|
||||||
|
fn range(&self) -> TextRange {
|
||||||
|
self.custom
|
||||||
|
}
|
||||||
|
}
|
||||||
|
pub type StmtDelete = crate::generic::StmtDelete<TextRange>;
|
||||||
|
#[cfg(feature = "more-attributes")]
|
||||||
|
impl Ranged for StmtAssign {
|
||||||
|
fn range(&self) -> TextRange {
|
||||||
|
self.custom
|
||||||
|
}
|
||||||
|
}
|
||||||
|
pub type StmtAssign = crate::generic::StmtAssign<TextRange>;
|
||||||
|
#[cfg(feature = "more-attributes")]
|
||||||
|
impl Ranged for StmtAugAssign {
|
||||||
|
fn range(&self) -> TextRange {
|
||||||
|
self.custom
|
||||||
|
}
|
||||||
|
}
|
||||||
|
pub type StmtAugAssign = crate::generic::StmtAugAssign<TextRange>;
|
||||||
|
#[cfg(feature = "more-attributes")]
|
||||||
|
impl Ranged for StmtAnnAssign {
|
||||||
|
fn range(&self) -> TextRange {
|
||||||
|
self.custom
|
||||||
|
}
|
||||||
|
}
|
||||||
|
pub type StmtAnnAssign = crate::generic::StmtAnnAssign<TextRange>;
|
||||||
|
#[cfg(feature = "more-attributes")]
|
||||||
|
impl Ranged for StmtFor {
|
||||||
|
fn range(&self) -> TextRange {
|
||||||
|
self.custom
|
||||||
|
}
|
||||||
|
}
|
||||||
|
pub type StmtFor = crate::generic::StmtFor<TextRange>;
|
||||||
|
#[cfg(feature = "more-attributes")]
|
||||||
|
impl Ranged for StmtAsyncFor {
|
||||||
|
fn range(&self) -> TextRange {
|
||||||
|
self.custom
|
||||||
|
}
|
||||||
|
}
|
||||||
|
pub type StmtAsyncFor = crate::generic::StmtAsyncFor<TextRange>;
|
||||||
|
#[cfg(feature = "more-attributes")]
|
||||||
|
impl Ranged for StmtWhile {
|
||||||
|
fn range(&self) -> TextRange {
|
||||||
|
self.custom
|
||||||
|
}
|
||||||
|
}
|
||||||
|
pub type StmtWhile = crate::generic::StmtWhile<TextRange>;
|
||||||
|
#[cfg(feature = "more-attributes")]
|
||||||
|
impl Ranged for StmtIf {
|
||||||
|
fn range(&self) -> TextRange {
|
||||||
|
self.custom
|
||||||
|
}
|
||||||
|
}
|
||||||
|
pub type StmtIf = crate::generic::StmtIf<TextRange>;
|
||||||
|
#[cfg(feature = "more-attributes")]
|
||||||
|
impl Ranged for StmtWith {
|
||||||
|
fn range(&self) -> TextRange {
|
||||||
|
self.custom
|
||||||
|
}
|
||||||
|
}
|
||||||
|
pub type StmtWith = crate::generic::StmtWith<TextRange>;
|
||||||
|
#[cfg(feature = "more-attributes")]
|
||||||
|
impl Ranged for StmtAsyncWith {
|
||||||
|
fn range(&self) -> TextRange {
|
||||||
|
self.custom
|
||||||
|
}
|
||||||
|
}
|
||||||
|
pub type StmtAsyncWith = crate::generic::StmtAsyncWith<TextRange>;
|
||||||
|
#[cfg(feature = "more-attributes")]
|
||||||
|
impl Ranged for StmtMatch {
|
||||||
|
fn range(&self) -> TextRange {
|
||||||
|
self.custom
|
||||||
|
}
|
||||||
|
}
|
||||||
|
pub type StmtMatch = crate::generic::StmtMatch<TextRange>;
|
||||||
|
#[cfg(feature = "more-attributes")]
|
||||||
|
impl Ranged for StmtRaise {
|
||||||
|
fn range(&self) -> TextRange {
|
||||||
|
self.custom
|
||||||
|
}
|
||||||
|
}
|
||||||
|
pub type StmtRaise = crate::generic::StmtRaise<TextRange>;
|
||||||
|
#[cfg(feature = "more-attributes")]
|
||||||
|
impl Ranged for StmtTry {
|
||||||
|
fn range(&self) -> TextRange {
|
||||||
|
self.custom
|
||||||
|
}
|
||||||
|
}
|
||||||
|
pub type StmtTry = crate::generic::StmtTry<TextRange>;
|
||||||
|
#[cfg(feature = "more-attributes")]
|
||||||
|
impl Ranged for StmtTryStar {
|
||||||
|
fn range(&self) -> TextRange {
|
||||||
|
self.custom
|
||||||
|
}
|
||||||
|
}
|
||||||
|
pub type StmtTryStar = crate::generic::StmtTryStar<TextRange>;
|
||||||
|
#[cfg(feature = "more-attributes")]
|
||||||
|
impl Ranged for StmtAssert {
|
||||||
|
fn range(&self) -> TextRange {
|
||||||
|
self.custom
|
||||||
|
}
|
||||||
|
}
|
||||||
|
pub type StmtAssert = crate::generic::StmtAssert<TextRange>;
|
||||||
|
#[cfg(feature = "more-attributes")]
|
||||||
|
impl Ranged for StmtImport {
|
||||||
|
fn range(&self) -> TextRange {
|
||||||
|
self.custom
|
||||||
|
}
|
||||||
|
}
|
||||||
|
pub type StmtImport = crate::generic::StmtImport<TextRange>;
|
||||||
|
#[cfg(feature = "more-attributes")]
|
||||||
|
impl Ranged for StmtImportFrom {
|
||||||
|
fn range(&self) -> TextRange {
|
||||||
|
self.custom
|
||||||
|
}
|
||||||
|
}
|
||||||
|
pub type StmtImportFrom = crate::generic::StmtImportFrom<TextRange>;
|
||||||
|
#[cfg(feature = "more-attributes")]
|
||||||
|
impl Ranged for StmtGlobal {
|
||||||
|
fn range(&self) -> TextRange {
|
||||||
|
self.custom
|
||||||
|
}
|
||||||
|
}
|
||||||
|
pub type StmtGlobal = crate::generic::StmtGlobal<TextRange>;
|
||||||
|
#[cfg(feature = "more-attributes")]
|
||||||
|
impl Ranged for StmtNonlocal {
|
||||||
|
fn range(&self) -> TextRange {
|
||||||
|
self.custom
|
||||||
|
}
|
||||||
|
}
|
||||||
|
pub type StmtNonlocal = crate::generic::StmtNonlocal<TextRange>;
|
||||||
|
#[cfg(feature = "more-attributes")]
|
||||||
|
impl Ranged for StmtExpr {
|
||||||
|
fn range(&self) -> TextRange {
|
||||||
|
self.custom
|
||||||
|
}
|
||||||
|
}
|
||||||
|
pub type StmtExpr = crate::generic::StmtExpr<TextRange>;
|
||||||
|
#[cfg(feature = "more-attributes")]
|
||||||
|
impl Ranged for StmtPass {
|
||||||
|
fn range(&self) -> TextRange {
|
||||||
|
self.custom
|
||||||
|
}
|
||||||
|
}
|
||||||
|
pub type StmtPass = crate::generic::StmtPass<TextRange>;
|
||||||
|
#[cfg(feature = "more-attributes")]
|
||||||
|
impl Ranged for StmtBreak {
|
||||||
|
fn range(&self) -> TextRange {
|
||||||
|
self.custom
|
||||||
|
}
|
||||||
|
}
|
||||||
|
pub type StmtBreak = crate::generic::StmtBreak<TextRange>;
|
||||||
|
#[cfg(feature = "more-attributes")]
|
||||||
|
impl Ranged for StmtContinue {
|
||||||
|
fn range(&self) -> TextRange {
|
||||||
|
self.custom
|
||||||
|
}
|
||||||
|
}
|
||||||
|
pub type StmtContinue = crate::generic::StmtContinue<TextRange>;
|
||||||
|
#[cfg(feature = "more-attributes")]
|
||||||
|
impl Ranged for Expr {
|
||||||
|
fn range(&self) -> TextRange {
|
||||||
|
self.custom
|
||||||
|
}
|
||||||
|
}
|
||||||
|
pub type Expr = crate::generic::Expr<TextRange>;
|
||||||
|
#[cfg(feature = "more-attributes")]
|
||||||
|
impl Ranged for ExprBoolOp {
|
||||||
|
fn range(&self) -> TextRange {
|
||||||
|
self.custom
|
||||||
|
}
|
||||||
|
}
|
||||||
|
pub type ExprBoolOp = crate::generic::ExprBoolOp<TextRange>;
|
||||||
|
#[cfg(feature = "more-attributes")]
|
||||||
|
impl Ranged for ExprNamedExpr {
|
||||||
|
fn range(&self) -> TextRange {
|
||||||
|
self.custom
|
||||||
|
}
|
||||||
|
}
|
||||||
|
pub type ExprNamedExpr = crate::generic::ExprNamedExpr<TextRange>;
|
||||||
|
#[cfg(feature = "more-attributes")]
|
||||||
|
impl Ranged for ExprBinOp {
|
||||||
|
fn range(&self) -> TextRange {
|
||||||
|
self.custom
|
||||||
|
}
|
||||||
|
}
|
||||||
|
pub type ExprBinOp = crate::generic::ExprBinOp<TextRange>;
|
||||||
|
#[cfg(feature = "more-attributes")]
|
||||||
|
impl Ranged for ExprUnaryOp {
|
||||||
|
fn range(&self) -> TextRange {
|
||||||
|
self.custom
|
||||||
|
}
|
||||||
|
}
|
||||||
|
pub type ExprUnaryOp = crate::generic::ExprUnaryOp<TextRange>;
|
||||||
|
#[cfg(feature = "more-attributes")]
|
||||||
|
impl Ranged for ExprLambda {
|
||||||
|
fn range(&self) -> TextRange {
|
||||||
|
self.custom
|
||||||
|
}
|
||||||
|
}
|
||||||
|
pub type ExprLambda = crate::generic::ExprLambda<TextRange>;
|
||||||
|
#[cfg(feature = "more-attributes")]
|
||||||
|
impl Ranged for ExprIfExp {
|
||||||
|
fn range(&self) -> TextRange {
|
||||||
|
self.custom
|
||||||
|
}
|
||||||
|
}
|
||||||
|
pub type ExprIfExp = crate::generic::ExprIfExp<TextRange>;
|
||||||
|
#[cfg(feature = "more-attributes")]
|
||||||
|
impl Ranged for ExprDict {
|
||||||
|
fn range(&self) -> TextRange {
|
||||||
|
self.custom
|
||||||
|
}
|
||||||
|
}
|
||||||
|
pub type ExprDict = crate::generic::ExprDict<TextRange>;
|
||||||
|
#[cfg(feature = "more-attributes")]
|
||||||
|
impl Ranged for ExprSet {
|
||||||
|
fn range(&self) -> TextRange {
|
||||||
|
self.custom
|
||||||
|
}
|
||||||
|
}
|
||||||
|
pub type ExprSet = crate::generic::ExprSet<TextRange>;
|
||||||
|
#[cfg(feature = "more-attributes")]
|
||||||
|
impl Ranged for ExprListComp {
|
||||||
|
fn range(&self) -> TextRange {
|
||||||
|
self.custom
|
||||||
|
}
|
||||||
|
}
|
||||||
|
pub type ExprListComp = crate::generic::ExprListComp<TextRange>;
|
||||||
|
#[cfg(feature = "more-attributes")]
|
||||||
|
impl Ranged for ExprSetComp {
|
||||||
|
fn range(&self) -> TextRange {
|
||||||
|
self.custom
|
||||||
|
}
|
||||||
|
}
|
||||||
|
pub type ExprSetComp = crate::generic::ExprSetComp<TextRange>;
|
||||||
|
#[cfg(feature = "more-attributes")]
|
||||||
|
impl Ranged for ExprDictComp {
|
||||||
|
fn range(&self) -> TextRange {
|
||||||
|
self.custom
|
||||||
|
}
|
||||||
|
}
|
||||||
|
pub type ExprDictComp = crate::generic::ExprDictComp<TextRange>;
|
||||||
|
#[cfg(feature = "more-attributes")]
|
||||||
|
impl Ranged for ExprGeneratorExp {
|
||||||
|
fn range(&self) -> TextRange {
|
||||||
|
self.custom
|
||||||
|
}
|
||||||
|
}
|
||||||
|
pub type ExprGeneratorExp = crate::generic::ExprGeneratorExp<TextRange>;
|
||||||
|
#[cfg(feature = "more-attributes")]
|
||||||
|
impl Ranged for ExprAwait {
|
||||||
|
fn range(&self) -> TextRange {
|
||||||
|
self.custom
|
||||||
|
}
|
||||||
|
}
|
||||||
|
pub type ExprAwait = crate::generic::ExprAwait<TextRange>;
|
||||||
|
#[cfg(feature = "more-attributes")]
|
||||||
|
impl Ranged for ExprYield {
|
||||||
|
fn range(&self) -> TextRange {
|
||||||
|
self.custom
|
||||||
|
}
|
||||||
|
}
|
||||||
|
pub type ExprYield = crate::generic::ExprYield<TextRange>;
|
||||||
|
#[cfg(feature = "more-attributes")]
|
||||||
|
impl Ranged for ExprYieldFrom {
|
||||||
|
fn range(&self) -> TextRange {
|
||||||
|
self.custom
|
||||||
|
}
|
||||||
|
}
|
||||||
|
pub type ExprYieldFrom = crate::generic::ExprYieldFrom<TextRange>;
|
||||||
|
#[cfg(feature = "more-attributes")]
|
||||||
|
impl Ranged for ExprCompare {
|
||||||
|
fn range(&self) -> TextRange {
|
||||||
|
self.custom
|
||||||
|
}
|
||||||
|
}
|
||||||
|
pub type ExprCompare = crate::generic::ExprCompare<TextRange>;
|
||||||
|
#[cfg(feature = "more-attributes")]
|
||||||
|
impl Ranged for ExprCall {
|
||||||
|
fn range(&self) -> TextRange {
|
||||||
|
self.custom
|
||||||
|
}
|
||||||
|
}
|
||||||
|
pub type ExprCall = crate::generic::ExprCall<TextRange>;
|
||||||
|
#[cfg(feature = "more-attributes")]
|
||||||
|
impl Ranged for ExprFormattedValue {
|
||||||
|
fn range(&self) -> TextRange {
|
||||||
|
self.custom
|
||||||
|
}
|
||||||
|
}
|
||||||
|
pub type ExprFormattedValue = crate::generic::ExprFormattedValue<TextRange>;
|
||||||
|
#[cfg(feature = "more-attributes")]
|
||||||
|
impl Ranged for ExprJoinedStr {
|
||||||
|
fn range(&self) -> TextRange {
|
||||||
|
self.custom
|
||||||
|
}
|
||||||
|
}
|
||||||
|
pub type ExprJoinedStr = crate::generic::ExprJoinedStr<TextRange>;
|
||||||
|
#[cfg(feature = "more-attributes")]
|
||||||
|
impl Ranged for ExprConstant {
|
||||||
|
fn range(&self) -> TextRange {
|
||||||
|
self.custom
|
||||||
|
}
|
||||||
|
}
|
||||||
|
pub type ExprConstant = crate::generic::ExprConstant<TextRange>;
|
||||||
|
#[cfg(feature = "more-attributes")]
|
||||||
|
impl Ranged for ExprAttribute {
|
||||||
|
fn range(&self) -> TextRange {
|
||||||
|
self.custom
|
||||||
|
}
|
||||||
|
}
|
||||||
|
pub type ExprAttribute = crate::generic::ExprAttribute<TextRange>;
|
||||||
|
#[cfg(feature = "more-attributes")]
|
||||||
|
impl Ranged for ExprSubscript {
|
||||||
|
fn range(&self) -> TextRange {
|
||||||
|
self.custom
|
||||||
|
}
|
||||||
|
}
|
||||||
|
pub type ExprSubscript = crate::generic::ExprSubscript<TextRange>;
|
||||||
|
#[cfg(feature = "more-attributes")]
|
||||||
|
impl Ranged for ExprStarred {
|
||||||
|
fn range(&self) -> TextRange {
|
||||||
|
self.custom
|
||||||
|
}
|
||||||
|
}
|
||||||
|
pub type ExprStarred = crate::generic::ExprStarred<TextRange>;
|
||||||
|
#[cfg(feature = "more-attributes")]
|
||||||
|
impl Ranged for ExprName {
|
||||||
|
fn range(&self) -> TextRange {
|
||||||
|
self.custom
|
||||||
|
}
|
||||||
|
}
|
||||||
|
pub type ExprName = crate::generic::ExprName<TextRange>;
|
||||||
|
#[cfg(feature = "more-attributes")]
|
||||||
|
impl Ranged for ExprList {
|
||||||
|
fn range(&self) -> TextRange {
|
||||||
|
self.custom
|
||||||
|
}
|
||||||
|
}
|
||||||
|
pub type ExprList = crate::generic::ExprList<TextRange>;
|
||||||
|
#[cfg(feature = "more-attributes")]
|
||||||
|
impl Ranged for ExprTuple {
|
||||||
|
fn range(&self) -> TextRange {
|
||||||
|
self.custom
|
||||||
|
}
|
||||||
|
}
|
||||||
|
pub type ExprTuple = crate::generic::ExprTuple<TextRange>;
|
||||||
|
#[cfg(feature = "more-attributes")]
|
||||||
|
impl Ranged for ExprSlice {
|
||||||
|
fn range(&self) -> TextRange {
|
||||||
|
self.custom
|
||||||
|
}
|
||||||
|
}
|
||||||
|
pub type ExprSlice = crate::generic::ExprSlice<TextRange>;
|
||||||
|
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;
|
||||||
|
#[cfg(feature = "more-attributes")]
|
||||||
|
impl Ranged for Comprehension {
|
||||||
|
fn range(&self) -> TextRange {
|
||||||
|
self.custom
|
||||||
|
}
|
||||||
|
}
|
||||||
|
pub type Comprehension = crate::generic::Comprehension<TextRange>;
|
||||||
|
#[cfg(feature = "more-attributes")]
|
||||||
|
impl Ranged for Excepthandler {
|
||||||
|
fn range(&self) -> TextRange {
|
||||||
|
self.custom
|
||||||
|
}
|
||||||
|
}
|
||||||
|
pub type Excepthandler = crate::generic::Excepthandler<TextRange>;
|
||||||
|
#[cfg(feature = "more-attributes")]
|
||||||
|
impl Ranged for ExcepthandlerExceptHandler {
|
||||||
|
fn range(&self) -> TextRange {
|
||||||
|
self.custom
|
||||||
|
}
|
||||||
|
}
|
||||||
|
pub type ExcepthandlerExceptHandler = crate::generic::ExcepthandlerExceptHandler<TextRange>;
|
||||||
|
#[cfg(feature = "more-attributes")]
|
||||||
|
impl Ranged for Arguments {
|
||||||
|
fn range(&self) -> TextRange {
|
||||||
|
self.custom
|
||||||
|
}
|
||||||
|
}
|
||||||
|
pub type Arguments = crate::generic::Arguments<TextRange>;
|
||||||
|
#[cfg(feature = "more-attributes")]
|
||||||
|
impl Ranged for Arg {
|
||||||
|
fn range(&self) -> TextRange {
|
||||||
|
self.custom
|
||||||
|
}
|
||||||
|
}
|
||||||
|
pub type Arg = crate::generic::Arg<TextRange>;
|
||||||
|
#[cfg(feature = "more-attributes")]
|
||||||
|
impl Ranged for Keyword {
|
||||||
|
fn range(&self) -> TextRange {
|
||||||
|
self.custom
|
||||||
|
}
|
||||||
|
}
|
||||||
|
pub type Keyword = crate::generic::Keyword<TextRange>;
|
||||||
|
#[cfg(feature = "more-attributes")]
|
||||||
|
impl Ranged for Alias {
|
||||||
|
fn range(&self) -> TextRange {
|
||||||
|
self.custom
|
||||||
|
}
|
||||||
|
}
|
||||||
|
pub type Alias = crate::generic::Alias<TextRange>;
|
||||||
|
#[cfg(feature = "more-attributes")]
|
||||||
|
impl Ranged for Withitem {
|
||||||
|
fn range(&self) -> TextRange {
|
||||||
|
self.custom
|
||||||
|
}
|
||||||
|
}
|
||||||
|
pub type Withitem = crate::generic::Withitem<TextRange>;
|
||||||
|
#[cfg(feature = "more-attributes")]
|
||||||
|
impl Ranged for MatchCase {
|
||||||
|
fn range(&self) -> TextRange {
|
||||||
|
self.custom
|
||||||
|
}
|
||||||
|
}
|
||||||
|
pub type MatchCase = crate::generic::MatchCase<TextRange>;
|
||||||
|
#[cfg(feature = "more-attributes")]
|
||||||
|
impl Ranged for Pattern {
|
||||||
|
fn range(&self) -> TextRange {
|
||||||
|
self.custom
|
||||||
|
}
|
||||||
|
}
|
||||||
|
pub type Pattern = crate::generic::Pattern<TextRange>;
|
||||||
|
#[cfg(feature = "more-attributes")]
|
||||||
|
impl Ranged for PatternMatchValue {
|
||||||
|
fn range(&self) -> TextRange {
|
||||||
|
self.custom
|
||||||
|
}
|
||||||
|
}
|
||||||
|
pub type PatternMatchValue = crate::generic::PatternMatchValue<TextRange>;
|
||||||
|
#[cfg(feature = "more-attributes")]
|
||||||
|
impl Ranged for PatternMatchSingleton {
|
||||||
|
fn range(&self) -> TextRange {
|
||||||
|
self.custom
|
||||||
|
}
|
||||||
|
}
|
||||||
|
pub type PatternMatchSingleton = crate::generic::PatternMatchSingleton<TextRange>;
|
||||||
|
#[cfg(feature = "more-attributes")]
|
||||||
|
impl Ranged for PatternMatchSequence {
|
||||||
|
fn range(&self) -> TextRange {
|
||||||
|
self.custom
|
||||||
|
}
|
||||||
|
}
|
||||||
|
pub type PatternMatchSequence = crate::generic::PatternMatchSequence<TextRange>;
|
||||||
|
#[cfg(feature = "more-attributes")]
|
||||||
|
impl Ranged for PatternMatchMapping {
|
||||||
|
fn range(&self) -> TextRange {
|
||||||
|
self.custom
|
||||||
|
}
|
||||||
|
}
|
||||||
|
pub type PatternMatchMapping = crate::generic::PatternMatchMapping<TextRange>;
|
||||||
|
#[cfg(feature = "more-attributes")]
|
||||||
|
impl Ranged for PatternMatchClass {
|
||||||
|
fn range(&self) -> TextRange {
|
||||||
|
self.custom
|
||||||
|
}
|
||||||
|
}
|
||||||
|
pub type PatternMatchClass = crate::generic::PatternMatchClass<TextRange>;
|
||||||
|
#[cfg(feature = "more-attributes")]
|
||||||
|
impl Ranged for PatternMatchStar {
|
||||||
|
fn range(&self) -> TextRange {
|
||||||
|
self.custom
|
||||||
|
}
|
||||||
|
}
|
||||||
|
pub type PatternMatchStar = crate::generic::PatternMatchStar<TextRange>;
|
||||||
|
#[cfg(feature = "more-attributes")]
|
||||||
|
impl Ranged for PatternMatchAs {
|
||||||
|
fn range(&self) -> TextRange {
|
||||||
|
self.custom
|
||||||
|
}
|
||||||
|
}
|
||||||
|
pub type PatternMatchAs = crate::generic::PatternMatchAs<TextRange>;
|
||||||
|
#[cfg(feature = "more-attributes")]
|
||||||
|
impl Ranged for PatternMatchOr {
|
||||||
|
fn range(&self) -> TextRange {
|
||||||
|
self.custom
|
||||||
|
}
|
||||||
|
}
|
||||||
|
pub type PatternMatchOr = crate::generic::PatternMatchOr<TextRange>;
|
||||||
|
#[cfg(feature = "more-attributes")]
|
||||||
|
impl Ranged for TypeIgnore {
|
||||||
|
fn range(&self) -> TextRange {
|
||||||
|
self.custom
|
||||||
|
}
|
||||||
|
}
|
||||||
|
pub type TypeIgnore = crate::generic::TypeIgnore<TextRange>;
|
||||||
|
#[cfg(feature = "more-attributes")]
|
||||||
|
impl Ranged for TypeIgnoreTypeIgnore {
|
||||||
|
fn range(&self) -> TextRange {
|
||||||
|
self.custom
|
||||||
|
}
|
||||||
|
}
|
||||||
|
pub type TypeIgnoreTypeIgnore = crate::generic::TypeIgnoreTypeIgnore<TextRange>;
|
|
@ -1,13 +1,14 @@
|
||||||
mod builtin;
|
mod builtin;
|
||||||
#[cfg(feature = "fold")]
|
#[cfg(feature = "fold")]
|
||||||
mod fold_helpers;
|
mod fold_helpers;
|
||||||
mod generic {
|
pub mod generic {
|
||||||
#![allow(clippy::derive_partial_eq_without_eq)]
|
#![allow(clippy::derive_partial_eq_without_eq)]
|
||||||
pub use crate::builtin::*;
|
pub use crate::builtin::*;
|
||||||
|
|
||||||
include!("gen/generic.rs");
|
include!("gen/generic.rs");
|
||||||
}
|
}
|
||||||
mod impls;
|
pub mod ranged;
|
||||||
|
// mod impls; // TODO: temp disable
|
||||||
#[cfg(feature = "location")]
|
#[cfg(feature = "location")]
|
||||||
mod source_locator;
|
mod source_locator;
|
||||||
#[cfg(feature = "unparse")]
|
#[cfg(feature = "unparse")]
|
||||||
|
@ -19,18 +20,6 @@ pub use rustpython_parser_core::{text_size, ConversionFlag};
|
||||||
|
|
||||||
pub type Suite<U = ()> = Vec<Stmt<U>>;
|
pub type Suite<U = ()> = Vec<Stmt<U>>;
|
||||||
|
|
||||||
pub trait Ranged {
|
|
||||||
fn range(&self) -> TextRange;
|
|
||||||
|
|
||||||
fn start(&self) -> TextSize {
|
|
||||||
self.range().start()
|
|
||||||
}
|
|
||||||
|
|
||||||
fn end(&self) -> TextSize {
|
|
||||||
self.range().end()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
#[cfg(feature = "fold")]
|
#[cfg(feature = "fold")]
|
||||||
pub mod fold {
|
pub mod fold {
|
||||||
use super::generic::*;
|
use super::generic::*;
|
||||||
|
@ -45,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;
|
||||||
|
@ -57,6 +44,5 @@ pub use visitor::Visitor;
|
||||||
#[cfg(feature = "constant-optimization")]
|
#[cfg(feature = "constant-optimization")]
|
||||||
mod optimizer;
|
mod optimizer;
|
||||||
|
|
||||||
use crate::text_size::{TextRange, TextSize};
|
|
||||||
#[cfg(feature = "constant-optimization")]
|
#[cfg(feature = "constant-optimization")]
|
||||||
pub use optimizer::ConstantOptimizer;
|
pub use optimizer::ConstantOptimizer;
|
||||||
|
|
17
ast/src/located.rs
Normal file
17
ast/src/located.rs
Normal file
|
@ -0,0 +1,17 @@
|
||||||
|
#![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) -> SourceLocation {
|
||||||
|
self.range().end()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
pub use crate::builtin::*;
|
||||||
|
include!("gen/located.rs");
|
17
ast/src/ranged.rs
Normal file
17
ast/src/ranged.rs
Normal file
|
@ -0,0 +1,17 @@
|
||||||
|
#![allow(clippy::derive_partial_eq_without_eq)]
|
||||||
|
use crate::text_size::{TextRange, TextSize};
|
||||||
|
|
||||||
|
pub trait Ranged {
|
||||||
|
fn range(&self) -> TextRange;
|
||||||
|
|
||||||
|
fn start(&self) -> TextSize {
|
||||||
|
self.range().start()
|
||||||
|
}
|
||||||
|
|
||||||
|
fn end(&self) -> TextSize {
|
||||||
|
self.range().end()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
pub use crate::builtin::*;
|
||||||
|
include!("gen/ranged.rs");
|
|
@ -4,7 +4,7 @@
|
||||||
// See also: https://greentreesnakes.readthedocs.io/en/latest/nodes.html#keyword
|
// See also: https://greentreesnakes.readthedocs.io/en/latest/nodes.html#keyword
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
ast::{self, Ranged},
|
ast::ranged::{self as ast, Ranged},
|
||||||
lexer::{LexicalError, LexicalErrorType},
|
lexer::{LexicalError, LexicalErrorType},
|
||||||
function::{ArgumentList, parse_args, parse_params, validate_arguments},
|
function::{ArgumentList, parse_args, parse_params, validate_arguments},
|
||||||
context::set_context,
|
context::set_context,
|
||||||
|
|
6
parser/src/python.rs
generated
6
parser/src/python.rs
generated
|
@ -1,7 +1,7 @@
|
||||||
// auto-generated: "lalrpop 0.20.0"
|
// auto-generated: "lalrpop 0.20.0"
|
||||||
// sha3: 888004f35fc4f9b0dfa2a4425adf0308b0b1a6bb8153ba94dc5c5f28fd3e263c
|
// sha3: 8a3fbd9c7ec6b7da4f0fc78dee12593317d7407da92a4ff54c0c398bf36bee6e
|
||||||
use crate::{
|
use crate::{
|
||||||
ast::{self, Ranged},
|
ast::ranged::{self as ast, Ranged},
|
||||||
lexer::{LexicalError, LexicalErrorType},
|
lexer::{LexicalError, LexicalErrorType},
|
||||||
function::{ArgumentList, parse_args, parse_params, validate_arguments},
|
function::{ArgumentList, parse_args, parse_params, validate_arguments},
|
||||||
context::set_context,
|
context::set_context,
|
||||||
|
@ -22,7 +22,7 @@ extern crate alloc;
|
||||||
mod __parse__Top {
|
mod __parse__Top {
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
ast::{self, Ranged},
|
ast::ranged::{self as ast, Ranged},
|
||||||
lexer::{LexicalError, LexicalErrorType},
|
lexer::{LexicalError, LexicalErrorType},
|
||||||
function::{ArgumentList, parse_args, parse_params, validate_arguments},
|
function::{ArgumentList, parse_args, parse_params, validate_arguments},
|
||||||
context::set_context,
|
context::set_context,
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue