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 = []
unparse = ["rustpython-literal"]
visitor = []
more-attributes = []
[dependencies]
rustpython-parser-core = { workspace = true }

View file

@ -387,7 +387,7 @@ class StructVisitor(EmitVisitor):
product_name = rust_type_name(name)
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:
self.visit(f, type_info, "pub ", depth + 1)
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_generic_visitor_signature(name, depth)
depth += 1
self.emit("match node.node {", depth)
self.emit("match node {", depth)
for t in sum.types:
self.visit_match_for_type(name, enum_name, t, depth + 1)
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)})?)?"
class RangedDefVisitor(EmitVisitor):
def visitModule(self, mod):
for dfn in mod.dfns:
@ -937,41 +936,73 @@ class RangedDefVisitor(EmitVisitor):
def visitSum(self, sum, name, depth):
info = self.type_info[name]
# if info.is_simple:
# return
if info.is_simple:
return
if not info.no_cfg(self.type_info):
self.emit('#[cfg(feature = "more-attributes")]', 0)
self.emit(
f"""
impl Ranged for crate::generic::{info.rust_sum_name}::<TextRange> {{
fn range(&self) -> TextRange {{
self.range
}}
}}
""", 0)
for ty in sum.types:
info = self.type_info[ty.name]
self.make_ranged_impl(info)
def visitProduct(self, product, name, depth):
info = self.type_info[name]
# if info.is_simple:
# return
self.make_ranged_impl(info)
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):
self.emit('#[cfg(feature = "more-attributes")]', 0)
self.emit(
self.file.write(
f"""
impl Ranged for crate::generic::{info.rust_sum_name}::<TextRange> {{
fn range(&self) -> TextRange {{
self.range
}}
}}
""", 0)
for f in product.fields:
self.visit(f, info, "pub ", depth + 1)
impl Located for {info.rust_sum_name} {{
fn range(&self) -> SourceRange {{
self.range
}}
}}
""".strip()
)
class ChainOfVisitors:
def __init__(self, *visitors):
@ -997,40 +1028,12 @@ def write_visitor_def(mod, type_info, f):
def write_ranged_def(mod, type_info, f):
f.write("use crate::Ranged;")
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):
for info in type_info.values():
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
}}
}}
"""
)
LocatedDefVisitor(f, type_info).visit(mod)
def write_ast_mod(mod, type_info, f):
f.write(

View file

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

View file

@ -1,487 +1,469 @@
// File automatically generated by ast/asdl_rs.py.
#[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 {
self.range
}
}
#[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 {
self.range
}
}
#[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 {
self.range
}
}
#[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 {
self.range
}
}
#[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 {
self.range
}
}
impl Located for crate::generic::Stmt<SourceRange> {
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> {
pub type ExcepthandlerExceptHandler = crate::generic::ExcepthandlerExceptHandler<SourceRange>;
impl Located for ExcepthandlerExceptHandler {
fn range(&self) -> SourceRange {
self.range
}
}
#[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 {
self.range
}
}
impl Located for crate::generic::Excepthandler<SourceRange> {
pub type Arg = crate::generic::Arg<SourceRange>;
impl Located for Arg {
fn range(&self) -> SourceRange {
self.range
}
}
impl Located for crate::generic::ExcepthandlerExceptHandler<SourceRange> {
pub type Keyword = crate::generic::Keyword<SourceRange>;
impl Located for Keyword {
fn range(&self) -> SourceRange {
self.range
}
}
pub type Alias = crate::generic::Alias<SourceRange>;
impl Located for Alias {
fn range(&self) -> SourceRange {
self.range
}
}
#[cfg(feature = "more-attributes")]
impl Located for crate::generic::Arguments<SourceRange> {
fn range(&self) -> SourceRange {
self.range
}
}
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> {
pub type Withitem = crate::generic::Withitem<SourceRange>;
#[cfg(feature = "more-attributes")]
impl Located for Withitem {
fn range(&self) -> SourceRange {
self.range
}
}
#[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 {
self.range
}
}
#[cfg(feature = "more-attributes")]
impl Located for crate::generic::MatchCase<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
}
}
pub type TypeIgnoreTypeIgnore = crate::generic::TypeIgnoreTypeIgnore<SourceRange>;
#[cfg(feature = "more-attributes")]
impl Located for crate::generic::TypeIgnore<SourceRange> {
fn range(&self) -> SourceRange {
self.range
}
}
#[cfg(feature = "more-attributes")]
impl Located for crate::generic::TypeIgnoreTypeIgnore<SourceRange> {
impl Located for TypeIgnoreTypeIgnore {
fn range(&self) -> SourceRange {
self.range
}

View file

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

View file

@ -6,7 +6,7 @@ pub trait Visitor<R = crate::text_size::TextRange> {
self.generic_visit_stmt(node)
}
fn generic_visit_stmt(&mut self, node: Stmt<R>) {
match node.node {
match node {
Stmt::FunctionDef(data) => self.visit_stmt_FunctionDef(data),
Stmt::AsyncFunctionDef(data) => self.visit_stmt_AsyncFunctionDef(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)
}
fn generic_visit_expr(&mut self, node: Expr<R>) {
match node.node {
match node {
Expr::BoolOp(data) => self.visit_expr_BoolOp(data),
Expr::NamedExpr(data) => self.visit_expr_NamedExpr(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)
}
fn generic_visit_excepthandler(&mut self, node: Excepthandler<R>) {
match node.node {
match node {
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)
}
fn generic_visit_pattern(&mut self, node: Pattern<R>) {
match node.node {
match node {
Pattern::MatchValue(data) => self.visit_pattern_MatchValue(data),
Pattern::MatchSingleton(data) => self.visit_pattern_MatchSingleton(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::{Constant, Excepthandler, Expr, Pattern, Stmt};
use crate::{Constant, Excepthandler, Expr, Pattern, Ranged, Stmt};
impl<R> Expr<R> {
/// 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::Slice { .. } => "slice",
Expr::JoinedStr(crate::ExprJoinedStr { values, .. }) => {
if values
.iter()
.any(|e| matches!(e.node, Expr::JoinedStr { .. }))
{
if values.iter().any(|e| e.is_joined_str_expr()) {
"f-string expression"
} else {
"literal"

View file

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

View file

@ -1,16 +1,4 @@
use crate::text_size::{TextRange, TextSize};
pub trait Ranged {
fn range(&self) -> TextRange;
fn start(&self) -> TextSize {
self.range().start()
}
fn end(&self) -> TextSize {
self.range().end()
}
}
use crate::text_size::TextRange;
pub use crate::builtin::*;
include!("gen/ranged.rs");

View file

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

View file

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

View file

@ -12,6 +12,7 @@ edition = "2021"
default = ["location"]
location = ["rustpython-ast/location"]
serde = ["dep:serde", "rustpython-parser-core/serde"]
more-attributes = ["rustpython-ast/more-attributes"]
[build-dependencies]
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 {
match expr.node {
ExprKind::Name(ast::ExprName { id, range, .. }) => Expr {
node: ast::ExprName { id, ctx, range }.into(),
..expr
},
ExprKind::Tuple(ast::ExprTuple { elts, range, .. }) => Expr {
node: ast::ExprTuple {
elts: elts
.into_iter()
.map(|elt| set_context(elt, ctx.clone()))
.collect(),
range,
ctx,
}
.into(),
..expr
},
ExprKind::List(ast::ExprList { elts, range, .. }) => Expr {
node: ast::ExprList {
elts: elts
.into_iter()
.map(|elt| set_context(elt, ctx.clone()))
.collect(),
range,
ctx,
}
.into(),
..expr
},
ExprKind::Attribute(ast::ExprAttribute {
match expr {
Expr::Name(ast::ExprName { id, range, .. }) => ast::ExprName { id, ctx, range }.into(),
Expr::Tuple(ast::ExprTuple { elts, range, .. }) => ast::ExprTuple {
elts: elts
.into_iter()
.map(|elt| set_context(elt, ctx.clone()))
.collect(),
range,
ctx,
}
.into(),
Expr::List(ast::ExprList { elts, range, .. }) => ast::ExprList {
elts: elts
.into_iter()
.map(|elt| set_context(elt, ctx.clone()))
.collect(),
range,
ctx,
}
.into(),
Expr::Attribute(ast::ExprAttribute {
value, attr, range, ..
}) => Expr {
node: ast::ExprAttribute {
value,
attr,
range,
ctx,
}
.into(),
..expr
},
ExprKind::Subscript(ast::ExprSubscript {
}) => ast::ExprAttribute {
value,
attr,
range,
ctx,
}
.into(),
Expr::Subscript(ast::ExprSubscript {
value,
slice,
range,
..
}) => Expr {
node: ast::ExprSubscript {
value,
slice,
range,
ctx,
}
.into(),
..expr
},
ExprKind::Starred(ast::ExprStarred { value, range, .. }) => Expr {
node: ast::ExprStarred {
value: Box::new(set_context(*value, ctx.clone())),
range,
ctx,
}
.into(),
..expr
},
}) => ast::ExprSubscript {
value,
slice,
range,
ctx,
}
.into(),
Expr::Starred(ast::ExprStarred { value, range, .. }) => ast::ExprStarred {
value: Box::new(set_context(*value, ctx.clone())),
range,
ctx,
}
.into(),
_ => expr,
}
}

View file

@ -21,7 +21,7 @@ type ParameterDef = (ast::Arg, Option<ast::Expr>);
pub(crate) fn validate_arguments(
arguments: ast::Arguments,
) -> 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.args.iter());
@ -118,11 +118,11 @@ pub(crate) fn parse_args(func_args: Vec<FunctionArgument>) -> Result<ArgumentLis
double_starred = true;
}
keywords.push(ast::Keyword::new(ast::KeywordData {
keywords.push(ast::Keyword {
arg: name.map(ast::Identifier::new),
value,
range: TextRange::new(start, end),
}));
});
}
None => {
// 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.
fn is_starred(exp: &ast::Expr) -> bool {
matches!(exp.node, ast::ExprKind::Starred { .. })
const fn is_starred(exp: &ast::Expr) -> bool {
exp.is_starred_expr()
}
#[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)]
mod tests {
use super::*;

View file

@ -4,11 +4,11 @@
// See also: https://greentreesnakes.readthedocs.io/en/latest/nodes.html#keyword
use crate::{
ast::ranged::{self as ast, Ranged},
ast::{self as ast, Ranged},
lexer::{LexicalError, LexicalErrorType},
function::{ArgumentList, parse_args, parse_params, validate_arguments},
context::set_context,
string::parse_strings,
string::parse_strings, parser::range_or_phantom,
token::{self, StringKind},
text_size::TextSize,
};
@ -20,9 +20,9 @@ grammar;
// For each public entry point, a full parse table is generated.
// By having only a single pub function, we reduce this to one.
pub Top: ast::Mod = {
<start:@L> StartModule <body:Program> <end:@R> => ast::ModModule { body, type_ignores: vec![], range: (start..end).into() }.into(),
<start:@L> StartInteractive <body:Program> <end:@R> => ast::ModInteractive { body, range: (start..end).into() }.into(),
<start:@L> StartExpression <body:TestList> ("\n")* <end:@R> => ast::ModExpression { body: Box::new(body), 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: range_or_phantom(start..end) }.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 = {
@ -68,15 +68,13 @@ SmallStatement: ast::Stmt = {
PassStatement: ast::Stmt = {
<location:@L> "pass" <end_location:@R> => {
ast::Stmt::new(
ast::StmtKind::Pass(ast::StmtPass { range: (location..end_location).into() }),
)
ast::Stmt::Pass(ast::StmtPass { range: (location..end_location).into() })
},
};
DelStatement: ast::Stmt = {
<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() }
)
},
@ -86,7 +84,7 @@ ExpressionStatement: ast::Stmt = {
<location:@L> <expression:TestOrStarExprList> <suffix:AssignSuffix*> <end_location:@R> => {
// Just an expression, no assignment:
if suffix.is_empty() {
ast::Stmt::new(
ast::Stmt::Expr(
ast::StmtExpr { value: Box::new(expression), range: (location..end_location).into() }
)
} else {
@ -99,13 +97,13 @@ ExpressionStatement: ast::Stmt = {
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() }
)
}
},
<location:@L> <target:TestOrStarExprList> <op:AugAssign> <rhs:TestListOrYieldExpr> <end_location:@R> => {
ast::Stmt::new(
ast::Stmt::AugAssign(
ast::StmtAugAssign {
target: Box::new(set_context(target, ast::ExprContext::Store)),
op,
@ -115,8 +113,8 @@ ExpressionStatement: ast::Stmt = {
)
},
<location:@L> <target:Test<"all">> ":" <annotation:Test<"all">> <rhs:AssignSuffix?> <end_location:@R> => {
let simple = matches!(target.node, ast::ExprKind::Name { .. });
ast::Stmt::new(
let simple = target.is_name_expr();
ast::Stmt::AnnAssign(
ast::StmtAnnAssign {
target: Box::new(set_context(target, ast::ExprContext::Store)),
annotation: Box::new(annotation),
@ -176,22 +174,19 @@ AugAssign: ast::Operator = {
FlowStatement: ast::Stmt = {
<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> => {
ast::Stmt::new(
ast::StmtKind::Continue(ast::StmtContinue { range: (location..end_location).into() }),
)
ast::Stmt::Continue(ast::StmtContinue { range: (location..end_location).into() })
},
<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() }
)
},
<location:@L> <expression:YieldExpr> <end_location:@R> => {
ast::Stmt::new(
ast::Stmt::Expr(
ast::StmtExpr { value: Box::new(expression), range: (location..end_location).into() }
)
},
@ -200,12 +195,12 @@ FlowStatement: ast::Stmt = {
RaiseStatement: ast::Stmt = {
<location:@L> "raise" <end_location:@R> => {
ast::Stmt::new(
ast::Stmt::Raise(
ast::StmtRaise { exc: None, cause: None, range: (location..end_location).into() }
)
},
<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() }
)
},
@ -213,13 +208,13 @@ RaiseStatement: ast::Stmt = {
ImportStatement: ast::Stmt = {
<location:@L> "import" <names: OneOrMore<ImportAsAlias<DottedName>>> <end_location:@R> => {
ast::Stmt::new(
ast::Stmt::Import(
ast::StmtImport { names, range: (location..end_location).into() }
)
},
<location:@L> "from" <source:ImportFromLocation> "import" <names: ImportAsNames> <end_location:@R> => {
let (level, module) = source;
ast::Stmt::new(
ast::Stmt::ImportFrom(
ast::StmtImportFrom {
level,
module,
@ -249,14 +244,14 @@ ImportAsNames: Vec<ast::Alias> = {
<location:@L> "(" <i:OneOrMore<ImportAsAlias<Identifier>>> ","? ")" <end_location:@R> => i,
<location:@L> "*" <end_location:@R> => {
// 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]
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
@ -274,7 +269,7 @@ DottedName: ast::Identifier = {
GlobalStatement: ast::Stmt = {
<location:@L> "global" <names:OneOrMore<Identifier>> <end_location:@R> => {
ast::Stmt::new(
ast::Stmt::Global(
ast::StmtGlobal { names, range: (location..end_location).into() }
)
},
@ -282,7 +277,7 @@ GlobalStatement: ast::Stmt = {
NonlocalStatement: ast::Stmt = {
<location:@L> "nonlocal" <names:OneOrMore<Identifier>> <end_location:@R> => {
ast::Stmt::new(
ast::Stmt::Nonlocal(
ast::StmtNonlocal { names, range: (location..end_location).into() }
)
},
@ -290,7 +285,7 @@ NonlocalStatement: ast::Stmt = {
AssertStatement: ast::Stmt = {
<location:@L> "assert" <test:Test<"all">> <msg: ("," Test<"all">)?> <end_location:@R> => {
ast::Stmt::new(
ast::Stmt::Assert(
ast::StmtAssert {
test: Box::new(test),
msg: msg.map(|e| Box::new(e.1)),
@ -320,7 +315,7 @@ MatchStatement: ast::Stmt = {
.last()
.unwrap()
.end();
ast::Stmt::new(
ast::Stmt::Match(
ast::StmtMatch {
subject: Box::new(subject),
cases,
@ -336,7 +331,7 @@ MatchStatement: ast::Stmt = {
.last()
.unwrap()
.end();
ast::Stmt::new(
ast::Stmt::Match(
ast::StmtMatch {
subject: Box::new(subject),
cases,
@ -354,9 +349,9 @@ MatchStatement: ast::Stmt = {
.end();
let mut subjects = subjects;
subjects.insert(0, subject);
ast::Stmt::new(
ast::Stmt::Match(
ast::StmtMatch {
subject: Box::new(ast::Expr::new(
subject: Box::new(ast::Expr::Tuple(
ast::ExprTuple {
elts: subjects,
ctx: ast::ExprContext::Load,
@ -376,7 +371,7 @@ MatchCase: ast::MatchCase = {
pattern,
guard: guard.map(Box::new),
body,
range: (start..end).into()
range: range_or_phantom(start..end)
}
},
}
@ -388,7 +383,7 @@ Guard: ast::Expr = {
}
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 {
patterns: vec![pattern],
range: (location..end_location).into()
@ -397,7 +392,7 @@ Patterns: ast::Pattern = {
<location:@L> <pattern:Pattern> "," <patterns:OneOrMore<Pattern>> ","? <end_location:@R> => {
let mut patterns = patterns;
patterns.insert(0, pattern);
ast::Pattern::new(
ast::Pattern::MatchSequence(
ast::PatternMatchSequence {
patterns,
range: (location..end_location).into()
@ -420,7 +415,7 @@ AsPattern: ast::Pattern = {
location,
})?
} else {
Ok(ast::Pattern::new(
Ok(ast::Pattern::MatchAs(
ast::PatternMatchAs {
pattern: Some(Box::new(pattern)),
name: Some(name),
@ -436,39 +431,25 @@ OrPattern: ast::Pattern = {
<location:@L> <pattern:ClosedPattern> <patterns:("|" <ClosedPattern>)+> <end_location:@R> => {
let mut patterns = patterns;
patterns.insert(0, pattern);
ast::Pattern::new(
ast::Pattern::MatchOr(
ast::PatternMatchOr { patterns, range: (location..end_location).into() }
)
}
}
ClosedPattern: ast::Pattern = {
<node:LiteralPattern> => ast::Pattern::new(
node,
),
<node:CapturePattern> => ast::Pattern::new(
node,
),
<node:StarPattern> => ast::Pattern::new(
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,
),
<node:LiteralPattern> => node,
<node:CapturePattern> => node,
<node:StarPattern> => node,
<node:ValuePattern> => node,
<node:SequencePattern> => node,
<node:MappingPattern> => node,
<node:ClassPattern> => node,
}
SequencePattern: ast::PatternKind = {
SequencePattern: ast::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 {
patterns: vec![],
range: (location..end_location).into()
@ -487,7 +468,7 @@ SequencePattern: ast::PatternKind = {
}.into(),
}
StarPattern: ast::PatternKind = {
StarPattern: ast::Pattern = {
<location:@L> "*" <name:Identifier> <end_location:@R> => ast::PatternMatchStar {
name: if name.as_str() == "_" { None } else { Some(name) },
range: (location..end_location).into()
@ -495,14 +476,14 @@ StarPattern: ast::PatternKind = {
}
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() }
),
}
ConstantExpr: ast::Expr = {
ConstantAtom,
<location:@L> "-" <operand:ConstantAtom> <end_location:@R> => ast::Expr::new(
<location:@L> "-" <operand:ConstantAtom> <end_location:@R> => ast::Expr::UnaryOp(
ast::ExprUnaryOp {
op: ast::Unaryop::USub,
operand: Box::new(operand),
@ -512,7 +493,7 @@ ConstantExpr: 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 {
left: Box::new(left),
op,
@ -522,7 +503,7 @@ AddOpExpr: ast::Expr = {
),
}
LiteralPattern: ast::PatternKind = {
LiteralPattern: ast::Pattern = {
<location:@L> "None" <end_location:@R> => ast::PatternMatchSingleton {
value: ast::Constant::None,
range: (location..end_location).into()
@ -549,7 +530,7 @@ LiteralPattern: ast::PatternKind = {
}.into()),
}
CapturePattern: ast::PatternKind = {
CapturePattern: ast::Pattern = {
<location:@L> <name:Identifier> <end_location:@R> => ast::PatternMatchAs {
pattern: None,
name: if name.as_str() == "_" { None } else { Some(name) },
@ -558,13 +539,13 @@ CapturePattern: ast::PatternKind = {
}
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() },
),
}
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 {
value: Box::new(name),
attr,
@ -572,7 +553,7 @@ MatchNameOrAttr: ast::Expr = {
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 {
value: Box::new(e),
attr,
@ -582,7 +563,7 @@ MatchNameOrAttr: ast::Expr = {
)
}
ValuePattern: ast::PatternKind = {
ValuePattern: ast::Pattern = {
<location:@L> <e:MatchNameOrAttr> <end_location:@R> => ast::PatternMatchValue {
value: Box::new(e),
range: (location..end_location).into()
@ -593,21 +574,21 @@ MappingKey: ast::Expr = {
ConstantExpr,
AddOpExpr,
MatchNameOrAttr,
<location:@L> "None" <end_location:@R> => ast::Expr::new(
<location:@L> "None" <end_location:@R> => ast::Expr::Constant(
ast::ExprConstant {
value: ast::Constant::None,
kind: None,
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 {
value: true.into(),
kind: None,
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 {
value: false.into(),
kind: None,
@ -621,7 +602,7 @@ MatchMappingEntry: (ast::Expr, ast::Pattern) = {
<k:MappingKey> ":" <v:Pattern> => (k, v),
};
MappingPattern: ast::PatternKind = {
MappingPattern: ast::Pattern = {
<location:@L> "{" "}" <end_location:@R> => {
return ast::PatternMatchMapping {
keys: vec![],
@ -666,7 +647,7 @@ MatchKeywordEntry: (ast::Identifier, ast::Pattern) = {
<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> => {
let (kwd_attrs, kwd_patterns) = kwds
.into_iter()
@ -765,13 +746,13 @@ IfStatement: ast::Stmt = {
.end();
// handle elif:
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() }
);
last = vec![x];
}
ast::Stmt::new(
ast::Stmt::If(
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())
.unwrap()
.end();
ast::Stmt::new(
ast::Stmt::While(
ast::StmtWhile {
test: Box::new(test),
body,
@ -807,12 +788,11 @@ ForStatement: ast::Stmt = {
let target = Box::new(set_context(target, ast::ExprContext::Store));
let iter = Box::new(iter);
let type_comment = None;
let node: ast::StmtKind = if is_async.is_some() {
ast::StmtAsyncFor { target, iter, body, orelse, type_comment, range: (location..end_location).into() }.into()
if is_async.is_some() {
ast::Stmt::AsyncFor(ast::StmtAsyncFor { target, iter, body, orelse, type_comment, range: (location..end_location).into() })
} else {
ast::StmtFor { target, iter, body, orelse, type_comment, range: (location..end_location).into() }.into()
};
ast::Stmt::new(node)
ast::Stmt::For(ast::StmtFor { target, iter, body, orelse, type_comment, range: (location..end_location).into() })
}
},
};
@ -826,7 +806,7 @@ TryStatement: ast::Stmt = {
.or_else(|| orelse.last().map(|last| last.end()))
.or_else(|| handlers.last().map(|last| last.end()))
.unwrap();
ast::Stmt::new(
ast::Stmt::Try(
ast::StmtTry {
body,
handlers,
@ -845,7 +825,7 @@ TryStatement: ast::Stmt = {
.map(|last| last.end())
.or_else(|| handlers.last().map(|last| last.end()))
.unwrap();
ast::Stmt::new(
ast::Stmt::TryStar(
ast::StmtTryStar {
body,
handlers,
@ -860,7 +840,7 @@ TryStatement: ast::Stmt = {
let orelse = vec![];
let finalbody = finally.2;
let end_location = finalbody.last().unwrap().end();
ast::Stmt::new(
ast::Stmt::Try(
ast::StmtTry {
body,
handlers,
@ -875,7 +855,7 @@ TryStatement: ast::Stmt = {
ExceptStarClause: ast::Excepthandler = {
<location:@L> "except" "*" <typ:Test<"all">> ":" <body:Suite> => {
let end_location = body.last().unwrap().end();
ast::Excepthandler::new(
ast::Excepthandler::ExceptHandler(
ast::ExcepthandlerExceptHandler {
type_: Some(Box::new(typ)),
name: None,
@ -886,7 +866,7 @@ ExceptStarClause: ast::Excepthandler = {
},
<location:@L> "except" "*" <x:(Test<"all"> "as" Identifier)> ":" <body:Suite> => {
let end_location = body.last().unwrap().end();
ast::Excepthandler::new(
ast::Excepthandler::ExceptHandler(
ast::ExcepthandlerExceptHandler {
type_: Some(Box::new(x.0)),
name: Some(x.2),
@ -901,7 +881,7 @@ ExceptStarClause: ast::Excepthandler = {
ExceptClause: ast::Excepthandler = {
<location:@L> "except" <typ:Test<"all">?> ":" <body:Suite> => {
let end_location = body.last().unwrap().end();
ast::Excepthandler::new(
ast::Excepthandler::ExceptHandler(
ast::ExcepthandlerExceptHandler {
type_: typ.map(Box::new),
name: None,
@ -912,7 +892,7 @@ ExceptClause: ast::Excepthandler = {
},
<location:@L> "except" <x:(Test<"all"> "as" Identifier)> ":" <body:Suite> => {
let end_location = body.last().unwrap().end();
ast::Excepthandler::new(
ast::Excepthandler::ExceptHandler(
ast::ExcepthandlerExceptHandler {
type_: Some(Box::new(x.0)),
name: Some(x.2),
@ -927,12 +907,11 @@ WithStatement: ast::Stmt = {
<location:@L> <is_async:"async"?> "with" <items:WithItems> ":" <body:Suite> => {
let end_location = body.last().unwrap().end();
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()
} else {
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]
WithItemsNoAs: Vec<ast::Withitem> = {
<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 = {
<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> => {
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 end_location = body.last().unwrap().end();
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()
} else {
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![],
kwarg: None,
defaults: vec![],
range: (location..end_location).into()
range: range_or_phantom(location..end_location)
})
)?;
@ -1013,7 +991,7 @@ ParameterList<ArgType, StarArgType>: ast::Arguments = {
kwarg,
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> =>? {
@ -1033,7 +1011,7 @@ ParameterList<ArgType, StarArgType>: ast::Arguments = {
kwarg,
defaults,
kw_defaults,
range: (location..end_location).into()
range: range_or_phantom(location..end_location)
})
},
<location:@L> <params:ParameterListStarArgs<ArgType, StarArgType>> ","? <end_location:@R> => {
@ -1046,7 +1024,7 @@ ParameterList<ArgType, StarArgType>: ast::Arguments = {
kwarg,
defaults: vec![],
kw_defaults,
range: (location..end_location).into()
range: range_or_phantom(location..end_location)
}
},
<location:@L> <kwarg:KwargParameter<ArgType>> ","? <end_location:@R> => {
@ -1058,7 +1036,7 @@ ParameterList<ArgType, StarArgType>: ast::Arguments = {
kwarg,
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 = {
<location:@L> <arg:Identifier> <end_location:@R> => ast::Arg::new(
ast::ArgData { arg, annotation: None, type_comment: None, range: (location..end_location).into() },
),
<location:@L> <arg:Identifier> <end_location:@R> => ast::Arg { arg, annotation: None, type_comment: None, range: (location..end_location).into() },
};
TypedParameter: ast::Arg = {
<location:@L> <arg:Identifier> <a:(":" Test<"all">)?> <end_location:@R> => {
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 = {
<location:@L> <arg:Identifier> <a:(":" TestOrStarExpr)?> <end_location:@R> => {
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![]),
};
let end_location = body.last().unwrap().end();
ast::Stmt::new(
ast::Stmt::ClassDef(
ast::StmtClassDef {
name,
bases,
@ -1166,16 +1142,16 @@ Decorator: 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() }
),
<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() }
),
};
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 {
test: Box::new(test),
body: Box::new(body),
@ -1194,9 +1170,9 @@ NamedExpressionTest: ast::Expr = {
NamedExpression: ast::Expr = {
<location:@L> <id:Identifier> <end_location:@R> ":=" <value:Test<"all">> => {
ast::Expr::new(
ast::Expr::NamedExpr(
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() },
)),
range: (location..value.end()).into(),
@ -1218,12 +1194,12 @@ LambdaDef: ast::Expr = {
kw_defaults: vec![],
kwarg: None,
defaults: vec![],
range: (location..end_location).into()
range: range_or_phantom(location..end_location)
}
}
))?;
Ok(ast::Expr::new(
Ok(ast::Expr::Lambda(
ast::ExprLambda {
args: Box::new(p),
body: Box::new(body),
@ -1237,7 +1213,7 @@ OrTest<Goal>: ast::Expr = {
<location:@L> <e1:AndTest<"all">> <e2:("or" AndTest<"all">)+> <end_location:@R> => {
let mut values = vec![e1];
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() }
)
},
@ -1248,7 +1224,7 @@ AndTest<Goal>: ast::Expr = {
<location:@L> <e1:NotTest<"all">> <e2:("and" NotTest<"all">)+> <end_location:@R> => {
let mut values = vec![e1];
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() }
)
},
@ -1256,7 +1232,7 @@ AndTest<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() }
),
Comparison<Goal>,
@ -1265,7 +1241,7 @@ NotTest<Goal>: ast::Expr = {
Comparison<Goal>: ast::Expr = {
<location:@L> <left:Expression<"all">> <comparisons:(CompOp Expression<"all">)+> <end_location:@R> => {
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() }
)
},
@ -1286,28 +1262,28 @@ CompOp: ast::Cmpop = {
};
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() }
),
XorExpression<Goal>,
};
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() }
),
AndExpression<Goal>,
};
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() }
),
ShiftExpression<Goal>,
};
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() }
),
ArithmeticExpression<Goal>,
@ -1319,7 +1295,7 @@ ShiftOp: ast::Operator = {
};
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() }
),
Term<Goal>,
@ -1331,7 +1307,7 @@ AddOp: ast::Operator = {
};
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() }
),
Factor<Goal>,
@ -1346,7 +1322,7 @@ MulOp: ast::Operator = {
};
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() }
),
Power<Goal>,
@ -1359,7 +1335,7 @@ UnaryOp: ast::Unaryop = {
};
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() }
),
AtomExpr<Goal>,
@ -1367,7 +1343,7 @@ Power<Goal>: ast::Expr = {
AtomExpr<Goal>: ast::Expr = {
<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() }
)
},
@ -1377,14 +1353,14 @@ AtomExpr<Goal>: ast::Expr = {
AtomExpr2<Goal>: ast::Expr = {
Atom<Goal>,
<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() }
)
},
<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() }
),
<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() }
),
};
@ -1399,7 +1375,7 @@ SubscriptList: ast::Expr = {
dims.push(x.1)
}
ast::Expr::new(
ast::Expr::Tuple(
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 upper = e2.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() }
)
}
@ -1424,20 +1400,20 @@ SliceOp: Option<ast::Expr> = {
Atom<Goal>: ast::Expr = {
<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() }
),
<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() }
),
<location:@L> "[" <e:ListLiteralValues?> "]"<end_location:@R> => {
let elts = e.unwrap_or_default();
ast::Expr::new(
ast::Expr::List(
ast::ExprList { elts, ctx: ast::ExprContext::Load, range: (location..end_location).into() }
)
},
<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() }
)
},
@ -1445,14 +1421,14 @@ Atom<Goal>: ast::Expr = {
if elts.len() == 1 && trailing_comma.is_none() {
elts.into_iter().next().unwrap()
} else {
ast::Expr::new(
ast::Expr::Tuple(
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> =>? {
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{
error: LexicalErrorType::OtherError("cannot use starred expression here".to_string()),
location: mid.start(),
@ -1461,17 +1437,17 @@ Atom<Goal>: ast::Expr = {
Ok(mid)
} else {
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() },
))
}
},
<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() }
),
"(" <e:YieldExpr> ")" => e,
<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() }
)
},
@ -1487,12 +1463,12 @@ Atom<Goal>: ast::Expr = {
.into_iter()
.map(|(k, v)| (k.map(|x| *x), v))
.unzip();
ast::Expr::new(
ast::Expr::Dict(
ast::ExprDict { keys, values, range: (location..end_location).into() }
)
},
<location:@L> "{" <e1:DictEntry> <generators:CompFor> "}" <end_location:@R> => {
ast::Expr::new(
ast::Expr::DictComp(
ast::ExprDictComp {
key: Box::new(e1.0),
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() }
),
<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() }
)
},
<location:@L> "True" <end_location:@R> => ast::Expr::new(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> "None" <end_location:@R> => ast::Expr::new(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> "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::Constant(ast::ExprConstant { value: false.into(), 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::Constant(ast::ExprConstant { value: ast::Constant::Ellipsis, kind: None, range: (location..end_location).into() }),
};
ListLiteralValues: Vec<ast::Expr> = {
@ -1563,7 +1539,7 @@ GenericList<Element>: ast::Expr = {
if elts.len() == 1 && trailing_comma.is_none() {
elts.into_iter().next().unwrap()
} else {
ast::Expr::new(
ast::Expr::Tuple(
ast::ExprTuple { elts, ctx: ast::ExprContext::Load, range: (location..end_location).into() }
)
}
@ -1572,7 +1548,7 @@ GenericList<Element>: ast::Expr = {
// Test
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() },
)
};
@ -1588,7 +1564,7 @@ SingleForComprehension: ast::Comprehension = {
iter,
ifs,
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) = {
<location:@L> <e:NamedExpressionTest> <c:CompFor?> <end_location:@R> => {
let expr = match c {
Some(c) => ast::Expr::new(
Some(c) => ast::Expr::GeneratorExp(
ast::ExprGeneratorExp {
elt: Box::new(e),
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> "*" <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() },
);
(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
---
[
Attributed {
custom: (),
node: AnnAssign(
StmtAnnAssign {
target: Attributed {
custom: (),
node: Name(
ExprName {
id: Identifier(
"x",
),
ctx: Store,
range: 0..1,
},
AnnAssign(
StmtAnnAssign {
target: Name(
ExprName {
id: Identifier(
"x",
),
ctx: Store,
range: 0..1,
},
annotation: Attributed {
custom: (),
node: Name(
ExprName {
id: Identifier(
"int",
),
ctx: Load,
range: 3..6,
},
),
annotation: Name(
ExprName {
id: Identifier(
"int",
),
ctx: Load,
range: 3..6,
},
value: Some(
Attributed {
custom: (),
node: Constant(
ExprConstant {
value: Int(
1,
),
kind: None,
range: 9..10,
},
),
value: Some(
Constant(
ExprConstant {
value: Int(
1,
),
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
---
[
Attributed {
custom: (),
node: Assign(
StmtAssign {
targets: [
Attributed {
custom: (),
node: Attribute(
ExprAttribute {
value: Attributed {
custom: (),
node: Name(
ExprName {
id: Identifier(
"x",
),
ctx: Load,
range: 0..1,
},
),
},
attr: Identifier(
"y",
Assign(
StmtAssign {
targets: [
Attribute(
ExprAttribute {
value: Name(
ExprName {
id: Identifier(
"x",
),
ctx: Store,
range: 0..3,
ctx: Load,
range: 0..1,
},
),
attr: Identifier(
"y",
),
ctx: Store,
range: 0..3,
},
],
value: Attributed {
custom: (),
node: Tuple(
ExprTuple {
elts: [
Attributed {
custom: (),
node: Constant(
ExprConstant {
value: Int(
1,
),
kind: None,
range: 7..8,
},
),
},
Attributed {
custom: (),
node: Constant(
ExprConstant {
value: Int(
2,
),
kind: None,
range: 10..11,
},
),
},
Attributed {
custom: (),
node: Constant(
ExprConstant {
value: Int(
3,
),
kind: None,
range: 13..14,
},
),
},
],
ctx: Load,
range: 6..15,
},
),
),
],
value: Tuple(
ExprTuple {
elts: [
Constant(
ExprConstant {
value: Int(
1,
),
kind: None,
range: 7..8,
},
),
Constant(
ExprConstant {
value: Int(
2,
),
kind: None,
range: 10..11,
},
),
Constant(
ExprConstant {
value: Int(
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
---
[
Attributed {
custom: (),
node: For(
StmtFor {
target: Attributed {
custom: (),
node: Name(
ExprName {
id: Identifier(
"x",
),
ctx: Store,
range: 4..5,
},
For(
StmtFor {
target: Name(
ExprName {
id: Identifier(
"x",
),
ctx: Store,
range: 4..5,
},
iter: Attributed {
custom: (),
node: Tuple(
ExprTuple {
elts: [
Attributed {
custom: (),
node: Constant(
ExprConstant {
value: Int(
1,
),
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,
),
iter: Tuple(
ExprTuple {
elts: [
Constant(
ExprConstant {
value: Int(
1,
),
kind: None,
range: 10..11,
},
),
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,
range: 0..24,
},
),
},
),
],
orelse: [],
type_comment: None,
range: 0..24,
},
),
]

View file

@ -3,97 +3,73 @@ source: parser/src/context.rs
expression: parse_ast
---
[
Attributed {
custom: (),
node: Assign(
StmtAssign {
targets: [
Attributed {
custom: (),
node: List(
ExprList {
elts: [
Attributed {
custom: (),
node: Name(
ExprName {
id: Identifier(
"x",
),
ctx: Store,
range: 1..2,
},
),
},
Attributed {
custom: (),
node: Name(
ExprName {
id: Identifier(
"y",
),
ctx: Store,
range: 4..5,
},
),
},
],
ctx: Store,
range: 0..6,
Assign(
StmtAssign {
targets: [
List(
ExprList {
elts: [
Name(
ExprName {
id: Identifier(
"x",
),
ctx: Store,
range: 1..2,
},
),
Name(
ExprName {
id: Identifier(
"y",
),
ctx: Store,
range: 4..5,
},
),
],
ctx: Store,
range: 0..6,
},
),
],
value: Tuple(
ExprTuple {
elts: [
Constant(
ExprConstant {
value: Int(
1,
),
kind: None,
range: 10..11,
},
),
},
],
value: Attributed {
custom: (),
node: Tuple(
ExprTuple {
elts: [
Attributed {
custom: (),
node: Constant(
ExprConstant {
value: Int(
1,
),
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,
},
),
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,
},
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
---
[
Attributed {
custom: (),
node: Assign(
StmtAssign {
targets: [
Attributed {
custom: (),
node: Name(
ExprName {
id: Identifier(
"x",
),
ctx: Store,
range: 0..1,
},
Assign(
StmtAssign {
targets: [
Name(
ExprName {
id: Identifier(
"x",
),
ctx: Store,
range: 0..1,
},
],
value: Attributed {
custom: (),
node: ListComp(
ExprListComp {
elt: Attributed {
custom: (),
node: Name(
ExprName {
id: Identifier(
"y",
),
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,
),
],
value: ListComp(
ExprListComp {
elt: Name(
ExprName {
id: Identifier(
"y",
),
ctx: Load,
range: 5..6,
},
),
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
---
[
Attributed {
custom: (),
node: Assign(
StmtAssign {
targets: [
Attributed {
custom: (),
node: Name(
ExprName {
id: Identifier(
"x",
Assign(
StmtAssign {
targets: [
Name(
ExprName {
id: Identifier(
"x",
),
ctx: Store,
range: 0..1,
},
),
],
value: Tuple(
ExprTuple {
elts: [
Constant(
ExprConstant {
value: Int(
1,
),
ctx: Store,
range: 0..1,
kind: None,
range: 5..6,
},
),
},
],
value: Attributed {
custom: (),
node: Tuple(
ExprTuple {
elts: [
Attributed {
custom: (),
node: Constant(
ExprConstant {
value: Int(
1,
),
kind: None,
range: 5..6,
},
),
},
Attributed {
custom: (),
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,
},
),
Constant(
ExprConstant {
value: Int(
2,
),
kind: None,
range: 8..9,
},
),
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
---
[
Attributed {
custom: (),
node: If(
StmtIf {
test: Attributed {
custom: (),
node: NamedExpr(
ExprNamedExpr {
target: Attributed {
custom: (),
node: Name(
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,
If(
StmtIf {
test: NamedExpr(
ExprNamedExpr {
target: Name(
ExprName {
id: Identifier(
"x",
),
ctx: Store,
range: 3..4,
},
),
value: Constant(
ExprConstant {
value: Int(
1,
),
kind: None,
range: 7..8,
},
),
range: 3..8,
},
body: [
Attributed {
custom: (),
node: Pass(
StmtPass {
range: 10..14,
},
),
),
body: [
Pass(
StmtPass {
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
---
[
Attributed {
custom: (),
node: Assign(
StmtAssign {
targets: [
Attributed {
custom: (),
node: Name(
ExprName {
id: Identifier(
"x",
),
ctx: Store,
range: 0..1,
},
Assign(
StmtAssign {
targets: [
Name(
ExprName {
id: Identifier(
"x",
),
ctx: Store,
range: 0..1,
},
],
value: Attributed {
custom: (),
node: SetComp(
ExprSetComp {
elt: Attributed {
custom: (),
node: Name(
ExprName {
id: Identifier(
"y",
),
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,
),
],
value: SetComp(
ExprSetComp {
elt: Name(
ExprName {
id: Identifier(
"y",
),
ctx: Load,
range: 5..6,
},
),
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
---
[
Attributed {
custom: (),
node: Assign(
StmtAssign {
targets: [
Attributed {
custom: (),
node: Tuple(
ExprTuple {
elts: [
Attributed {
custom: (),
node: Name(
ExprName {
id: Identifier(
"x",
),
ctx: Store,
range: 1..2,
},
),
},
Attributed {
custom: (),
node: Starred(
ExprStarred {
value: Attributed {
custom: (),
node: Name(
ExprName {
id: Identifier(
"y",
),
ctx: Store,
range: 5..6,
},
),
},
ctx: Store,
range: 4..6,
},
),
},
],
ctx: Store,
range: 0..7,
Assign(
StmtAssign {
targets: [
Tuple(
ExprTuple {
elts: [
Name(
ExprName {
id: Identifier(
"x",
),
ctx: Store,
range: 1..2,
},
),
Starred(
ExprStarred {
value: Name(
ExprName {
id: Identifier(
"y",
),
ctx: Store,
range: 5..6,
},
),
ctx: Store,
range: 4..6,
},
),
],
ctx: Store,
range: 0..7,
},
),
],
value: Tuple(
ExprTuple {
elts: [
Constant(
ExprConstant {
value: Int(
1,
),
kind: None,
range: 11..12,
},
),
},
],
value: Attributed {
custom: (),
node: Tuple(
ExprTuple {
elts: [
Attributed {
custom: (),
node: Constant(
ExprConstant {
value: Int(
1,
),
kind: None,
range: 11..12,
},
),
},
Attributed {
custom: (),
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,
},
),
Constant(
ExprConstant {
value: Int(
2,
),
kind: None,
range: 14..15,
},
),
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
---
[
Attributed {
custom: (),
node: Assign(
StmtAssign {
targets: [
Attributed {
custom: (),
node: Subscript(
ExprSubscript {
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,
Assign(
StmtAssign {
targets: [
Subscript(
ExprSubscript {
value: Name(
ExprName {
id: Identifier(
"x",
),
ctx: Load,
range: 0..1,
},
),
slice: Name(
ExprName {
id: Identifier(
"y",
),
ctx: Load,
range: 2..3,
},
),
ctx: Store,
range: 0..4,
},
],
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,
range: 7..16,
},
),
),
],
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,
},
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
---
[
Attributed {
custom: (),
node: Assign(
StmtAssign {
targets: [
Attributed {
custom: (),
node: Tuple(
ExprTuple {
elts: [
Attributed {
custom: (),
node: Name(
ExprName {
id: Identifier(
"x",
),
ctx: Store,
range: 1..2,
},
),
},
Attributed {
custom: (),
node: Name(
ExprName {
id: Identifier(
"y",
),
ctx: Store,
range: 4..5,
},
),
},
],
ctx: Store,
range: 0..6,
Assign(
StmtAssign {
targets: [
Tuple(
ExprTuple {
elts: [
Name(
ExprName {
id: Identifier(
"x",
),
ctx: Store,
range: 1..2,
},
),
Name(
ExprName {
id: Identifier(
"y",
),
ctx: Store,
range: 4..5,
},
),
],
ctx: Store,
range: 0..6,
},
),
],
value: Tuple(
ExprTuple {
elts: [
Constant(
ExprConstant {
value: Int(
1,
),
kind: None,
range: 10..11,
},
),
},
],
value: Attributed {
custom: (),
node: Tuple(
ExprTuple {
elts: [
Attributed {
custom: (),
node: Constant(
ExprConstant {
value: Int(
1,
),
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,
},
),
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,
},
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
---
[
Attributed {
custom: (),
node: With(
StmtWith {
items: [
Withitem {
context_expr: Attributed {
custom: (),
node: Constant(
ExprConstant {
value: Int(
1,
),
kind: None,
range: 5..6,
},
With(
StmtWith {
items: [
Withitem {
context_expr: Constant(
ExprConstant {
value: Int(
1,
),
kind: None,
range: 5..6,
},
optional_vars: Some(
Attributed {
custom: (),
node: Name(
ExprName {
id: Identifier(
"x",
),
ctx: Store,
range: 10..11,
},
),
optional_vars: Some(
Name(
ExprName {
id: Identifier(
"x",
),
ctx: Store,
range: 10..11,
},
),
range: 5..11,
),
range: PhantomData<ruff_text_size::range::TextRange>,
},
],
body: [
Pass(
StmtPass {
range: 13..17,
},
],
body: [
Attributed {
custom: (),
node: Pass(
StmtPass {
range: 13..17,
},
),
},
],
type_comment: None,
range: 0..17,
},
),
},
),
],
type_comment: None,
range: 0..17,
},
),
]

View file

@ -3,84 +3,63 @@ source: parser/src/context.rs
expression: parse_ast
---
[
Attributed {
custom: (),
node: AugAssign(
StmtAugAssign {
target: Attributed {
custom: (),
node: Attribute(
ExprAttribute {
value: Attributed {
custom: (),
node: Name(
ExprName {
id: Identifier(
"x",
),
ctx: Load,
range: 0..1,
},
),
},
attr: Identifier(
"y",
AugAssign(
StmtAugAssign {
target: Attribute(
ExprAttribute {
value: Name(
ExprName {
id: Identifier(
"x",
),
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,
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
---
[
Attributed {
custom: (),
node: AugAssign(
StmtAugAssign {
target: Attributed {
custom: (),
node: Name(
ExprName {
id: Identifier(
"x",
),
ctx: Store,
range: 0..1,
},
AugAssign(
StmtAugAssign {
target: Name(
ExprName {
id: Identifier(
"x",
),
ctx: Store,
range: 0..1,
},
op: Add,
value: Attributed {
custom: (),
node: Constant(
ExprConstant {
value: Int(
1,
),
kind: None,
range: 5..6,
},
),
op: Add,
value: Constant(
ExprConstant {
value: Int(
1,
),
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
---
[
Attributed {
custom: (),
node: AugAssign(
StmtAugAssign {
target: Attributed {
custom: (),
node: Subscript(
ExprSubscript {
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,
},
),
},
],
AugAssign(
StmtAugAssign {
target: Subscript(
ExprSubscript {
value: Name(
ExprName {
id: Identifier(
"x",
),
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
---
[
Attributed {
custom: (),
node: Delete(
StmtDelete {
targets: [
Attributed {
custom: (),
node: Attribute(
ExprAttribute {
value: Attributed {
custom: (),
node: Name(
ExprName {
id: Identifier(
"x",
),
ctx: Load,
range: 4..5,
},
),
},
attr: Identifier(
"y",
Delete(
StmtDelete {
targets: [
Attribute(
ExprAttribute {
value: Name(
ExprName {
id: Identifier(
"x",
),
ctx: Del,
range: 4..7,
ctx: Load,
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
---
[
Attributed {
custom: (),
node: Delete(
StmtDelete {
targets: [
Attributed {
custom: (),
node: Name(
ExprName {
id: Identifier(
"x",
),
ctx: Del,
range: 4..5,
},
Delete(
StmtDelete {
targets: [
Name(
ExprName {
id: Identifier(
"x",
),
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
---
[
Attributed {
custom: (),
node: Delete(
StmtDelete {
targets: [
Attributed {
custom: (),
node: Subscript(
ExprSubscript {
value: Attributed {
custom: (),
node: Name(
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,
Delete(
StmtDelete {
targets: [
Subscript(
ExprSubscript {
value: Name(
ExprName {
id: Identifier(
"x",
),
ctx: Load,
range: 4..5,
},
),
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(
[
Attributed {
custom: (),
node: FunctionDef(
StmtFunctionDef {
name: Identifier(
"f",
),
args: Arguments {
posonlyargs: [],
args: [],
vararg: None,
kwonlyargs: [
Attributed {
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,
},
FunctionDef(
StmtFunctionDef {
name: Identifier(
"f",
),
args: Arguments {
posonlyargs: [],
args: [],
vararg: None,
kwonlyargs: [
Arg {
arg: Identifier(
"a",
),
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: [],
returns: None,
type_comment: None,
range: 0..23,
kw_defaults: [],
kwarg: None,
defaults: [],
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(
[
Attributed {
custom: (),
node: FunctionDef(
StmtFunctionDef {
name: Identifier(
"f",
),
args: Arguments {
posonlyargs: [],
args: [],
vararg: None,
kwonlyargs: [
Attributed {
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,
},
FunctionDef(
StmtFunctionDef {
name: Identifier(
"f",
),
args: Arguments {
posonlyargs: [],
args: [],
vararg: None,
kwonlyargs: [
Arg {
arg: Identifier(
"a",
),
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: [],
returns: None,
type_comment: None,
range: 0..29,
kw_defaults: [
Constant(
ExprConstant {
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(
[
Attributed {
custom: (),
node: FunctionDef(
StmtFunctionDef {
name: Identifier(
"f",
),
args: Arguments {
posonlyargs: [],
args: [],
vararg: None,
kwonlyargs: [],
kw_defaults: [],
kwarg: None,
defaults: [],
range: 5..7,
},
body: [
Attributed {
custom: (),
node: Pass(
StmtPass {
range: 9..13,
},
),
},
],
decorator_list: [],
returns: None,
type_comment: None,
range: 0..13,
FunctionDef(
StmtFunctionDef {
name: Identifier(
"f",
),
args: Arguments {
posonlyargs: [],
args: [],
vararg: None,
kwonlyargs: [],
kw_defaults: [],
kwarg: None,
defaults: [],
range: PhantomData<ruff_text_size::range::TextRange>,
},
),
},
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(
[
Attributed {
custom: (),
node: FunctionDef(
StmtFunctionDef {
name: Identifier(
"f",
),
args: Arguments {
posonlyargs: [],
args: [
Attributed {
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,
},
FunctionDef(
StmtFunctionDef {
name: Identifier(
"f",
),
args: Arguments {
posonlyargs: [],
args: [
Arg {
arg: Identifier(
"a",
),
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: [],
returns: None,
type_comment: None,
range: 0..32,
vararg: None,
kwonlyargs: [
Arg {
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(
[
Attributed {
custom: (),
node: FunctionDef(
StmtFunctionDef {
name: Identifier(
"f",
),
args: Arguments {
posonlyargs: [],
args: [
Attributed {
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,
},
FunctionDef(
StmtFunctionDef {
name: Identifier(
"f",
),
args: Arguments {
posonlyargs: [],
args: [
Arg {
arg: Identifier(
"a",
),
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: [],
returns: None,
type_comment: None,
range: 0..38,
vararg: None,
kwonlyargs: [
Arg {
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(
[
Attributed {
custom: (),
node: FunctionDef(
StmtFunctionDef {
name: Identifier(
"f",
),
args: Arguments {
posonlyargs: [],
args: [
Attributed {
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,
},
FunctionDef(
StmtFunctionDef {
name: Identifier(
"f",
),
args: Arguments {
posonlyargs: [],
args: [
Arg {
arg: Identifier(
"a",
),
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: [],
returns: None,
type_comment: None,
range: 0..42,
vararg: Some(
Arg {
arg: Identifier(
"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(
[
Attributed {
custom: (),
node: FunctionDef(
StmtFunctionDef {
name: Identifier(
"f",
),
args: Arguments {
posonlyargs: [],
args: [
Attributed {
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,
},
FunctionDef(
StmtFunctionDef {
name: Identifier(
"f",
),
args: Arguments {
posonlyargs: [],
args: [
Arg {
arg: Identifier(
"a",
),
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: [],
returns: None,
type_comment: None,
range: 0..52,
vararg: Some(
Arg {
arg: Identifier(
"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(
[
Attributed {
custom: (),
node: FunctionDef(
StmtFunctionDef {
name: Identifier(
"f",
),
args: Arguments {
posonlyargs: [],
args: [
Attributed {
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,
},
FunctionDef(
StmtFunctionDef {
name: Identifier(
"f",
),
args: Arguments {
posonlyargs: [],
args: [
Arg {
arg: Identifier(
"a",
),
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: [],
returns: None,
type_comment: None,
range: 0..20,
vararg: None,
kwonlyargs: [],
kw_defaults: [],
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(
[
Attributed {
custom: (),
node: FunctionDef(
StmtFunctionDef {
name: Identifier(
"f",
),
args: Arguments {
posonlyargs: [],
args: [
Attributed {
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,
},
FunctionDef(
StmtFunctionDef {
name: Identifier(
"f",
),
args: Arguments {
posonlyargs: [],
args: [
Arg {
arg: Identifier(
"a",
),
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: [],
returns: None,
type_comment: None,
range: 0..26,
vararg: None,
kwonlyargs: [],
kw_defaults: [],
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(
[
Attributed {
custom: (),
node: Expr(
StmtExpr {
value: Attributed {
custom: (),
node: Lambda(
ExprLambda {
args: Arguments {
posonlyargs: [],
args: [],
vararg: None,
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,
},
Expr(
StmtExpr {
value: Lambda(
ExprLambda {
args: Arguments {
posonlyargs: [],
args: [],
vararg: None,
kwonlyargs: [
Arg {
arg: Identifier(
"a",
),
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(
[
Attributed {
custom: (),
node: Expr(
StmtExpr {
value: Attributed {
custom: (),
node: Lambda(
ExprLambda {
args: Arguments {
posonlyargs: [],
args: [],
vararg: None,
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,
},
Expr(
StmtExpr {
value: Lambda(
ExprLambda {
args: Arguments {
posonlyargs: [],
args: [],
vararg: None,
kwonlyargs: [
Arg {
arg: Identifier(
"a",
),
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(
[
Attributed {
custom: (),
node: Expr(
StmtExpr {
value: Attributed {
custom: (),
node: Lambda(
ExprLambda {
args: Arguments {
posonlyargs: [],
args: [],
vararg: None,
kwonlyargs: [],
kw_defaults: [],
kwarg: None,
defaults: [],
range: 0..9,
},
body: Attributed {
custom: (),
node: Constant(
ExprConstant {
value: Int(
1,
),
kind: None,
range: 8..9,
},
),
},
range: 0..9,
Expr(
StmtExpr {
value: Lambda(
ExprLambda {
args: Arguments {
posonlyargs: [],
args: [],
vararg: None,
kwonlyargs: [],
kw_defaults: [],
kwarg: None,
defaults: [],
range: PhantomData<ruff_text_size::range::TextRange>,
},
body: Constant(
ExprConstant {
value: Int(
1,
),
kind: None,
range: 8..9,
},
),
range: 0..9,
},
range: 0..9,
},
),
},
),
range: 0..9,
},
),
],
)

View file

@ -4,100 +4,76 @@ expression: parse_ast
---
Ok(
[
Attributed {
custom: (),
node: Expr(
StmtExpr {
value: Attributed {
custom: (),
node: Lambda(
ExprLambda {
args: Arguments {
posonlyargs: [],
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,
},
Expr(
StmtExpr {
value: Lambda(
ExprLambda {
args: Arguments {
posonlyargs: [],
args: [
Arg {
arg: Identifier(
"a",
),
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(
[
Attributed {
custom: (),
node: Expr(
StmtExpr {
value: Attributed {
custom: (),
node: Lambda(
ExprLambda {
args: Arguments {
posonlyargs: [],
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,
},
Expr(
StmtExpr {
value: Lambda(
ExprLambda {
args: Arguments {
posonlyargs: [],
args: [
Arg {
arg: Identifier(
"a",
),
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(
[
Attributed {
custom: (),
node: Expr(
StmtExpr {
value: Attributed {
custom: (),
node: Lambda(
ExprLambda {
args: Arguments {
posonlyargs: [],
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,
},
Expr(
StmtExpr {
value: Lambda(
ExprLambda {
args: Arguments {
posonlyargs: [],
args: [
Arg {
arg: Identifier(
"a",
),
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
expression: parse_ast
---
Attributed {
custom: (),
node: Dict(
ExprDict {
keys: [
Some(
Attributed {
custom: (),
node: Constant(
ExprConstant {
value: Str(
"a",
),
kind: None,
range: 1..4,
},
Dict(
ExprDict {
keys: [
Some(
Constant(
ExprConstant {
value: Str(
"a",
),
kind: None,
range: 1..4,
},
),
None,
Some(
Attributed {
custom: (),
node: Constant(
ExprConstant {
value: Str(
"d",
),
kind: None,
range: 16..19,
},
),
None,
Some(
Constant(
ExprConstant {
value: Str(
"d",
),
kind: None,
range: 16..19,
},
),
],
values: [
Attributed {
custom: (),
node: Constant(
ExprConstant {
value: Str(
"b",
),
kind: None,
range: 6..9,
},
),
],
values: [
Constant(
ExprConstant {
value: Str(
"b",
),
kind: None,
range: 6..9,
},
Attributed {
custom: (),
node: Name(
ExprName {
id: Identifier(
"c",
),
ctx: Load,
range: 13..14,
},
),
Name(
ExprName {
id: Identifier(
"c",
),
ctx: Load,
range: 13..14,
},
Attributed {
custom: (),
node: Constant(
ExprConstant {
value: Str(
"e",
),
kind: None,
range: 21..24,
},
),
Constant(
ExprConstant {
value: Str(
"e",
),
kind: None,
range: 21..24,
},
],
range: 0..25,
},
),
}
),
],
range: 0..25,
},
)

View file

@ -2,214 +2,157 @@
source: parser/src/parser.rs
expression: parse_ast
---
Attributed {
custom: (),
node: Call(
ExprCall {
func: Attributed {
custom: (),
node: Attribute(
ExprAttribute {
value: Attributed {
custom: (),
node: Constant(
ExprConstant {
value: Str(
" ",
),
kind: None,
range: 0..3,
},
),
},
attr: Identifier(
"join",
Call(
ExprCall {
func: Attribute(
ExprAttribute {
value: Constant(
ExprConstant {
value: Str(
" ",
),
ctx: Load,
range: 0..8,
kind: None,
range: 0..3,
},
),
attr: Identifier(
"join",
),
ctx: Load,
range: 0..8,
},
args: [
Attributed {
custom: (),
node: GeneratorExp(
ExprGeneratorExp {
elt: Attributed {
custom: (),
node: Name(
ExprName {
id: Identifier(
"sql",
),
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,
),
args: [
GeneratorExp(
ExprGeneratorExp {
elt: Name(
ExprName {
id: Identifier(
"sql",
),
ctx: Load,
range: 14..17,
},
),
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
expression: parse_ast
---
Attributed {
custom: (),
node: BoolOp(
ExprBoolOp {
op: And,
values: [
Attributed {
custom: (),
node: Name(
ExprName {
id: Identifier(
"x",
),
ctx: Load,
range: 0..1,
},
BoolOp(
ExprBoolOp {
op: And,
values: [
Name(
ExprName {
id: Identifier(
"x",
),
ctx: Load,
range: 0..1,
},
Attributed {
custom: (),
node: Name(
ExprName {
id: Identifier(
"y",
),
ctx: Load,
range: 6..7,
},
),
Name(
ExprName {
id: Identifier(
"y",
),
ctx: Load,
range: 6..7,
},
],
range: 0..7,
},
),
}
),
],
range: 0..7,
},
)

View file

@ -2,38 +2,29 @@
source: parser/src/parser.rs
expression: parse_ast
---
Attributed {
custom: (),
node: BoolOp(
ExprBoolOp {
op: Or,
values: [
Attributed {
custom: (),
node: Name(
ExprName {
id: Identifier(
"x",
),
ctx: Load,
range: 0..1,
},
BoolOp(
ExprBoolOp {
op: Or,
values: [
Name(
ExprName {
id: Identifier(
"x",
),
ctx: Load,
range: 0..1,
},
Attributed {
custom: (),
node: Name(
ExprName {
id: Identifier(
"y",
),
ctx: Load,
range: 5..6,
},
),
Name(
ExprName {
id: Identifier(
"y",
),
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()"
---
[
Attributed {
custom: (),
node: ClassDef(
StmtClassDef {
name: Identifier(
"Foo",
ClassDef(
StmtClassDef {
name: Identifier(
"Foo",
),
bases: [
Name(
ExprName {
id: Identifier(
"A",
),
ctx: Load,
range: 10..11,
},
),
bases: [
Attributed {
custom: (),
node: Name(
ExprName {
id: Identifier(
"A",
),
ctx: Load,
range: 10..11,
},
Name(
ExprName {
id: Identifier(
"B",
),
ctx: Load,
range: 13..14,
},
Attributed {
custom: (),
node: Name(
ExprName {
id: Identifier(
"B",
),
ctx: Load,
range: 13..14,
},
),
],
keywords: [],
body: [
FunctionDef(
StmtFunctionDef {
name: Identifier(
"__init__",
),
},
],
keywords: [],
body: [
Attributed {
custom: (),
node: FunctionDef(
StmtFunctionDef {
name: Identifier(
"__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: [],
args: Arguments {
posonlyargs: [],
args: [
Arg {
arg: Identifier(
"self",
),
annotation: None,
type_comment: None,
range: 31..35,
},
body: [
Attributed {
custom: (),
node: Pass(
StmtPass {
range: 40..44,
},
),
},
],
decorator_list: [],
returns: None,
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,
],
vararg: None,
kwonlyargs: [],
kw_defaults: [],
kwarg: None,
defaults: [],
range: PhantomData<ruff_text_size::range::TextRange>,
},
body: [
Pass(
StmtPass {
range: 40..44,
},
body: [
Attributed {
custom: (),
node: Pass(
StmtPass {
range: 94..98,
},
),
},
],
decorator_list: [],
returns: None,
type_comment: None,
range: 46..98,
},
),
),
],
decorator_list: [],
returns: None,
type_comment: None,
range: 18..44,
},
],
decorator_list: [],
range: 0..98,
},
),
},
),
FunctionDef(
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
expression: parse_ast
---
Attributed {
custom: (),
node: DictComp(
ExprDictComp {
key: Attributed {
custom: (),
node: Name(
DictComp(
ExprDictComp {
key: Name(
ExprName {
id: Identifier(
"x1",
),
ctx: Load,
range: 1..3,
},
),
value: Name(
ExprName {
id: Identifier(
"x2",
),
ctx: Load,
range: 5..7,
},
),
generators: [
Comprehension {
target: Name(
ExprName {
id: Identifier(
"x1",
"y",
),
ctx: Load,
range: 1..3,
ctx: Store,
range: 12..13,
},
),
},
value: Attributed {
custom: (),
node: Name(
iter: Name(
ExprName {
id: Identifier(
"x2",
"z",
),
ctx: Load,
range: 5..7,
range: 17..18,
},
),
ifs: [],
is_async: false,
range: PhantomData<ruff_text_size::range::TextRange>,
},
generators: [
Comprehension {
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,
},
),
}
],
range: 0..19,
},
)

View file

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

View file

@ -3,34 +3,25 @@ source: parser/src/parser.rs
expression: parse_ast
---
[
Attributed {
custom: (),
node: Expr(
StmtExpr {
value: Attributed {
custom: (),
node: JoinedStr(
ExprJoinedStr {
values: [
Attributed {
custom: (),
node: Constant(
ExprConstant {
value: Str(
"Hello world",
),
kind: None,
range: 0..14,
},
),
},
],
range: 0..14,
},
),
Expr(
StmtExpr {
value: JoinedStr(
ExprJoinedStr {
values: [
Constant(
ExprConstant {
value: Str(
"Hello world",
),
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
expression: parse_ast
---
Attributed {
custom: (),
node: GeneratorExp(
ExprGeneratorExp {
elt: Attributed {
custom: (),
node: Name(
GeneratorExp(
ExprGeneratorExp {
elt: Name(
ExprName {
id: Identifier(
"x",
),
ctx: Load,
range: 1..2,
},
),
generators: [
Comprehension {
target: Name(
ExprName {
id: Identifier(
"x",
"y",
),
ctx: Load,
range: 1..2,
ctx: Store,
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 {
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,
},
),
}
],
range: 0..14,
},
)

View file

@ -3,112 +3,82 @@ source: parser/src/parser.rs
expression: parse_ast
---
[
Attributed {
custom: (),
node: If(
StmtIf {
test: Attributed {
custom: (),
node: Constant(
ExprConstant {
value: Int(
1,
),
kind: None,
range: 3..4,
},
If(
StmtIf {
test: Constant(
ExprConstant {
value: Int(
1,
),
kind: None,
range: 3..4,
},
body: [
Attributed {
custom: (),
node: Expr(
StmtExpr {
value: Attributed {
custom: (),
node: Constant(
ExprConstant {
value: Int(
10,
),
kind: None,
range: 6..8,
},
),
},
),
body: [
Expr(
StmtExpr {
value: Constant(
ExprConstant {
value: Int(
10,
),
kind: None,
range: 6..8,
},
),
range: 6..8,
},
],
orelse: [
Attributed {
custom: (),
node: If(
StmtIf {
test: Attributed {
custom: (),
node: Constant(
ExprConstant {
value: Int(
2,
),
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,
),
],
orelse: [
If(
StmtIf {
test: Constant(
ExprConstant {
value: Int(
2,
),
kind: None,
range: 14..15,
},
),
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
expression: parse_ast
---
Attributed {
custom: (),
node: GeneratorExp(
ExprGeneratorExp {
elt: Attributed {
custom: (),
node: IfExp(
ExprIfExp {
test: Attributed {
custom: (),
node: Name(
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,
GeneratorExp(
ExprGeneratorExp {
elt: IfExp(
ExprIfExp {
test: Name(
ExprName {
id: Identifier(
"y",
),
ctx: Load,
range: 6..7,
},
),
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 {
target: Attributed {
custom: (),
node: Name(
ExprName {
id: Identifier(
"y",
),
ctx: Store,
range: 19..20,
},
),
generators: [
Comprehension {
target: Name(
ExprName {
id: Identifier(
"y",
),
ctx: Store,
range: 19..20,
},
iter: Attributed {
custom: (),
node: Name(
ExprName {
id: Identifier(
"z",
),
ctx: Load,
range: 24..25,
},
),
iter: Name(
ExprName {
id: Identifier(
"z",
),
ctx: Load,
range: 24..25,
},
ifs: [],
is_async: false,
range: 15..25,
},
],
range: 0..26,
},
),
}
),
ifs: [],
is_async: false,
range: PhantomData<ruff_text_size::range::TextRange>,
},
],
range: 0..26,
},
)

View file

@ -3,71 +3,53 @@ source: parser/src/parser.rs
expression: parse_ast
---
[
Attributed {
custom: (),
node: Expr(
StmtExpr {
value: Attributed {
custom: (),
node: Call(
ExprCall {
func: Attributed {
custom: (),
node: Name(
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,
Expr(
StmtExpr {
value: Call(
ExprCall {
func: Name(
ExprName {
id: Identifier(
"my_func",
),
ctx: Load,
range: 0..7,
},
),
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
---
[
Attributed {
custom: (),
node: Expr(
StmtExpr {
value: Attributed {
custom: (),
node: Lambda(
ExprLambda {
args: Arguments {
posonlyargs: [],
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,
},
Expr(
StmtExpr {
value: Lambda(
ExprLambda {
args: Arguments {
posonlyargs: [],
args: [
Arg {
arg: Identifier(
"x",
),
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
expression: parse_ast
---
Attributed {
custom: (),
node: ListComp(
ExprListComp {
elt: Attributed {
custom: (),
node: Name(
ListComp(
ExprListComp {
elt: Name(
ExprName {
id: Identifier(
"x",
),
ctx: Load,
range: 1..2,
},
),
generators: [
Comprehension {
target: Name(
ExprName {
id: Identifier(
"x",
"y",
),
ctx: Load,
range: 1..2,
ctx: Store,
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 {
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,
},
),
}
],
range: 0..14,
},
)

View file

@ -2,95 +2,71 @@
source: parser/src/parser.rs
expression: parse_ast
---
Attributed {
custom: (),
node: GeneratorExp(
ExprGeneratorExp {
elt: Attributed {
custom: (),
node: NamedExpr(
ExprNamedExpr {
target: Attributed {
custom: (),
node: Name(
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,
GeneratorExp(
ExprGeneratorExp {
elt: NamedExpr(
ExprNamedExpr {
target: Name(
ExprName {
id: Identifier(
"x",
),
ctx: Store,
range: 1..2,
},
),
},
generators: [
Comprehension {
target: Attributed {
custom: (),
node: Name(
value: BinOp(
ExprBinOp {
left: Name(
ExprName {
id: Identifier(
"y",
),
ctx: Store,
range: 16..17,
},
),
},
iter: Attributed {
custom: (),
node: Name(
ExprName {
id: Identifier(
"z",
),
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: 12..22,
},
],
range: 0..23,
},
),
}
),
range: 1..11,
},
),
generators: [
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
---
[
Attributed {
custom: (),
node: Expr(
StmtExpr {
value: Attributed {
custom: (),
node: Call(
ExprCall {
func: Attributed {
custom: (),
node: Name(
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,
Expr(
StmtExpr {
value: Call(
ExprCall {
func: Name(
ExprName {
id: Identifier(
"print",
),
ctx: Load,
range: 0..5,
},
),
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
---
[
Attributed {
custom: (),
node: Expr(
StmtExpr {
value: Attributed {
custom: (),
node: Call(
ExprCall {
func: Attributed {
custom: (),
node: Name(
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,
Expr(
StmtExpr {
value: Call(
ExprCall {
func: Name(
ExprName {
id: Identifier(
"print",
),
ctx: Load,
range: 0..5,
},
),
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
---
[
Attributed {
custom: (),
node: Expr(
StmtExpr {
value: Attributed {
custom: (),
node: Constant(
ExprConstant {
value: Str(
"Hello world",
),
kind: None,
range: 0..13,
},
Expr(
StmtExpr {
value: Constant(
ExprConstant {
value: Str(
"Hello world",
),
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()"
---
[
Attributed {
custom: (),
node: Assign(
StmtAssign {
targets: [
Attributed {
custom: (),
node: Tuple(
ExprTuple {
elts: [
Attributed {
custom: (),
node: Name(
ExprName {
id: Identifier(
"a",
),
ctx: Store,
range: 0..1,
},
),
},
Attributed {
custom: (),
node: Name(
ExprName {
id: Identifier(
"b",
),
ctx: Store,
range: 3..4,
},
),
},
],
ctx: Store,
range: 0..4,
Assign(
StmtAssign {
targets: [
Tuple(
ExprTuple {
elts: [
Name(
ExprName {
id: Identifier(
"a",
),
ctx: Store,
range: 0..1,
},
),
Name(
ExprName {
id: Identifier(
"b",
),
ctx: Store,
range: 3..4,
},
),
],
ctx: Store,
range: 0..4,
},
),
],
value: Tuple(
ExprTuple {
elts: [
Constant(
ExprConstant {
value: Int(
4,
),
kind: None,
range: 7..8,
},
),
},
],
value: Attributed {
custom: (),
node: Tuple(
ExprTuple {
elts: [
Attributed {
custom: (),
node: Constant(
ExprConstant {
value: Int(
4,
),
kind: None,
range: 7..8,
},
),
},
Attributed {
custom: (),
node: Constant(
ExprConstant {
value: Int(
5,
),
kind: None,
range: 10..11,
},
),
},
],
ctx: Load,
range: 7..11,
},
),
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
expression: parse_ast
---
Attributed {
custom: (),
node: Subscript(
ExprSubscript {
value: Attributed {
custom: (),
node: Name(
ExprName {
id: Identifier(
"x",
),
ctx: Load,
range: 0..1,
},
Subscript(
ExprSubscript {
value: Name(
ExprName {
id: Identifier(
"x",
),
ctx: Load,
range: 0..1,
},
slice: Attributed {
custom: (),
node: Slice(
ExprSlice {
lower: Some(
Attributed {
custom: (),
node: Constant(
ExprConstant {
value: Int(
1,
),
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,
},
),
slice: Slice(
ExprSlice {
lower: Some(
Constant(
ExprConstant {
value: Int(
1,
),
kind: None,
range: 2..3,
},
),
),
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
---
[
Attributed {
custom: (),
node: Assign(
StmtAssign {
targets: [
Attributed {
custom: (),
node: Name(
ExprName {
id: Identifier(
"array_slice",
),
ctx: Store,
range: 0..11,
},
Assign(
StmtAssign {
targets: [
Name(
ExprName {
id: Identifier(
"array_slice",
),
ctx: Store,
range: 0..11,
},
],
value: Attributed {
custom: (),
node: Subscript(
ExprSubscript {
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(
),
],
value: Subscript(
ExprSubscript {
value: Name(
ExprName {
id: Identifier(
"array_slice",
"array",
),
ctx: Load,
range: 62..73,
range: 14..19,
},
),
},
type_comment: None,
range: 37..73,
},
),
},
Attributed {
custom: (),
node: Expr(
StmtExpr {
value: Attributed {
custom: (),
node: Subscript(
ExprSubscript {
value: Attributed {
custom: (),
node: Name(
ExprName {
id: Identifier(
"array",
slice: Tuple(
ExprTuple {
elts: [
Constant(
ExprConstant {
value: Int(
0,
),
kind: None,
range: 20..21,
},
),
Starred(
ExprStarred {
value: Name(
ExprName {
id: Identifier(
"indexes",
),
ctx: Load,
range: 24..31,
},
),
ctx: Load,
range: 74..79,
range: 23..31,
},
),
},
slice: Attributed {
custom: (),
node: Tuple(
ExprTuple {
elts: [
Attributed {
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,
},
UnaryOp(
ExprUnaryOp {
op: USub,
operand: Constant(
ExprConstant {
value: Int(
1,
),
kind: None,
range: 34..35,
},
Attributed {
custom: (),
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,
),
range: 33..35,
},
),
},
],
ctx: Load,
range: 74..119,
range: 20..35,
},
),
ctx: Load,
range: 14..36,
},
range: 74..119,
},
),
},
Attributed {
custom: (),
node: Expr(
StmtExpr {
value: Attributed {
custom: (),
node: Subscript(
ExprSubscript {
value: Attributed {
custom: (),
node: Name(
ExprName {
id: Identifier(
"array",
),
type_comment: None,
range: 0..36,
},
),
Assign(
StmtAssign {
targets: [
Subscript(
ExprSubscript {
value: Name(
ExprName {
id: Identifier(
"array",
),
ctx: Load,
range: 37..42,
},
),
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,
range: 120..125,
range: 80..98,
},
),
},
slice: Attributed {
custom: (),
node: Tuple(
ExprTuple {
elts: [
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,
},
Starred(
ExprStarred {
value: Name(
ExprName {
id: Identifier(
"indexes_to_select",
),
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,
range: 126..149,
range: 100..118,
},
),
},
],
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
---
[
Attributed {
custom: (),
node: Try(
StmtTry {
body: [
Attributed {
custom: (),
node: Raise(
StmtRaise {
exc: Some(
Attributed {
custom: (),
node: Call(
ExprCall {
func: Attributed {
custom: (),
node: Name(
ExprName {
id: Identifier(
"ValueError",
Try(
StmtTry {
body: [
Raise(
StmtRaise {
exc: Some(
Call(
ExprCall {
func: Name(
ExprName {
id: Identifier(
"ValueError",
),
ctx: Load,
range: 15..25,
},
),
args: [
Constant(
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,
range: 15..25,
},
),
},
args: [
Attributed {
custom: (),
node: Constant(
ExprConstant {
value: Int(
1,
),
kind: None,
range: 26..27,
},
),
FormattedValue(
ExprFormattedValue {
value: Call(
ExprCall {
func: Name(
ExprName {
id: Identifier(
"type",
),
ctx: Load,
range: 72..76,
},
),
args: [
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,
},
),
},
),
name: Some(
Identifier(
"e",
],
keywords: [],
range: 56..82,
},
),
),
body: [
Attributed {
custom: (),
node: Expr(
StmtExpr {
value: Attributed {
custom: (),
node: Call(
ExprCall {
func: Attributed {
custom: (),
node: Name(
ExprName {
id: Identifier(
"print",
),
ctx: Load,
range: 56..61,
},
),
},
args: [
Attributed {
custom: (),
node: JoinedStr(
ExprJoinedStr {
values: [
Attributed {
custom: (),
node: Constant(
ExprConstant {
value: Str(
"caught ",
),
kind: None,
range: 62..81,
},
),
},
Attributed {
custom: (),
node: FormattedValue(
ExprFormattedValue {
value: Attributed {
custom: (),
node: Call(
ExprCall {
func: Attributed {
custom: (),
node: Name(
ExprName {
id: Identifier(
"type",
),
ctx: Load,
range: 72..76,
},
),
},
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,
},
range: 56..82,
},
),
],
range: 29..82,
},
),
ExceptHandler(
ExcepthandlerExceptHandler {
type_: Some(
Name(
ExprName {
id: Identifier(
"OSError",
),
ctx: Load,
range: 90..97,
},
),
),
name: Some(
Identifier(
"e",
),
),
body: [
Expr(
StmtExpr {
value: Call(
ExprCall {
func: Name(
ExprName {
id: Identifier(
"print",
),
ctx: Load,
range: 108..113,
},
),
args: [
JoinedStr(
ExprJoinedStr {
values: [
Constant(
ExprConstant {
value: Str(
"caught ",
),
kind: None,
range: 114..133,
},
),
FormattedValue(
ExprFormattedValue {
value: Call(
ExprCall {
func: Name(
ExprName {
id: Identifier(
"type",
),
ctx: Load,
range: 124..128,
},
),
args: [
Name(
ExprName {
id: Identifier(
"e",
),
ctx: Load,
range: 129..130,
},
),
],
range: 62..81,
keywords: [],
range: 124..131,
},
),
},
],
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,
},
conversion: Int(
0,
),
format_spec: None,
range: 114..133,
},
],
keywords: [],
range: 108..134,
},
),
},
range: 108..134,
},
),
},
],
range: 83..134,
},
),
),
],
range: 114..133,
},
),
],
keywords: [],
range: 108..134,
},
),
range: 108..134,
},
),
],
range: 83..134,
},
],
orelse: [],
finalbody: [],
range: 0..134,
},
),
},
),
],
orelse: [],
finalbody: [],
range: 0..134,
},
),
]

View file

@ -3,569 +3,425 @@ source: parser/src/parser.rs
expression: parse_ast
---
[
Attributed {
custom: (),
node: TryStar(
StmtTryStar {
body: [
Attributed {
custom: (),
node: Raise(
StmtRaise {
exc: Some(
Attributed {
custom: (),
node: Call(
ExprCall {
func: Attributed {
custom: (),
node: Name(
ExprName {
id: Identifier(
"ExceptionGroup",
TryStar(
StmtTryStar {
body: [
Raise(
StmtRaise {
exc: Some(
Call(
ExprCall {
func: Name(
ExprName {
id: Identifier(
"ExceptionGroup",
),
ctx: Load,
range: 15..29,
},
),
args: [
Constant(
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,
range: 15..29,
args: [
Constant(
ExprConstant {
value: Int(
1,
),
kind: None,
range: 56..57,
},
),
],
keywords: [],
range: 45..58,
},
),
},
args: [
Attributed {
custom: (),
node: Constant(
ExprConstant {
value: Str(
"eg",
Call(
ExprCall {
func: Name(
ExprName {
id: Identifier(
"TypeError",
),
ctx: Load,
range: 60..69,
},
),
args: [
Constant(
ExprConstant {
value: Int(
2,
),
kind: None,
range: 70..71,
},
),
kind: None,
range: 30..34,
},
),
},
Attributed {
custom: (),
node: List(
ExprList {
elts: [
Attributed {
custom: (),
node: Call(
ExprCall {
func: Attributed {
custom: (),
node: Name(
ExprName {
id: Identifier(
"ValueError",
),
ctx: Load,
range: 45..55,
},
),
},
args: [
Attributed {
custom: (),
node: Constant(
ExprConstant {
value: Int(
1,
),
kind: None,
range: 56..57,
},
),
},
],
keywords: [],
range: 45..58,
},
],
keywords: [],
range: 60..72,
},
),
Call(
ExprCall {
func: Name(
ExprName {
id: Identifier(
"OSError",
),
ctx: Load,
range: 74..81,
},
),
args: [
Constant(
ExprConstant {
value: Int(
3,
),
kind: None,
range: 82..83,
},
Attributed {
custom: (),
node: Call(
ExprCall {
func: Attributed {
custom: (),
node: Name(
ExprName {
id: Identifier(
"TypeError",
),
ctx: Load,
range: 60..69,
},
),
},
args: [
Attributed {
custom: (),
node: Constant(
ExprConstant {
value: Int(
2,
),
kind: None,
range: 70..71,
},
),
},
],
keywords: [],
range: 60..72,
},
),
],
keywords: [],
range: 74..84,
},
),
Call(
ExprCall {
func: Name(
ExprName {
id: Identifier(
"OSError",
),
ctx: Load,
range: 86..93,
},
),
args: [
Constant(
ExprConstant {
value: Int(
4,
),
kind: None,
range: 94..95,
},
Attributed {
custom: (),
node: Call(
ExprCall {
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: 86..96,
},
),
],
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,
range: 107..116,
range: 44..97,
},
),
},
),
name: Some(
Identifier(
"e",
],
keywords: [],
range: 15..98,
},
),
),
cause: None,
range: 9..98,
},
),
],
handlers: [
ExceptHandler(
ExcepthandlerExceptHandler {
type_: Some(
Name(
ExprName {
id: Identifier(
"TypeError",
),
),
body: [
Attributed {
custom: (),
node: Expr(
StmtExpr {
value: Attributed {
custom: (),
node: Call(
ExprCall {
func: Attributed {
custom: (),
node: Name(
ExprName {
id: Identifier(
"print",
),
ctx: Load,
range: 127..132,
},
),
},
args: [
Attributed {
custom: (),
node: JoinedStr(
ExprJoinedStr {
values: [
Attributed {
custom: (),
node: Constant(
ExprConstant {
value: Str(
"caught ",
),
kind: None,
range: 133..179,
},
),
},
Attributed {
custom: (),
node: FormattedValue(
ExprFormattedValue {
value: Attributed {
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: 107..116,
},
),
),
name: Some(
Identifier(
"e",
),
),
body: [
Expr(
StmtExpr {
value: Call(
ExprCall {
func: Name(
ExprName {
id: Identifier(
"print",
),
ctx: Load,
range: 127..132,
},
),
args: [
JoinedStr(
ExprJoinedStr {
values: [
Constant(
ExprConstant {
value: Str(
"caught ",
),
kind: None,
range: 133..179,
},
),
FormattedValue(
ExprFormattedValue {
value: Call(
ExprCall {
func: Name(
ExprName {
id: Identifier(
"type",
),
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: [],
range: 127..180,
},
),
},
range: 127..180,
},
),
},
],
range: 99..180,
},
),
},
Attributed {
custom: (),
node: ExceptHandler(
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,
},
),
Constant(
ExprConstant {
value: Str(
" with nested ",
),
kind: None,
range: 133..179,
},
),
FormattedValue(
ExprFormattedValue {
value: Attribute(
ExprAttribute {
value: Name(
ExprName {
id: Identifier(
"e",
),
ctx: Load,
range: 165..166,
},
Attributed {
custom: (),
node: FormattedValue(
ExprFormattedValue {
value: Attributed {
custom: (),
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,
),
attr: Identifier(
"exceptions",
),
ctx: Load,
range: 165..177,
},
),
conversion: Int(
0,
),
format_spec: None,
range: 133..179,
},
],
keywords: [],
range: 207..260,
},
),
},
range: 207..260,
},
),
},
],
range: 181..260,
},
),
),
],
range: 133..179,
},
),
],
keywords: [],
range: 127..180,
},
),
range: 127..180,
},
),
],
range: 99..180,
},
],
orelse: [],
finalbody: [],
range: 0..260,
},
),
},
),
ExceptHandler(
ExcepthandlerExceptHandler {
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
---
[
Attributed {
custom: (),
node: FunctionDef(
StmtFunctionDef {
name: Identifier(
"args_to_tuple",
),
args: Arguments {
posonlyargs: [],
args: [],
vararg: Some(
Attributed {
custom: (),
node: ArgData {
arg: Identifier(
"args",
),
annotation: Some(
Attributed {
custom: (),
node: Starred(
ExprStarred {
value: Attributed {
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,
FunctionDef(
StmtFunctionDef {
name: Identifier(
"args_to_tuple",
),
args: Arguments {
posonlyargs: [],
args: [],
vararg: Some(
Arg {
arg: Identifier(
"args",
),
annotation: Some(
Starred(
ExprStarred {
value: 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: PhantomData<ruff_text_size::range::TextRange>,
},
body: [
Expr(
StmtExpr {
value: Constant(
ExprConstant {
value: Ellipsis,
kind: None,
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,
},
),
range: 46..49,
},
),
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
---
[
Attributed {
custom: (),
node: Expr(
StmtExpr {
value: Attributed {
custom: (),
node: Constant(
ExprConstant {
value: Str(
"\u{8}",
),
kind: None,
range: 0..15,
},
Expr(
StmtExpr {
value: Constant(
ExprConstant {
value: Str(
"\u{8}",
),
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
---
[
Attributed {
custom: (),
node: Expr(
StmtExpr {
value: Attributed {
custom: (),
node: Constant(
ExprConstant {
value: Str(
"\u{7}",
),
kind: None,
range: 0..9,
},
Expr(
StmtExpr {
value: Constant(
ExprConstant {
value: Str(
"\u{7}",
),
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
---
[
Attributed {
custom: (),
node: Expr(
StmtExpr {
value: Attributed {
custom: (),
node: Constant(
ExprConstant {
value: Str(
"\r",
),
kind: None,
range: 0..21,
},
Expr(
StmtExpr {
value: Constant(
ExprConstant {
value: Str(
"\r",
),
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
---
[
Attributed {
custom: (),
node: Expr(
StmtExpr {
value: Attributed {
custom: (),
node: Constant(
ExprConstant {
value: Str(
"\u{89}",
),
kind: None,
range: 0..45,
},
Expr(
StmtExpr {
value: Constant(
ExprConstant {
value: Str(
"\u{89}",
),
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
---
[
Attributed {
custom: (),
node: Expr(
StmtExpr {
value: Attributed {
custom: (),
node: Constant(
ExprConstant {
value: Str(
"\u{7f}",
),
kind: None,
range: 0..12,
},
Expr(
StmtExpr {
value: Constant(
ExprConstant {
value: Str(
"\u{7f}",
),
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
---
[
Attributed {
custom: (),
node: Expr(
StmtExpr {
value: Attributed {
custom: (),
node: Constant(
ExprConstant {
value: Bytes(
[
0,
1,
2,
3,
4,
5,
6,
7,
8,
9,
10,
11,
12,
13,
14,
15,
16,
17,
18,
19,
20,
21,
22,
23,
24,
25,
26,
27,
28,
29,
30,
31,
32,
33,
34,
35,
36,
37,
38,
39,
40,
41,
42,
43,
44,
45,
46,
47,
48,
49,
50,
51,
52,
53,
54,
55,
56,
57,
58,
59,
60,
61,
62,
63,
64,
65,
66,
67,
68,
69,
70,
71,
72,
73,
74,
75,
76,
77,
78,
79,
80,
81,
82,
83,
84,
85,
86,
87,
88,
89,
90,
91,
92,
93,
94,
95,
96,
97,
98,
99,
100,
101,
102,
103,
104,
105,
106,
107,
108,
109,
110,
111,
112,
113,
114,
115,
116,
117,
118,
119,
120,
121,
122,
123,
124,
125,
126,
127,
128,
129,
130,
131,
132,
133,
134,
135,
136,
137,
138,
139,
140,
141,
142,
143,
144,
145,
146,
147,
148,
149,
150,
151,
152,
153,
154,
155,
156,
157,
158,
159,
160,
161,
162,
163,
164,
165,
166,
167,
168,
169,
170,
171,
172,
173,
174,
175,
176,
177,
178,
179,
180,
181,
182,
183,
184,
185,
186,
187,
188,
189,
190,
191,
192,
193,
194,
195,
196,
197,
198,
199,
200,
201,
202,
203,
204,
205,
206,
207,
208,
209,
210,
211,
212,
213,
214,
215,
216,
217,
218,
219,
220,
221,
222,
223,
224,
225,
226,
227,
228,
229,
230,
231,
232,
233,
234,
235,
236,
237,
238,
239,
240,
241,
242,
243,
244,
245,
246,
247,
248,
249,
250,
251,
252,
253,
254,
255,
],
),
kind: None,
range: 0..738,
},
Expr(
StmtExpr {
value: Constant(
ExprConstant {
value: Bytes(
[
0,
1,
2,
3,
4,
5,
6,
7,
8,
9,
10,
11,
12,
13,
14,
15,
16,
17,
18,
19,
20,
21,
22,
23,
24,
25,
26,
27,
28,
29,
30,
31,
32,
33,
34,
35,
36,
37,
38,
39,
40,
41,
42,
43,
44,
45,
46,
47,
48,
49,
50,
51,
52,
53,
54,
55,
56,
57,
58,
59,
60,
61,
62,
63,
64,
65,
66,
67,
68,
69,
70,
71,
72,
73,
74,
75,
76,
77,
78,
79,
80,
81,
82,
83,
84,
85,
86,
87,
88,
89,
90,
91,
92,
93,
94,
95,
96,
97,
98,
99,
100,
101,
102,
103,
104,
105,
106,
107,
108,
109,
110,
111,
112,
113,
114,
115,
116,
117,
118,
119,
120,
121,
122,
123,
124,
125,
126,
127,
128,
129,
130,
131,
132,
133,
134,
135,
136,
137,
138,
139,
140,
141,
142,
143,
144,
145,
146,
147,
148,
149,
150,
151,
152,
153,
154,
155,
156,
157,
158,
159,
160,
161,
162,
163,
164,
165,
166,
167,
168,
169,
170,
171,
172,
173,
174,
175,
176,
177,
178,
179,
180,
181,
182,
183,
184,
185,
186,
187,
188,
189,
190,
191,
192,
193,
194,
195,
196,
197,
198,
199,
200,
201,
202,
203,
204,
205,
206,
207,
208,
209,
210,
211,
212,
213,
214,
215,
216,
217,
218,
219,
220,
221,
222,
223,
224,
225,
226,
227,
228,
229,
230,
231,
232,
233,
234,
235,
236,
237,
238,
239,
240,
241,
242,
243,
244,
245,
246,
247,
248,
249,
250,
251,
252,
253,
254,
255,
],
),
kind: None,
range: 0..738,
},
range: 0..738,
},
),
},
),
range: 0..738,
},
),
]

View file

@ -3,24 +3,18 @@ source: parser/src/string.rs
expression: parse_ast
---
[
Attributed {
custom: (),
node: Expr(
StmtExpr {
value: Attributed {
custom: (),
node: Constant(
ExprConstant {
value: Str(
"\u{1b}",
),
kind: None,
range: 0..12,
},
Expr(
StmtExpr {
value: Constant(
ExprConstant {
value: Str(
"\u{1b}",
),
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
---
[
Attributed {
custom: (),
node: Expr(
StmtExpr {
value: Attributed {
custom: (),
node: Constant(
ExprConstant {
value: Bytes(
[
111,
109,
107,
109,
111,
107,
92,
88,
97,
97,
],
),
kind: None,
range: 0..13,
},
Expr(
StmtExpr {
value: Constant(
ExprConstant {
value: Bytes(
[
111,
109,
107,
109,
111,
107,
92,
88,
97,
97,
],
),
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
---
[
Attributed {
custom: (),
node: Expr(
StmtExpr {
value: Attributed {
custom: (),
node: Constant(
ExprConstant {
value: Bytes(
[
35,
97,
4,
83,
52,
],
),
kind: None,
range: 0..14,
},
Expr(
StmtExpr {
value: Constant(
ExprConstant {
value: Bytes(
[
35,
97,
4,
83,
52,
],
),
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
---
[
Attributed {
custom: (),
node: Expr(
StmtExpr {
value: Attributed {
custom: (),
node: Constant(
ExprConstant {
value: Str(
"\u{c}",
),
kind: None,
range: 0..15,
},
Expr(
StmtExpr {
value: Constant(
ExprConstant {
value: Str(
"\u{c}",
),
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
---
[
Attributed {
custom: (),
node: Expr(
StmtExpr {
value: Attributed {
custom: (),
node: JoinedStr(
ExprJoinedStr {
values: [
Attributed {
custom: (),
node: Constant(
ExprConstant {
value: Str(
"\\",
),
kind: None,
range: 0..8,
},
),
},
Attributed {
custom: (),
node: FormattedValue(
ExprFormattedValue {
value: Attributed {
custom: (),
node: Name(
ExprName {
id: Identifier(
"x",
),
ctx: Load,
range: 5..6,
},
),
},
conversion: Int(
0,
),
format_spec: None,
range: 0..8,
},
),
},
],
range: 0..8,
},
),
Expr(
StmtExpr {
value: JoinedStr(
ExprJoinedStr {
values: [
Constant(
ExprConstant {
value: Str(
"\\",
),
kind: None,
range: 0..8,
},
),
FormattedValue(
ExprFormattedValue {
value: Name(
ExprName {
id: Identifier(
"x",
),
ctx: Load,
range: 5..6,
},
),
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
---
[
Attributed {
custom: (),
node: Expr(
StmtExpr {
value: Attributed {
custom: (),
node: JoinedStr(
ExprJoinedStr {
values: [
Attributed {
custom: (),
node: Constant(
ExprConstant {
value: Str(
"\n",
),
kind: None,
range: 0..8,
},
),
},
Attributed {
custom: (),
node: FormattedValue(
ExprFormattedValue {
value: Attributed {
custom: (),
node: Name(
ExprName {
id: Identifier(
"x",
),
ctx: Load,
range: 5..6,
},
),
},
conversion: Int(
0,
),
format_spec: None,
range: 0..8,
},
),
},
],
range: 0..8,
},
),
Expr(
StmtExpr {
value: JoinedStr(
ExprJoinedStr {
values: [
Constant(
ExprConstant {
value: Str(
"\n",
),
kind: None,
range: 0..8,
},
),
FormattedValue(
ExprFormattedValue {
value: Name(
ExprName {
id: Identifier(
"x",
),
ctx: Load,
range: 5..6,
},
),
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
---
[
Attributed {
custom: (),
node: Expr(
StmtExpr {
value: Attributed {
custom: (),
node: JoinedStr(
ExprJoinedStr {
values: [
Attributed {
custom: (),
node: Constant(
ExprConstant {
value: Str(
"\\\n",
),
kind: None,
range: 0..9,
},
),
},
Attributed {
custom: (),
node: FormattedValue(
ExprFormattedValue {
value: Attributed {
custom: (),
node: Name(
ExprName {
id: Identifier(
"x",
),
ctx: Load,
range: 6..7,
},
),
},
conversion: Int(
0,
),
format_spec: None,
range: 0..9,
},
),
},
],
range: 0..9,
},
),
Expr(
StmtExpr {
value: JoinedStr(
ExprJoinedStr {
values: [
Constant(
ExprConstant {
value: Str(
"\\\n",
),
kind: None,
range: 0..9,
},
),
FormattedValue(
ExprFormattedValue {
value: Name(
ExprName {
id: Identifier(
"x",
),
ctx: Load,
range: 6..7,
},
),
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
---
[
Attributed {
custom: (),
node: Constant(
ExprConstant {
value: Str(
"user=",
),
kind: None,
range: 0..10,
},
),
},
Attributed {
custom: (),
node: Constant(
ExprConstant {
value: Str(
"",
),
kind: None,
range: 0..10,
},
),
},
Attributed {
custom: (),
node: FormattedValue(
ExprFormattedValue {
value: Attributed {
custom: (),
node: Name(
ExprName {
id: Identifier(
"user",
),
ctx: Load,
range: 3..7,
},
Constant(
ExprConstant {
value: Str(
"user=",
),
kind: None,
range: 0..10,
},
),
Constant(
ExprConstant {
value: Str(
"",
),
kind: None,
range: 0..10,
},
),
FormattedValue(
ExprFormattedValue {
value: Name(
ExprName {
id: Identifier(
"user",
),
ctx: Load,
range: 3..7,
},
conversion: Int(
114,
),
format_spec: None,
range: 0..10,
},
),
},
),
conversion: Int(
114,
),
format_spec: None,
range: 0..10,
},
),
]

View file

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

View file

@ -3,75 +3,57 @@ source: parser/src/string.rs
expression: parse_ast
---
[
Attributed {
custom: (),
node: Constant(
ExprConstant {
value: Str(
"user=",
),
kind: None,
range: 0..14,
},
),
},
Attributed {
custom: (),
node: Constant(
ExprConstant {
value: Str(
"",
),
kind: None,
range: 0..14,
},
),
},
Attributed {
custom: (),
node: FormattedValue(
ExprFormattedValue {
value: Attributed {
custom: (),
node: Name(
ExprName {
id: Identifier(
"user",
),
ctx: Load,
range: 3..7,
},
Constant(
ExprConstant {
value: Str(
"user=",
),
kind: None,
range: 0..14,
},
),
Constant(
ExprConstant {
value: Str(
"",
),
kind: None,
range: 0..14,
},
),
FormattedValue(
ExprFormattedValue {
value: Name(
ExprName {
id: Identifier(
"user",
),
ctx: Load,
range: 3..7,
},
conversion: Int(
0,
),
format_spec: Some(
Attributed {
custom: (),
node: JoinedStr(
ExprJoinedStr {
values: [
Attributed {
custom: (),
node: Constant(
ExprConstant {
value: Str(
">10",
),
kind: None,
range: 0..14,
},
),
},
],
range: 0..14,
},
),
),
conversion: Int(
0,
),
format_spec: Some(
JoinedStr(
ExprJoinedStr {
values: [
Constant(
ExprConstant {
value: Str(
">10",
),
kind: None,
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
---
[
Attributed {
custom: (),
node: Expr(
StmtExpr {
value: Attributed {
custom: (),
node: JoinedStr(
ExprJoinedStr {
values: [
Attributed {
custom: (),
node: Constant(
ExprConstant {
value: Str(
"\n",
),
kind: None,
range: 0..11,
},
),
},
Attributed {
custom: (),
node: FormattedValue(
ExprFormattedValue {
value: Attributed {
custom: (),
node: Name(
ExprName {
id: Identifier(
"x",
),
ctx: Load,
range: 6..7,
},
),
},
conversion: Int(
0,
),
format_spec: None,
range: 0..11,
},
),
},
],
range: 0..11,
},
),
Expr(
StmtExpr {
value: JoinedStr(
ExprJoinedStr {
values: [
Constant(
ExprConstant {
value: Str(
"\n",
),
kind: None,
range: 0..11,
},
),
FormattedValue(
ExprFormattedValue {
value: Name(
ExprName {
id: Identifier(
"x",
),
ctx: Load,
range: 6..7,
},
),
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
---
[
Attributed {
custom: (),
node: Expr(
StmtExpr {
value: Attributed {
custom: (),
node: Constant(
ExprConstant {
value: Str(
"\u{88}",
),
kind: None,
range: 0..9,
},
Expr(
StmtExpr {
value: Constant(
ExprConstant {
value: Str(
"\u{88}",
),
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
---
[
Attributed {
custom: (),
node: Expr(
StmtExpr {
value: Attributed {
custom: (),
node: JoinedStr(
ExprJoinedStr {
values: [
Attributed {
custom: (),
node: Constant(
ExprConstant {
value: Str(
"Hello world",
),
kind: None,
range: 0..17,
},
),
},
],
range: 0..17,
},
),
Expr(
StmtExpr {
value: JoinedStr(
ExprJoinedStr {
values: [
Constant(
ExprConstant {
value: Str(
"Hello world",
),
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
---
[
Attributed {
custom: (),
node: Expr(
StmtExpr {
value: Attributed {
custom: (),
node: JoinedStr(
ExprJoinedStr {
values: [
Attributed {
custom: (),
node: Constant(
ExprConstant {
value: Str(
"Hello world",
),
kind: None,
range: 0..17,
},
),
},
],
range: 0..17,
},
),
Expr(
StmtExpr {
value: JoinedStr(
ExprJoinedStr {
values: [
Constant(
ExprConstant {
value: Str(
"Hello world",
),
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
---
[
Attributed {
custom: (),
node: Expr(
StmtExpr {
value: Attributed {
custom: (),
node: JoinedStr(
ExprJoinedStr {
values: [
Attributed {
custom: (),
node: Constant(
ExprConstant {
value: Str(
"Hello world",
),
kind: None,
range: 0..22,
},
),
},
Attributed {
custom: (),
node: FormattedValue(
ExprFormattedValue {
value: Attributed {
custom: (),
node: Constant(
ExprConstant {
value: Str(
"!",
),
kind: None,
range: 17..20,
},
),
},
conversion: Int(
0,
),
format_spec: None,
range: 9..22,
},
),
},
],
range: 0..22,
},
),
Expr(
StmtExpr {
value: JoinedStr(
ExprJoinedStr {
values: [
Constant(
ExprConstant {
value: Str(
"Hello world",
),
kind: None,
range: 0..22,
},
),
FormattedValue(
ExprFormattedValue {
value: Constant(
ExprConstant {
value: Str(
"!",
),
kind: None,
range: 17..20,
},
),
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