This commit is contained in:
Micha Reiser 2023-05-12 19:43:56 +02:00
parent 535ec930c9
commit 7e48ec46b9
No known key found for this signature in database
120 changed files with 14151 additions and 18060 deletions

View file

@ -14,6 +14,7 @@ location = ["fold", "rustpython-parser-core/location"]
fold = [] fold = []
unparse = ["rustpython-literal"] unparse = ["rustpython-literal"]
visitor = [] visitor = []
more-attributes = []
[dependencies] [dependencies]
rustpython-parser-core = { workspace = true } rustpython-parser-core = { workspace = true }

View file

@ -387,7 +387,7 @@ class StructVisitor(EmitVisitor):
product_name = rust_type_name(name) product_name = rust_type_name(name)
self.emit_attrs(depth) self.emit_attrs(depth)
self.emit(f"pub struct {product_name}<R> {{", depth) self.emit(f"pub struct {product_name}<R = TextRange> {{", depth)
for f in product.fields: for f in product.fields:
self.visit(f, type_info, "pub ", depth + 1) self.visit(f, type_info, "pub ", depth + 1)
assert bool(product.attributes) == type_info.no_cfg(self.type_info) assert bool(product.attributes) == type_info.no_cfg(self.type_info)
@ -657,7 +657,7 @@ class VisitorTraitDefVisitor(StructVisitor):
self.emit_visitor(name, depth) self.emit_visitor(name, depth)
self.emit_generic_visitor_signature(name, depth) self.emit_generic_visitor_signature(name, depth)
depth += 1 depth += 1
self.emit("match node.node {", depth) self.emit("match node {", depth)
for t in sum.types: for t in sum.types:
self.visit_match_for_type(name, enum_name, t, depth + 1) self.visit_match_for_type(name, enum_name, t, depth + 1)
self.emit("}", depth) self.emit("}", depth)
@ -925,7 +925,6 @@ class TraitImplVisitor(EmitVisitor):
return f"Node::ast_from_object(_vm, get_node_field(_vm, &_object, {name}, {json.dumps(typename)})?)?" return f"Node::ast_from_object(_vm, get_node_field(_vm, &_object, {name}, {json.dumps(typename)})?)?"
class RangedDefVisitor(EmitVisitor): class RangedDefVisitor(EmitVisitor):
def visitModule(self, mod): def visitModule(self, mod):
for dfn in mod.dfns: for dfn in mod.dfns:
@ -937,41 +936,73 @@ class RangedDefVisitor(EmitVisitor):
def visitSum(self, sum, name, depth): def visitSum(self, sum, name, depth):
info = self.type_info[name] info = self.type_info[name]
# if info.is_simple: if info.is_simple:
# return return
if not info.no_cfg(self.type_info): for ty in sum.types:
self.emit('#[cfg(feature = "more-attributes")]', 0) info = self.type_info[ty.name]
self.make_ranged_impl(info)
self.emit(
f"""
impl Ranged for crate::generic::{info.rust_sum_name}::<TextRange> {{
fn range(&self) -> TextRange {{
self.range
}}
}}
""", 0)
def visitProduct(self, product, name, depth): def visitProduct(self, product, name, depth):
info = self.type_info[name] info = self.type_info[name]
# if info.is_simple: self.make_ranged_impl(info)
# return
def make_ranged_impl(self, info):
if not info.no_cfg(self.type_info):
self.emit('#[cfg(feature = "more-attributes")]', 0)
self.file.write(
f"""
impl Ranged for crate::generic::{info.rust_sum_name}::<TextRange> {{
fn range(&self) -> TextRange {{
self.range
}}
}}
""".strip()
)
class LocatedDefVisitor(EmitVisitor):
def visitModule(self, mod):
for dfn in mod.dfns:
self.visit(dfn)
def visitType(self, type, depth=0):
self.visit(type.value, type.name, depth)
def visitSum(self, sum, name, depth):
info = self.type_info[name]
if info.is_simple:
return
for ty in sum.types:
info = self.type_info[ty.name]
self.make_located_impl(info)
def visitProduct(self, product, name, depth):
info = self.type_info[name]
self.make_located_impl(info)
def make_located_impl(self, info):
if not info.no_cfg(self.type_info):
self.emit('#[cfg(feature = "more-attributes")]', 0)
self.emit(f"pub type {info.rust_sum_name} = crate::generic::{info.rust_sum_name}::<SourceRange>;", 0)
if not info.no_cfg(self.type_info): if not info.no_cfg(self.type_info):
self.emit('#[cfg(feature = "more-attributes")]', 0) self.emit('#[cfg(feature = "more-attributes")]', 0)
self.emit( self.file.write(
f""" f"""
impl Ranged for crate::generic::{info.rust_sum_name}::<TextRange> {{ impl Located for {info.rust_sum_name} {{
fn range(&self) -> TextRange {{ fn range(&self) -> SourceRange {{
self.range self.range
}} }}
}} }}
""", 0) """.strip()
)
for f in product.fields:
self.visit(f, info, "pub ", depth + 1)
class ChainOfVisitors: class ChainOfVisitors:
def __init__(self, *visitors): def __init__(self, *visitors):
@ -997,40 +1028,12 @@ def write_visitor_def(mod, type_info, f):
def write_ranged_def(mod, type_info, f): def write_ranged_def(mod, type_info, f):
f.write("use crate::Ranged;")
RangedDefVisitor(f, type_info).visit(mod) RangedDefVisitor(f, type_info).visit(mod)
# def write_ranged_def(mod, type_info, f):
# import pprint
# for info in type_info.values():
# pprint.pp(info.__dict__)
# if not info.is_simple and not info.product:
# if not info.no_cfg(type_info):
# f.write('#[cfg(feature = "more-attributes")]')
# f.write(
# f"""
# impl Ranged for crate::generic::{info.rust_sum_name}::<TextRange> {{
# fn range(&self) -> TextRange {{
# self.range
# }}
# }}
# """
# )
def write_located_def(mod, type_info, f): def write_located_def(mod, type_info, f):
for info in type_info.values(): LocatedDefVisitor(f, type_info).visit(mod)
if not info.is_simple:
if not info.no_cfg(type_info):
f.write('#[cfg(feature = "more-attributes")]')
f.write(
f"""
impl Located for crate::generic::{info.rust_sum_name}::<SourceRange> {{
fn range(&self) -> SourceRange {{
self.range
}}
}}
"""
)
def write_ast_mod(mod, type_info, f): def write_ast_mod(mod, type_info, f):
f.write( f.write(

View file

@ -964,7 +964,7 @@ pub enum Cmpop {
} }
#[derive(Clone, Debug, PartialEq)] #[derive(Clone, Debug, PartialEq)]
pub struct Comprehension<R> { pub struct Comprehension<R = TextRange> {
pub target: Expr<R>, pub target: Expr<R>,
pub iter: Expr<R>, pub iter: Expr<R>,
pub ifs: Vec<Expr<R>>, pub ifs: Vec<Expr<R>>,
@ -995,7 +995,7 @@ pub enum Excepthandler<R = TextRange> {
} }
#[derive(Clone, Debug, PartialEq)] #[derive(Clone, Debug, PartialEq)]
pub struct Arguments<R> { pub struct Arguments<R = TextRange> {
pub posonlyargs: Vec<Arg<R>>, pub posonlyargs: Vec<Arg<R>>,
pub args: Vec<Arg<R>>, pub args: Vec<Arg<R>>,
pub vararg: Option<Box<Arg<R>>>, pub vararg: Option<Box<Arg<R>>>,
@ -1010,7 +1010,7 @@ pub struct Arguments<R> {
} }
#[derive(Clone, Debug, PartialEq)] #[derive(Clone, Debug, PartialEq)]
pub struct Arg<R> { pub struct Arg<R = TextRange> {
pub arg: Identifier, pub arg: Identifier,
pub annotation: Option<Box<Expr<R>>>, pub annotation: Option<Box<Expr<R>>>,
pub type_comment: Option<String>, pub type_comment: Option<String>,
@ -1018,21 +1018,21 @@ pub struct Arg<R> {
} }
#[derive(Clone, Debug, PartialEq)] #[derive(Clone, Debug, PartialEq)]
pub struct Keyword<R> { pub struct Keyword<R = TextRange> {
pub arg: Option<Identifier>, pub arg: Option<Identifier>,
pub value: Expr<R>, pub value: Expr<R>,
pub range: R, pub range: R,
} }
#[derive(Clone, Debug, PartialEq)] #[derive(Clone, Debug, PartialEq)]
pub struct Alias<R> { pub struct Alias<R = TextRange> {
pub name: Identifier, pub name: Identifier,
pub asname: Option<Identifier>, pub asname: Option<Identifier>,
pub range: R, pub range: R,
} }
#[derive(Clone, Debug, PartialEq)] #[derive(Clone, Debug, PartialEq)]
pub struct Withitem<R> { pub struct Withitem<R = TextRange> {
pub context_expr: Expr<R>, pub context_expr: Expr<R>,
pub optional_vars: Option<Box<Expr<R>>>, pub optional_vars: Option<Box<Expr<R>>>,
#[cfg(feature = "more-attributes")] #[cfg(feature = "more-attributes")]
@ -1042,7 +1042,7 @@ pub struct Withitem<R> {
} }
#[derive(Clone, Debug, PartialEq)] #[derive(Clone, Debug, PartialEq)]
pub struct MatchCase<R> { pub struct MatchCase<R = TextRange> {
pub pattern: Pattern<R>, pub pattern: Pattern<R>,
pub guard: Option<Box<Expr<R>>>, pub guard: Option<Box<Expr<R>>>,
pub body: Vec<Stmt<R>>, pub body: Vec<Stmt<R>>,

View file

@ -1,487 +1,469 @@
// File automatically generated by ast/asdl_rs.py. // File automatically generated by ast/asdl_rs.py.
#[cfg(feature = "more-attributes")] #[cfg(feature = "more-attributes")]
impl Located for crate::generic::Mod<SourceRange> { pub type ModModule = crate::generic::ModModule<SourceRange>;
#[cfg(feature = "more-attributes")]
impl Located for ModModule {
fn range(&self) -> SourceRange { fn range(&self) -> SourceRange {
self.range self.range
} }
} }
#[cfg(feature = "more-attributes")] #[cfg(feature = "more-attributes")]
impl Located for crate::generic::ModModule<SourceRange> { pub type ModInteractive = crate::generic::ModInteractive<SourceRange>;
#[cfg(feature = "more-attributes")]
impl Located for ModInteractive {
fn range(&self) -> SourceRange { fn range(&self) -> SourceRange {
self.range self.range
} }
} }
#[cfg(feature = "more-attributes")] #[cfg(feature = "more-attributes")]
impl Located for crate::generic::ModInteractive<SourceRange> { pub type ModExpression = crate::generic::ModExpression<SourceRange>;
#[cfg(feature = "more-attributes")]
impl Located for ModExpression {
fn range(&self) -> SourceRange { fn range(&self) -> SourceRange {
self.range self.range
} }
} }
#[cfg(feature = "more-attributes")] #[cfg(feature = "more-attributes")]
impl Located for crate::generic::ModExpression<SourceRange> { pub type ModFunctionType = crate::generic::ModFunctionType<SourceRange>;
#[cfg(feature = "more-attributes")]
impl Located for ModFunctionType {
fn range(&self) -> SourceRange {
self.range
}
}
pub type StmtFunctionDef = crate::generic::StmtFunctionDef<SourceRange>;
impl Located for StmtFunctionDef {
fn range(&self) -> SourceRange {
self.range
}
}
pub type StmtAsyncFunctionDef = crate::generic::StmtAsyncFunctionDef<SourceRange>;
impl Located for StmtAsyncFunctionDef {
fn range(&self) -> SourceRange {
self.range
}
}
pub type StmtClassDef = crate::generic::StmtClassDef<SourceRange>;
impl Located for StmtClassDef {
fn range(&self) -> SourceRange {
self.range
}
}
pub type StmtReturn = crate::generic::StmtReturn<SourceRange>;
impl Located for StmtReturn {
fn range(&self) -> SourceRange {
self.range
}
}
pub type StmtDelete = crate::generic::StmtDelete<SourceRange>;
impl Located for StmtDelete {
fn range(&self) -> SourceRange {
self.range
}
}
pub type StmtAssign = crate::generic::StmtAssign<SourceRange>;
impl Located for StmtAssign {
fn range(&self) -> SourceRange {
self.range
}
}
pub type StmtAugAssign = crate::generic::StmtAugAssign<SourceRange>;
impl Located for StmtAugAssign {
fn range(&self) -> SourceRange {
self.range
}
}
pub type StmtAnnAssign = crate::generic::StmtAnnAssign<SourceRange>;
impl Located for StmtAnnAssign {
fn range(&self) -> SourceRange {
self.range
}
}
pub type StmtFor = crate::generic::StmtFor<SourceRange>;
impl Located for StmtFor {
fn range(&self) -> SourceRange {
self.range
}
}
pub type StmtAsyncFor = crate::generic::StmtAsyncFor<SourceRange>;
impl Located for StmtAsyncFor {
fn range(&self) -> SourceRange {
self.range
}
}
pub type StmtWhile = crate::generic::StmtWhile<SourceRange>;
impl Located for StmtWhile {
fn range(&self) -> SourceRange {
self.range
}
}
pub type StmtIf = crate::generic::StmtIf<SourceRange>;
impl Located for StmtIf {
fn range(&self) -> SourceRange {
self.range
}
}
pub type StmtWith = crate::generic::StmtWith<SourceRange>;
impl Located for StmtWith {
fn range(&self) -> SourceRange {
self.range
}
}
pub type StmtAsyncWith = crate::generic::StmtAsyncWith<SourceRange>;
impl Located for StmtAsyncWith {
fn range(&self) -> SourceRange {
self.range
}
}
pub type StmtMatch = crate::generic::StmtMatch<SourceRange>;
impl Located for StmtMatch {
fn range(&self) -> SourceRange {
self.range
}
}
pub type StmtRaise = crate::generic::StmtRaise<SourceRange>;
impl Located for StmtRaise {
fn range(&self) -> SourceRange {
self.range
}
}
pub type StmtTry = crate::generic::StmtTry<SourceRange>;
impl Located for StmtTry {
fn range(&self) -> SourceRange {
self.range
}
}
pub type StmtTryStar = crate::generic::StmtTryStar<SourceRange>;
impl Located for StmtTryStar {
fn range(&self) -> SourceRange {
self.range
}
}
pub type StmtAssert = crate::generic::StmtAssert<SourceRange>;
impl Located for StmtAssert {
fn range(&self) -> SourceRange {
self.range
}
}
pub type StmtImport = crate::generic::StmtImport<SourceRange>;
impl Located for StmtImport {
fn range(&self) -> SourceRange {
self.range
}
}
pub type StmtImportFrom = crate::generic::StmtImportFrom<SourceRange>;
impl Located for StmtImportFrom {
fn range(&self) -> SourceRange {
self.range
}
}
pub type StmtGlobal = crate::generic::StmtGlobal<SourceRange>;
impl Located for StmtGlobal {
fn range(&self) -> SourceRange {
self.range
}
}
pub type StmtNonlocal = crate::generic::StmtNonlocal<SourceRange>;
impl Located for StmtNonlocal {
fn range(&self) -> SourceRange {
self.range
}
}
pub type StmtExpr = crate::generic::StmtExpr<SourceRange>;
impl Located for StmtExpr {
fn range(&self) -> SourceRange {
self.range
}
}
pub type StmtPass = crate::generic::StmtPass<SourceRange>;
impl Located for StmtPass {
fn range(&self) -> SourceRange {
self.range
}
}
pub type StmtBreak = crate::generic::StmtBreak<SourceRange>;
impl Located for StmtBreak {
fn range(&self) -> SourceRange {
self.range
}
}
pub type StmtContinue = crate::generic::StmtContinue<SourceRange>;
impl Located for StmtContinue {
fn range(&self) -> SourceRange {
self.range
}
}
pub type ExprBoolOp = crate::generic::ExprBoolOp<SourceRange>;
impl Located for ExprBoolOp {
fn range(&self) -> SourceRange {
self.range
}
}
pub type ExprNamedExpr = crate::generic::ExprNamedExpr<SourceRange>;
impl Located for ExprNamedExpr {
fn range(&self) -> SourceRange {
self.range
}
}
pub type ExprBinOp = crate::generic::ExprBinOp<SourceRange>;
impl Located for ExprBinOp {
fn range(&self) -> SourceRange {
self.range
}
}
pub type ExprUnaryOp = crate::generic::ExprUnaryOp<SourceRange>;
impl Located for ExprUnaryOp {
fn range(&self) -> SourceRange {
self.range
}
}
pub type ExprLambda = crate::generic::ExprLambda<SourceRange>;
impl Located for ExprLambda {
fn range(&self) -> SourceRange {
self.range
}
}
pub type ExprIfExp = crate::generic::ExprIfExp<SourceRange>;
impl Located for ExprIfExp {
fn range(&self) -> SourceRange {
self.range
}
}
pub type ExprDict = crate::generic::ExprDict<SourceRange>;
impl Located for ExprDict {
fn range(&self) -> SourceRange {
self.range
}
}
pub type ExprSet = crate::generic::ExprSet<SourceRange>;
impl Located for ExprSet {
fn range(&self) -> SourceRange {
self.range
}
}
pub type ExprListComp = crate::generic::ExprListComp<SourceRange>;
impl Located for ExprListComp {
fn range(&self) -> SourceRange {
self.range
}
}
pub type ExprSetComp = crate::generic::ExprSetComp<SourceRange>;
impl Located for ExprSetComp {
fn range(&self) -> SourceRange {
self.range
}
}
pub type ExprDictComp = crate::generic::ExprDictComp<SourceRange>;
impl Located for ExprDictComp {
fn range(&self) -> SourceRange {
self.range
}
}
pub type ExprGeneratorExp = crate::generic::ExprGeneratorExp<SourceRange>;
impl Located for ExprGeneratorExp {
fn range(&self) -> SourceRange {
self.range
}
}
pub type ExprAwait = crate::generic::ExprAwait<SourceRange>;
impl Located for ExprAwait {
fn range(&self) -> SourceRange {
self.range
}
}
pub type ExprYield = crate::generic::ExprYield<SourceRange>;
impl Located for ExprYield {
fn range(&self) -> SourceRange {
self.range
}
}
pub type ExprYieldFrom = crate::generic::ExprYieldFrom<SourceRange>;
impl Located for ExprYieldFrom {
fn range(&self) -> SourceRange {
self.range
}
}
pub type ExprCompare = crate::generic::ExprCompare<SourceRange>;
impl Located for ExprCompare {
fn range(&self) -> SourceRange {
self.range
}
}
pub type ExprCall = crate::generic::ExprCall<SourceRange>;
impl Located for ExprCall {
fn range(&self) -> SourceRange {
self.range
}
}
pub type ExprFormattedValue = crate::generic::ExprFormattedValue<SourceRange>;
impl Located for ExprFormattedValue {
fn range(&self) -> SourceRange {
self.range
}
}
pub type ExprJoinedStr = crate::generic::ExprJoinedStr<SourceRange>;
impl Located for ExprJoinedStr {
fn range(&self) -> SourceRange {
self.range
}
}
pub type ExprConstant = crate::generic::ExprConstant<SourceRange>;
impl Located for ExprConstant {
fn range(&self) -> SourceRange {
self.range
}
}
pub type ExprAttribute = crate::generic::ExprAttribute<SourceRange>;
impl Located for ExprAttribute {
fn range(&self) -> SourceRange {
self.range
}
}
pub type ExprSubscript = crate::generic::ExprSubscript<SourceRange>;
impl Located for ExprSubscript {
fn range(&self) -> SourceRange {
self.range
}
}
pub type ExprStarred = crate::generic::ExprStarred<SourceRange>;
impl Located for ExprStarred {
fn range(&self) -> SourceRange {
self.range
}
}
pub type ExprName = crate::generic::ExprName<SourceRange>;
impl Located for ExprName {
fn range(&self) -> SourceRange {
self.range
}
}
pub type ExprList = crate::generic::ExprList<SourceRange>;
impl Located for ExprList {
fn range(&self) -> SourceRange {
self.range
}
}
pub type ExprTuple = crate::generic::ExprTuple<SourceRange>;
impl Located for ExprTuple {
fn range(&self) -> SourceRange {
self.range
}
}
pub type ExprSlice = crate::generic::ExprSlice<SourceRange>;
impl Located for ExprSlice {
fn range(&self) -> SourceRange { fn range(&self) -> SourceRange {
self.range self.range
} }
} }
#[cfg(feature = "more-attributes")] #[cfg(feature = "more-attributes")]
impl Located for crate::generic::ModFunctionType<SourceRange> { pub type Comprehension = crate::generic::Comprehension<SourceRange>;
#[cfg(feature = "more-attributes")]
impl Located for Comprehension {
fn range(&self) -> SourceRange { fn range(&self) -> SourceRange {
self.range self.range
} }
} }
pub type ExcepthandlerExceptHandler = crate::generic::ExcepthandlerExceptHandler<SourceRange>;
impl Located for crate::generic::Stmt<SourceRange> { impl Located for ExcepthandlerExceptHandler {
fn range(&self) -> SourceRange {
self.range
}
}
impl Located for crate::generic::StmtFunctionDef<SourceRange> {
fn range(&self) -> SourceRange {
self.range
}
}
impl Located for crate::generic::StmtAsyncFunctionDef<SourceRange> {
fn range(&self) -> SourceRange {
self.range
}
}
impl Located for crate::generic::StmtClassDef<SourceRange> {
fn range(&self) -> SourceRange {
self.range
}
}
impl Located for crate::generic::StmtReturn<SourceRange> {
fn range(&self) -> SourceRange {
self.range
}
}
impl Located for crate::generic::StmtDelete<SourceRange> {
fn range(&self) -> SourceRange {
self.range
}
}
impl Located for crate::generic::StmtAssign<SourceRange> {
fn range(&self) -> SourceRange {
self.range
}
}
impl Located for crate::generic::StmtAugAssign<SourceRange> {
fn range(&self) -> SourceRange {
self.range
}
}
impl Located for crate::generic::StmtAnnAssign<SourceRange> {
fn range(&self) -> SourceRange {
self.range
}
}
impl Located for crate::generic::StmtFor<SourceRange> {
fn range(&self) -> SourceRange {
self.range
}
}
impl Located for crate::generic::StmtAsyncFor<SourceRange> {
fn range(&self) -> SourceRange {
self.range
}
}
impl Located for crate::generic::StmtWhile<SourceRange> {
fn range(&self) -> SourceRange {
self.range
}
}
impl Located for crate::generic::StmtIf<SourceRange> {
fn range(&self) -> SourceRange {
self.range
}
}
impl Located for crate::generic::StmtWith<SourceRange> {
fn range(&self) -> SourceRange {
self.range
}
}
impl Located for crate::generic::StmtAsyncWith<SourceRange> {
fn range(&self) -> SourceRange {
self.range
}
}
impl Located for crate::generic::StmtMatch<SourceRange> {
fn range(&self) -> SourceRange {
self.range
}
}
impl Located for crate::generic::StmtRaise<SourceRange> {
fn range(&self) -> SourceRange {
self.range
}
}
impl Located for crate::generic::StmtTry<SourceRange> {
fn range(&self) -> SourceRange {
self.range
}
}
impl Located for crate::generic::StmtTryStar<SourceRange> {
fn range(&self) -> SourceRange {
self.range
}
}
impl Located for crate::generic::StmtAssert<SourceRange> {
fn range(&self) -> SourceRange {
self.range
}
}
impl Located for crate::generic::StmtImport<SourceRange> {
fn range(&self) -> SourceRange {
self.range
}
}
impl Located for crate::generic::StmtImportFrom<SourceRange> {
fn range(&self) -> SourceRange {
self.range
}
}
impl Located for crate::generic::StmtGlobal<SourceRange> {
fn range(&self) -> SourceRange {
self.range
}
}
impl Located for crate::generic::StmtNonlocal<SourceRange> {
fn range(&self) -> SourceRange {
self.range
}
}
impl Located for crate::generic::StmtExpr<SourceRange> {
fn range(&self) -> SourceRange {
self.range
}
}
impl Located for crate::generic::StmtPass<SourceRange> {
fn range(&self) -> SourceRange {
self.range
}
}
impl Located for crate::generic::StmtBreak<SourceRange> {
fn range(&self) -> SourceRange {
self.range
}
}
impl Located for crate::generic::StmtContinue<SourceRange> {
fn range(&self) -> SourceRange {
self.range
}
}
impl Located for crate::generic::Expr<SourceRange> {
fn range(&self) -> SourceRange {
self.range
}
}
impl Located for crate::generic::ExprBoolOp<SourceRange> {
fn range(&self) -> SourceRange {
self.range
}
}
impl Located for crate::generic::ExprNamedExpr<SourceRange> {
fn range(&self) -> SourceRange {
self.range
}
}
impl Located for crate::generic::ExprBinOp<SourceRange> {
fn range(&self) -> SourceRange {
self.range
}
}
impl Located for crate::generic::ExprUnaryOp<SourceRange> {
fn range(&self) -> SourceRange {
self.range
}
}
impl Located for crate::generic::ExprLambda<SourceRange> {
fn range(&self) -> SourceRange {
self.range
}
}
impl Located for crate::generic::ExprIfExp<SourceRange> {
fn range(&self) -> SourceRange {
self.range
}
}
impl Located for crate::generic::ExprDict<SourceRange> {
fn range(&self) -> SourceRange {
self.range
}
}
impl Located for crate::generic::ExprSet<SourceRange> {
fn range(&self) -> SourceRange {
self.range
}
}
impl Located for crate::generic::ExprListComp<SourceRange> {
fn range(&self) -> SourceRange {
self.range
}
}
impl Located for crate::generic::ExprSetComp<SourceRange> {
fn range(&self) -> SourceRange {
self.range
}
}
impl Located for crate::generic::ExprDictComp<SourceRange> {
fn range(&self) -> SourceRange {
self.range
}
}
impl Located for crate::generic::ExprGeneratorExp<SourceRange> {
fn range(&self) -> SourceRange {
self.range
}
}
impl Located for crate::generic::ExprAwait<SourceRange> {
fn range(&self) -> SourceRange {
self.range
}
}
impl Located for crate::generic::ExprYield<SourceRange> {
fn range(&self) -> SourceRange {
self.range
}
}
impl Located for crate::generic::ExprYieldFrom<SourceRange> {
fn range(&self) -> SourceRange {
self.range
}
}
impl Located for crate::generic::ExprCompare<SourceRange> {
fn range(&self) -> SourceRange {
self.range
}
}
impl Located for crate::generic::ExprCall<SourceRange> {
fn range(&self) -> SourceRange {
self.range
}
}
impl Located for crate::generic::ExprFormattedValue<SourceRange> {
fn range(&self) -> SourceRange {
self.range
}
}
impl Located for crate::generic::ExprJoinedStr<SourceRange> {
fn range(&self) -> SourceRange {
self.range
}
}
impl Located for crate::generic::ExprConstant<SourceRange> {
fn range(&self) -> SourceRange {
self.range
}
}
impl Located for crate::generic::ExprAttribute<SourceRange> {
fn range(&self) -> SourceRange {
self.range
}
}
impl Located for crate::generic::ExprSubscript<SourceRange> {
fn range(&self) -> SourceRange {
self.range
}
}
impl Located for crate::generic::ExprStarred<SourceRange> {
fn range(&self) -> SourceRange {
self.range
}
}
impl Located for crate::generic::ExprName<SourceRange> {
fn range(&self) -> SourceRange {
self.range
}
}
impl Located for crate::generic::ExprList<SourceRange> {
fn range(&self) -> SourceRange {
self.range
}
}
impl Located for crate::generic::ExprTuple<SourceRange> {
fn range(&self) -> SourceRange {
self.range
}
}
impl Located for crate::generic::ExprSlice<SourceRange> {
fn range(&self) -> SourceRange { fn range(&self) -> SourceRange {
self.range self.range
} }
} }
#[cfg(feature = "more-attributes")] #[cfg(feature = "more-attributes")]
impl Located for crate::generic::Comprehension<SourceRange> { pub type Arguments = crate::generic::Arguments<SourceRange>;
#[cfg(feature = "more-attributes")]
impl Located for Arguments {
fn range(&self) -> SourceRange { fn range(&self) -> SourceRange {
self.range self.range
} }
} }
pub type Arg = crate::generic::Arg<SourceRange>;
impl Located for crate::generic::Excepthandler<SourceRange> { impl Located for Arg {
fn range(&self) -> SourceRange { fn range(&self) -> SourceRange {
self.range self.range
} }
} }
pub type Keyword = crate::generic::Keyword<SourceRange>;
impl Located for crate::generic::ExcepthandlerExceptHandler<SourceRange> { impl Located for Keyword {
fn range(&self) -> SourceRange {
self.range
}
}
pub type Alias = crate::generic::Alias<SourceRange>;
impl Located for Alias {
fn range(&self) -> SourceRange { fn range(&self) -> SourceRange {
self.range self.range
} }
} }
#[cfg(feature = "more-attributes")] #[cfg(feature = "more-attributes")]
impl Located for crate::generic::Arguments<SourceRange> { pub type Withitem = crate::generic::Withitem<SourceRange>;
fn range(&self) -> SourceRange { #[cfg(feature = "more-attributes")]
self.range impl Located for Withitem {
}
}
impl Located for crate::generic::Arg<SourceRange> {
fn range(&self) -> SourceRange {
self.range
}
}
impl Located for crate::generic::Keyword<SourceRange> {
fn range(&self) -> SourceRange {
self.range
}
}
impl Located for crate::generic::Alias<SourceRange> {
fn range(&self) -> SourceRange { fn range(&self) -> SourceRange {
self.range self.range
} }
} }
#[cfg(feature = "more-attributes")] #[cfg(feature = "more-attributes")]
impl Located for crate::generic::Withitem<SourceRange> { pub type MatchCase = crate::generic::MatchCase<SourceRange>;
#[cfg(feature = "more-attributes")]
impl Located for MatchCase {
fn range(&self) -> SourceRange {
self.range
}
}
pub type PatternMatchValue = crate::generic::PatternMatchValue<SourceRange>;
impl Located for PatternMatchValue {
fn range(&self) -> SourceRange {
self.range
}
}
pub type PatternMatchSingleton = crate::generic::PatternMatchSingleton<SourceRange>;
impl Located for PatternMatchSingleton {
fn range(&self) -> SourceRange {
self.range
}
}
pub type PatternMatchSequence = crate::generic::PatternMatchSequence<SourceRange>;
impl Located for PatternMatchSequence {
fn range(&self) -> SourceRange {
self.range
}
}
pub type PatternMatchMapping = crate::generic::PatternMatchMapping<SourceRange>;
impl Located for PatternMatchMapping {
fn range(&self) -> SourceRange {
self.range
}
}
pub type PatternMatchClass = crate::generic::PatternMatchClass<SourceRange>;
impl Located for PatternMatchClass {
fn range(&self) -> SourceRange {
self.range
}
}
pub type PatternMatchStar = crate::generic::PatternMatchStar<SourceRange>;
impl Located for PatternMatchStar {
fn range(&self) -> SourceRange {
self.range
}
}
pub type PatternMatchAs = crate::generic::PatternMatchAs<SourceRange>;
impl Located for PatternMatchAs {
fn range(&self) -> SourceRange {
self.range
}
}
pub type PatternMatchOr = crate::generic::PatternMatchOr<SourceRange>;
impl Located for PatternMatchOr {
fn range(&self) -> SourceRange { fn range(&self) -> SourceRange {
self.range self.range
} }
} }
#[cfg(feature = "more-attributes")] #[cfg(feature = "more-attributes")]
impl Located for crate::generic::MatchCase<SourceRange> { pub type TypeIgnoreTypeIgnore = crate::generic::TypeIgnoreTypeIgnore<SourceRange>;
fn range(&self) -> SourceRange {
self.range
}
}
impl Located for crate::generic::Pattern<SourceRange> {
fn range(&self) -> SourceRange {
self.range
}
}
impl Located for crate::generic::PatternMatchValue<SourceRange> {
fn range(&self) -> SourceRange {
self.range
}
}
impl Located for crate::generic::PatternMatchSingleton<SourceRange> {
fn range(&self) -> SourceRange {
self.range
}
}
impl Located for crate::generic::PatternMatchSequence<SourceRange> {
fn range(&self) -> SourceRange {
self.range
}
}
impl Located for crate::generic::PatternMatchMapping<SourceRange> {
fn range(&self) -> SourceRange {
self.range
}
}
impl Located for crate::generic::PatternMatchClass<SourceRange> {
fn range(&self) -> SourceRange {
self.range
}
}
impl Located for crate::generic::PatternMatchStar<SourceRange> {
fn range(&self) -> SourceRange {
self.range
}
}
impl Located for crate::generic::PatternMatchAs<SourceRange> {
fn range(&self) -> SourceRange {
self.range
}
}
impl Located for crate::generic::PatternMatchOr<SourceRange> {
fn range(&self) -> SourceRange {
self.range
}
}
#[cfg(feature = "more-attributes")] #[cfg(feature = "more-attributes")]
impl Located for crate::generic::TypeIgnore<SourceRange> { impl Located for TypeIgnoreTypeIgnore {
fn range(&self) -> SourceRange {
self.range
}
}
#[cfg(feature = "more-attributes")]
impl Located for crate::generic::TypeIgnoreTypeIgnore<SourceRange> {
fn range(&self) -> SourceRange { fn range(&self) -> SourceRange {
self.range self.range
} }

View file

@ -1,130 +1,386 @@
// File automatically generated by ast/asdl_rs.py. // File automatically generated by ast/asdl_rs.py.
use crate::Ranged;
#[cfg(feature = "more-attributes")] #[cfg(feature = "more-attributes")]
impl Ranged for crate::generic::ModModule<TextRange> {
impl Ranged for crate::generic::Mod<TextRange> {
fn range(&self) -> TextRange { fn range(&self) -> TextRange {
self.range self.range
} }
} }
impl Ranged for crate::generic::Stmt<TextRange> {
fn range(&self) -> TextRange {
self.range
}
}
impl Ranged for crate::generic::Expr<TextRange> {
fn range(&self) -> TextRange {
self.range
}
}
#[cfg(feature = "more-attributes")] #[cfg(feature = "more-attributes")]
impl Ranged for crate::generic::ModInteractive<TextRange> {
impl Ranged for crate::generic::ExprContext<TextRange> {
fn range(&self) -> TextRange { fn range(&self) -> TextRange {
self.range self.range
} }
} }
#[cfg(feature = "more-attributes")] #[cfg(feature = "more-attributes")]
impl Ranged for crate::generic::ModExpression<TextRange> {
impl Ranged for crate::generic::Boolop<TextRange> {
fn range(&self) -> TextRange { fn range(&self) -> TextRange {
self.range self.range
} }
} }
#[cfg(feature = "more-attributes")] #[cfg(feature = "more-attributes")]
impl Ranged for crate::generic::ModFunctionType<TextRange> {
impl Ranged for crate::generic::Operator<TextRange> {
fn range(&self) -> TextRange { fn range(&self) -> TextRange {
self.range self.range
} }
} }
impl Ranged for crate::generic::StmtFunctionDef<TextRange> {
#[cfg(feature = "more-attributes")]
impl Ranged for crate::generic::Unaryop<TextRange> {
fn range(&self) -> TextRange { fn range(&self) -> TextRange {
self.range self.range
} }
} }
impl Ranged for crate::generic::StmtAsyncFunctionDef<TextRange> {
#[cfg(feature = "more-attributes")] fn range(&self) -> TextRange {
self.range
impl Ranged for crate::generic::Cmpop<TextRange> { }
}
impl Ranged for crate::generic::StmtClassDef<TextRange> {
fn range(&self) -> TextRange {
self.range
}
}
impl Ranged for crate::generic::StmtReturn<TextRange> {
fn range(&self) -> TextRange {
self.range
}
}
impl Ranged for crate::generic::StmtDelete<TextRange> {
fn range(&self) -> TextRange {
self.range
}
}
impl Ranged for crate::generic::StmtAssign<TextRange> {
fn range(&self) -> TextRange {
self.range
}
}
impl Ranged for crate::generic::StmtAugAssign<TextRange> {
fn range(&self) -> TextRange {
self.range
}
}
impl Ranged for crate::generic::StmtAnnAssign<TextRange> {
fn range(&self) -> TextRange {
self.range
}
}
impl Ranged for crate::generic::StmtFor<TextRange> {
fn range(&self) -> TextRange {
self.range
}
}
impl Ranged for crate::generic::StmtAsyncFor<TextRange> {
fn range(&self) -> TextRange {
self.range
}
}
impl Ranged for crate::generic::StmtWhile<TextRange> {
fn range(&self) -> TextRange {
self.range
}
}
impl Ranged for crate::generic::StmtIf<TextRange> {
fn range(&self) -> TextRange {
self.range
}
}
impl Ranged for crate::generic::StmtWith<TextRange> {
fn range(&self) -> TextRange {
self.range
}
}
impl Ranged for crate::generic::StmtAsyncWith<TextRange> {
fn range(&self) -> TextRange {
self.range
}
}
impl Ranged for crate::generic::StmtMatch<TextRange> {
fn range(&self) -> TextRange {
self.range
}
}
impl Ranged for crate::generic::StmtRaise<TextRange> {
fn range(&self) -> TextRange {
self.range
}
}
impl Ranged for crate::generic::StmtTry<TextRange> {
fn range(&self) -> TextRange {
self.range
}
}
impl Ranged for crate::generic::StmtTryStar<TextRange> {
fn range(&self) -> TextRange {
self.range
}
}
impl Ranged for crate::generic::StmtAssert<TextRange> {
fn range(&self) -> TextRange {
self.range
}
}
impl Ranged for crate::generic::StmtImport<TextRange> {
fn range(&self) -> TextRange {
self.range
}
}
impl Ranged for crate::generic::StmtImportFrom<TextRange> {
fn range(&self) -> TextRange {
self.range
}
}
impl Ranged for crate::generic::StmtGlobal<TextRange> {
fn range(&self) -> TextRange {
self.range
}
}
impl Ranged for crate::generic::StmtNonlocal<TextRange> {
fn range(&self) -> TextRange {
self.range
}
}
impl Ranged for crate::generic::StmtExpr<TextRange> {
fn range(&self) -> TextRange {
self.range
}
}
impl Ranged for crate::generic::StmtPass<TextRange> {
fn range(&self) -> TextRange {
self.range
}
}
impl Ranged for crate::generic::StmtBreak<TextRange> {
fn range(&self) -> TextRange {
self.range
}
}
impl Ranged for crate::generic::StmtContinue<TextRange> {
fn range(&self) -> TextRange {
self.range
}
}
impl Ranged for crate::generic::ExprBoolOp<TextRange> {
fn range(&self) -> TextRange {
self.range
}
}
impl Ranged for crate::generic::ExprNamedExpr<TextRange> {
fn range(&self) -> TextRange {
self.range
}
}
impl Ranged for crate::generic::ExprBinOp<TextRange> {
fn range(&self) -> TextRange {
self.range
}
}
impl Ranged for crate::generic::ExprUnaryOp<TextRange> {
fn range(&self) -> TextRange {
self.range
}
}
impl Ranged for crate::generic::ExprLambda<TextRange> {
fn range(&self) -> TextRange {
self.range
}
}
impl Ranged for crate::generic::ExprIfExp<TextRange> {
fn range(&self) -> TextRange {
self.range
}
}
impl Ranged for crate::generic::ExprDict<TextRange> {
fn range(&self) -> TextRange {
self.range
}
}
impl Ranged for crate::generic::ExprSet<TextRange> {
fn range(&self) -> TextRange {
self.range
}
}
impl Ranged for crate::generic::ExprListComp<TextRange> {
fn range(&self) -> TextRange {
self.range
}
}
impl Ranged for crate::generic::ExprSetComp<TextRange> {
fn range(&self) -> TextRange {
self.range
}
}
impl Ranged for crate::generic::ExprDictComp<TextRange> {
fn range(&self) -> TextRange {
self.range
}
}
impl Ranged for crate::generic::ExprGeneratorExp<TextRange> {
fn range(&self) -> TextRange {
self.range
}
}
impl Ranged for crate::generic::ExprAwait<TextRange> {
fn range(&self) -> TextRange {
self.range
}
}
impl Ranged for crate::generic::ExprYield<TextRange> {
fn range(&self) -> TextRange {
self.range
}
}
impl Ranged for crate::generic::ExprYieldFrom<TextRange> {
fn range(&self) -> TextRange {
self.range
}
}
impl Ranged for crate::generic::ExprCompare<TextRange> {
fn range(&self) -> TextRange {
self.range
}
}
impl Ranged for crate::generic::ExprCall<TextRange> {
fn range(&self) -> TextRange {
self.range
}
}
impl Ranged for crate::generic::ExprFormattedValue<TextRange> {
fn range(&self) -> TextRange {
self.range
}
}
impl Ranged for crate::generic::ExprJoinedStr<TextRange> {
fn range(&self) -> TextRange {
self.range
}
}
impl Ranged for crate::generic::ExprConstant<TextRange> {
fn range(&self) -> TextRange {
self.range
}
}
impl Ranged for crate::generic::ExprAttribute<TextRange> {
fn range(&self) -> TextRange {
self.range
}
}
impl Ranged for crate::generic::ExprSubscript<TextRange> {
fn range(&self) -> TextRange {
self.range
}
}
impl Ranged for crate::generic::ExprStarred<TextRange> {
fn range(&self) -> TextRange {
self.range
}
}
impl Ranged for crate::generic::ExprName<TextRange> {
fn range(&self) -> TextRange {
self.range
}
}
impl Ranged for crate::generic::ExprList<TextRange> {
fn range(&self) -> TextRange {
self.range
}
}
impl Ranged for crate::generic::ExprTuple<TextRange> {
fn range(&self) -> TextRange {
self.range
}
}
impl Ranged for crate::generic::ExprSlice<TextRange> {
fn range(&self) -> TextRange { fn range(&self) -> TextRange {
self.range self.range
} }
} }
#[cfg(feature = "more-attributes")] #[cfg(feature = "more-attributes")]
impl Ranged for crate::generic::Comprehension<TextRange> { impl Ranged for crate::generic::Comprehension<TextRange> {
fn range(&self) -> TextRange { fn range(&self) -> TextRange {
self.range self.range
} }
} }
impl Ranged for crate::generic::ExcepthandlerExceptHandler<TextRange> {
impl Ranged for crate::generic::Excepthandler<TextRange> {
fn range(&self) -> TextRange { fn range(&self) -> TextRange {
self.range self.range
} }
} }
#[cfg(feature = "more-attributes")] #[cfg(feature = "more-attributes")]
impl Ranged for crate::generic::Arguments<TextRange> { impl Ranged for crate::generic::Arguments<TextRange> {
fn range(&self) -> TextRange { fn range(&self) -> TextRange {
self.range self.range
} }
} }
impl Ranged for crate::generic::Arg<TextRange> { impl Ranged for crate::generic::Arg<TextRange> {
fn range(&self) -> TextRange { fn range(&self) -> TextRange {
self.range self.range
} }
} }
impl Ranged for crate::generic::Keyword<TextRange> { impl Ranged for crate::generic::Keyword<TextRange> {
fn range(&self) -> TextRange { fn range(&self) -> TextRange {
self.range self.range
} }
} }
impl Ranged for crate::generic::Alias<TextRange> { impl Ranged for crate::generic::Alias<TextRange> {
fn range(&self) -> TextRange { fn range(&self) -> TextRange {
self.range self.range
} }
} }
#[cfg(feature = "more-attributes")] #[cfg(feature = "more-attributes")]
impl Ranged for crate::generic::Withitem<TextRange> { impl Ranged for crate::generic::Withitem<TextRange> {
fn range(&self) -> TextRange { fn range(&self) -> TextRange {
self.range self.range
} }
} }
#[cfg(feature = "more-attributes")] #[cfg(feature = "more-attributes")]
impl Ranged for crate::generic::MatchCase<TextRange> { impl Ranged for crate::generic::MatchCase<TextRange> {
fn range(&self) -> TextRange { fn range(&self) -> TextRange {
self.range self.range
} }
} }
impl Ranged for crate::generic::PatternMatchValue<TextRange> {
impl Ranged for crate::generic::Pattern<TextRange> { fn range(&self) -> TextRange {
self.range
}
}
impl Ranged for crate::generic::PatternMatchSingleton<TextRange> {
fn range(&self) -> TextRange {
self.range
}
}
impl Ranged for crate::generic::PatternMatchSequence<TextRange> {
fn range(&self) -> TextRange {
self.range
}
}
impl Ranged for crate::generic::PatternMatchMapping<TextRange> {
fn range(&self) -> TextRange {
self.range
}
}
impl Ranged for crate::generic::PatternMatchClass<TextRange> {
fn range(&self) -> TextRange {
self.range
}
}
impl Ranged for crate::generic::PatternMatchStar<TextRange> {
fn range(&self) -> TextRange {
self.range
}
}
impl Ranged for crate::generic::PatternMatchAs<TextRange> {
fn range(&self) -> TextRange {
self.range
}
}
impl Ranged for crate::generic::PatternMatchOr<TextRange> {
fn range(&self) -> TextRange { fn range(&self) -> TextRange {
self.range self.range
} }
} }
#[cfg(feature = "more-attributes")] #[cfg(feature = "more-attributes")]
impl Ranged for crate::generic::TypeIgnoreTypeIgnore<TextRange> {
impl Ranged for crate::generic::TypeIgnore<TextRange> {
fn range(&self) -> TextRange { fn range(&self) -> TextRange {
self.range self.range
} }

View file

@ -6,7 +6,7 @@ pub trait Visitor<R = crate::text_size::TextRange> {
self.generic_visit_stmt(node) self.generic_visit_stmt(node)
} }
fn generic_visit_stmt(&mut self, node: Stmt<R>) { fn generic_visit_stmt(&mut self, node: Stmt<R>) {
match node.node { match node {
Stmt::FunctionDef(data) => self.visit_stmt_FunctionDef(data), Stmt::FunctionDef(data) => self.visit_stmt_FunctionDef(data),
Stmt::AsyncFunctionDef(data) => self.visit_stmt_AsyncFunctionDef(data), Stmt::AsyncFunctionDef(data) => self.visit_stmt_AsyncFunctionDef(data),
Stmt::ClassDef(data) => self.visit_stmt_ClassDef(data), Stmt::ClassDef(data) => self.visit_stmt_ClassDef(data),
@ -345,7 +345,7 @@ pub trait Visitor<R = crate::text_size::TextRange> {
self.generic_visit_expr(node) self.generic_visit_expr(node)
} }
fn generic_visit_expr(&mut self, node: Expr<R>) { fn generic_visit_expr(&mut self, node: Expr<R>) {
match node.node { match node {
Expr::BoolOp(data) => self.visit_expr_BoolOp(data), Expr::BoolOp(data) => self.visit_expr_BoolOp(data),
Expr::NamedExpr(data) => self.visit_expr_NamedExpr(data), Expr::NamedExpr(data) => self.visit_expr_NamedExpr(data),
Expr::BinOp(data) => self.visit_expr_BinOp(data), Expr::BinOp(data) => self.visit_expr_BinOp(data),
@ -689,7 +689,7 @@ pub trait Visitor<R = crate::text_size::TextRange> {
self.generic_visit_excepthandler(node) self.generic_visit_excepthandler(node)
} }
fn generic_visit_excepthandler(&mut self, node: Excepthandler<R>) { fn generic_visit_excepthandler(&mut self, node: Excepthandler<R>) {
match node.node { match node {
Excepthandler::ExceptHandler(data) => self.visit_excepthandler_ExceptHandler(data), Excepthandler::ExceptHandler(data) => self.visit_excepthandler_ExceptHandler(data),
} }
} }
@ -732,7 +732,7 @@ pub trait Visitor<R = crate::text_size::TextRange> {
self.generic_visit_pattern(node) self.generic_visit_pattern(node)
} }
fn generic_visit_pattern(&mut self, node: Pattern<R>) { fn generic_visit_pattern(&mut self, node: Pattern<R>) {
match node.node { match node {
Pattern::MatchValue(data) => self.visit_pattern_MatchValue(data), Pattern::MatchValue(data) => self.visit_pattern_MatchValue(data),
Pattern::MatchSingleton(data) => self.visit_pattern_MatchSingleton(data), Pattern::MatchSingleton(data) => self.visit_pattern_MatchSingleton(data),
Pattern::MatchSequence(data) => self.visit_pattern_MatchSequence(data), Pattern::MatchSequence(data) => self.visit_pattern_MatchSequence(data),

View file

@ -1,6 +1,5 @@
use crate::ranged::Ranged;
use crate::text_size::TextRange; use crate::text_size::TextRange;
use crate::{Constant, Excepthandler, Expr, Pattern, Stmt}; use crate::{Constant, Excepthandler, Expr, Pattern, Ranged, Stmt};
impl<R> Expr<R> { impl<R> Expr<R> {
/// Returns a short name for the node suitable for use in error messages. /// Returns a short name for the node suitable for use in error messages.
@ -41,10 +40,7 @@ impl<R> Expr<R> {
Expr::Starred { .. } => "starred", Expr::Starred { .. } => "starred",
Expr::Slice { .. } => "slice", Expr::Slice { .. } => "slice",
Expr::JoinedStr(crate::ExprJoinedStr { values, .. }) => { Expr::JoinedStr(crate::ExprJoinedStr { values, .. }) => {
if values if values.iter().any(|e| e.is_joined_str_expr()) {
.iter()
.any(|e| matches!(e.node, Expr::JoinedStr { .. }))
{
"f-string expression" "f-string expression"
} else { } else {
"literal" "literal"

View file

@ -1,7 +1,7 @@
mod builtin; mod builtin;
#[cfg(feature = "fold")] #[cfg(feature = "fold")]
mod fold_helpers; mod fold_helpers;
pub mod generic { mod generic {
#![allow(clippy::derive_partial_eq_without_eq)] #![allow(clippy::derive_partial_eq_without_eq)]
pub use crate::builtin::*; pub use crate::builtin::*;
@ -18,7 +18,7 @@ pub use builtin::*;
pub use generic::*; pub use generic::*;
pub use rustpython_parser_core::{text_size, ConversionFlag}; pub use rustpython_parser_core::{text_size, ConversionFlag};
pub type Suite<U = ()> = Vec<Stmt<U>>; pub type Suite<R = TextRange> = Vec<Stmt<R>>;
#[cfg(feature = "fold")] #[cfg(feature = "fold")]
pub mod fold { pub mod fold {
@ -41,8 +41,21 @@ pub use rustpython_parser_core::source_code;
#[cfg(feature = "visitor")] #[cfg(feature = "visitor")]
pub use visitor::Visitor; pub use visitor::Visitor;
pub trait Ranged {
fn range(&self) -> TextRange;
fn start(&self) -> TextSize {
self.range().start()
}
fn end(&self) -> TextSize {
self.range().end()
}
}
#[cfg(feature = "constant-optimization")] #[cfg(feature = "constant-optimization")]
mod optimizer; mod optimizer;
#[cfg(feature = "constant-optimization")] #[cfg(feature = "constant-optimization")]
pub use optimizer::ConstantOptimizer; pub use optimizer::ConstantOptimizer;
use rustpython_parser_core::text_size::{TextRange, TextSize};

View file

@ -20,19 +20,16 @@ impl<U> crate::fold::Fold<U> for ConstantOptimizer {
Ok(user) Ok(user)
} }
fn fold_expr(&mut self, node: crate::Expr<U>) -> Result<crate::Expr<U>, Self::Error> { fn fold_expr(&mut self, node: crate::Expr<U>) -> Result<crate::Expr<U>, Self::Error> {
match node.node { match node {
crate::Expr::Tuple(crate::ExprTuple { elts, ctx, range }) => { crate::Expr::Tuple(crate::ExprTuple { elts, ctx, range }) => {
let elts = elts let elts = elts
.into_iter() .into_iter()
.map(|x| self.fold_expr(x)) .map(|x| self.fold_expr(x))
.collect::<Result<Vec<_>, _>>()?; .collect::<Result<Vec<_>, _>>()?;
let expr = if elts let expr = if elts.iter().all(|e| e.is_constant_expr()) {
.iter()
.all(|e| matches!(e.node, crate::Expr::Constant { .. }))
{
let tuple = elts let tuple = elts
.into_iter() .into_iter()
.map(|e| match e.node { .map(|e| match e {
crate::Expr::Constant(crate::ExprConstant { value, .. }) => value, crate::Expr::Constant(crate::ExprConstant { value, .. }) => value,
_ => unreachable!(), _ => unreachable!(),
}) })
@ -55,7 +52,6 @@ impl<U> crate::fold::Fold<U> for ConstantOptimizer {
#[cfg(test)] #[cfg(test)]
mod tests { mod tests {
use num_bigint::BigInt; use num_bigint::BigInt;
use rustpython_parser_core::text_size::TextRange;
#[cfg(feature = "constant-optimization")] #[cfg(feature = "constant-optimization")]
#[test] #[test]
@ -63,8 +59,6 @@ mod tests {
use crate::{fold::Fold, *}; use crate::{fold::Fold, *};
let range = TextRange::default(); let range = TextRange::default();
#[allow(clippy::let_unit_value)]
let custom = ();
let ast = ExprTuple { let ast = ExprTuple {
ctx: ExprContext::Load, ctx: ExprContext::Load,
elts: vec![ elts: vec![
@ -72,12 +66,14 @@ mod tests {
value: BigInt::from(1).into(), value: BigInt::from(1).into(),
kind: None, kind: None,
range, range,
}, }
.into(),
ExprConstant { ExprConstant {
value: BigInt::from(2).into(), value: BigInt::from(2).into(),
kind: None, kind: None,
range, range,
}, }
.into(),
ExprTuple { ExprTuple {
ctx: ExprContext::Load, ctx: ExprContext::Load,
elts: vec![ elts: vec![
@ -101,12 +97,13 @@ mod tests {
.into(), .into(),
], ],
range, range,
}, }
.into(),
], ],
range, range,
}; };
let new_ast = ConstantOptimizer::new() let new_ast = ConstantOptimizer::new()
.fold_expr(ast) .fold_expr(ast.into())
.unwrap_or_else(|e| match e {}); .unwrap_or_else(|e| match e {});
assert_eq!( assert_eq!(
new_ast, new_ast,

View file

@ -1,16 +1,4 @@
use crate::text_size::{TextRange, TextSize}; use crate::text_size::TextRange;
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::*; pub use crate::builtin::*;
include!("gen/ranged.rs"); include!("gen/ranged.rs");

View file

@ -71,7 +71,7 @@ impl<'a> Unparser<'a> {
ret ret
}}; }};
} }
match &ast.node { match &ast {
Expr::BoolOp(crate::ExprBoolOp { Expr::BoolOp(crate::ExprBoolOp {
op, op,
values, values,
@ -330,13 +330,13 @@ impl<'a> Unparser<'a> {
} }
for kw in keywords { for kw in keywords {
self.p_delim(&mut first, ", ")?; self.p_delim(&mut first, ", ")?;
if let Some(arg) = &kw.node.arg { if let Some(arg) = &kw.arg {
self.p_id(arg)?; self.p_id(arg)?;
self.p("=")?; self.p("=")?;
} else { } else {
self.p("**")?; self.p("**")?;
} }
self.unparse_expr(&kw.node.value, precedence::TEST)?; self.unparse_expr(&kw.value, precedence::TEST)?;
} }
} }
self.p(")")?; self.p(")")?;
@ -376,7 +376,7 @@ impl<'a> Unparser<'a> {
let period = if let Expr::Constant(crate::ExprConstant { let period = if let Expr::Constant(crate::ExprConstant {
value: Constant::Int(_), value: Constant::Int(_),
.. ..
}) = &value.node }) = value.as_ref()
{ {
" ." " ."
} else { } else {
@ -388,10 +388,10 @@ impl<'a> Unparser<'a> {
Expr::Subscript(crate::ExprSubscript { value, slice, .. }) => { Expr::Subscript(crate::ExprSubscript { value, slice, .. }) => {
self.unparse_expr(value, precedence::ATOM)?; self.unparse_expr(value, precedence::ATOM)?;
let mut lvl = precedence::TUPLE; let mut lvl = precedence::TUPLE;
if let Expr::Tuple(crate::ExprTuple { elts, .. }) = &slice.node { if let Expr::Tuple(crate::ExprTuple { elts, .. }) = slice.as_ref() {
if elts if elts
.iter() .iter()
.any(|expr| matches!(expr.node, Expr::Starred { .. })) .any(|expr| expr.is_starred_expr())
{ {
lvl += 1 lvl += 1
} }
@ -487,8 +487,8 @@ impl<'a> Unparser<'a> {
Ok(()) Ok(())
} }
fn unparse_arg<U>(&mut self, arg: &Arg<U>) -> fmt::Result { fn unparse_arg<U>(&mut self, arg: &Arg<U>) -> fmt::Result {
self.p_id(&arg.node.arg)?; self.p_id(&arg.arg)?;
if let Some(ann) = &arg.node.annotation { if let Some(ann) = &arg.annotation {
write!(self, ": {}", **ann)?; write!(self, ": {}", **ann)?;
} }
Ok(()) Ok(())
@ -554,7 +554,7 @@ impl<'a> Unparser<'a> {
} }
fn unparse_fstring_elem<U>(&mut self, expr: &Expr<U>, is_spec: bool) -> fmt::Result { fn unparse_fstring_elem<U>(&mut self, expr: &Expr<U>, is_spec: bool) -> fmt::Result {
match &expr.node { match &expr {
Expr::Constant(crate::ExprConstant { value, .. }) => { Expr::Constant(crate::ExprConstant { value, .. }) => {
if let Constant::Str(s) = value { if let Constant::Str(s) = value {
self.unparse_fstring_str(s) self.unparse_fstring_str(s)

View file

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

View file

@ -12,6 +12,7 @@ edition = "2021"
default = ["location"] default = ["location"]
location = ["rustpython-ast/location"] location = ["rustpython-ast/location"]
serde = ["dep:serde", "rustpython-parser-core/serde"] serde = ["dep:serde", "rustpython-parser-core/serde"]
more-attributes = ["rustpython-ast/more-attributes"]
[build-dependencies] [build-dependencies]
anyhow = { workspace = true } anyhow = { workspace = true }

View file

@ -1,71 +1,54 @@
use crate::ast::{self, Expr, ExprContext, ExprKind}; use crate::ast::{self, Expr, ExprContext};
pub(crate) fn set_context(expr: Expr, ctx: ExprContext) -> Expr { pub(crate) fn set_context(expr: Expr, ctx: ExprContext) -> Expr {
match expr.node { match expr {
ExprKind::Name(ast::ExprName { id, range, .. }) => Expr { Expr::Name(ast::ExprName { id, range, .. }) => ast::ExprName { id, ctx, range }.into(),
node: ast::ExprName { id, ctx, range }.into(), Expr::Tuple(ast::ExprTuple { elts, range, .. }) => ast::ExprTuple {
..expr elts: elts
}, .into_iter()
ExprKind::Tuple(ast::ExprTuple { elts, range, .. }) => Expr { .map(|elt| set_context(elt, ctx.clone()))
node: ast::ExprTuple { .collect(),
elts: elts range,
.into_iter() ctx,
.map(|elt| set_context(elt, ctx.clone())) }
.collect(), .into(),
range,
ctx, Expr::List(ast::ExprList { elts, range, .. }) => ast::ExprList {
} elts: elts
.into(), .into_iter()
..expr .map(|elt| set_context(elt, ctx.clone()))
}, .collect(),
ExprKind::List(ast::ExprList { elts, range, .. }) => Expr { range,
node: ast::ExprList { ctx,
elts: elts }
.into_iter() .into(),
.map(|elt| set_context(elt, ctx.clone())) Expr::Attribute(ast::ExprAttribute {
.collect(),
range,
ctx,
}
.into(),
..expr
},
ExprKind::Attribute(ast::ExprAttribute {
value, attr, range, .. value, attr, range, ..
}) => Expr { }) => ast::ExprAttribute {
node: ast::ExprAttribute { value,
value, attr,
attr, range,
range, ctx,
ctx, }
} .into(),
.into(), Expr::Subscript(ast::ExprSubscript {
..expr
},
ExprKind::Subscript(ast::ExprSubscript {
value, value,
slice, slice,
range, range,
.. ..
}) => Expr { }) => ast::ExprSubscript {
node: ast::ExprSubscript { value,
value, slice,
slice, range,
range, ctx,
ctx, }
} .into(),
.into(), Expr::Starred(ast::ExprStarred { value, range, .. }) => ast::ExprStarred {
..expr value: Box::new(set_context(*value, ctx.clone())),
}, range,
ExprKind::Starred(ast::ExprStarred { value, range, .. }) => Expr { ctx,
node: ast::ExprStarred { }
value: Box::new(set_context(*value, ctx.clone())), .into(),
range,
ctx,
}
.into(),
..expr
},
_ => expr, _ => expr,
} }
} }

View file

@ -21,7 +21,7 @@ type ParameterDef = (ast::Arg, Option<ast::Expr>);
pub(crate) fn validate_arguments( pub(crate) fn validate_arguments(
arguments: ast::Arguments, arguments: ast::Arguments,
) -> Result<ast::Arguments, LexicalError> { ) -> Result<ast::Arguments, LexicalError> {
let mut all_args: Vec<&ast::Attributed<ast::ArgData>> = vec![]; let mut all_args: Vec<&ast::Arg> = vec![];
all_args.extend(arguments.posonlyargs.iter()); all_args.extend(arguments.posonlyargs.iter());
all_args.extend(arguments.args.iter()); all_args.extend(arguments.args.iter());
@ -118,11 +118,11 @@ pub(crate) fn parse_args(func_args: Vec<FunctionArgument>) -> Result<ArgumentLis
double_starred = true; double_starred = true;
} }
keywords.push(ast::Keyword::new(ast::KeywordData { keywords.push(ast::Keyword {
arg: name.map(ast::Identifier::new), arg: name.map(ast::Identifier::new),
value, value,
range: TextRange::new(start, end), range: TextRange::new(start, end),
})); });
} }
None => { None => {
// Positional arguments mustn't follow keyword arguments. // Positional arguments mustn't follow keyword arguments.
@ -148,8 +148,8 @@ pub(crate) fn parse_args(func_args: Vec<FunctionArgument>) -> Result<ArgumentLis
} }
// Check if an expression is a starred expression. // Check if an expression is a starred expression.
fn is_starred(exp: &ast::Expr) -> bool { const fn is_starred(exp: &ast::Expr) -> bool {
matches!(exp.node, ast::ExprKind::Starred { .. }) exp.is_starred_expr()
} }
#[cfg(test)] #[cfg(test)]

View file

@ -318,6 +318,20 @@ impl ParseErrorType {
} }
} }
#[cfg(feature = "more-attributes")]
#[inline(always)]
pub(super) fn range_or_phantom<T: Into<crate::text_size::TextRange>>(
range: T,
) -> crate::text_size::TextRange {
range.into()
}
#[cfg(not(feature = "more-attributes"))]
#[inline(always)]
pub(super) fn range_or_phantom<T, R>(_: T) -> std::marker::PhantomData<R> {
std::marker::PhantomData::<R>
}
#[cfg(test)] #[cfg(test)]
mod tests { mod tests {
use super::*; use super::*;

View file

@ -4,11 +4,11 @@
// 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::ranged::{self as ast, Ranged}, ast::{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,
string::parse_strings, string::parse_strings, parser::range_or_phantom,
token::{self, StringKind}, token::{self, StringKind},
text_size::TextSize, text_size::TextSize,
}; };
@ -20,9 +20,9 @@ grammar;
// For each public entry point, a full parse table is generated. // For each public entry point, a full parse table is generated.
// By having only a single pub function, we reduce this to one. // By having only a single pub function, we reduce this to one.
pub Top: ast::Mod = { pub Top: ast::Mod = {
<start:@L> StartModule <body:Program> <end:@R> => ast::ModModule { body, type_ignores: vec![], range: (start..end).into() }.into(), <start:@L> StartModule <body:Program> <end:@R> => ast::ModModule { body, type_ignores: vec![], range: range_or_phantom(start..end) }.into(),
<start:@L> StartInteractive <body:Program> <end:@R> => ast::ModInteractive { body, range: (start..end).into() }.into(), <start:@L> StartInteractive <body:Program> <end:@R> => ast::ModInteractive { body, range: range_or_phantom(start..end) }.into(),
<start:@L> StartExpression <body:TestList> ("\n")* <end:@R> => ast::ModExpression { body: Box::new(body), range: (start..end).into() }.into() <start:@L> StartExpression <body:TestList> ("\n")* <end:@R> => ast::ModExpression { body: Box::new(body), range: range_or_phantom(start..end) }.into()
}; };
Program: ast::Suite = { Program: ast::Suite = {
@ -68,15 +68,13 @@ SmallStatement: ast::Stmt = {
PassStatement: ast::Stmt = { PassStatement: ast::Stmt = {
<location:@L> "pass" <end_location:@R> => { <location:@L> "pass" <end_location:@R> => {
ast::Stmt::new( ast::Stmt::Pass(ast::StmtPass { range: (location..end_location).into() })
ast::StmtKind::Pass(ast::StmtPass { range: (location..end_location).into() }),
)
}, },
}; };
DelStatement: ast::Stmt = { DelStatement: ast::Stmt = {
<location:@L> "del" <targets:ExpressionList2> <end_location:@R> => { <location:@L> "del" <targets:ExpressionList2> <end_location:@R> => {
ast::Stmt::new( ast::Stmt::Delete(
ast::StmtDelete { targets: targets.into_iter().map(|expr| set_context(expr, ast::ExprContext::Del)).collect(), range: (location..end_location).into() } ast::StmtDelete { targets: targets.into_iter().map(|expr| set_context(expr, ast::ExprContext::Del)).collect(), range: (location..end_location).into() }
) )
}, },
@ -86,7 +84,7 @@ ExpressionStatement: ast::Stmt = {
<location:@L> <expression:TestOrStarExprList> <suffix:AssignSuffix*> <end_location:@R> => { <location:@L> <expression:TestOrStarExprList> <suffix:AssignSuffix*> <end_location:@R> => {
// Just an expression, no assignment: // Just an expression, no assignment:
if suffix.is_empty() { if suffix.is_empty() {
ast::Stmt::new( ast::Stmt::Expr(
ast::StmtExpr { value: Box::new(expression), range: (location..end_location).into() } ast::StmtExpr { value: Box::new(expression), range: (location..end_location).into() }
) )
} else { } else {
@ -99,13 +97,13 @@ ExpressionStatement: ast::Stmt = {
let value = Box::new(values.into_iter().next().unwrap()); let value = Box::new(values.into_iter().next().unwrap());
ast::Stmt::new( ast::Stmt::Assign(
ast::StmtAssign { targets, value, type_comment: None, range: (location..end_location).into() } ast::StmtAssign { targets, value, type_comment: None, range: (location..end_location).into() }
) )
} }
}, },
<location:@L> <target:TestOrStarExprList> <op:AugAssign> <rhs:TestListOrYieldExpr> <end_location:@R> => { <location:@L> <target:TestOrStarExprList> <op:AugAssign> <rhs:TestListOrYieldExpr> <end_location:@R> => {
ast::Stmt::new( ast::Stmt::AugAssign(
ast::StmtAugAssign { ast::StmtAugAssign {
target: Box::new(set_context(target, ast::ExprContext::Store)), target: Box::new(set_context(target, ast::ExprContext::Store)),
op, op,
@ -115,8 +113,8 @@ ExpressionStatement: ast::Stmt = {
) )
}, },
<location:@L> <target:Test<"all">> ":" <annotation:Test<"all">> <rhs:AssignSuffix?> <end_location:@R> => { <location:@L> <target:Test<"all">> ":" <annotation:Test<"all">> <rhs:AssignSuffix?> <end_location:@R> => {
let simple = matches!(target.node, ast::ExprKind::Name { .. }); let simple = target.is_name_expr();
ast::Stmt::new( ast::Stmt::AnnAssign(
ast::StmtAnnAssign { ast::StmtAnnAssign {
target: Box::new(set_context(target, ast::ExprContext::Store)), target: Box::new(set_context(target, ast::ExprContext::Store)),
annotation: Box::new(annotation), annotation: Box::new(annotation),
@ -176,22 +174,19 @@ AugAssign: ast::Operator = {
FlowStatement: ast::Stmt = { FlowStatement: ast::Stmt = {
<location:@L> "break" <end_location:@R> => { <location:@L> "break" <end_location:@R> => {
ast::Stmt::new(
ast::StmtKind::Break(ast::StmtBreak { range: (location..end_location).into() }), ast::Stmt::Break(ast::StmtBreak { range: (location..end_location).into() })
)
}, },
<location:@L> "continue" <end_location:@R> => { <location:@L> "continue" <end_location:@R> => {
ast::Stmt::new( ast::Stmt::Continue(ast::StmtContinue { range: (location..end_location).into() })
ast::StmtKind::Continue(ast::StmtContinue { range: (location..end_location).into() }),
)
}, },
<location:@L> "return" <value:TestList?> <end_location:@R> => { <location:@L> "return" <value:TestList?> <end_location:@R> => {
ast::Stmt::new( ast::Stmt::Return(
ast::StmtReturn { value: value.map(Box::new), range: (location..end_location).into() } ast::StmtReturn { value: value.map(Box::new), range: (location..end_location).into() }
) )
}, },
<location:@L> <expression:YieldExpr> <end_location:@R> => { <location:@L> <expression:YieldExpr> <end_location:@R> => {
ast::Stmt::new( ast::Stmt::Expr(
ast::StmtExpr { value: Box::new(expression), range: (location..end_location).into() } ast::StmtExpr { value: Box::new(expression), range: (location..end_location).into() }
) )
}, },
@ -200,12 +195,12 @@ FlowStatement: ast::Stmt = {
RaiseStatement: ast::Stmt = { RaiseStatement: ast::Stmt = {
<location:@L> "raise" <end_location:@R> => { <location:@L> "raise" <end_location:@R> => {
ast::Stmt::new( ast::Stmt::Raise(
ast::StmtRaise { exc: None, cause: None, range: (location..end_location).into() } ast::StmtRaise { exc: None, cause: None, range: (location..end_location).into() }
) )
}, },
<location:@L> "raise" <t:Test<"all">> <c:("from" Test<"all">)?> <end_location:@R> => { <location:@L> "raise" <t:Test<"all">> <c:("from" Test<"all">)?> <end_location:@R> => {
ast::Stmt::new( ast::Stmt::Raise(
ast::StmtRaise { exc: Some(Box::new(t)), cause: c.map(|x| Box::new(x.1)), range: (location..end_location).into() } ast::StmtRaise { exc: Some(Box::new(t)), cause: c.map(|x| Box::new(x.1)), range: (location..end_location).into() }
) )
}, },
@ -213,13 +208,13 @@ RaiseStatement: ast::Stmt = {
ImportStatement: ast::Stmt = { ImportStatement: ast::Stmt = {
<location:@L> "import" <names: OneOrMore<ImportAsAlias<DottedName>>> <end_location:@R> => { <location:@L> "import" <names: OneOrMore<ImportAsAlias<DottedName>>> <end_location:@R> => {
ast::Stmt::new( ast::Stmt::Import(
ast::StmtImport { names, range: (location..end_location).into() } ast::StmtImport { names, range: (location..end_location).into() }
) )
}, },
<location:@L> "from" <source:ImportFromLocation> "import" <names: ImportAsNames> <end_location:@R> => { <location:@L> "from" <source:ImportFromLocation> "import" <names: ImportAsNames> <end_location:@R> => {
let (level, module) = source; let (level, module) = source;
ast::Stmt::new( ast::Stmt::ImportFrom(
ast::StmtImportFrom { ast::StmtImportFrom {
level, level,
module, module,
@ -249,14 +244,14 @@ ImportAsNames: Vec<ast::Alias> = {
<location:@L> "(" <i:OneOrMore<ImportAsAlias<Identifier>>> ","? ")" <end_location:@R> => i, <location:@L> "(" <i:OneOrMore<ImportAsAlias<Identifier>>> ","? ")" <end_location:@R> => i,
<location:@L> "*" <end_location:@R> => { <location:@L> "*" <end_location:@R> => {
// Star import all // Star import all
vec![ast::Alias::new(ast::AliasData { name: ast::Identifier::new("*"), asname: None, range: (location..end_location).into() })] vec![ast::Alias { name: ast::Identifier::new("*"), asname: None, range: (location..end_location).into() }]
}, },
}; };
#[inline] #[inline]
ImportAsAlias<I>: ast::Alias = { ImportAsAlias<I>: ast::Alias = {
<location:@L> <name:I> <a: ("as" Identifier)?> <end_location:@R> => ast::Alias::new(ast::AliasData { name, asname: a.map(|a| a.1), range: (location..end_location).into() }), <location:@L> <name:I> <a: ("as" Identifier)?> <end_location:@R> => ast::Alias { name, asname: a.map(|a| a.1), range: (location..end_location).into() },
} }
// A name like abc or abc.def.ghi // A name like abc or abc.def.ghi
@ -274,7 +269,7 @@ DottedName: ast::Identifier = {
GlobalStatement: ast::Stmt = { GlobalStatement: ast::Stmt = {
<location:@L> "global" <names:OneOrMore<Identifier>> <end_location:@R> => { <location:@L> "global" <names:OneOrMore<Identifier>> <end_location:@R> => {
ast::Stmt::new( ast::Stmt::Global(
ast::StmtGlobal { names, range: (location..end_location).into() } ast::StmtGlobal { names, range: (location..end_location).into() }
) )
}, },
@ -282,7 +277,7 @@ GlobalStatement: ast::Stmt = {
NonlocalStatement: ast::Stmt = { NonlocalStatement: ast::Stmt = {
<location:@L> "nonlocal" <names:OneOrMore<Identifier>> <end_location:@R> => { <location:@L> "nonlocal" <names:OneOrMore<Identifier>> <end_location:@R> => {
ast::Stmt::new( ast::Stmt::Nonlocal(
ast::StmtNonlocal { names, range: (location..end_location).into() } ast::StmtNonlocal { names, range: (location..end_location).into() }
) )
}, },
@ -290,7 +285,7 @@ NonlocalStatement: ast::Stmt = {
AssertStatement: ast::Stmt = { AssertStatement: ast::Stmt = {
<location:@L> "assert" <test:Test<"all">> <msg: ("," Test<"all">)?> <end_location:@R> => { <location:@L> "assert" <test:Test<"all">> <msg: ("," Test<"all">)?> <end_location:@R> => {
ast::Stmt::new( ast::Stmt::Assert(
ast::StmtAssert { ast::StmtAssert {
test: Box::new(test), test: Box::new(test),
msg: msg.map(|e| Box::new(e.1)), msg: msg.map(|e| Box::new(e.1)),
@ -320,7 +315,7 @@ MatchStatement: ast::Stmt = {
.last() .last()
.unwrap() .unwrap()
.end(); .end();
ast::Stmt::new( ast::Stmt::Match(
ast::StmtMatch { ast::StmtMatch {
subject: Box::new(subject), subject: Box::new(subject),
cases, cases,
@ -336,7 +331,7 @@ MatchStatement: ast::Stmt = {
.last() .last()
.unwrap() .unwrap()
.end(); .end();
ast::Stmt::new( ast::Stmt::Match(
ast::StmtMatch { ast::StmtMatch {
subject: Box::new(subject), subject: Box::new(subject),
cases, cases,
@ -354,9 +349,9 @@ MatchStatement: ast::Stmt = {
.end(); .end();
let mut subjects = subjects; let mut subjects = subjects;
subjects.insert(0, subject); subjects.insert(0, subject);
ast::Stmt::new( ast::Stmt::Match(
ast::StmtMatch { ast::StmtMatch {
subject: Box::new(ast::Expr::new( subject: Box::new(ast::Expr::Tuple(
ast::ExprTuple { ast::ExprTuple {
elts: subjects, elts: subjects,
ctx: ast::ExprContext::Load, ctx: ast::ExprContext::Load,
@ -376,7 +371,7 @@ MatchCase: ast::MatchCase = {
pattern, pattern,
guard: guard.map(Box::new), guard: guard.map(Box::new),
body, body,
range: (start..end).into() range: range_or_phantom(start..end)
} }
}, },
} }
@ -388,7 +383,7 @@ Guard: ast::Expr = {
} }
Patterns: ast::Pattern = { Patterns: ast::Pattern = {
<location:@L> <pattern:Pattern> "," <end_location:@R> => ast::Pattern::new( <location:@L> <pattern:Pattern> "," <end_location:@R> => ast::Pattern::MatchSequence(
ast::PatternMatchSequence { ast::PatternMatchSequence {
patterns: vec![pattern], patterns: vec![pattern],
range: (location..end_location).into() range: (location..end_location).into()
@ -397,7 +392,7 @@ Patterns: ast::Pattern = {
<location:@L> <pattern:Pattern> "," <patterns:OneOrMore<Pattern>> ","? <end_location:@R> => { <location:@L> <pattern:Pattern> "," <patterns:OneOrMore<Pattern>> ","? <end_location:@R> => {
let mut patterns = patterns; let mut patterns = patterns;
patterns.insert(0, pattern); patterns.insert(0, pattern);
ast::Pattern::new( ast::Pattern::MatchSequence(
ast::PatternMatchSequence { ast::PatternMatchSequence {
patterns, patterns,
range: (location..end_location).into() range: (location..end_location).into()
@ -420,7 +415,7 @@ AsPattern: ast::Pattern = {
location, location,
})? })?
} else { } else {
Ok(ast::Pattern::new( Ok(ast::Pattern::MatchAs(
ast::PatternMatchAs { ast::PatternMatchAs {
pattern: Some(Box::new(pattern)), pattern: Some(Box::new(pattern)),
name: Some(name), name: Some(name),
@ -436,39 +431,25 @@ OrPattern: ast::Pattern = {
<location:@L> <pattern:ClosedPattern> <patterns:("|" <ClosedPattern>)+> <end_location:@R> => { <location:@L> <pattern:ClosedPattern> <patterns:("|" <ClosedPattern>)+> <end_location:@R> => {
let mut patterns = patterns; let mut patterns = patterns;
patterns.insert(0, pattern); patterns.insert(0, pattern);
ast::Pattern::new( ast::Pattern::MatchOr(
ast::PatternMatchOr { patterns, range: (location..end_location).into() } ast::PatternMatchOr { patterns, range: (location..end_location).into() }
) )
} }
} }
ClosedPattern: ast::Pattern = { ClosedPattern: ast::Pattern = {
<node:LiteralPattern> => ast::Pattern::new( <node:LiteralPattern> => node,
node, <node:CapturePattern> => node,
), <node:StarPattern> => node,
<node:CapturePattern> => ast::Pattern::new( <node:ValuePattern> => node,
node, <node:SequencePattern> => node,
), <node:MappingPattern> => node,
<node:StarPattern> => ast::Pattern::new( <node:ClassPattern> => node,
node,
),
<node:ValuePattern> => ast::Pattern::new(
node,
),
<node:SequencePattern> => ast::Pattern::new(
node,
),
<node:MappingPattern> => ast::Pattern::new(
node,
),
<node:ClassPattern> => ast::Pattern::new(
node,
),
} }
SequencePattern: ast::PatternKind = { SequencePattern: ast::Pattern = {
// A single-item tuple is a special case: it's a group pattern, _not_ a sequence pattern. // A single-item tuple is a special case: it's a group pattern, _not_ a sequence pattern.
<location:@L> "(" <pattern:Pattern> ")" <end_location:@R> => pattern.node, <location:@L> "(" <pattern:Pattern> ")" <end_location:@R> => pattern,
<location:@L> "(" ")" <end_location:@R> => ast::PatternMatchSequence { <location:@L> "(" ")" <end_location:@R> => ast::PatternMatchSequence {
patterns: vec![], patterns: vec![],
range: (location..end_location).into() range: (location..end_location).into()
@ -487,7 +468,7 @@ SequencePattern: ast::PatternKind = {
}.into(), }.into(),
} }
StarPattern: ast::PatternKind = { StarPattern: ast::Pattern = {
<location:@L> "*" <name:Identifier> <end_location:@R> => ast::PatternMatchStar { <location:@L> "*" <name:Identifier> <end_location:@R> => ast::PatternMatchStar {
name: if name.as_str() == "_" { None } else { Some(name) }, name: if name.as_str() == "_" { None } else { Some(name) },
range: (location..end_location).into() range: (location..end_location).into()
@ -495,14 +476,14 @@ StarPattern: ast::PatternKind = {
} }
ConstantAtom: ast::Expr = { ConstantAtom: ast::Expr = {
<location:@L> <value:Constant> <end_location:@R> => ast::Expr::new( <location:@L> <value:Constant> <end_location:@R> => ast::Expr::Constant(
ast::ExprConstant { value, kind: None, range: (location..end_location).into() } ast::ExprConstant { value, kind: None, range: (location..end_location).into() }
), ),
} }
ConstantExpr: ast::Expr = { ConstantExpr: ast::Expr = {
ConstantAtom, ConstantAtom,
<location:@L> "-" <operand:ConstantAtom> <end_location:@R> => ast::Expr::new( <location:@L> "-" <operand:ConstantAtom> <end_location:@R> => ast::Expr::UnaryOp(
ast::ExprUnaryOp { ast::ExprUnaryOp {
op: ast::Unaryop::USub, op: ast::Unaryop::USub,
operand: Box::new(operand), operand: Box::new(operand),
@ -512,7 +493,7 @@ ConstantExpr: ast::Expr = {
} }
AddOpExpr: ast::Expr = { AddOpExpr: ast::Expr = {
<location:@L> <left:ConstantExpr> <op:AddOp> <right:ConstantAtom> <end_location:@R> => ast::Expr::new( <location:@L> <left:ConstantExpr> <op:AddOp> <right:ConstantAtom> <end_location:@R> => ast::Expr::BinOp(
ast::ExprBinOp { ast::ExprBinOp {
left: Box::new(left), left: Box::new(left),
op, op,
@ -522,7 +503,7 @@ AddOpExpr: ast::Expr = {
), ),
} }
LiteralPattern: ast::PatternKind = { LiteralPattern: ast::Pattern = {
<location:@L> "None" <end_location:@R> => ast::PatternMatchSingleton { <location:@L> "None" <end_location:@R> => ast::PatternMatchSingleton {
value: ast::Constant::None, value: ast::Constant::None,
range: (location..end_location).into() range: (location..end_location).into()
@ -549,7 +530,7 @@ LiteralPattern: ast::PatternKind = {
}.into()), }.into()),
} }
CapturePattern: ast::PatternKind = { CapturePattern: ast::Pattern = {
<location:@L> <name:Identifier> <end_location:@R> => ast::PatternMatchAs { <location:@L> <name:Identifier> <end_location:@R> => ast::PatternMatchAs {
pattern: None, pattern: None,
name: if name.as_str() == "_" { None } else { Some(name) }, name: if name.as_str() == "_" { None } else { Some(name) },
@ -558,13 +539,13 @@ CapturePattern: ast::PatternKind = {
} }
MatchName: ast::Expr = { MatchName: ast::Expr = {
<location:@L> <name:Identifier> <end_location:@R> => ast::Expr::new( <location:@L> <name:Identifier> <end_location:@R> => ast::Expr::Name(
ast::ExprName { id: name, ctx: ast::ExprContext::Load, range: (location..end_location).into() }, ast::ExprName { id: name, ctx: ast::ExprContext::Load, range: (location..end_location).into() },
), ),
} }
MatchNameOrAttr: ast::Expr = { MatchNameOrAttr: ast::Expr = {
<location:@L> <name:MatchName> "." <attr:Identifier> <end_location:@R> => ast::Expr::new( <location:@L> <name:MatchName> "." <attr:Identifier> <end_location:@R> => ast::Expr::Attribute(
ast::ExprAttribute { ast::ExprAttribute {
value: Box::new(name), value: Box::new(name),
attr, attr,
@ -572,7 +553,7 @@ MatchNameOrAttr: ast::Expr = {
range: (location..end_location).into() range: (location..end_location).into()
}, },
), ),
<location:@L> <e:MatchNameOrAttr> "." <attr:Identifier> <end_location:@R> => ast::Expr::new( <location:@L> <e:MatchNameOrAttr> "." <attr:Identifier> <end_location:@R> => ast::Expr::Attribute(
ast::ExprAttribute { ast::ExprAttribute {
value: Box::new(e), value: Box::new(e),
attr, attr,
@ -582,7 +563,7 @@ MatchNameOrAttr: ast::Expr = {
) )
} }
ValuePattern: ast::PatternKind = { ValuePattern: ast::Pattern = {
<location:@L> <e:MatchNameOrAttr> <end_location:@R> => ast::PatternMatchValue { <location:@L> <e:MatchNameOrAttr> <end_location:@R> => ast::PatternMatchValue {
value: Box::new(e), value: Box::new(e),
range: (location..end_location).into() range: (location..end_location).into()
@ -593,21 +574,21 @@ MappingKey: ast::Expr = {
ConstantExpr, ConstantExpr,
AddOpExpr, AddOpExpr,
MatchNameOrAttr, MatchNameOrAttr,
<location:@L> "None" <end_location:@R> => ast::Expr::new( <location:@L> "None" <end_location:@R> => ast::Expr::Constant(
ast::ExprConstant { ast::ExprConstant {
value: ast::Constant::None, value: ast::Constant::None,
kind: None, kind: None,
range: (location..end_location).into() range: (location..end_location).into()
}, },
), ),
<location:@L> "True" <end_location:@R> => ast::Expr::new( <location:@L> "True" <end_location:@R> => ast::Expr::Constant(
ast::ExprConstant { ast::ExprConstant {
value: true.into(), value: true.into(),
kind: None, kind: None,
range: (location..end_location).into() range: (location..end_location).into()
}, },
), ),
<location:@L> "False" <end_location:@R> => ast::Expr::new( <location:@L> "False" <end_location:@R> => ast::Expr::Constant(
ast::ExprConstant { ast::ExprConstant {
value: false.into(), value: false.into(),
kind: None, kind: None,
@ -621,7 +602,7 @@ MatchMappingEntry: (ast::Expr, ast::Pattern) = {
<k:MappingKey> ":" <v:Pattern> => (k, v), <k:MappingKey> ":" <v:Pattern> => (k, v),
}; };
MappingPattern: ast::PatternKind = { MappingPattern: ast::Pattern = {
<location:@L> "{" "}" <end_location:@R> => { <location:@L> "{" "}" <end_location:@R> => {
return ast::PatternMatchMapping { return ast::PatternMatchMapping {
keys: vec![], keys: vec![],
@ -666,7 +647,7 @@ MatchKeywordEntry: (ast::Identifier, ast::Pattern) = {
<k:Identifier> "=" <v:Pattern> => (k, v), <k:Identifier> "=" <v:Pattern> => (k, v),
}; };
ClassPattern: ast::PatternKind = { ClassPattern: ast::Pattern = {
<location:@L> <e:MatchName> "(" <patterns: OneOrMore<Pattern>> "," <kwds:OneOrMore<MatchKeywordEntry>> ","? ")" <end_location:@R> => { <location:@L> <e:MatchName> "(" <patterns: OneOrMore<Pattern>> "," <kwds:OneOrMore<MatchKeywordEntry>> ","? ")" <end_location:@R> => {
let (kwd_attrs, kwd_patterns) = kwds let (kwd_attrs, kwd_patterns) = kwds
.into_iter() .into_iter()
@ -765,13 +746,13 @@ IfStatement: ast::Stmt = {
.end(); .end();
// handle elif: // handle elif:
for i in s2.into_iter().rev() { for i in s2.into_iter().rev() {
let x = ast::Stmt::new( let x = ast::Stmt::If(
ast::StmtIf { test: Box::new(i.2), body: i.4, orelse: last, range: (i.0..end_location).into() } ast::StmtIf { test: Box::new(i.2), body: i.4, orelse: last, range: (i.0..end_location).into() }
); );
last = vec![x]; last = vec![x];
} }
ast::Stmt::new( ast::Stmt::If(
ast::StmtIf { test: Box::new(test), body, orelse: last, range: (location..end_location).into() } ast::StmtIf { test: Box::new(test), body, orelse: last, range: (location..end_location).into() }
) )
}, },
@ -785,7 +766,7 @@ WhileStatement: ast::Stmt = {
.or_else(|| body.last()) .or_else(|| body.last())
.unwrap() .unwrap()
.end(); .end();
ast::Stmt::new( ast::Stmt::While(
ast::StmtWhile { ast::StmtWhile {
test: Box::new(test), test: Box::new(test),
body, body,
@ -807,12 +788,11 @@ ForStatement: ast::Stmt = {
let target = Box::new(set_context(target, ast::ExprContext::Store)); let target = Box::new(set_context(target, ast::ExprContext::Store));
let iter = Box::new(iter); let iter = Box::new(iter);
let type_comment = None; let type_comment = None;
let node: ast::StmtKind = if is_async.is_some() { if is_async.is_some() {
ast::StmtAsyncFor { target, iter, body, orelse, type_comment, range: (location..end_location).into() }.into() ast::Stmt::AsyncFor(ast::StmtAsyncFor { target, iter, body, orelse, type_comment, range: (location..end_location).into() })
} else { } else {
ast::StmtFor { target, iter, body, orelse, type_comment, range: (location..end_location).into() }.into() ast::Stmt::For(ast::StmtFor { target, iter, body, orelse, type_comment, range: (location..end_location).into() })
}; }
ast::Stmt::new(node)
}, },
}; };
@ -826,7 +806,7 @@ TryStatement: ast::Stmt = {
.or_else(|| orelse.last().map(|last| last.end())) .or_else(|| orelse.last().map(|last| last.end()))
.or_else(|| handlers.last().map(|last| last.end())) .or_else(|| handlers.last().map(|last| last.end()))
.unwrap(); .unwrap();
ast::Stmt::new( ast::Stmt::Try(
ast::StmtTry { ast::StmtTry {
body, body,
handlers, handlers,
@ -845,7 +825,7 @@ TryStatement: ast::Stmt = {
.map(|last| last.end()) .map(|last| last.end())
.or_else(|| handlers.last().map(|last| last.end())) .or_else(|| handlers.last().map(|last| last.end()))
.unwrap(); .unwrap();
ast::Stmt::new( ast::Stmt::TryStar(
ast::StmtTryStar { ast::StmtTryStar {
body, body,
handlers, handlers,
@ -860,7 +840,7 @@ TryStatement: ast::Stmt = {
let orelse = vec![]; let orelse = vec![];
let finalbody = finally.2; let finalbody = finally.2;
let end_location = finalbody.last().unwrap().end(); let end_location = finalbody.last().unwrap().end();
ast::Stmt::new( ast::Stmt::Try(
ast::StmtTry { ast::StmtTry {
body, body,
handlers, handlers,
@ -875,7 +855,7 @@ TryStatement: ast::Stmt = {
ExceptStarClause: ast::Excepthandler = { ExceptStarClause: ast::Excepthandler = {
<location:@L> "except" "*" <typ:Test<"all">> ":" <body:Suite> => { <location:@L> "except" "*" <typ:Test<"all">> ":" <body:Suite> => {
let end_location = body.last().unwrap().end(); let end_location = body.last().unwrap().end();
ast::Excepthandler::new( ast::Excepthandler::ExceptHandler(
ast::ExcepthandlerExceptHandler { ast::ExcepthandlerExceptHandler {
type_: Some(Box::new(typ)), type_: Some(Box::new(typ)),
name: None, name: None,
@ -886,7 +866,7 @@ ExceptStarClause: ast::Excepthandler = {
}, },
<location:@L> "except" "*" <x:(Test<"all"> "as" Identifier)> ":" <body:Suite> => { <location:@L> "except" "*" <x:(Test<"all"> "as" Identifier)> ":" <body:Suite> => {
let end_location = body.last().unwrap().end(); let end_location = body.last().unwrap().end();
ast::Excepthandler::new( ast::Excepthandler::ExceptHandler(
ast::ExcepthandlerExceptHandler { ast::ExcepthandlerExceptHandler {
type_: Some(Box::new(x.0)), type_: Some(Box::new(x.0)),
name: Some(x.2), name: Some(x.2),
@ -901,7 +881,7 @@ ExceptStarClause: ast::Excepthandler = {
ExceptClause: ast::Excepthandler = { ExceptClause: ast::Excepthandler = {
<location:@L> "except" <typ:Test<"all">?> ":" <body:Suite> => { <location:@L> "except" <typ:Test<"all">?> ":" <body:Suite> => {
let end_location = body.last().unwrap().end(); let end_location = body.last().unwrap().end();
ast::Excepthandler::new( ast::Excepthandler::ExceptHandler(
ast::ExcepthandlerExceptHandler { ast::ExcepthandlerExceptHandler {
type_: typ.map(Box::new), type_: typ.map(Box::new),
name: None, name: None,
@ -912,7 +892,7 @@ ExceptClause: ast::Excepthandler = {
}, },
<location:@L> "except" <x:(Test<"all"> "as" Identifier)> ":" <body:Suite> => { <location:@L> "except" <x:(Test<"all"> "as" Identifier)> ":" <body:Suite> => {
let end_location = body.last().unwrap().end(); let end_location = body.last().unwrap().end();
ast::Excepthandler::new( ast::Excepthandler::ExceptHandler(
ast::ExcepthandlerExceptHandler { ast::ExcepthandlerExceptHandler {
type_: Some(Box::new(x.0)), type_: Some(Box::new(x.0)),
name: Some(x.2), name: Some(x.2),
@ -927,12 +907,11 @@ WithStatement: ast::Stmt = {
<location:@L> <is_async:"async"?> "with" <items:WithItems> ":" <body:Suite> => { <location:@L> <is_async:"async"?> "with" <items:WithItems> ":" <body:Suite> => {
let end_location = body.last().unwrap().end(); let end_location = body.last().unwrap().end();
let type_comment = None; let type_comment = None;
let node: ast::StmtKind = if is_async.is_some() { if is_async.is_some() {
ast::StmtAsyncWith { items, body, type_comment, range: (location..end_location).into() }.into() ast::StmtAsyncWith { items, body, type_comment, range: (location..end_location).into() }.into()
} else { } else {
ast::StmtWith { items, body, type_comment, range: (location..end_location).into() }.into() ast::StmtWith { items, body, type_comment, range: (location..end_location).into() }.into()
}; }
ast::Stmt::new(node)
}, },
}; };
@ -950,15 +929,15 @@ WithItems: Vec<ast::Withitem> = {
#[inline] #[inline]
WithItemsNoAs: Vec<ast::Withitem> = { WithItemsNoAs: Vec<ast::Withitem> = {
<location:@L> <all:OneOrMore<Test<"all">>> <end_location:@R> => { <location:@L> <all:OneOrMore<Test<"all">>> <end_location:@R> => {
all.into_iter().map(|context_expr| ast::Withitem { context_expr, optional_vars: None, range: (location..end_location).into() }).collect() all.into_iter().map(|context_expr| ast::Withitem { context_expr, optional_vars: None, range: range_or_phantom(location..end_location) }).collect()
}, },
} }
WithItem<Goal>: ast::Withitem = { WithItem<Goal>: ast::Withitem = {
<location:@L> <context_expr: Test<Goal>> <end_location:@R> if Goal != "as" => ast::Withitem { context_expr, optional_vars: None, range: (location..end_location).into() }, <location:@L> <context_expr: Test<Goal>> <end_location:@R> if Goal != "as" => ast::Withitem { context_expr, optional_vars: None, range: range_or_phantom(location..end_location) },
<location:@L> <context_expr:Test<"all">> "as" <vars:Expression<"all">> <end_location:@R> => { <location:@L> <context_expr:Test<"all">> "as" <vars:Expression<"all">> <end_location:@R> => {
let optional_vars = Some(Box::new(set_context(vars, ast::ExprContext::Store))); let optional_vars = Some(Box::new(set_context(vars, ast::ExprContext::Store)));
ast::Withitem { context_expr, optional_vars, range: (location..end_location).into() } ast::Withitem { context_expr, optional_vars, range: range_or_phantom(location..end_location) }
}, },
}; };
@ -968,12 +947,11 @@ FuncDef: ast::Stmt = {
let returns = r.map(|x| Box::new(x.1)); let returns = r.map(|x| Box::new(x.1));
let end_location = body.last().unwrap().end(); let end_location = body.last().unwrap().end();
let type_comment = None; let type_comment = None;
let node: ast::StmtKind = if is_async.is_some() { if is_async.is_some() {
ast::StmtAsyncFunctionDef { name, args, body, decorator_list, returns, type_comment, range: (location..end_location).into() }.into() ast::StmtAsyncFunctionDef { name, args, body, decorator_list, returns, type_comment, range: (location..end_location).into() }.into()
} else { } else {
ast::StmtFunctionDef { name, args, body, decorator_list, returns, type_comment, range: (location..end_location).into() }.into() ast::StmtFunctionDef { name, args, body, decorator_list, returns, type_comment, range: (location..end_location).into() }.into()
}; }
ast::Stmt::new(node)
}, },
}; };
@ -988,7 +966,7 @@ Parameters: ast::Arguments = {
kw_defaults: vec![], kw_defaults: vec![],
kwarg: None, kwarg: None,
defaults: vec![], defaults: vec![],
range: (location..end_location).into() range: range_or_phantom(location..end_location)
}) })
)?; )?;
@ -1013,7 +991,7 @@ ParameterList<ArgType, StarArgType>: ast::Arguments = {
kwarg, kwarg,
defaults, defaults,
kw_defaults, kw_defaults,
range: (location..end_location).into() range: range_or_phantom(location..end_location)
}) })
}, },
<location:@L> <param1:ParameterDefs<ArgType>> <kw:("," KwargParameter<ArgType>)> ","? <end_location:@R> =>? { <location:@L> <param1:ParameterDefs<ArgType>> <kw:("," KwargParameter<ArgType>)> ","? <end_location:@R> =>? {
@ -1033,7 +1011,7 @@ ParameterList<ArgType, StarArgType>: ast::Arguments = {
kwarg, kwarg,
defaults, defaults,
kw_defaults, kw_defaults,
range: (location..end_location).into() range: range_or_phantom(location..end_location)
}) })
}, },
<location:@L> <params:ParameterListStarArgs<ArgType, StarArgType>> ","? <end_location:@R> => { <location:@L> <params:ParameterListStarArgs<ArgType, StarArgType>> ","? <end_location:@R> => {
@ -1046,7 +1024,7 @@ ParameterList<ArgType, StarArgType>: ast::Arguments = {
kwarg, kwarg,
defaults: vec![], defaults: vec![],
kw_defaults, kw_defaults,
range: (location..end_location).into() range: range_or_phantom(location..end_location)
} }
}, },
<location:@L> <kwarg:KwargParameter<ArgType>> ","? <end_location:@R> => { <location:@L> <kwarg:KwargParameter<ArgType>> ","? <end_location:@R> => {
@ -1058,7 +1036,7 @@ ParameterList<ArgType, StarArgType>: ast::Arguments = {
kwarg, kwarg,
defaults: vec![], defaults: vec![],
kw_defaults: vec![], kw_defaults: vec![],
range: (location..end_location).into() range: range_or_phantom(location..end_location)
} }
}, },
}; };
@ -1080,22 +1058,20 @@ ParameterDef<ArgType>: (ast::Arg, Option<ast::Expr>) = {
}; };
UntypedParameter: ast::Arg = { UntypedParameter: ast::Arg = {
<location:@L> <arg:Identifier> <end_location:@R> => ast::Arg::new( <location:@L> <arg:Identifier> <end_location:@R> => ast::Arg { arg, annotation: None, type_comment: None, range: (location..end_location).into() },
ast::ArgData { arg, annotation: None, type_comment: None, range: (location..end_location).into() },
),
}; };
TypedParameter: ast::Arg = { TypedParameter: ast::Arg = {
<location:@L> <arg:Identifier> <a:(":" Test<"all">)?> <end_location:@R> => { <location:@L> <arg:Identifier> <a:(":" Test<"all">)?> <end_location:@R> => {
let annotation = a.map(|x| Box::new(x.1)); let annotation = a.map(|x| Box::new(x.1));
ast::Arg::new(ast::ArgData { arg, annotation, type_comment: None, range: (location..end_location).into() }) ast::Arg { arg, annotation, type_comment: None, range: (location..end_location).into() }
}, },
}; };
StarTypedParameter: ast::Arg = { StarTypedParameter: ast::Arg = {
<location:@L> <arg:Identifier> <a:(":" TestOrStarExpr)?> <end_location:@R> => { <location:@L> <arg:Identifier> <a:(":" TestOrStarExpr)?> <end_location:@R> => {
let annotation = a.map(|x| Box::new(x.1)); let annotation = a.map(|x| Box::new(x.1));
ast::Arg::new(ast::ArgData { arg, annotation, type_comment: None, range: (location..end_location).into() }) ast::Arg { arg, annotation, type_comment: None, range: (location..end_location).into() }
}, },
}; };
@ -1145,7 +1121,7 @@ ClassDef: ast::Stmt = {
None => (vec![], vec![]), None => (vec![], vec![]),
}; };
let end_location = body.last().unwrap().end(); let end_location = body.last().unwrap().end();
ast::Stmt::new( ast::Stmt::ClassDef(
ast::StmtClassDef { ast::StmtClassDef {
name, name,
bases, bases,
@ -1166,16 +1142,16 @@ Decorator: ast::Expr = {
}; };
YieldExpr: ast::Expr = { YieldExpr: ast::Expr = {
<location:@L> "yield" <value:TestList?> <end_location:@R> => ast::Expr::new( <location:@L> "yield" <value:TestList?> <end_location:@R> => ast::Expr::Yield(
ast::ExprYield { value: value.map(Box::new), range: (location..end_location).into() } ast::ExprYield { value: value.map(Box::new), range: (location..end_location).into() }
), ),
<location:@L> "yield" "from" <e:Test<"all">> <end_location:@R> => ast::Expr::new( <location:@L> "yield" "from" <e:Test<"all">> <end_location:@R> => ast::Expr::YieldFrom(
ast::ExprYieldFrom { value: Box::new(e), range: (location..end_location).into() } ast::ExprYieldFrom { value: Box::new(e), range: (location..end_location).into() }
), ),
}; };
Test<Goal>: ast::Expr = { Test<Goal>: ast::Expr = {
<location:@L> <body:OrTest<"all">> "if" <test:OrTest<"all">> "else" <orelse:Test<"all">> <end_location:@R> => ast::Expr::new( <location:@L> <body:OrTest<"all">> "if" <test:OrTest<"all">> "else" <orelse:Test<"all">> <end_location:@R> => ast::Expr::IfExp(
ast::ExprIfExp { ast::ExprIfExp {
test: Box::new(test), test: Box::new(test),
body: Box::new(body), body: Box::new(body),
@ -1194,9 +1170,9 @@ NamedExpressionTest: ast::Expr = {
NamedExpression: ast::Expr = { NamedExpression: ast::Expr = {
<location:@L> <id:Identifier> <end_location:@R> ":=" <value:Test<"all">> => { <location:@L> <id:Identifier> <end_location:@R> ":=" <value:Test<"all">> => {
ast::Expr::new( ast::Expr::NamedExpr(
ast::ExprNamedExpr { ast::ExprNamedExpr {
target: Box::new(ast::Expr::new( target: Box::new(ast::Expr::Name(
ast::ExprName { id, ctx: ast::ExprContext::Store, range: (location..end_location).into() }, ast::ExprName { id, ctx: ast::ExprContext::Store, range: (location..end_location).into() },
)), )),
range: (location..value.end()).into(), range: (location..value.end()).into(),
@ -1218,12 +1194,12 @@ LambdaDef: ast::Expr = {
kw_defaults: vec![], kw_defaults: vec![],
kwarg: None, kwarg: None,
defaults: vec![], defaults: vec![],
range: (location..end_location).into() range: range_or_phantom(location..end_location)
} }
} }
))?; ))?;
Ok(ast::Expr::new( Ok(ast::Expr::Lambda(
ast::ExprLambda { ast::ExprLambda {
args: Box::new(p), args: Box::new(p),
body: Box::new(body), body: Box::new(body),
@ -1237,7 +1213,7 @@ OrTest<Goal>: ast::Expr = {
<location:@L> <e1:AndTest<"all">> <e2:("or" AndTest<"all">)+> <end_location:@R> => { <location:@L> <e1:AndTest<"all">> <e2:("or" AndTest<"all">)+> <end_location:@R> => {
let mut values = vec![e1]; let mut values = vec![e1];
values.extend(e2.into_iter().map(|e| e.1)); values.extend(e2.into_iter().map(|e| e.1));
ast::Expr::new( ast::Expr::BoolOp(
ast::ExprBoolOp { op: ast::Boolop::Or, values, range: (location..end_location).into() } ast::ExprBoolOp { op: ast::Boolop::Or, values, range: (location..end_location).into() }
) )
}, },
@ -1248,7 +1224,7 @@ AndTest<Goal>: ast::Expr = {
<location:@L> <e1:NotTest<"all">> <e2:("and" NotTest<"all">)+> <end_location:@R> => { <location:@L> <e1:NotTest<"all">> <e2:("and" NotTest<"all">)+> <end_location:@R> => {
let mut values = vec![e1]; let mut values = vec![e1];
values.extend(e2.into_iter().map(|e| e.1)); values.extend(e2.into_iter().map(|e| e.1));
ast::Expr::new( ast::Expr::BoolOp(
ast::ExprBoolOp { op: ast::Boolop::And, values, range: (location..end_location).into() } ast::ExprBoolOp { op: ast::Boolop::And, values, range: (location..end_location).into() }
) )
}, },
@ -1256,7 +1232,7 @@ AndTest<Goal>: ast::Expr = {
}; };
NotTest<Goal>: ast::Expr = { NotTest<Goal>: ast::Expr = {
<location:@L> "not" <e:NotTest<"all">> <end_location:@R> => ast::Expr::new( <location:@L> "not" <e:NotTest<"all">> <end_location:@R> => ast::Expr::UnaryOp(
ast::ExprUnaryOp { operand: Box::new(e), op: ast::Unaryop::Not, range: (location..end_location).into() } ast::ExprUnaryOp { operand: Box::new(e), op: ast::Unaryop::Not, range: (location..end_location).into() }
), ),
Comparison<Goal>, Comparison<Goal>,
@ -1265,7 +1241,7 @@ NotTest<Goal>: ast::Expr = {
Comparison<Goal>: ast::Expr = { Comparison<Goal>: ast::Expr = {
<location:@L> <left:Expression<"all">> <comparisons:(CompOp Expression<"all">)+> <end_location:@R> => { <location:@L> <left:Expression<"all">> <comparisons:(CompOp Expression<"all">)+> <end_location:@R> => {
let (ops, comparators) = comparisons.into_iter().unzip(); let (ops, comparators) = comparisons.into_iter().unzip();
ast::Expr::new( ast::Expr::Compare(
ast::ExprCompare { left: Box::new(left), ops, comparators, range: (location..end_location).into() } ast::ExprCompare { left: Box::new(left), ops, comparators, range: (location..end_location).into() }
) )
}, },
@ -1286,28 +1262,28 @@ CompOp: ast::Cmpop = {
}; };
Expression<Goal>: ast::Expr = { Expression<Goal>: ast::Expr = {
<location:@L> <e1:Expression<"all">> "|" <e2:XorExpression<"all">> <end_location:@R> => ast::Expr::new( <location:@L> <e1:Expression<"all">> "|" <e2:XorExpression<"all">> <end_location:@R> => ast::Expr::BinOp(
ast::ExprBinOp { left: Box::new(e1), op: ast::Operator::BitOr, right: Box::new(e2), range: (location..end_location).into() } ast::ExprBinOp { left: Box::new(e1), op: ast::Operator::BitOr, right: Box::new(e2), range: (location..end_location).into() }
), ),
XorExpression<Goal>, XorExpression<Goal>,
}; };
XorExpression<Goal>: ast::Expr = { XorExpression<Goal>: ast::Expr = {
<location:@L> <e1:XorExpression<"all">> "^" <e2:AndExpression<"all">> <end_location:@R> => ast::Expr::new( <location:@L> <e1:XorExpression<"all">> "^" <e2:AndExpression<"all">> <end_location:@R> => ast::Expr::BinOp(
ast::ExprBinOp { left: Box::new(e1), op: ast::Operator::BitXor, right: Box::new(e2), range: (location..end_location).into() } ast::ExprBinOp { left: Box::new(e1), op: ast::Operator::BitXor, right: Box::new(e2), range: (location..end_location).into() }
), ),
AndExpression<Goal>, AndExpression<Goal>,
}; };
AndExpression<Goal>: ast::Expr = { AndExpression<Goal>: ast::Expr = {
<location:@L> <e1:AndExpression<"all">> "&" <e2:ShiftExpression<"all">> <end_location:@R> => ast::Expr::new( <location:@L> <e1:AndExpression<"all">> "&" <e2:ShiftExpression<"all">> <end_location:@R> => ast::Expr::BinOp(
ast::ExprBinOp { left: Box::new(e1), op: ast::Operator::BitAnd, right: Box::new(e2), range: (location..end_location).into() } ast::ExprBinOp { left: Box::new(e1), op: ast::Operator::BitAnd, right: Box::new(e2), range: (location..end_location).into() }
), ),
ShiftExpression<Goal>, ShiftExpression<Goal>,
}; };
ShiftExpression<Goal>: ast::Expr = { ShiftExpression<Goal>: ast::Expr = {
<location:@L> <e1:ShiftExpression<"all">> <op:ShiftOp> <e2:ArithmeticExpression<"all">> <end_location:@R> => ast::Expr::new( <location:@L> <e1:ShiftExpression<"all">> <op:ShiftOp> <e2:ArithmeticExpression<"all">> <end_location:@R> => ast::Expr::BinOp(
ast::ExprBinOp { left: Box::new(e1), op, right: Box::new(e2), range: (location..end_location).into() } ast::ExprBinOp { left: Box::new(e1), op, right: Box::new(e2), range: (location..end_location).into() }
), ),
ArithmeticExpression<Goal>, ArithmeticExpression<Goal>,
@ -1319,7 +1295,7 @@ ShiftOp: ast::Operator = {
}; };
ArithmeticExpression<Goal>: ast::Expr = { ArithmeticExpression<Goal>: ast::Expr = {
<location:@L> <a:ArithmeticExpression<"all">> <op:AddOp> <b:Term<"all">> <end_location:@R> => ast::Expr::new( <location:@L> <a:ArithmeticExpression<"all">> <op:AddOp> <b:Term<"all">> <end_location:@R> => ast::Expr::BinOp(
ast::ExprBinOp { left: Box::new(a), op, right: Box::new(b), range: (location..end_location).into() } ast::ExprBinOp { left: Box::new(a), op, right: Box::new(b), range: (location..end_location).into() }
), ),
Term<Goal>, Term<Goal>,
@ -1331,7 +1307,7 @@ AddOp: ast::Operator = {
}; };
Term<Goal>: ast::Expr = { Term<Goal>: ast::Expr = {
<location:@L> <a:Term<"all">> <op:MulOp> <b:Factor<"all">> <end_location:@R> => ast::Expr::new( <location:@L> <a:Term<"all">> <op:MulOp> <b:Factor<"all">> <end_location:@R> => ast::Expr::BinOp(
ast::ExprBinOp { left: Box::new(a), op, right: Box::new(b), range: (location..end_location).into() } ast::ExprBinOp { left: Box::new(a), op, right: Box::new(b), range: (location..end_location).into() }
), ),
Factor<Goal>, Factor<Goal>,
@ -1346,7 +1322,7 @@ MulOp: ast::Operator = {
}; };
Factor<Goal>: ast::Expr = { Factor<Goal>: ast::Expr = {
<location:@L> <op:UnaryOp> <e:Factor<"all">> <end_location:@R> => ast::Expr::new( <location:@L> <op:UnaryOp> <e:Factor<"all">> <end_location:@R> => ast::Expr::UnaryOp(
ast::ExprUnaryOp { operand: Box::new(e), op, range: (location..end_location).into() } ast::ExprUnaryOp { operand: Box::new(e), op, range: (location..end_location).into() }
), ),
Power<Goal>, Power<Goal>,
@ -1359,7 +1335,7 @@ UnaryOp: ast::Unaryop = {
}; };
Power<Goal>: ast::Expr = { Power<Goal>: ast::Expr = {
<location:@L> <e:AtomExpr<"all">> "**" <b:Factor<"all">> <end_location:@R> => ast::Expr::new( <location:@L> <e:AtomExpr<"all">> "**" <b:Factor<"all">> <end_location:@R> => ast::Expr::BinOp(
ast::ExprBinOp { left: Box::new(e), op: ast::Operator::Pow, right: Box::new(b), range: (location..end_location).into() } ast::ExprBinOp { left: Box::new(e), op: ast::Operator::Pow, right: Box::new(b), range: (location..end_location).into() }
), ),
AtomExpr<Goal>, AtomExpr<Goal>,
@ -1367,7 +1343,7 @@ Power<Goal>: ast::Expr = {
AtomExpr<Goal>: ast::Expr = { AtomExpr<Goal>: ast::Expr = {
<location:@L> "await" <atom:AtomExpr2<"all">> <end_location:@R> => { <location:@L> "await" <atom:AtomExpr2<"all">> <end_location:@R> => {
ast::Expr::new( ast::Expr::Await(
ast::ExprAwait { value: Box::new(atom), range: (location..end_location).into() } ast::ExprAwait { value: Box::new(atom), range: (location..end_location).into() }
) )
}, },
@ -1377,14 +1353,14 @@ AtomExpr<Goal>: ast::Expr = {
AtomExpr2<Goal>: ast::Expr = { AtomExpr2<Goal>: ast::Expr = {
Atom<Goal>, Atom<Goal>,
<location:@L> <f:AtomExpr2<"all">> "(" <a:ArgumentList> ")" <end_location:@R> => { <location:@L> <f:AtomExpr2<"all">> "(" <a:ArgumentList> ")" <end_location:@R> => {
ast::Expr::new( ast::Expr::Call(
ast::ExprCall { func: Box::new(f), args: a.args, keywords: a.keywords, range: (location..end_location).into() } ast::ExprCall { func: Box::new(f), args: a.args, keywords: a.keywords, range: (location..end_location).into() }
) )
}, },
<location:@L> <e:AtomExpr2<"all">> "[" <s:SubscriptList> "]" <end_location:@R> => ast::Expr::new( <location:@L> <e:AtomExpr2<"all">> "[" <s:SubscriptList> "]" <end_location:@R> => ast::Expr::Subscript(
ast::ExprSubscript { value: Box::new(e), slice: Box::new(s), ctx: ast::ExprContext::Load, range: (location..end_location).into() } ast::ExprSubscript { value: Box::new(e), slice: Box::new(s), ctx: ast::ExprContext::Load, range: (location..end_location).into() }
), ),
<location:@L> <e:AtomExpr2<"all">> "." <attr:Identifier> <end_location:@R> => ast::Expr::new( <location:@L> <e:AtomExpr2<"all">> "." <attr:Identifier> <end_location:@R> => ast::Expr::Attribute(
ast::ExprAttribute { value: Box::new(e), attr, ctx: ast::ExprContext::Load, range: (location..end_location).into() } ast::ExprAttribute { value: Box::new(e), attr, ctx: ast::ExprContext::Load, range: (location..end_location).into() }
), ),
}; };
@ -1399,7 +1375,7 @@ SubscriptList: ast::Expr = {
dims.push(x.1) dims.push(x.1)
} }
ast::Expr::new( ast::Expr::Tuple(
ast::ExprTuple { elts: dims, ctx: ast::ExprContext::Load, range: (location..end_location).into() }, ast::ExprTuple { elts: dims, ctx: ast::ExprContext::Load, range: (location..end_location).into() },
) )
} }
@ -1412,7 +1388,7 @@ Subscript: ast::Expr = {
let lower = e1.map(Box::new); let lower = e1.map(Box::new);
let upper = e2.map(Box::new); let upper = e2.map(Box::new);
let step = e3.flatten().map(Box::new); let step = e3.flatten().map(Box::new);
ast::Expr::new( ast::Expr::Slice(
ast::ExprSlice { lower, upper, step, range: (location..end_location).into() } ast::ExprSlice { lower, upper, step, range: (location..end_location).into() }
) )
} }
@ -1424,20 +1400,20 @@ SliceOp: Option<ast::Expr> = {
Atom<Goal>: ast::Expr = { Atom<Goal>: ast::Expr = {
<location:@L> <s:(@L string @R)+> =>? Ok(parse_strings(s)?), <location:@L> <s:(@L string @R)+> =>? Ok(parse_strings(s)?),
<location:@L> <value:Constant> <end_location:@R> => ast::Expr::new( <location:@L> <value:Constant> <end_location:@R> => ast::Expr::Constant(
ast::ExprConstant { value, kind: None, range: (location..end_location).into() } ast::ExprConstant { value, kind: None, range: (location..end_location).into() }
), ),
<location:@L> <name:Identifier> <end_location:@R> => ast::Expr::new( <location:@L> <name:Identifier> <end_location:@R> => ast::Expr::Name(
ast::ExprName { id: name, ctx: ast::ExprContext::Load, range: (location..end_location).into() } ast::ExprName { id: name, ctx: ast::ExprContext::Load, range: (location..end_location).into() }
), ),
<location:@L> "[" <e:ListLiteralValues?> "]"<end_location:@R> => { <location:@L> "[" <e:ListLiteralValues?> "]"<end_location:@R> => {
let elts = e.unwrap_or_default(); let elts = e.unwrap_or_default();
ast::Expr::new( ast::Expr::List(
ast::ExprList { elts, ctx: ast::ExprContext::Load, range: (location..end_location).into() } ast::ExprList { elts, ctx: ast::ExprContext::Load, range: (location..end_location).into() }
) )
}, },
<location:@L> "[" <elt:TestOrStarNamedExpr> <generators:CompFor> "]" <end_location:@R> => { <location:@L> "[" <elt:TestOrStarNamedExpr> <generators:CompFor> "]" <end_location:@R> => {
ast::Expr::new( ast::Expr::ListComp(
ast::ExprListComp { elt: Box::new(elt), generators, range: (location..end_location).into() } ast::ExprListComp { elt: Box::new(elt), generators, range: (location..end_location).into() }
) )
}, },
@ -1445,14 +1421,14 @@ Atom<Goal>: ast::Expr = {
if elts.len() == 1 && trailing_comma.is_none() { if elts.len() == 1 && trailing_comma.is_none() {
elts.into_iter().next().unwrap() elts.into_iter().next().unwrap()
} else { } else {
ast::Expr::new( ast::Expr::Tuple(
ast::ExprTuple { elts, ctx: ast::ExprContext::Load, range: (location..end_location).into() } ast::ExprTuple { elts, ctx: ast::ExprContext::Load, range: (location..end_location).into() }
) )
} }
}, },
<location:@L> "(" <left:(<OneOrMore<Test<"all">>> ",")?> <mid:NamedOrStarExpr> <right:("," <TestOrStarNamedExpr>)*> <trailing_comma:","?> ")" <end_location:@R> =>? { <location:@L> "(" <left:(<OneOrMore<Test<"all">>> ",")?> <mid:NamedOrStarExpr> <right:("," <TestOrStarNamedExpr>)*> <trailing_comma:","?> ")" <end_location:@R> =>? {
if left.is_none() && right.is_empty() && trailing_comma.is_none() { if left.is_none() && right.is_empty() && trailing_comma.is_none() {
if matches!(mid.node, ast::ExprKind::Starred { .. }) { if mid.is_starred_expr() {
Err(LexicalError{ Err(LexicalError{
error: LexicalErrorType::OtherError("cannot use starred expression here".to_string()), error: LexicalErrorType::OtherError("cannot use starred expression here".to_string()),
location: mid.start(), location: mid.start(),
@ -1461,17 +1437,17 @@ Atom<Goal>: ast::Expr = {
Ok(mid) Ok(mid)
} else { } else {
let elts = left.into_iter().flatten().chain([mid]).chain(right).collect(); let elts = left.into_iter().flatten().chain([mid]).chain(right).collect();
Ok(ast::Expr::new( Ok(ast::Expr::Tuple(
ast::ExprTuple { elts, ctx: ast::ExprContext::Load, range: (location..end_location).into() }, ast::ExprTuple { elts, ctx: ast::ExprContext::Load, range: (location..end_location).into() },
)) ))
} }
}, },
<location:@L> "(" ")" <end_location:@R> => ast::Expr::new( <location:@L> "(" ")" <end_location:@R> => ast::Expr::Tuple(
ast::ExprTuple { elts: Vec::new(), ctx: ast::ExprContext::Load, range: (location..end_location).into() } ast::ExprTuple { elts: Vec::new(), ctx: ast::ExprContext::Load, range: (location..end_location).into() }
), ),
"(" <e:YieldExpr> ")" => e, "(" <e:YieldExpr> ")" => e,
<location:@L> "(" <elt:NamedExpressionTest> <generators:CompFor> ")" <end_location:@R> => { <location:@L> "(" <elt:NamedExpressionTest> <generators:CompFor> ")" <end_location:@R> => {
ast::Expr::new( ast::Expr::GeneratorExp(
ast::ExprGeneratorExp { elt: Box::new(elt), generators, range: (location..end_location).into() } ast::ExprGeneratorExp { elt: Box::new(elt), generators, range: (location..end_location).into() }
) )
}, },
@ -1487,12 +1463,12 @@ Atom<Goal>: ast::Expr = {
.into_iter() .into_iter()
.map(|(k, v)| (k.map(|x| *x), v)) .map(|(k, v)| (k.map(|x| *x), v))
.unzip(); .unzip();
ast::Expr::new( ast::Expr::Dict(
ast::ExprDict { keys, values, range: (location..end_location).into() } ast::ExprDict { keys, values, range: (location..end_location).into() }
) )
}, },
<location:@L> "{" <e1:DictEntry> <generators:CompFor> "}" <end_location:@R> => { <location:@L> "{" <e1:DictEntry> <generators:CompFor> "}" <end_location:@R> => {
ast::Expr::new( ast::Expr::DictComp(
ast::ExprDictComp { ast::ExprDictComp {
key: Box::new(e1.0), key: Box::new(e1.0),
value: Box::new(e1.1), value: Box::new(e1.1),
@ -1501,18 +1477,18 @@ Atom<Goal>: ast::Expr = {
} }
) )
}, },
<location:@L> "{" <elts:SetLiteralValues> "}" <end_location:@R> => ast::Expr::new( <location:@L> "{" <elts:SetLiteralValues> "}" <end_location:@R> => ast::Expr::Set(
ast::ExprSet { elts, range: (location..end_location).into() } ast::ExprSet { elts, range: (location..end_location).into() }
), ),
<location:@L> "{" <elt:NamedExpressionTest> <generators:CompFor> "}" <end_location:@R> => { <location:@L> "{" <elt:NamedExpressionTest> <generators:CompFor> "}" <end_location:@R> => {
ast::Expr::new( ast::Expr::SetComp(
ast::ExprSetComp { elt: Box::new(elt), generators, range: (location..end_location).into() } ast::ExprSetComp { elt: Box::new(elt), generators, range: (location..end_location).into() }
) )
}, },
<location:@L> "True" <end_location:@R> => ast::Expr::new(ast::ExprConstant { value: true.into(), kind: None, range: (location..end_location).into() }), <location:@L> "True" <end_location:@R> => ast::Expr::Constant(ast::ExprConstant { value: true.into(), kind: None, range: (location..end_location).into() }),
<location:@L> "False" <end_location:@R> => ast::Expr::new(ast::ExprConstant { value: false.into(), kind: None, range: (location..end_location).into() }), <location:@L> "False" <end_location:@R> => ast::Expr::Constant(ast::ExprConstant { value: false.into(), kind: None, range: (location..end_location).into() }),
<location:@L> "None" <end_location:@R> => ast::Expr::new(ast::ExprConstant { value: ast::Constant::None, kind: None, range: (location..end_location).into() }), <location:@L> "None" <end_location:@R> => ast::Expr::Constant(ast::ExprConstant { value: ast::Constant::None, kind: None, range: (location..end_location).into() }),
<location:@L> "..." <end_location:@R> => ast::Expr::new(ast::ExprConstant { value: ast::Constant::Ellipsis, kind: None, range: (location..end_location).into() }), <location:@L> "..." <end_location:@R> => ast::Expr::Constant(ast::ExprConstant { value: ast::Constant::Ellipsis, kind: None, range: (location..end_location).into() }),
}; };
ListLiteralValues: Vec<ast::Expr> = { ListLiteralValues: Vec<ast::Expr> = {
@ -1563,7 +1539,7 @@ GenericList<Element>: ast::Expr = {
if elts.len() == 1 && trailing_comma.is_none() { if elts.len() == 1 && trailing_comma.is_none() {
elts.into_iter().next().unwrap() elts.into_iter().next().unwrap()
} else { } else {
ast::Expr::new( ast::Expr::Tuple(
ast::ExprTuple { elts, ctx: ast::ExprContext::Load, range: (location..end_location).into() } ast::ExprTuple { elts, ctx: ast::ExprContext::Load, range: (location..end_location).into() }
) )
} }
@ -1572,7 +1548,7 @@ GenericList<Element>: ast::Expr = {
// Test // Test
StarExpr: ast::Expr = { StarExpr: ast::Expr = {
<location:@L> "*" <e:Expression<"all">> <end_location:@R> => ast::Expr::new( <location:@L> "*" <e:Expression<"all">> <end_location:@R> => ast::Expr::Starred(
ast::ExprStarred { value: Box::new(e), ctx: ast::ExprContext::Load, range: (location..end_location).into() }, ast::ExprStarred { value: Box::new(e), ctx: ast::ExprContext::Load, range: (location..end_location).into() },
) )
}; };
@ -1588,7 +1564,7 @@ SingleForComprehension: ast::Comprehension = {
iter, iter,
ifs, ifs,
is_async, is_async,
range: (location..end_location).into() range: range_or_phantom(location..end_location)
} }
} }
}; };
@ -1606,7 +1582,7 @@ ArgumentList: ArgumentList = {
FunctionArgument: (Option<(TextSize, TextSize, Option<ast::Identifier>)>, ast::Expr) = { FunctionArgument: (Option<(TextSize, TextSize, Option<ast::Identifier>)>, ast::Expr) = {
<location:@L> <e:NamedExpressionTest> <c:CompFor?> <end_location:@R> => { <location:@L> <e:NamedExpressionTest> <c:CompFor?> <end_location:@R> => {
let expr = match c { let expr = match c {
Some(c) => ast::Expr::new( Some(c) => ast::Expr::GeneratorExp(
ast::ExprGeneratorExp { ast::ExprGeneratorExp {
elt: Box::new(e), elt: Box::new(e),
generators: c, generators: c,
@ -1619,7 +1595,7 @@ FunctionArgument: (Option<(TextSize, TextSize, Option<ast::Identifier>)>, ast::E
}, },
<location:@L> <i:Identifier> "=" <e:Test<"all">> <end_location:@R> => (Some((location, end_location, Some(i))), e), <location:@L> <i:Identifier> "=" <e:Test<"all">> <end_location:@R> => (Some((location, end_location, Some(i))), e),
<location:@L> "*" <e:Test<"all">> <end_location:@R> => { <location:@L> "*" <e:Test<"all">> <end_location:@R> => {
let expr = ast::Expr::new( let expr = ast::Expr::Starred(
ast::ExprStarred { value: Box::new(e), ctx: ast::ExprContext::Load, range: (location..end_location).into() }, ast::ExprStarred { value: Box::new(e), ctx: ast::ExprContext::Load, range: (location..end_location).into() },
); );
(None, expr) (None, expr)

3299
parser/src/python.rs generated

File diff suppressed because it is too large Load diff

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

@ -4,73 +4,58 @@ expression: parse_ast
--- ---
Ok( Ok(
[ [
Attributed { FunctionDef(
custom: (), StmtFunctionDef {
node: FunctionDef( name: Identifier(
StmtFunctionDef { "f",
name: Identifier( ),
"f", args: Arguments {
), posonlyargs: [],
args: Arguments { args: [],
posonlyargs: [], vararg: None,
args: [], kwonlyargs: [
vararg: None, Arg {
kwonlyargs: [ arg: Identifier(
Attributed { "a",
custom: (),
node: ArgData {
arg: Identifier(
"a",
),
annotation: None,
type_comment: None,
range: 9..10,
},
},
Attributed {
custom: (),
node: ArgData {
arg: Identifier(
"b",
),
annotation: None,
type_comment: None,
range: 12..13,
},
},
Attributed {
custom: (),
node: ArgData {
arg: Identifier(
"c",
),
annotation: None,
type_comment: None,
range: 15..16,
},
},
],
kw_defaults: [],
kwarg: None,
defaults: [],
range: 6..16,
},
body: [
Attributed {
custom: (),
node: Pass(
StmtPass {
range: 19..23,
},
), ),
annotation: None,
type_comment: None,
range: 9..10,
},
Arg {
arg: Identifier(
"b",
),
annotation: None,
type_comment: None,
range: 12..13,
},
Arg {
arg: Identifier(
"c",
),
annotation: None,
type_comment: None,
range: 15..16,
}, },
], ],
decorator_list: [], kw_defaults: [],
returns: None, kwarg: None,
type_comment: None, defaults: [],
range: 0..23, range: PhantomData<ruff_text_size::range::TextRange>,
}, },
), body: [
}, Pass(
StmtPass {
range: 19..23,
},
),
],
decorator_list: [],
returns: None,
type_comment: None,
range: 0..23,
},
),
], ],
) )

View file

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

View file

@ -4,39 +4,33 @@ expression: parse_ast
--- ---
Ok( Ok(
[ [
Attributed { FunctionDef(
custom: (), StmtFunctionDef {
node: FunctionDef( name: Identifier(
StmtFunctionDef { "f",
name: Identifier( ),
"f", args: Arguments {
), posonlyargs: [],
args: Arguments { args: [],
posonlyargs: [], vararg: None,
args: [], kwonlyargs: [],
vararg: None, kw_defaults: [],
kwonlyargs: [], kwarg: None,
kw_defaults: [], defaults: [],
kwarg: None, range: PhantomData<ruff_text_size::range::TextRange>,
defaults: [],
range: 5..7,
},
body: [
Attributed {
custom: (),
node: Pass(
StmtPass {
range: 9..13,
},
),
},
],
decorator_list: [],
returns: None,
type_comment: None,
range: 0..13,
}, },
), body: [
}, Pass(
StmtPass {
range: 9..13,
},
),
],
decorator_list: [],
returns: None,
type_comment: None,
range: 0..13,
},
),
], ],
) )

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

@ -4,43 +4,34 @@ expression: parse_ast
--- ---
Ok( Ok(
[ [
Attributed { Expr(
custom: (), StmtExpr {
node: Expr( value: Lambda(
StmtExpr { ExprLambda {
value: Attributed { args: Arguments {
custom: (), posonlyargs: [],
node: Lambda( args: [],
ExprLambda { vararg: None,
args: Arguments { kwonlyargs: [],
posonlyargs: [], kw_defaults: [],
args: [], kwarg: None,
vararg: None, defaults: [],
kwonlyargs: [], range: PhantomData<ruff_text_size::range::TextRange>,
kw_defaults: [], },
kwarg: None, body: Constant(
defaults: [], ExprConstant {
range: 0..9, value: Int(
}, 1,
body: Attributed { ),
custom: (), kind: None,
node: Constant( range: 8..9,
ExprConstant {
value: Int(
1,
),
kind: None,
range: 8..9,
},
),
},
range: 0..9,
}, },
), ),
range: 0..9,
}, },
range: 0..9, ),
}, range: 0..9,
), },
}, ),
], ],
) )

View file

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

View file

@ -4,77 +4,59 @@ expression: parse_ast
--- ---
Ok( Ok(
[ [
Attributed { Expr(
custom: (), StmtExpr {
node: Expr( value: Lambda(
StmtExpr { ExprLambda {
value: Attributed { args: Arguments {
custom: (), posonlyargs: [],
node: Lambda( args: [
ExprLambda { Arg {
args: Arguments { arg: Identifier(
posonlyargs: [], "a",
args: [
Attributed {
custom: (),
node: ArgData {
arg: Identifier(
"a",
),
annotation: None,
type_comment: None,
range: 7..8,
},
},
Attributed {
custom: (),
node: ArgData {
arg: Identifier(
"b",
),
annotation: None,
type_comment: None,
range: 10..11,
},
},
Attributed {
custom: (),
node: ArgData {
arg: Identifier(
"c",
),
annotation: None,
type_comment: None,
range: 13..14,
},
},
],
vararg: None,
kwonlyargs: [],
kw_defaults: [],
kwarg: None,
defaults: [],
range: 7..14,
},
body: Attributed {
custom: (),
node: Constant(
ExprConstant {
value: Int(
1,
),
kind: None,
range: 16..17,
},
), ),
annotation: None,
type_comment: None,
range: 7..8,
}, },
range: 0..17, Arg {
arg: Identifier(
"b",
),
annotation: None,
type_comment: None,
range: 10..11,
},
Arg {
arg: Identifier(
"c",
),
annotation: None,
type_comment: None,
range: 13..14,
},
],
vararg: None,
kwonlyargs: [],
kw_defaults: [],
kwarg: None,
defaults: [],
range: PhantomData<ruff_text_size::range::TextRange>,
},
body: Constant(
ExprConstant {
value: Int(
1,
),
kind: None,
range: 16..17,
}, },
), ),
range: 0..17,
}, },
range: 0..17, ),
}, range: 0..17,
), },
}, ),
], ],
) )

View file

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

View file

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

View file

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

File diff suppressed because it is too large Load diff

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

File diff suppressed because it is too large Load diff

View file

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

View file

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

View file

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

View file

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

View file

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

File diff suppressed because it is too large Load diff

View file

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

View file

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

View file

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

View file

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

View file

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

View file

@ -3,281 +3,275 @@ source: parser/src/string.rs
expression: parse_ast expression: parse_ast
--- ---
[ [
Attributed { Expr(
custom: (), StmtExpr {
node: Expr( value: Constant(
StmtExpr { ExprConstant {
value: Attributed { value: Bytes(
custom: (), [
node: Constant( 0,
ExprConstant { 1,
value: Bytes( 2,
[ 3,
0, 4,
1, 5,
2, 6,
3, 7,
4, 8,
5, 9,
6, 10,
7, 11,
8, 12,
9, 13,
10, 14,
11, 15,
12, 16,
13, 17,
14, 18,
15, 19,
16, 20,
17, 21,
18, 22,
19, 23,
20, 24,
21, 25,
22, 26,
23, 27,
24, 28,
25, 29,
26, 30,
27, 31,
28, 32,
29, 33,
30, 34,
31, 35,
32, 36,
33, 37,
34, 38,
35, 39,
36, 40,
37, 41,
38, 42,
39, 43,
40, 44,
41, 45,
42, 46,
43, 47,
44, 48,
45, 49,
46, 50,
47, 51,
48, 52,
49, 53,
50, 54,
51, 55,
52, 56,
53, 57,
54, 58,
55, 59,
56, 60,
57, 61,
58, 62,
59, 63,
60, 64,
61, 65,
62, 66,
63, 67,
64, 68,
65, 69,
66, 70,
67, 71,
68, 72,
69, 73,
70, 74,
71, 75,
72, 76,
73, 77,
74, 78,
75, 79,
76, 80,
77, 81,
78, 82,
79, 83,
80, 84,
81, 85,
82, 86,
83, 87,
84, 88,
85, 89,
86, 90,
87, 91,
88, 92,
89, 93,
90, 94,
91, 95,
92, 96,
93, 97,
94, 98,
95, 99,
96, 100,
97, 101,
98, 102,
99, 103,
100, 104,
101, 105,
102, 106,
103, 107,
104, 108,
105, 109,
106, 110,
107, 111,
108, 112,
109, 113,
110, 114,
111, 115,
112, 116,
113, 117,
114, 118,
115, 119,
116, 120,
117, 121,
118, 122,
119, 123,
120, 124,
121, 125,
122, 126,
123, 127,
124, 128,
125, 129,
126, 130,
127, 131,
128, 132,
129, 133,
130, 134,
131, 135,
132, 136,
133, 137,
134, 138,
135, 139,
136, 140,
137, 141,
138, 142,
139, 143,
140, 144,
141, 145,
142, 146,
143, 147,
144, 148,
145, 149,
146, 150,
147, 151,
148, 152,
149, 153,
150, 154,
151, 155,
152, 156,
153, 157,
154, 158,
155, 159,
156, 160,
157, 161,
158, 162,
159, 163,
160, 164,
161, 165,
162, 166,
163, 167,
164, 168,
165, 169,
166, 170,
167, 171,
168, 172,
169, 173,
170, 174,
171, 175,
172, 176,
173, 177,
174, 178,
175, 179,
176, 180,
177, 181,
178, 182,
179, 183,
180, 184,
181, 185,
182, 186,
183, 187,
184, 188,
185, 189,
186, 190,
187, 191,
188, 192,
189, 193,
190, 194,
191, 195,
192, 196,
193, 197,
194, 198,
195, 199,
196, 200,
197, 201,
198, 202,
199, 203,
200, 204,
201, 205,
202, 206,
203, 207,
204, 208,
205, 209,
206, 210,
207, 211,
208, 212,
209, 213,
210, 214,
211, 215,
212, 216,
213, 217,
214, 218,
215, 219,
216, 220,
217, 221,
218, 222,
219, 223,
220, 224,
221, 225,
222, 226,
223, 227,
224, 228,
225, 229,
226, 230,
227, 231,
228, 232,
229, 233,
230, 234,
231, 235,
232, 236,
233, 237,
234, 238,
235, 239,
236, 240,
237, 241,
238, 242,
239, 243,
240, 244,
241, 245,
242, 246,
243, 247,
244, 248,
245, 249,
246, 250,
247, 251,
248, 252,
249, 253,
250, 254,
251, 255,
252, ],
253,
254,
255,
],
),
kind: None,
range: 0..738,
},
), ),
kind: None,
range: 0..738,
}, },
range: 0..738, ),
}, range: 0..738,
), },
}, ),
] ]

View file

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

View file

@ -3,35 +3,29 @@ source: parser/src/string.rs
expression: parse_ast expression: parse_ast
--- ---
[ [
Attributed { Expr(
custom: (), StmtExpr {
node: Expr( value: Constant(
StmtExpr { ExprConstant {
value: Attributed { value: Bytes(
custom: (), [
node: Constant( 111,
ExprConstant { 109,
value: Bytes( 107,
[ 109,
111, 111,
109, 107,
107, 92,
109, 88,
111, 97,
107, 97,
92, ],
88,
97,
97,
],
),
kind: None,
range: 0..13,
},
), ),
kind: None,
range: 0..13,
}, },
range: 0..13, ),
}, range: 0..13,
), },
}, ),
] ]

View file

@ -3,30 +3,24 @@ source: parser/src/string.rs
expression: parse_ast expression: parse_ast
--- ---
[ [
Attributed { Expr(
custom: (), StmtExpr {
node: Expr( value: Constant(
StmtExpr { ExprConstant {
value: Attributed { value: Bytes(
custom: (), [
node: Constant( 35,
ExprConstant { 97,
value: Bytes( 4,
[ 83,
35, 52,
97, ],
4,
83,
52,
],
),
kind: None,
range: 0..14,
},
), ),
kind: None,
range: 0..14,
}, },
range: 0..14, ),
}, range: 0..14,
), },
}, ),
] ]

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

@ -3,24 +3,18 @@ source: parser/src/string.rs
expression: parse_ast expression: parse_ast
--- ---
[ [
Attributed { Expr(
custom: (), StmtExpr {
node: Expr( value: Constant(
StmtExpr { ExprConstant {
value: Attributed { value: Str(
custom: (), "\u{88}",
node: Constant(
ExprConstant {
value: Str(
"\u{88}",
),
kind: None,
range: 0..9,
},
), ),
kind: None,
range: 0..9,
}, },
range: 0..9, ),
}, range: 0..9,
), },
}, ),
] ]

View file

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

View file

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

View file

@ -3,58 +3,43 @@ source: parser/src/string.rs
expression: parse_ast expression: parse_ast
--- ---
[ [
Attributed { Expr(
custom: (), StmtExpr {
node: Expr( value: JoinedStr(
StmtExpr { ExprJoinedStr {
value: Attributed { values: [
custom: (), Constant(
node: JoinedStr( ExprConstant {
ExprJoinedStr { value: Str(
values: [ "Hello world",
Attributed { ),
custom: (), kind: None,
node: Constant( range: 0..22,
ExprConstant { },
value: Str( ),
"Hello world", FormattedValue(
), ExprFormattedValue {
kind: None, value: Constant(
range: 0..22, ExprConstant {
}, value: Str(
), "!",
}, ),
Attributed { kind: None,
custom: (), range: 17..20,
node: FormattedValue( },
ExprFormattedValue { ),
value: Attributed { conversion: Int(
custom: (), 0,
node: Constant( ),
ExprConstant { format_spec: None,
value: Str( range: 9..22,
"!", },
), ),
kind: None, ],
range: 17..20, range: 0..22,
},
),
},
conversion: Int(
0,
),
format_spec: None,
range: 9..22,
},
),
},
],
range: 0..22,
},
),
}, },
range: 0..22, ),
}, range: 0..22,
), },
}, ),
] ]

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