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.emit(
self.file.write(
f"""
impl Ranged for crate::generic::{info.rust_sum_name}::<TextRange> {{
fn range(&self) -> TextRange {{
self.range
}}
}}
""", 0)
""".strip()
)
for f in product.fields:
self.visit(f, info, "pub ", depth + 1)
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.file.write(
f"""
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,13 +1,9 @@
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 {
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()))
@ -16,10 +12,8 @@ pub(crate) fn set_context(expr: Expr, ctx: ExprContext) -> Expr {
ctx,
}
.into(),
..expr
},
ExprKind::List(ast::ExprList { elts, range, .. }) => Expr {
node: ast::ExprList {
Expr::List(ast::ExprList { elts, range, .. }) => ast::ExprList {
elts: elts
.into_iter()
.map(|elt| set_context(elt, ctx.clone()))
@ -28,44 +22,33 @@ pub(crate) fn set_context(expr: Expr, ctx: ExprContext) -> Expr {
ctx,
}
.into(),
..expr
},
ExprKind::Attribute(ast::ExprAttribute {
Expr::Attribute(ast::ExprAttribute {
value, attr, range, ..
}) => Expr {
node: ast::ExprAttribute {
}) => ast::ExprAttribute {
value,
attr,
range,
ctx,
}
.into(),
..expr
},
ExprKind::Subscript(ast::ExprSubscript {
Expr::Subscript(ast::ExprSubscript {
value,
slice,
range,
..
}) => Expr {
node: ast::ExprSubscript {
}) => ast::ExprSubscript {
value,
slice,
range,
ctx,
}
.into(),
..expr
},
ExprKind::Starred(ast::ExprStarred { value, range, .. }) => Expr {
node: ast::ExprStarred {
Expr::Starred(ast::ExprStarred { value, range, .. }) => ast::ExprStarred {
value: Box::new(set_context(*value, ctx.clone())),
range,
ctx,
}
.into(),
..expr
},
_ => 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,13 +3,9 @@ source: parser/src/context.rs
expression: parse_ast
---
[
Attributed {
custom: (),
node: AnnAssign(
AnnAssign(
StmtAnnAssign {
target: Attributed {
custom: (),
node: Name(
target: Name(
ExprName {
id: Identifier(
"x",
@ -18,10 +14,7 @@ expression: parse_ast
range: 0..1,
},
),
},
annotation: Attributed {
custom: (),
node: Name(
annotation: Name(
ExprName {
id: Identifier(
"int",
@ -30,11 +23,8 @@ expression: parse_ast
range: 3..6,
},
),
},
value: Some(
Attributed {
custom: (),
node: Constant(
Constant(
ExprConstant {
value: Int(
1,
@ -43,11 +33,9 @@ expression: parse_ast
range: 9..10,
},
),
},
),
simple: true,
range: 0..10,
},
),
},
]

View file

@ -3,18 +3,12 @@ source: parser/src/context.rs
expression: parse_ast
---
[
Attributed {
custom: (),
node: Assign(
Assign(
StmtAssign {
targets: [
Attributed {
custom: (),
node: Attribute(
Attribute(
ExprAttribute {
value: Attributed {
custom: (),
node: Name(
value: Name(
ExprName {
id: Identifier(
"x",
@ -23,7 +17,6 @@ expression: parse_ast
range: 0..1,
},
),
},
attr: Identifier(
"y",
),
@ -31,16 +24,11 @@ expression: parse_ast
range: 0..3,
},
),
},
],
value: Attributed {
custom: (),
node: Tuple(
value: Tuple(
ExprTuple {
elts: [
Attributed {
custom: (),
node: Constant(
Constant(
ExprConstant {
value: Int(
1,
@ -49,10 +37,7 @@ expression: parse_ast
range: 7..8,
},
),
},
Attributed {
custom: (),
node: Constant(
Constant(
ExprConstant {
value: Int(
2,
@ -61,10 +46,7 @@ expression: parse_ast
range: 10..11,
},
),
},
Attributed {
custom: (),
node: Constant(
Constant(
ExprConstant {
value: Int(
3,
@ -73,16 +55,13 @@ expression: parse_ast
range: 13..14,
},
),
},
],
ctx: Load,
range: 6..15,
},
),
},
type_comment: None,
range: 0..15,
},
),
},
]

View file

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

View file

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

View file

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

View file

@ -3,14 +3,10 @@ source: parser/src/context.rs
expression: parse_ast
---
[
Attributed {
custom: (),
node: Assign(
Assign(
StmtAssign {
targets: [
Attributed {
custom: (),
node: Name(
Name(
ExprName {
id: Identifier(
"x",
@ -19,16 +15,11 @@ expression: parse_ast
range: 0..1,
},
),
},
],
value: Attributed {
custom: (),
node: Tuple(
value: Tuple(
ExprTuple {
elts: [
Attributed {
custom: (),
node: Constant(
Constant(
ExprConstant {
value: Int(
1,
@ -37,10 +28,7 @@ expression: parse_ast
range: 5..6,
},
),
},
Attributed {
custom: (),
node: Constant(
Constant(
ExprConstant {
value: Int(
2,
@ -49,10 +37,7 @@ expression: parse_ast
range: 8..9,
},
),
},
Attributed {
custom: (),
node: Constant(
Constant(
ExprConstant {
value: Int(
3,
@ -61,16 +46,13 @@ expression: parse_ast
range: 11..12,
},
),
},
],
ctx: Load,
range: 4..13,
},
),
},
type_comment: None,
range: 0..13,
},
),
},
]

View file

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

View file

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

View file

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

View file

@ -3,18 +3,12 @@ source: parser/src/context.rs
expression: parse_ast
---
[
Attributed {
custom: (),
node: Assign(
Assign(
StmtAssign {
targets: [
Attributed {
custom: (),
node: Subscript(
Subscript(
ExprSubscript {
value: Attributed {
custom: (),
node: Name(
value: Name(
ExprName {
id: Identifier(
"x",
@ -23,10 +17,7 @@ expression: parse_ast
range: 0..1,
},
),
},
slice: Attributed {
custom: (),
node: Name(
slice: Name(
ExprName {
id: Identifier(
"y",
@ -35,21 +26,15 @@ expression: parse_ast
range: 2..3,
},
),
},
ctx: Store,
range: 0..4,
},
),
},
],
value: Attributed {
custom: (),
node: Tuple(
value: Tuple(
ExprTuple {
elts: [
Attributed {
custom: (),
node: Constant(
Constant(
ExprConstant {
value: Int(
1,
@ -58,10 +43,7 @@ expression: parse_ast
range: 8..9,
},
),
},
Attributed {
custom: (),
node: Constant(
Constant(
ExprConstant {
value: Int(
2,
@ -70,10 +52,7 @@ expression: parse_ast
range: 11..12,
},
),
},
Attributed {
custom: (),
node: Constant(
Constant(
ExprConstant {
value: Int(
3,
@ -82,16 +61,13 @@ expression: parse_ast
range: 14..15,
},
),
},
],
ctx: Load,
range: 7..16,
},
),
},
type_comment: None,
range: 0..16,
},
),
},
]

View file

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

View file

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

View file

@ -3,17 +3,11 @@ source: parser/src/context.rs
expression: parse_ast
---
[
Attributed {
custom: (),
node: AugAssign(
AugAssign(
StmtAugAssign {
target: Attributed {
custom: (),
node: Attribute(
target: Attribute(
ExprAttribute {
value: Attributed {
custom: (),
node: Name(
value: Name(
ExprName {
id: Identifier(
"x",
@ -22,7 +16,6 @@ expression: parse_ast
range: 0..1,
},
),
},
attr: Identifier(
"y",
),
@ -30,16 +23,11 @@ expression: parse_ast
range: 0..3,
},
),
},
op: Add,
value: Attributed {
custom: (),
node: Tuple(
value: Tuple(
ExprTuple {
elts: [
Attributed {
custom: (),
node: Constant(
Constant(
ExprConstant {
value: Int(
1,
@ -48,10 +36,7 @@ expression: parse_ast
range: 8..9,
},
),
},
Attributed {
custom: (),
node: Constant(
Constant(
ExprConstant {
value: Int(
2,
@ -60,10 +45,7 @@ expression: parse_ast
range: 11..12,
},
),
},
Attributed {
custom: (),
node: Constant(
Constant(
ExprConstant {
value: Int(
3,
@ -72,15 +54,12 @@ expression: parse_ast
range: 14..15,
},
),
},
],
ctx: Load,
range: 7..16,
},
),
},
range: 0..16,
},
),
},
]

View file

@ -3,13 +3,9 @@ source: parser/src/context.rs
expression: parse_ast
---
[
Attributed {
custom: (),
node: AugAssign(
AugAssign(
StmtAugAssign {
target: Attributed {
custom: (),
node: Name(
target: Name(
ExprName {
id: Identifier(
"x",
@ -18,11 +14,8 @@ expression: parse_ast
range: 0..1,
},
),
},
op: Add,
value: Attributed {
custom: (),
node: Constant(
value: Constant(
ExprConstant {
value: Int(
1,
@ -31,9 +24,7 @@ expression: parse_ast
range: 5..6,
},
),
},
range: 0..6,
},
),
},
]

View file

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

View file

@ -3,18 +3,12 @@ source: parser/src/context.rs
expression: parse_ast
---
[
Attributed {
custom: (),
node: Delete(
Delete(
StmtDelete {
targets: [
Attributed {
custom: (),
node: Attribute(
Attribute(
ExprAttribute {
value: Attributed {
custom: (),
node: Name(
value: Name(
ExprName {
id: Identifier(
"x",
@ -23,7 +17,6 @@ expression: parse_ast
range: 4..5,
},
),
},
attr: Identifier(
"y",
),
@ -31,10 +24,8 @@ expression: parse_ast
range: 4..7,
},
),
},
],
range: 0..7,
},
),
},
]

View file

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

View file

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

View file

@ -4,9 +4,7 @@ expression: parse_ast
---
Ok(
[
Attributed {
custom: (),
node: FunctionDef(
FunctionDef(
StmtFunctionDef {
name: Identifier(
"f",
@ -16,9 +14,7 @@ Ok(
args: [],
vararg: None,
kwonlyargs: [
Attributed {
custom: (),
node: ArgData {
Arg {
arg: Identifier(
"a",
),
@ -26,10 +22,7 @@ Ok(
type_comment: None,
range: 9..10,
},
},
Attributed {
custom: (),
node: ArgData {
Arg {
arg: Identifier(
"b",
),
@ -37,10 +30,7 @@ Ok(
type_comment: None,
range: 12..13,
},
},
Attributed {
custom: (),
node: ArgData {
Arg {
arg: Identifier(
"c",
),
@ -48,22 +38,18 @@ Ok(
type_comment: None,
range: 15..16,
},
},
],
kw_defaults: [],
kwarg: None,
defaults: [],
range: 6..16,
range: PhantomData<ruff_text_size::range::TextRange>,
},
body: [
Attributed {
custom: (),
node: Pass(
Pass(
StmtPass {
range: 19..23,
},
),
},
],
decorator_list: [],
returns: None,
@ -71,6 +57,5 @@ Ok(
range: 0..23,
},
),
},
],
)

View file

@ -4,9 +4,7 @@ expression: parse_ast
---
Ok(
[
Attributed {
custom: (),
node: FunctionDef(
FunctionDef(
StmtFunctionDef {
name: Identifier(
"f",
@ -16,9 +14,7 @@ Ok(
args: [],
vararg: None,
kwonlyargs: [
Attributed {
custom: (),
node: ArgData {
Arg {
arg: Identifier(
"a",
),
@ -26,10 +22,7 @@ Ok(
type_comment: None,
range: 9..10,
},
},
Attributed {
custom: (),
node: ArgData {
Arg {
arg: Identifier(
"b",
),
@ -37,10 +30,7 @@ Ok(
type_comment: None,
range: 12..13,
},
},
Attributed {
custom: (),
node: ArgData {
Arg {
arg: Identifier(
"c",
),
@ -48,12 +38,9 @@ Ok(
type_comment: None,
range: 18..19,
},
},
],
kw_defaults: [
Attributed {
custom: (),
node: Constant(
Constant(
ExprConstant {
value: Int(
20,
@ -62,10 +49,7 @@ Ok(
range: 14..16,
},
),
},
Attributed {
custom: (),
node: Constant(
Constant(
ExprConstant {
value: Int(
30,
@ -74,21 +58,17 @@ Ok(
range: 20..22,
},
),
},
],
kwarg: None,
defaults: [],
range: 6..22,
range: PhantomData<ruff_text_size::range::TextRange>,
},
body: [
Attributed {
custom: (),
node: Pass(
Pass(
StmtPass {
range: 25..29,
},
),
},
],
decorator_list: [],
returns: None,
@ -96,6 +76,5 @@ Ok(
range: 0..29,
},
),
},
],
)

View file

@ -4,9 +4,7 @@ expression: parse_ast
---
Ok(
[
Attributed {
custom: (),
node: FunctionDef(
FunctionDef(
StmtFunctionDef {
name: Identifier(
"f",
@ -19,17 +17,14 @@ Ok(
kw_defaults: [],
kwarg: None,
defaults: [],
range: 5..7,
range: PhantomData<ruff_text_size::range::TextRange>,
},
body: [
Attributed {
custom: (),
node: Pass(
Pass(
StmtPass {
range: 9..13,
},
),
},
],
decorator_list: [],
returns: None,
@ -37,6 +32,5 @@ Ok(
range: 0..13,
},
),
},
],
)

View file

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

View file

@ -4,9 +4,7 @@ expression: parse_ast
---
Ok(
[
Attributed {
custom: (),
node: FunctionDef(
FunctionDef(
StmtFunctionDef {
name: Identifier(
"f",
@ -14,9 +12,7 @@ Ok(
args: Arguments {
posonlyargs: [],
args: [
Attributed {
custom: (),
node: ArgData {
Arg {
arg: Identifier(
"a",
),
@ -24,10 +20,7 @@ Ok(
type_comment: None,
range: 6..7,
},
},
Attributed {
custom: (),
node: ArgData {
Arg {
arg: Identifier(
"b",
),
@ -35,10 +28,7 @@ Ok(
type_comment: None,
range: 9..10,
},
},
Attributed {
custom: (),
node: ArgData {
Arg {
arg: Identifier(
"c",
),
@ -46,13 +36,10 @@ Ok(
type_comment: None,
range: 12..13,
},
},
],
vararg: None,
kwonlyargs: [
Attributed {
custom: (),
node: ArgData {
Arg {
arg: Identifier(
"d",
),
@ -60,10 +47,7 @@ Ok(
type_comment: None,
range: 18..19,
},
},
Attributed {
custom: (),
node: ArgData {
Arg {
arg: Identifier(
"e",
),
@ -71,10 +55,7 @@ Ok(
type_comment: None,
range: 21..22,
},
},
Attributed {
custom: (),
node: ArgData {
Arg {
arg: Identifier(
"f",
),
@ -82,12 +63,9 @@ Ok(
type_comment: None,
range: 27..28,
},
},
],
kw_defaults: [
Attributed {
custom: (),
node: Constant(
Constant(
ExprConstant {
value: Int(
20,
@ -96,10 +74,7 @@ Ok(
range: 23..25,
},
),
},
Attributed {
custom: (),
node: Constant(
Constant(
ExprConstant {
value: Int(
30,
@ -108,21 +83,17 @@ Ok(
range: 29..31,
},
),
},
],
kwarg: None,
defaults: [],
range: 6..31,
range: PhantomData<ruff_text_size::range::TextRange>,
},
body: [
Attributed {
custom: (),
node: Pass(
Pass(
StmtPass {
range: 34..38,
},
),
},
],
decorator_list: [],
returns: None,
@ -130,6 +101,5 @@ Ok(
range: 0..38,
},
),
},
],
)

View file

@ -4,9 +4,7 @@ expression: parse_ast
---
Ok(
[
Attributed {
custom: (),
node: FunctionDef(
FunctionDef(
StmtFunctionDef {
name: Identifier(
"f",
@ -14,9 +12,7 @@ Ok(
args: Arguments {
posonlyargs: [],
args: [
Attributed {
custom: (),
node: ArgData {
Arg {
arg: Identifier(
"a",
),
@ -24,10 +20,7 @@ Ok(
type_comment: None,
range: 6..7,
},
},
Attributed {
custom: (),
node: ArgData {
Arg {
arg: Identifier(
"b",
),
@ -35,10 +28,7 @@ Ok(
type_comment: None,
range: 9..10,
},
},
Attributed {
custom: (),
node: ArgData {
Arg {
arg: Identifier(
"c",
),
@ -46,12 +36,9 @@ Ok(
type_comment: None,
range: 12..13,
},
},
],
vararg: Some(
Attributed {
custom: (),
node: ArgData {
Arg {
arg: Identifier(
"args",
),
@ -59,12 +46,9 @@ Ok(
type_comment: None,
range: 16..20,
},
},
),
kwonlyargs: [
Attributed {
custom: (),
node: ArgData {
Arg {
arg: Identifier(
"d",
),
@ -72,10 +56,7 @@ Ok(
type_comment: None,
range: 22..23,
},
},
Attributed {
custom: (),
node: ArgData {
Arg {
arg: Identifier(
"e",
),
@ -83,10 +64,7 @@ Ok(
type_comment: None,
range: 25..26,
},
},
Attributed {
custom: (),
node: ArgData {
Arg {
arg: Identifier(
"f",
),
@ -94,12 +72,9 @@ Ok(
type_comment: None,
range: 31..32,
},
},
],
kw_defaults: [
Attributed {
custom: (),
node: Constant(
Constant(
ExprConstant {
value: Int(
20,
@ -108,10 +83,7 @@ Ok(
range: 27..29,
},
),
},
Attributed {
custom: (),
node: Constant(
Constant(
ExprConstant {
value: Int(
30,
@ -120,21 +92,17 @@ Ok(
range: 33..35,
},
),
},
],
kwarg: None,
defaults: [],
range: 6..35,
range: PhantomData<ruff_text_size::range::TextRange>,
},
body: [
Attributed {
custom: (),
node: Pass(
Pass(
StmtPass {
range: 38..42,
},
),
},
],
decorator_list: [],
returns: None,
@ -142,6 +110,5 @@ Ok(
range: 0..42,
},
),
},
],
)

View file

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

View file

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

View file

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

View file

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

View file

@ -4,22 +4,16 @@ expression: parse_ast
---
Ok(
[
Attributed {
custom: (),
node: Expr(
Expr(
StmtExpr {
value: Attributed {
custom: (),
node: Lambda(
value: Lambda(
ExprLambda {
args: Arguments {
posonlyargs: [],
args: [],
vararg: None,
kwonlyargs: [
Attributed {
custom: (),
node: ArgData {
Arg {
arg: Identifier(
"a",
),
@ -27,10 +21,7 @@ Ok(
type_comment: None,
range: 10..11,
},
},
Attributed {
custom: (),
node: ArgData {
Arg {
arg: Identifier(
"b",
),
@ -38,10 +29,7 @@ Ok(
type_comment: None,
range: 13..14,
},
},
Attributed {
custom: (),
node: ArgData {
Arg {
arg: Identifier(
"c",
),
@ -49,12 +37,9 @@ Ok(
type_comment: None,
range: 19..20,
},
},
],
kw_defaults: [
Attributed {
custom: (),
node: Constant(
Constant(
ExprConstant {
value: Int(
20,
@ -63,10 +48,7 @@ Ok(
range: 15..17,
},
),
},
Attributed {
custom: (),
node: Constant(
Constant(
ExprConstant {
value: Int(
30,
@ -75,15 +57,12 @@ Ok(
range: 21..23,
},
),
},
],
kwarg: None,
defaults: [],
range: 7..23,
range: PhantomData<ruff_text_size::range::TextRange>,
},
body: Attributed {
custom: (),
node: Constant(
body: Constant(
ExprConstant {
value: Int(
1,
@ -92,14 +71,11 @@ Ok(
range: 25..26,
},
),
},
range: 0..26,
},
),
},
range: 0..26,
},
),
},
],
)

View file

@ -4,13 +4,9 @@ expression: parse_ast
---
Ok(
[
Attributed {
custom: (),
node: Expr(
Expr(
StmtExpr {
value: Attributed {
custom: (),
node: Lambda(
value: Lambda(
ExprLambda {
args: Arguments {
posonlyargs: [],
@ -20,11 +16,9 @@ Ok(
kw_defaults: [],
kwarg: None,
defaults: [],
range: 0..9,
range: PhantomData<ruff_text_size::range::TextRange>,
},
body: Attributed {
custom: (),
node: Constant(
body: Constant(
ExprConstant {
value: Int(
1,
@ -33,14 +27,11 @@ Ok(
range: 8..9,
},
),
},
range: 0..9,
},
),
},
range: 0..9,
},
),
},
],
)

View file

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

View file

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

View file

@ -4,20 +4,14 @@ expression: parse_ast
---
Ok(
[
Attributed {
custom: (),
node: Expr(
Expr(
StmtExpr {
value: Attributed {
custom: (),
node: Lambda(
value: Lambda(
ExprLambda {
args: Arguments {
posonlyargs: [],
args: [
Attributed {
custom: (),
node: ArgData {
Arg {
arg: Identifier(
"a",
),
@ -25,10 +19,7 @@ Ok(
type_comment: None,
range: 7..8,
},
},
Attributed {
custom: (),
node: ArgData {
Arg {
arg: Identifier(
"b",
),
@ -36,10 +27,7 @@ Ok(
type_comment: None,
range: 10..11,
},
},
Attributed {
custom: (),
node: ArgData {
Arg {
arg: Identifier(
"c",
),
@ -47,16 +35,13 @@ Ok(
type_comment: None,
range: 16..17,
},
},
],
vararg: None,
kwonlyargs: [],
kw_defaults: [],
kwarg: None,
defaults: [
Attributed {
custom: (),
node: Constant(
Constant(
ExprConstant {
value: Int(
20,
@ -65,10 +50,7 @@ Ok(
range: 12..14,
},
),
},
Attributed {
custom: (),
node: Constant(
Constant(
ExprConstant {
value: Int(
30,
@ -77,13 +59,10 @@ Ok(
range: 18..20,
},
),
},
],
range: 7..20,
range: PhantomData<ruff_text_size::range::TextRange>,
},
body: Attributed {
custom: (),
node: Constant(
body: Constant(
ExprConstant {
value: Int(
1,
@ -92,14 +71,11 @@ Ok(
range: 22..23,
},
),
},
range: 0..23,
},
),
},
range: 0..23,
},
),
},
],
)

View file

@ -2,15 +2,11 @@
source: parser/src/parser.rs
expression: parse_ast
---
Attributed {
custom: (),
node: Dict(
Dict(
ExprDict {
keys: [
Some(
Attributed {
custom: (),
node: Constant(
Constant(
ExprConstant {
value: Str(
"a",
@ -19,13 +15,10 @@ Attributed {
range: 1..4,
},
),
},
),
None,
Some(
Attributed {
custom: (),
node: Constant(
Constant(
ExprConstant {
value: Str(
"d",
@ -34,13 +27,10 @@ Attributed {
range: 16..19,
},
),
},
),
],
values: [
Attributed {
custom: (),
node: Constant(
Constant(
ExprConstant {
value: Str(
"b",
@ -49,10 +39,7 @@ Attributed {
range: 6..9,
},
),
},
Attributed {
custom: (),
node: Name(
Name(
ExprName {
id: Identifier(
"c",
@ -61,10 +48,7 @@ Attributed {
range: 13..14,
},
),
},
Attributed {
custom: (),
node: Constant(
Constant(
ExprConstant {
value: Str(
"e",
@ -73,9 +57,7 @@ Attributed {
range: 21..24,
},
),
},
],
range: 0..25,
},
),
}
)

View file

@ -2,17 +2,11 @@
source: parser/src/parser.rs
expression: parse_ast
---
Attributed {
custom: (),
node: Call(
Call(
ExprCall {
func: Attributed {
custom: (),
node: Attribute(
func: Attribute(
ExprAttribute {
value: Attributed {
custom: (),
node: Constant(
value: Constant(
ExprConstant {
value: Str(
" ",
@ -21,7 +15,6 @@ Attributed {
range: 0..3,
},
),
},
attr: Identifier(
"join",
),
@ -29,15 +22,10 @@ Attributed {
range: 0..8,
},
),
},
args: [
Attributed {
custom: (),
node: GeneratorExp(
GeneratorExp(
ExprGeneratorExp {
elt: Attributed {
custom: (),
node: Name(
elt: Name(
ExprName {
id: Identifier(
"sql",
@ -46,12 +34,9 @@ Attributed {
range: 14..17,
},
),
},
generators: [
Comprehension {
target: Attributed {
custom: (),
node: Name(
target: Name(
ExprName {
id: Identifier(
"sql",
@ -60,19 +45,12 @@ Attributed {
range: 26..29,
},
),
},
iter: Attributed {
custom: (),
node: Tuple(
iter: Tuple(
ExprTuple {
elts: [
Attributed {
custom: (),
node: IfExp(
IfExp(
ExprIfExp {
test: Attributed {
custom: (),
node: Name(
test: Name(
ExprName {
id: Identifier(
"limit",
@ -81,14 +59,9 @@ Attributed {
range: 65..70,
},
),
},
body: Attributed {
custom: (),
node: BinOp(
body: BinOp(
ExprBinOp {
left: Attributed {
custom: (),
node: Constant(
left: Constant(
ExprConstant {
value: Str(
"LIMIT %d",
@ -97,11 +70,8 @@ Attributed {
range: 43..53,
},
),
},
op: Mod,
right: Attributed {
custom: (),
node: Name(
right: Name(
ExprName {
id: Identifier(
"limit",
@ -110,32 +80,22 @@ Attributed {
range: 56..61,
},
),
},
range: 43..61,
},
),
},
orelse: Attributed {
custom: (),
node: Constant(
orelse: Constant(
ExprConstant {
value: None,
kind: None,
range: 76..80,
},
),
},
range: 43..80,
},
),
},
Attributed {
custom: (),
node: IfExp(
IfExp(
ExprIfExp {
test: Attributed {
custom: (),
node: Name(
test: Name(
ExprName {
id: Identifier(
"offset",
@ -144,14 +104,9 @@ Attributed {
range: 116..122,
},
),
},
body: Attributed {
custom: (),
node: BinOp(
body: BinOp(
ExprBinOp {
left: Attributed {
custom: (),
node: Constant(
left: Constant(
ExprConstant {
value: Str(
"OFFSET %d",
@ -160,11 +115,8 @@ Attributed {
range: 91..102,
},
),
},
op: Mod,
right: Attributed {
custom: (),
node: Name(
right: Name(
ExprName {
id: Identifier(
"offset",
@ -173,43 +125,34 @@ Attributed {
range: 105..111,
},
),
},
range: 91..111,
},
),
},
orelse: Attributed {
custom: (),
node: Constant(
orelse: 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: PhantomData<ruff_text_size::range::TextRange>,
},
],
range: 14..139,
},
),
},
],
keywords: [],
range: 0..141,
},
),
}
)

View file

@ -3,19 +3,13 @@ source: parser/src/parser.rs
expression: parse_ast
---
[
Attributed {
custom: (),
node: Match(
Match(
StmtMatch {
subject: Attributed {
custom: (),
node: Dict(
subject: Dict(
ExprDict {
keys: [
Some(
Attributed {
custom: (),
node: Constant(
Constant(
ExprConstant {
value: Str(
"test",
@ -24,13 +18,10 @@ expression: parse_ast
range: 8..14,
},
),
},
),
],
values: [
Attributed {
custom: (),
node: Constant(
Constant(
ExprConstant {
value: Int(
1,
@ -39,17 +30,13 @@ expression: parse_ast
range: 16..17,
},
),
},
],
range: 7..18,
},
),
},
cases: [
MatchCase {
pattern: Attributed {
custom: (),
node: MatchMapping(
pattern: MatchMapping(
PatternMatchMapping {
keys: [],
patterns: [],
@ -61,20 +48,13 @@ expression: parse_ast
range: 29..52,
},
),
},
guard: None,
body: [
Attributed {
custom: (),
node: Expr(
Expr(
StmtExpr {
value: Attributed {
custom: (),
node: Call(
value: Call(
ExprCall {
func: Attributed {
custom: (),
node: Name(
func: Name(
ExprName {
id: Identifier(
"print",
@ -83,11 +63,8 @@ expression: parse_ast
range: 62..67,
},
),
},
args: [
Attributed {
custom: (),
node: Name(
Name(
ExprName {
id: Identifier(
"rest",
@ -96,38 +73,28 @@ expression: parse_ast
range: 68..72,
},
),
},
],
keywords: [],
range: 62..73,
},
),
},
range: 62..73,
},
),
},
],
range: 24..74,
range: PhantomData<ruff_text_size::range::TextRange>,
},
],
range: 1..73,
},
),
},
Attributed {
custom: (),
node: Match(
Match(
StmtMatch {
subject: Attributed {
custom: (),
node: Dict(
subject: Dict(
ExprDict {
keys: [
Some(
Attributed {
custom: (),
node: Constant(
Constant(
ExprConstant {
value: Str(
"label",
@ -136,13 +103,10 @@ expression: parse_ast
range: 81..88,
},
),
},
),
],
values: [
Attributed {
custom: (),
node: Constant(
Constant(
ExprConstant {
value: Str(
"test",
@ -151,22 +115,16 @@ expression: parse_ast
range: 90..96,
},
),
},
],
range: 80..97,
},
),
},
cases: [
MatchCase {
pattern: Attributed {
custom: (),
node: MatchMapping(
pattern: MatchMapping(
PatternMatchMapping {
keys: [
Attributed {
custom: (),
node: Constant(
Constant(
ExprConstant {
value: Str(
"label",
@ -175,26 +133,17 @@ expression: parse_ast
range: 118..125,
},
),
},
],
patterns: [
Attributed {
custom: (),
node: MatchAs(
MatchAs(
PatternMatchAs {
pattern: Some(
Attributed {
custom: (),
node: MatchOr(
MatchOr(
PatternMatchOr {
patterns: [
Attributed {
custom: (),
node: MatchClass(
MatchClass(
PatternMatchClass {
cls: Attributed {
custom: (),
node: Name(
cls: Name(
ExprName {
id: Identifier(
"str",
@ -203,28 +152,22 @@ expression: parse_ast
range: 127..130,
},
),
},
patterns: [],
kwd_attrs: [],
kwd_patterns: [],
range: 127..132,
},
),
},
Attributed {
custom: (),
node: MatchSingleton(
MatchSingleton(
PatternMatchSingleton {
value: None,
range: 135..139,
},
),
},
],
range: 127..139,
},
),
},
),
name: Some(
Identifier(
@ -234,26 +177,18 @@ expression: parse_ast
range: 127..148,
},
),
},
],
rest: None,
range: 108..155,
},
),
},
guard: None,
body: [
Attributed {
custom: (),
node: Expr(
Expr(
StmtExpr {
value: Attributed {
custom: (),
node: Call(
value: Call(
ExprCall {
func: Attributed {
custom: (),
node: Name(
func: Name(
ExprName {
id: Identifier(
"print",
@ -262,11 +197,8 @@ expression: parse_ast
range: 165..170,
},
),
},
args: [
Attributed {
custom: (),
node: Name(
Name(
ExprName {
id: Identifier(
"label",
@ -275,32 +207,24 @@ expression: parse_ast
range: 171..176,
},
),
},
],
keywords: [],
range: 165..177,
},
),
},
range: 165..177,
},
),
},
],
range: 103..178,
range: PhantomData<ruff_text_size::range::TextRange>,
},
],
range: 74..177,
},
),
},
Attributed {
custom: (),
node: Match(
Match(
StmtMatch {
subject: Attributed {
custom: (),
node: Name(
subject: Name(
ExprName {
id: Identifier(
"x",
@ -309,21 +233,14 @@ expression: parse_ast
range: 184..185,
},
),
},
cases: [
MatchCase {
pattern: Attributed {
custom: (),
node: MatchSequence(
pattern: MatchSequence(
PatternMatchSequence {
patterns: [
Attributed {
custom: (),
node: MatchValue(
MatchValue(
PatternMatchValue {
value: Attributed {
custom: (),
node: Constant(
value: Constant(
ExprConstant {
value: Int(
0,
@ -332,18 +249,12 @@ expression: parse_ast
range: 197..198,
},
),
},
range: 197..198,
},
),
},
Attributed {
custom: (),
node: MatchValue(
MatchValue(
PatternMatchValue {
value: Attributed {
custom: (),
node: Constant(
value: Constant(
ExprConstant {
value: Int(
1,
@ -352,26 +263,19 @@ expression: parse_ast
range: 200..201,
},
),
},
range: 200..201,
},
),
},
],
range: 196..203,
},
),
},
guard: None,
body: [
Attributed {
custom: (),
node: Assign(
Assign(
StmtAssign {
targets: [
Attributed {
custom: (),
node: Name(
Name(
ExprName {
id: Identifier(
"y",
@ -380,11 +284,8 @@ expression: parse_ast
range: 213..214,
},
),
},
],
value: Attributed {
custom: (),
node: Constant(
value: Constant(
ExprConstant {
value: Int(
0,
@ -393,27 +294,20 @@ expression: parse_ast
range: 217..218,
},
),
},
type_comment: None,
range: 213..218,
},
),
},
],
range: 191..219,
range: PhantomData<ruff_text_size::range::TextRange>,
},
],
range: 178..218,
},
),
},
Attributed {
custom: (),
node: Match(
Match(
StmtMatch {
subject: Attributed {
custom: (),
node: Name(
subject: Name(
ExprName {
id: Identifier(
"x",
@ -422,21 +316,14 @@ expression: parse_ast
range: 225..226,
},
),
},
cases: [
MatchCase {
pattern: Attributed {
custom: (),
node: MatchSequence(
pattern: MatchSequence(
PatternMatchSequence {
patterns: [
Attributed {
custom: (),
node: MatchValue(
MatchValue(
PatternMatchValue {
value: Attributed {
custom: (),
node: Constant(
value: Constant(
ExprConstant {
value: Int(
0,
@ -445,18 +332,12 @@ expression: parse_ast
range: 238..239,
},
),
},
range: 238..239,
},
),
},
Attributed {
custom: (),
node: MatchValue(
MatchValue(
PatternMatchValue {
value: Attributed {
custom: (),
node: Constant(
value: Constant(
ExprConstant {
value: Int(
1,
@ -465,26 +346,19 @@ expression: parse_ast
range: 241..242,
},
),
},
range: 241..242,
},
),
},
],
range: 237..244,
},
),
},
guard: None,
body: [
Attributed {
custom: (),
node: Assign(
Assign(
StmtAssign {
targets: [
Attributed {
custom: (),
node: Name(
Name(
ExprName {
id: Identifier(
"y",
@ -493,11 +367,8 @@ expression: parse_ast
range: 254..255,
},
),
},
],
value: Attributed {
custom: (),
node: Constant(
value: Constant(
ExprConstant {
value: Int(
0,
@ -506,27 +377,20 @@ expression: parse_ast
range: 258..259,
},
),
},
type_comment: None,
range: 254..259,
},
),
},
],
range: 232..260,
range: PhantomData<ruff_text_size::range::TextRange>,
},
],
range: 219..259,
},
),
},
Attributed {
custom: (),
node: Match(
Match(
StmtMatch {
subject: Attributed {
custom: (),
node: Name(
subject: Name(
ExprName {
id: Identifier(
"x",
@ -535,21 +399,14 @@ expression: parse_ast
range: 266..267,
},
),
},
cases: [
MatchCase {
pattern: Attributed {
custom: (),
node: MatchSequence(
pattern: MatchSequence(
PatternMatchSequence {
patterns: [
Attributed {
custom: (),
node: MatchValue(
MatchValue(
PatternMatchValue {
value: Attributed {
custom: (),
node: Constant(
value: Constant(
ExprConstant {
value: Int(
0,
@ -558,26 +415,19 @@ expression: parse_ast
range: 279..280,
},
),
},
range: 279..280,
},
),
},
],
range: 278..282,
},
),
},
guard: None,
body: [
Attributed {
custom: (),
node: Assign(
Assign(
StmtAssign {
targets: [
Attributed {
custom: (),
node: Name(
Name(
ExprName {
id: Identifier(
"y",
@ -586,11 +436,8 @@ expression: parse_ast
range: 292..293,
},
),
},
],
value: Attributed {
custom: (),
node: Constant(
value: Constant(
ExprConstant {
value: Int(
0,
@ -599,18 +446,15 @@ expression: parse_ast
range: 296..297,
},
),
},
type_comment: None,
range: 292..297,
},
),
},
],
range: 273..298,
range: PhantomData<ruff_text_size::range::TextRange>,
},
],
range: 260..297,
},
),
},
]

View file

@ -2,15 +2,11 @@
source: parser/src/parser.rs
expression: parse_ast
---
Attributed {
custom: (),
node: BoolOp(
BoolOp(
ExprBoolOp {
op: And,
values: [
Attributed {
custom: (),
node: Name(
Name(
ExprName {
id: Identifier(
"x",
@ -19,10 +15,7 @@ Attributed {
range: 0..1,
},
),
},
Attributed {
custom: (),
node: Name(
Name(
ExprName {
id: Identifier(
"y",
@ -31,9 +24,7 @@ Attributed {
range: 6..7,
},
),
},
],
range: 0..7,
},
),
}
)

View file

@ -2,15 +2,11 @@
source: parser/src/parser.rs
expression: parse_ast
---
Attributed {
custom: (),
node: BoolOp(
BoolOp(
ExprBoolOp {
op: Or,
values: [
Attributed {
custom: (),
node: Name(
Name(
ExprName {
id: Identifier(
"x",
@ -19,10 +15,7 @@ Attributed {
range: 0..1,
},
),
},
Attributed {
custom: (),
node: Name(
Name(
ExprName {
id: Identifier(
"y",
@ -31,9 +24,7 @@ Attributed {
range: 5..6,
},
),
},
],
range: 0..6,
},
),
}
)

View file

@ -3,17 +3,13 @@ source: parser/src/parser.rs
expression: "parse_program(source, \"<test>\").unwrap()"
---
[
Attributed {
custom: (),
node: ClassDef(
ClassDef(
StmtClassDef {
name: Identifier(
"Foo",
),
bases: [
Attributed {
custom: (),
node: Name(
Name(
ExprName {
id: Identifier(
"A",
@ -22,10 +18,7 @@ expression: "parse_program(source, \"<test>\").unwrap()"
range: 10..11,
},
),
},
Attributed {
custom: (),
node: Name(
Name(
ExprName {
id: Identifier(
"B",
@ -34,13 +27,10 @@ expression: "parse_program(source, \"<test>\").unwrap()"
range: 13..14,
},
),
},
],
keywords: [],
body: [
Attributed {
custom: (),
node: FunctionDef(
FunctionDef(
StmtFunctionDef {
name: Identifier(
"__init__",
@ -48,9 +38,7 @@ expression: "parse_program(source, \"<test>\").unwrap()"
args: Arguments {
posonlyargs: [],
args: [
Attributed {
custom: (),
node: ArgData {
Arg {
arg: Identifier(
"self",
),
@ -58,24 +46,20 @@ expression: "parse_program(source, \"<test>\").unwrap()"
type_comment: None,
range: 31..35,
},
},
],
vararg: None,
kwonlyargs: [],
kw_defaults: [],
kwarg: None,
defaults: [],
range: 31..35,
range: PhantomData<ruff_text_size::range::TextRange>,
},
body: [
Attributed {
custom: (),
node: Pass(
Pass(
StmtPass {
range: 40..44,
},
),
},
],
decorator_list: [],
returns: None,
@ -83,10 +67,7 @@ expression: "parse_program(source, \"<test>\").unwrap()"
range: 18..44,
},
),
},
Attributed {
custom: (),
node: FunctionDef(
FunctionDef(
StmtFunctionDef {
name: Identifier(
"method_with_default",
@ -94,9 +75,7 @@ expression: "parse_program(source, \"<test>\").unwrap()"
args: Arguments {
posonlyargs: [],
args: [
Attributed {
custom: (),
node: ArgData {
Arg {
arg: Identifier(
"self",
),
@ -104,10 +83,7 @@ expression: "parse_program(source, \"<test>\").unwrap()"
type_comment: None,
range: 70..74,
},
},
Attributed {
custom: (),
node: ArgData {
Arg {
arg: Identifier(
"arg",
),
@ -115,16 +91,13 @@ expression: "parse_program(source, \"<test>\").unwrap()"
type_comment: None,
range: 76..79,
},
},
],
vararg: None,
kwonlyargs: [],
kw_defaults: [],
kwarg: None,
defaults: [
Attributed {
custom: (),
node: Constant(
Constant(
ExprConstant {
value: Str(
"default",
@ -133,19 +106,15 @@ expression: "parse_program(source, \"<test>\").unwrap()"
range: 80..89,
},
),
},
],
range: 70..89,
range: PhantomData<ruff_text_size::range::TextRange>,
},
body: [
Attributed {
custom: (),
node: Pass(
Pass(
StmtPass {
range: 94..98,
},
),
},
],
decorator_list: [],
returns: None,
@ -153,11 +122,9 @@ expression: "parse_program(source, \"<test>\").unwrap()"
range: 46..98,
},
),
},
],
decorator_list: [],
range: 0..98,
},
),
},
]

View file

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

View file

@ -2,13 +2,9 @@
source: parser/src/parser.rs
expression: parse_ast
---
Attributed {
custom: (),
node: ListComp(
ListComp(
ExprListComp {
elt: Attributed {
custom: (),
node: Name(
elt: Name(
ExprName {
id: Identifier(
"x",
@ -17,17 +13,12 @@ Attributed {
range: 1..2,
},
),
},
generators: [
Comprehension {
target: Attributed {
custom: (),
node: Tuple(
target: Tuple(
ExprTuple {
elts: [
Attributed {
custom: (),
node: Name(
Name(
ExprName {
id: Identifier(
"y",
@ -36,10 +27,7 @@ Attributed {
range: 7..8,
},
),
},
Attributed {
custom: (),
node: Name(
Name(
ExprName {
id: Identifier(
"y2",
@ -48,16 +36,12 @@ Attributed {
range: 10..12,
},
),
},
],
ctx: Store,
range: 7..12,
},
),
},
iter: Attributed {
custom: (),
node: Name(
iter: Name(
ExprName {
id: Identifier(
"z",
@ -66,15 +50,12 @@ Attributed {
range: 16..17,
},
),
},
ifs: [],
is_async: false,
range: 3..17,
range: PhantomData<ruff_text_size::range::TextRange>,
},
Comprehension {
target: Attributed {
custom: (),
node: Name(
target: Name(
ExprName {
id: Identifier(
"a",
@ -83,10 +64,7 @@ Attributed {
range: 22..23,
},
),
},
iter: Attributed {
custom: (),
node: Name(
iter: Name(
ExprName {
id: Identifier(
"b",
@ -95,15 +73,10 @@ Attributed {
range: 27..28,
},
),
},
ifs: [
Attributed {
custom: (),
node: Compare(
Compare(
ExprCompare {
left: Attributed {
custom: (),
node: Name(
left: Name(
ExprName {
id: Identifier(
"a",
@ -112,14 +85,11 @@ Attributed {
range: 32..33,
},
),
},
ops: [
Lt,
],
comparators: [
Attributed {
custom: (),
node: Constant(
Constant(
ExprConstant {
value: Int(
5,
@ -128,19 +98,13 @@ Attributed {
range: 36..37,
},
),
},
],
range: 32..37,
},
),
},
Attributed {
custom: (),
node: Compare(
Compare(
ExprCompare {
left: Attributed {
custom: (),
node: Name(
left: Name(
ExprName {
id: Identifier(
"a",
@ -149,14 +113,11 @@ Attributed {
range: 41..42,
},
),
},
ops: [
Gt,
],
comparators: [
Attributed {
custom: (),
node: Constant(
Constant(
ExprConstant {
value: Int(
10,
@ -165,18 +126,15 @@ Attributed {
range: 45..47,
},
),
},
],
range: 41..47,
},
),
},
],
is_async: false,
range: 18..47,
range: PhantomData<ruff_text_size::range::TextRange>,
},
],
range: 0..48,
},
),
}
)

View file

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

View file

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

View file

@ -3,13 +3,9 @@ source: parser/src/parser.rs
expression: parse_ast
---
[
Attributed {
custom: (),
node: If(
If(
StmtIf {
test: Attributed {
custom: (),
node: Constant(
test: Constant(
ExprConstant {
value: Int(
1,
@ -18,15 +14,10 @@ expression: parse_ast
range: 3..4,
},
),
},
body: [
Attributed {
custom: (),
node: Expr(
Expr(
StmtExpr {
value: Attributed {
custom: (),
node: Constant(
value: Constant(
ExprConstant {
value: Int(
10,
@ -35,20 +26,14 @@ expression: parse_ast
range: 6..8,
},
),
},
range: 6..8,
},
),
},
],
orelse: [
Attributed {
custom: (),
node: If(
If(
StmtIf {
test: Attributed {
custom: (),
node: Constant(
test: Constant(
ExprConstant {
value: Int(
2,
@ -57,15 +42,10 @@ expression: parse_ast
range: 14..15,
},
),
},
body: [
Attributed {
custom: (),
node: Expr(
Expr(
StmtExpr {
value: Attributed {
custom: (),
node: Constant(
value: Constant(
ExprConstant {
value: Int(
20,
@ -74,20 +54,14 @@ expression: parse_ast
range: 17..19,
},
),
},
range: 17..19,
},
),
},
],
orelse: [
Attributed {
custom: (),
node: Expr(
Expr(
StmtExpr {
value: Attributed {
custom: (),
node: Constant(
value: Constant(
ExprConstant {
value: Int(
30,
@ -96,19 +70,15 @@ expression: parse_ast
range: 26..28,
},
),
},
range: 26..28,
},
),
},
],
range: 9..28,
},
),
},
],
range: 0..28,
},
),
},
]

View file

@ -2,17 +2,11 @@
source: parser/src/parser.rs
expression: parse_ast
---
Attributed {
custom: (),
node: GeneratorExp(
GeneratorExp(
ExprGeneratorExp {
elt: Attributed {
custom: (),
node: IfExp(
elt: IfExp(
ExprIfExp {
test: Attributed {
custom: (),
node: Name(
test: Name(
ExprName {
id: Identifier(
"y",
@ -21,10 +15,7 @@ Attributed {
range: 6..7,
},
),
},
body: Attributed {
custom: (),
node: Name(
body: Name(
ExprName {
id: Identifier(
"x",
@ -33,10 +24,7 @@ Attributed {
range: 1..2,
},
),
},
orelse: Attributed {
custom: (),
node: Name(
orelse: Name(
ExprName {
id: Identifier(
"y",
@ -45,16 +33,12 @@ Attributed {
range: 13..14,
},
),
},
range: 1..14,
},
),
},
generators: [
Comprehension {
target: Attributed {
custom: (),
node: Name(
target: Name(
ExprName {
id: Identifier(
"y",
@ -63,10 +47,7 @@ Attributed {
range: 19..20,
},
),
},
iter: Attributed {
custom: (),
node: Name(
iter: Name(
ExprName {
id: Identifier(
"z",
@ -75,13 +56,11 @@ Attributed {
range: 24..25,
},
),
},
ifs: [],
is_async: false,
range: 15..25,
range: PhantomData<ruff_text_size::range::TextRange>,
},
],
range: 0..26,
},
),
}
)

View file

@ -3,17 +3,11 @@ source: parser/src/parser.rs
expression: parse_ast
---
[
Attributed {
custom: (),
node: Expr(
Expr(
StmtExpr {
value: Attributed {
custom: (),
node: Call(
value: Call(
ExprCall {
func: Attributed {
custom: (),
node: Name(
func: Name(
ExprName {
id: Identifier(
"my_func",
@ -22,11 +16,8 @@ expression: parse_ast
range: 0..7,
},
),
},
args: [
Attributed {
custom: (),
node: Constant(
Constant(
ExprConstant {
value: Str(
"positional",
@ -35,20 +26,15 @@ expression: parse_ast
range: 8..20,
},
),
},
],
keywords: [
Attributed {
custom: (),
node: KeywordData {
Keyword {
arg: Some(
Identifier(
"keyword",
),
),
value: Attributed {
custom: (),
node: Constant(
value: Constant(
ExprConstant {
value: Int(
2,
@ -57,17 +43,13 @@ expression: parse_ast
range: 30..31,
},
),
},
range: 22..31,
},
},
],
range: 0..32,
},
),
},
range: 0..32,
},
),
},
]

View file

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

View file

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

View file

@ -2,17 +2,11 @@
source: parser/src/parser.rs
expression: parse_ast
---
Attributed {
custom: (),
node: GeneratorExp(
GeneratorExp(
ExprGeneratorExp {
elt: Attributed {
custom: (),
node: NamedExpr(
elt: NamedExpr(
ExprNamedExpr {
target: Attributed {
custom: (),
node: Name(
target: Name(
ExprName {
id: Identifier(
"x",
@ -21,14 +15,9 @@ Attributed {
range: 1..2,
},
),
},
value: Attributed {
custom: (),
node: BinOp(
value: BinOp(
ExprBinOp {
left: Attributed {
custom: (),
node: Name(
left: Name(
ExprName {
id: Identifier(
"y",
@ -37,11 +26,8 @@ Attributed {
range: 6..7,
},
),
},
op: Add,
right: Attributed {
custom: (),
node: Constant(
right: Constant(
ExprConstant {
value: Int(
1,
@ -50,20 +36,15 @@ Attributed {
range: 10..11,
},
),
},
range: 6..11,
},
),
},
range: 1..11,
},
),
},
generators: [
Comprehension {
target: Attributed {
custom: (),
node: Name(
target: Name(
ExprName {
id: Identifier(
"y",
@ -72,10 +53,7 @@ Attributed {
range: 16..17,
},
),
},
iter: Attributed {
custom: (),
node: Name(
iter: Name(
ExprName {
id: Identifier(
"z",
@ -84,13 +62,11 @@ Attributed {
range: 21..22,
},
),
},
ifs: [],
is_async: false,
range: 12..22,
range: PhantomData<ruff_text_size::range::TextRange>,
},
],
range: 0..23,
},
),
}
)

View file

@ -3,17 +3,11 @@ source: parser/src/parser.rs
expression: parse_ast
---
[
Attributed {
custom: (),
node: Expr(
Expr(
StmtExpr {
value: Attributed {
custom: (),
node: Call(
value: Call(
ExprCall {
func: Attributed {
custom: (),
node: Name(
func: Name(
ExprName {
id: Identifier(
"print",
@ -22,11 +16,8 @@ expression: parse_ast
range: 0..5,
},
),
},
args: [
Attributed {
custom: (),
node: Constant(
Constant(
ExprConstant {
value: Str(
"Hello world",
@ -35,10 +26,7 @@ expression: parse_ast
range: 6..19,
},
),
},
Attributed {
custom: (),
node: Constant(
Constant(
ExprConstant {
value: Int(
2,
@ -47,15 +35,12 @@ expression: parse_ast
range: 21..22,
},
),
},
],
keywords: [],
range: 0..23,
},
),
},
range: 0..23,
},
),
},
]

View file

@ -3,17 +3,11 @@ source: parser/src/parser.rs
expression: parse_ast
---
[
Attributed {
custom: (),
node: Expr(
Expr(
StmtExpr {
value: Attributed {
custom: (),
node: Call(
value: Call(
ExprCall {
func: Attributed {
custom: (),
node: Name(
func: Name(
ExprName {
id: Identifier(
"print",
@ -22,11 +16,8 @@ expression: parse_ast
range: 0..5,
},
),
},
args: [
Attributed {
custom: (),
node: Constant(
Constant(
ExprConstant {
value: Str(
"Hello world",
@ -35,15 +26,12 @@ expression: parse_ast
range: 6..19,
},
),
},
],
keywords: [],
range: 0..20,
},
),
},
range: 0..20,
},
),
},
]

View file

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

View file

@ -3,19 +3,13 @@ source: parser/src/parser.rs
expression: "parse_program(source, \"<test>\").unwrap()"
---
[
Attributed {
custom: (),
node: Assign(
Assign(
StmtAssign {
targets: [
Attributed {
custom: (),
node: Tuple(
Tuple(
ExprTuple {
elts: [
Attributed {
custom: (),
node: Name(
Name(
ExprName {
id: Identifier(
"a",
@ -24,10 +18,7 @@ expression: "parse_program(source, \"<test>\").unwrap()"
range: 0..1,
},
),
},
Attributed {
custom: (),
node: Name(
Name(
ExprName {
id: Identifier(
"b",
@ -36,22 +27,16 @@ expression: "parse_program(source, \"<test>\").unwrap()"
range: 3..4,
},
),
},
],
ctx: Store,
range: 0..4,
},
),
},
],
value: Attributed {
custom: (),
node: Tuple(
value: Tuple(
ExprTuple {
elts: [
Attributed {
custom: (),
node: Constant(
Constant(
ExprConstant {
value: Int(
4,
@ -60,10 +45,7 @@ expression: "parse_program(source, \"<test>\").unwrap()"
range: 7..8,
},
),
},
Attributed {
custom: (),
node: Constant(
Constant(
ExprConstant {
value: Int(
5,
@ -72,16 +54,13 @@ expression: "parse_program(source, \"<test>\").unwrap()"
range: 10..11,
},
),
},
],
ctx: Load,
range: 7..11,
},
),
},
type_comment: None,
range: 0..11,
},
),
},
]

File diff suppressed because it is too large Load diff

View file

@ -2,13 +2,9 @@
source: parser/src/parser.rs
expression: parse_ast
---
Attributed {
custom: (),
node: Subscript(
Subscript(
ExprSubscript {
value: Attributed {
custom: (),
node: Name(
value: Name(
ExprName {
id: Identifier(
"x",
@ -17,15 +13,10 @@ Attributed {
range: 0..1,
},
),
},
slice: Attributed {
custom: (),
node: Slice(
slice: Slice(
ExprSlice {
lower: Some(
Attributed {
custom: (),
node: Constant(
Constant(
ExprConstant {
value: Int(
1,
@ -34,12 +25,9 @@ Attributed {
range: 2..3,
},
),
},
),
upper: Some(
Attributed {
custom: (),
node: Constant(
Constant(
ExprConstant {
value: Int(
2,
@ -48,12 +36,9 @@ Attributed {
range: 4..5,
},
),
},
),
step: Some(
Attributed {
custom: (),
node: Constant(
Constant(
ExprConstant {
value: Int(
3,
@ -62,14 +47,11 @@ Attributed {
range: 6..7,
},
),
},
),
range: 2..7,
},
),
},
ctx: Load,
range: 0..8,
},
),
}
)

View file

@ -3,14 +3,10 @@ source: parser/src/parser.rs
expression: parse_ast
---
[
Attributed {
custom: (),
node: Assign(
Assign(
StmtAssign {
targets: [
Attributed {
custom: (),
node: Name(
Name(
ExprName {
id: Identifier(
"array_slice",
@ -19,15 +15,10 @@ expression: parse_ast
range: 0..11,
},
),
},
],
value: Attributed {
custom: (),
node: Subscript(
value: Subscript(
ExprSubscript {
value: Attributed {
custom: (),
node: Name(
value: Name(
ExprName {
id: Identifier(
"array",
@ -36,15 +27,10 @@ expression: parse_ast
range: 14..19,
},
),
},
slice: Attributed {
custom: (),
node: Tuple(
slice: Tuple(
ExprTuple {
elts: [
Attributed {
custom: (),
node: Constant(
Constant(
ExprConstant {
value: Int(
0,
@ -53,14 +39,9 @@ expression: parse_ast
range: 20..21,
},
),
},
Attributed {
custom: (),
node: Starred(
Starred(
ExprStarred {
value: Attributed {
custom: (),
node: Name(
value: Name(
ExprName {
id: Identifier(
"indexes",
@ -69,20 +50,14 @@ expression: parse_ast
range: 24..31,
},
),
},
ctx: Load,
range: 23..31,
},
),
},
Attributed {
custom: (),
node: UnaryOp(
UnaryOp(
ExprUnaryOp {
op: USub,
operand: Attributed {
custom: (),
node: Constant(
operand: Constant(
ExprConstant {
value: Int(
1,
@ -91,39 +66,28 @@ expression: parse_ast
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(
Assign(
StmtAssign {
targets: [
Attributed {
custom: (),
node: Subscript(
Subscript(
ExprSubscript {
value: Attributed {
custom: (),
node: Name(
value: Name(
ExprName {
id: Identifier(
"array",
@ -132,15 +96,10 @@ expression: parse_ast
range: 37..42,
},
),
},
slice: Attributed {
custom: (),
node: Tuple(
slice: Tuple(
ExprTuple {
elts: [
Attributed {
custom: (),
node: Constant(
Constant(
ExprConstant {
value: Int(
0,
@ -149,14 +108,9 @@ expression: parse_ast
range: 43..44,
},
),
},
Attributed {
custom: (),
node: Starred(
Starred(
ExprStarred {
value: Attributed {
custom: (),
node: Name(
value: Name(
ExprName {
id: Identifier(
"indexes",
@ -165,20 +119,14 @@ expression: parse_ast
range: 47..54,
},
),
},
ctx: Load,
range: 46..54,
},
),
},
Attributed {
custom: (),
node: UnaryOp(
UnaryOp(
ExprUnaryOp {
op: USub,
operand: Attributed {
custom: (),
node: Constant(
operand: Constant(
ExprConstant {
value: Int(
1,
@ -187,26 +135,20 @@ expression: parse_ast
range: 57..58,
},
),
},
range: 56..58,
},
),
},
],
ctx: Load,
range: 43..58,
},
),
},
ctx: Store,
range: 37..59,
},
),
},
],
value: Attributed {
custom: (),
node: Name(
value: Name(
ExprName {
id: Identifier(
"array_slice",
@ -215,23 +157,15 @@ expression: parse_ast
range: 62..73,
},
),
},
type_comment: None,
range: 37..73,
},
),
},
Attributed {
custom: (),
node: Expr(
Expr(
StmtExpr {
value: Attributed {
custom: (),
node: Subscript(
value: Subscript(
ExprSubscript {
value: Attributed {
custom: (),
node: Name(
value: Name(
ExprName {
id: Identifier(
"array",
@ -240,19 +174,12 @@ expression: parse_ast
range: 74..79,
},
),
},
slice: Attributed {
custom: (),
node: Tuple(
slice: Tuple(
ExprTuple {
elts: [
Attributed {
custom: (),
node: Starred(
Starred(
ExprStarred {
value: Attributed {
custom: (),
node: Name(
value: Name(
ExprName {
id: Identifier(
"indexes_to_select",
@ -261,19 +188,13 @@ expression: parse_ast
range: 81..98,
},
),
},
ctx: Load,
range: 80..98,
},
),
},
Attributed {
custom: (),
node: Starred(
Starred(
ExprStarred {
value: Attributed {
custom: (),
node: Name(
value: Name(
ExprName {
id: Identifier(
"indexes_to_select",
@ -282,38 +203,27 @@ expression: parse_ast
range: 101..118,
},
),
},
ctx: Load,
range: 100..118,
},
),
},
],
ctx: Load,
range: 80..118,
},
),
},
ctx: Load,
range: 74..119,
},
),
},
range: 74..119,
},
),
},
Attributed {
custom: (),
node: Expr(
Expr(
StmtExpr {
value: Attributed {
custom: (),
node: Subscript(
value: Subscript(
ExprSubscript {
value: Attributed {
custom: (),
node: Name(
value: Name(
ExprName {
id: Identifier(
"array",
@ -322,20 +232,13 @@ expression: parse_ast
range: 120..125,
},
),
},
slice: Attributed {
custom: (),
node: Tuple(
slice: Tuple(
ExprTuple {
elts: [
Attributed {
custom: (),
node: Slice(
Slice(
ExprSlice {
lower: Some(
Attributed {
custom: (),
node: Constant(
Constant(
ExprConstant {
value: Int(
3,
@ -344,12 +247,9 @@ expression: parse_ast
range: 126..127,
},
),
},
),
upper: Some(
Attributed {
custom: (),
node: Constant(
Constant(
ExprConstant {
value: Int(
5,
@ -358,20 +258,14 @@ expression: parse_ast
range: 128..129,
},
),
},
),
step: None,
range: 126..129,
},
),
},
Attributed {
custom: (),
node: Starred(
Starred(
ExprStarred {
value: Attributed {
custom: (),
node: Name(
value: Name(
ExprName {
id: Identifier(
"indexes_to_select",
@ -380,25 +274,20 @@ expression: parse_ast
range: 132..149,
},
),
},
ctx: Load,
range: 131..149,
},
),
},
],
ctx: Load,
range: 126..149,
},
),
},
ctx: Load,
range: 120..150,
},
),
},
range: 120..150,
},
),
},
]

View file

@ -3,23 +3,15 @@ source: parser/src/parser.rs
expression: parse_ast
---
[
Attributed {
custom: (),
node: Try(
Try(
StmtTry {
body: [
Attributed {
custom: (),
node: Raise(
Raise(
StmtRaise {
exc: Some(
Attributed {
custom: (),
node: Call(
Call(
ExprCall {
func: Attributed {
custom: (),
node: Name(
func: Name(
ExprName {
id: Identifier(
"ValueError",
@ -28,11 +20,8 @@ expression: parse_ast
range: 15..25,
},
),
},
args: [
Attributed {
custom: (),
node: Constant(
Constant(
ExprConstant {
value: Int(
1,
@ -41,29 +30,22 @@ expression: parse_ast
range: 26..27,
},
),
},
],
keywords: [],
range: 15..28,
},
),
},
),
cause: None,
range: 9..28,
},
),
},
],
handlers: [
Attributed {
custom: (),
node: ExceptHandler(
ExceptHandler(
ExcepthandlerExceptHandler {
type_: Some(
Attributed {
custom: (),
node: Name(
Name(
ExprName {
id: Identifier(
"TypeError",
@ -72,7 +54,6 @@ expression: parse_ast
range: 36..45,
},
),
},
),
name: Some(
Identifier(
@ -80,17 +61,11 @@ expression: parse_ast
),
),
body: [
Attributed {
custom: (),
node: Expr(
Expr(
StmtExpr {
value: Attributed {
custom: (),
node: Call(
value: Call(
ExprCall {
func: Attributed {
custom: (),
node: Name(
func: Name(
ExprName {
id: Identifier(
"print",
@ -99,16 +74,11 @@ expression: parse_ast
range: 56..61,
},
),
},
args: [
Attributed {
custom: (),
node: JoinedStr(
JoinedStr(
ExprJoinedStr {
values: [
Attributed {
custom: (),
node: Constant(
Constant(
ExprConstant {
value: Str(
"caught ",
@ -117,18 +87,11 @@ expression: parse_ast
range: 62..81,
},
),
},
Attributed {
custom: (),
node: FormattedValue(
FormattedValue(
ExprFormattedValue {
value: Attributed {
custom: (),
node: Call(
value: Call(
ExprCall {
func: Attributed {
custom: (),
node: Name(
func: Name(
ExprName {
id: Identifier(
"type",
@ -137,11 +100,8 @@ expression: parse_ast
range: 72..76,
},
),
},
args: [
Attributed {
custom: (),
node: Name(
Name(
ExprName {
id: Identifier(
"e",
@ -150,13 +110,11 @@ expression: parse_ast
range: 77..78,
},
),
},
],
keywords: [],
range: 72..79,
},
),
},
conversion: Int(
0,
),
@ -164,35 +122,26 @@ expression: parse_ast
range: 62..81,
},
),
},
],
range: 62..81,
},
),
},
],
keywords: [],
range: 56..82,
},
),
},
range: 56..82,
},
),
},
],
range: 29..82,
},
),
},
Attributed {
custom: (),
node: ExceptHandler(
ExceptHandler(
ExcepthandlerExceptHandler {
type_: Some(
Attributed {
custom: (),
node: Name(
Name(
ExprName {
id: Identifier(
"OSError",
@ -201,7 +150,6 @@ expression: parse_ast
range: 90..97,
},
),
},
),
name: Some(
Identifier(
@ -209,17 +157,11 @@ expression: parse_ast
),
),
body: [
Attributed {
custom: (),
node: Expr(
Expr(
StmtExpr {
value: Attributed {
custom: (),
node: Call(
value: Call(
ExprCall {
func: Attributed {
custom: (),
node: Name(
func: Name(
ExprName {
id: Identifier(
"print",
@ -228,16 +170,11 @@ expression: parse_ast
range: 108..113,
},
),
},
args: [
Attributed {
custom: (),
node: JoinedStr(
JoinedStr(
ExprJoinedStr {
values: [
Attributed {
custom: (),
node: Constant(
Constant(
ExprConstant {
value: Str(
"caught ",
@ -246,18 +183,11 @@ expression: parse_ast
range: 114..133,
},
),
},
Attributed {
custom: (),
node: FormattedValue(
FormattedValue(
ExprFormattedValue {
value: Attributed {
custom: (),
node: Call(
value: Call(
ExprCall {
func: Attributed {
custom: (),
node: Name(
func: Name(
ExprName {
id: Identifier(
"type",
@ -266,11 +196,8 @@ expression: parse_ast
range: 124..128,
},
),
},
args: [
Attributed {
custom: (),
node: Name(
Name(
ExprName {
id: Identifier(
"e",
@ -279,13 +206,11 @@ expression: parse_ast
range: 129..130,
},
),
},
],
keywords: [],
range: 124..131,
},
),
},
conversion: Int(
0,
),
@ -293,32 +218,26 @@ expression: parse_ast
range: 114..133,
},
),
},
],
range: 114..133,
},
),
},
],
keywords: [],
range: 108..134,
},
),
},
range: 108..134,
},
),
},
],
range: 83..134,
},
),
},
],
orelse: [],
finalbody: [],
range: 0..134,
},
),
},
]

View file

@ -3,23 +3,15 @@ source: parser/src/parser.rs
expression: parse_ast
---
[
Attributed {
custom: (),
node: TryStar(
TryStar(
StmtTryStar {
body: [
Attributed {
custom: (),
node: Raise(
Raise(
StmtRaise {
exc: Some(
Attributed {
custom: (),
node: Call(
Call(
ExprCall {
func: Attributed {
custom: (),
node: Name(
func: Name(
ExprName {
id: Identifier(
"ExceptionGroup",
@ -28,11 +20,8 @@ expression: parse_ast
range: 15..29,
},
),
},
args: [
Attributed {
custom: (),
node: Constant(
Constant(
ExprConstant {
value: Str(
"eg",
@ -41,19 +30,12 @@ expression: parse_ast
range: 30..34,
},
),
},
Attributed {
custom: (),
node: List(
List(
ExprList {
elts: [
Attributed {
custom: (),
node: Call(
Call(
ExprCall {
func: Attributed {
custom: (),
node: Name(
func: Name(
ExprName {
id: Identifier(
"ValueError",
@ -62,11 +44,8 @@ expression: parse_ast
range: 45..55,
},
),
},
args: [
Attributed {
custom: (),
node: Constant(
Constant(
ExprConstant {
value: Int(
1,
@ -75,20 +54,14 @@ expression: parse_ast
range: 56..57,
},
),
},
],
keywords: [],
range: 45..58,
},
),
},
Attributed {
custom: (),
node: Call(
Call(
ExprCall {
func: Attributed {
custom: (),
node: Name(
func: Name(
ExprName {
id: Identifier(
"TypeError",
@ -97,11 +70,8 @@ expression: parse_ast
range: 60..69,
},
),
},
args: [
Attributed {
custom: (),
node: Constant(
Constant(
ExprConstant {
value: Int(
2,
@ -110,20 +80,14 @@ expression: parse_ast
range: 70..71,
},
),
},
],
keywords: [],
range: 60..72,
},
),
},
Attributed {
custom: (),
node: Call(
Call(
ExprCall {
func: Attributed {
custom: (),
node: Name(
func: Name(
ExprName {
id: Identifier(
"OSError",
@ -132,11 +96,8 @@ expression: parse_ast
range: 74..81,
},
),
},
args: [
Attributed {
custom: (),
node: Constant(
Constant(
ExprConstant {
value: Int(
3,
@ -145,20 +106,14 @@ expression: parse_ast
range: 82..83,
},
),
},
],
keywords: [],
range: 74..84,
},
),
},
Attributed {
custom: (),
node: Call(
Call(
ExprCall {
func: Attributed {
custom: (),
node: Name(
func: Name(
ExprName {
id: Identifier(
"OSError",
@ -167,11 +122,8 @@ expression: parse_ast
range: 86..93,
},
),
},
args: [
Attributed {
custom: (),
node: Constant(
Constant(
ExprConstant {
value: Int(
4,
@ -180,41 +132,32 @@ expression: parse_ast
range: 94..95,
},
),
},
],
keywords: [],
range: 86..96,
},
),
},
],
ctx: Load,
range: 44..97,
},
),
},
],
keywords: [],
range: 15..98,
},
),
},
),
cause: None,
range: 9..98,
},
),
},
],
handlers: [
Attributed {
custom: (),
node: ExceptHandler(
ExceptHandler(
ExcepthandlerExceptHandler {
type_: Some(
Attributed {
custom: (),
node: Name(
Name(
ExprName {
id: Identifier(
"TypeError",
@ -223,7 +166,6 @@ expression: parse_ast
range: 107..116,
},
),
},
),
name: Some(
Identifier(
@ -231,17 +173,11 @@ expression: parse_ast
),
),
body: [
Attributed {
custom: (),
node: Expr(
Expr(
StmtExpr {
value: Attributed {
custom: (),
node: Call(
value: Call(
ExprCall {
func: Attributed {
custom: (),
node: Name(
func: Name(
ExprName {
id: Identifier(
"print",
@ -250,16 +186,11 @@ expression: parse_ast
range: 127..132,
},
),
},
args: [
Attributed {
custom: (),
node: JoinedStr(
JoinedStr(
ExprJoinedStr {
values: [
Attributed {
custom: (),
node: Constant(
Constant(
ExprConstant {
value: Str(
"caught ",
@ -268,18 +199,11 @@ expression: parse_ast
range: 133..179,
},
),
},
Attributed {
custom: (),
node: FormattedValue(
FormattedValue(
ExprFormattedValue {
value: Attributed {
custom: (),
node: Call(
value: Call(
ExprCall {
func: Attributed {
custom: (),
node: Name(
func: Name(
ExprName {
id: Identifier(
"type",
@ -288,11 +212,8 @@ expression: parse_ast
range: 143..147,
},
),
},
args: [
Attributed {
custom: (),
node: Name(
Name(
ExprName {
id: Identifier(
"e",
@ -301,13 +222,11 @@ expression: parse_ast
range: 148..149,
},
),
},
],
keywords: [],
range: 143..150,
},
),
},
conversion: Int(
0,
),
@ -315,10 +234,7 @@ expression: parse_ast
range: 133..179,
},
),
},
Attributed {
custom: (),
node: Constant(
Constant(
ExprConstant {
value: Str(
" with nested ",
@ -327,18 +243,11 @@ expression: parse_ast
range: 133..179,
},
),
},
Attributed {
custom: (),
node: FormattedValue(
FormattedValue(
ExprFormattedValue {
value: Attributed {
custom: (),
node: Attribute(
value: Attribute(
ExprAttribute {
value: Attributed {
custom: (),
node: Name(
value: Name(
ExprName {
id: Identifier(
"e",
@ -347,7 +256,6 @@ expression: parse_ast
range: 165..166,
},
),
},
attr: Identifier(
"exceptions",
),
@ -355,7 +263,6 @@ expression: parse_ast
range: 165..177,
},
),
},
conversion: Int(
0,
),
@ -363,35 +270,26 @@ expression: parse_ast
range: 133..179,
},
),
},
],
range: 133..179,
},
),
},
],
keywords: [],
range: 127..180,
},
),
},
range: 127..180,
},
),
},
],
range: 99..180,
},
),
},
Attributed {
custom: (),
node: ExceptHandler(
ExceptHandler(
ExcepthandlerExceptHandler {
type_: Some(
Attributed {
custom: (),
node: Name(
Name(
ExprName {
id: Identifier(
"OSError",
@ -400,7 +298,6 @@ expression: parse_ast
range: 189..196,
},
),
},
),
name: Some(
Identifier(
@ -408,17 +305,11 @@ expression: parse_ast
),
),
body: [
Attributed {
custom: (),
node: Expr(
Expr(
StmtExpr {
value: Attributed {
custom: (),
node: Call(
value: Call(
ExprCall {
func: Attributed {
custom: (),
node: Name(
func: Name(
ExprName {
id: Identifier(
"print",
@ -427,16 +318,11 @@ expression: parse_ast
range: 207..212,
},
),
},
args: [
Attributed {
custom: (),
node: JoinedStr(
JoinedStr(
ExprJoinedStr {
values: [
Attributed {
custom: (),
node: Constant(
Constant(
ExprConstant {
value: Str(
"caught ",
@ -445,18 +331,11 @@ expression: parse_ast
range: 213..259,
},
),
},
Attributed {
custom: (),
node: FormattedValue(
FormattedValue(
ExprFormattedValue {
value: Attributed {
custom: (),
node: Call(
value: Call(
ExprCall {
func: Attributed {
custom: (),
node: Name(
func: Name(
ExprName {
id: Identifier(
"type",
@ -465,11 +344,8 @@ expression: parse_ast
range: 223..227,
},
),
},
args: [
Attributed {
custom: (),
node: Name(
Name(
ExprName {
id: Identifier(
"e",
@ -478,13 +354,11 @@ expression: parse_ast
range: 228..229,
},
),
},
],
keywords: [],
range: 223..230,
},
),
},
conversion: Int(
0,
),
@ -492,10 +366,7 @@ expression: parse_ast
range: 213..259,
},
),
},
Attributed {
custom: (),
node: Constant(
Constant(
ExprConstant {
value: Str(
" with nested ",
@ -504,18 +375,11 @@ expression: parse_ast
range: 213..259,
},
),
},
Attributed {
custom: (),
node: FormattedValue(
FormattedValue(
ExprFormattedValue {
value: Attributed {
custom: (),
node: Attribute(
value: Attribute(
ExprAttribute {
value: Attributed {
custom: (),
node: Name(
value: Name(
ExprName {
id: Identifier(
"e",
@ -524,7 +388,6 @@ expression: parse_ast
range: 245..246,
},
),
},
attr: Identifier(
"exceptions",
),
@ -532,7 +395,6 @@ expression: parse_ast
range: 245..257,
},
),
},
conversion: Int(
0,
),
@ -540,32 +402,26 @@ expression: parse_ast
range: 213..259,
},
),
},
],
range: 213..259,
},
),
},
],
keywords: [],
range: 207..260,
},
),
},
range: 207..260,
},
),
},
],
range: 181..260,
},
),
},
],
orelse: [],
finalbody: [],
range: 0..260,
},
),
},
]

View file

@ -3,9 +3,7 @@ source: parser/src/parser.rs
expression: parse_ast
---
[
Attributed {
custom: (),
node: FunctionDef(
FunctionDef(
StmtFunctionDef {
name: Identifier(
"args_to_tuple",
@ -14,20 +12,14 @@ expression: parse_ast
posonlyargs: [],
args: [],
vararg: Some(
Attributed {
custom: (),
node: ArgData {
Arg {
arg: Identifier(
"args",
),
annotation: Some(
Attributed {
custom: (),
node: Starred(
Starred(
ExprStarred {
value: Attributed {
custom: (),
node: Name(
value: Name(
ExprName {
id: Identifier(
"Ts",
@ -36,53 +28,40 @@ expression: parse_ast
range: 27..29,
},
),
},
ctx: Load,
range: 26..29,
},
),
},
),
type_comment: None,
range: 20..29,
},
},
),
kwonlyargs: [],
kw_defaults: [],
kwarg: None,
defaults: [],
range: 19..29,
range: PhantomData<ruff_text_size::range::TextRange>,
},
body: [
Attributed {
custom: (),
node: Expr(
Expr(
StmtExpr {
value: Attributed {
custom: (),
node: Constant(
value: Constant(
ExprConstant {
value: Ellipsis,
kind: None,
range: 46..49,
},
),
},
range: 46..49,
},
),
},
],
decorator_list: [],
returns: Some(
Attributed {
custom: (),
node: Subscript(
Subscript(
ExprSubscript {
value: Attributed {
custom: (),
node: Name(
value: Name(
ExprName {
id: Identifier(
"Tuple",
@ -91,14 +70,9 @@ expression: parse_ast
range: 34..39,
},
),
},
slice: Attributed {
custom: (),
node: Starred(
slice: Starred(
ExprStarred {
value: Attributed {
custom: (),
node: Name(
value: Name(
ExprName {
id: Identifier(
"Ts",
@ -107,21 +81,17 @@ expression: parse_ast
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,13 +3,9 @@ source: parser/src/string.rs
expression: parse_ast
---
[
Attributed {
custom: (),
node: Expr(
Expr(
StmtExpr {
value: Attributed {
custom: (),
node: Constant(
value: Constant(
ExprConstant {
value: Str(
"\u{8}",
@ -18,9 +14,7 @@ expression: parse_ast
range: 0..15,
},
),
},
range: 0..15,
},
),
},
]

View file

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

View file

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

View file

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

View file

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

View file

@ -3,13 +3,9 @@ source: parser/src/string.rs
expression: parse_ast
---
[
Attributed {
custom: (),
node: Expr(
Expr(
StmtExpr {
value: Attributed {
custom: (),
node: Constant(
value: Constant(
ExprConstant {
value: Bytes(
[
@ -275,9 +271,7 @@ expression: parse_ast
range: 0..738,
},
),
},
range: 0..738,
},
),
},
]

View file

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

View file

@ -3,13 +3,9 @@ source: parser/src/string.rs
expression: parse_ast
---
[
Attributed {
custom: (),
node: Expr(
Expr(
StmtExpr {
value: Attributed {
custom: (),
node: Constant(
value: Constant(
ExprConstant {
value: Bytes(
[
@ -29,9 +25,7 @@ expression: parse_ast
range: 0..13,
},
),
},
range: 0..13,
},
),
},
]

View file

@ -3,13 +3,9 @@ source: parser/src/string.rs
expression: parse_ast
---
[
Attributed {
custom: (),
node: Expr(
Expr(
StmtExpr {
value: Attributed {
custom: (),
node: Constant(
value: Constant(
ExprConstant {
value: Bytes(
[
@ -24,9 +20,7 @@ expression: parse_ast
range: 0..14,
},
),
},
range: 0..14,
},
),
},
]

View file

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

View file

@ -3,18 +3,12 @@ source: parser/src/string.rs
expression: parse_ast
---
[
Attributed {
custom: (),
node: Expr(
Expr(
StmtExpr {
value: Attributed {
custom: (),
node: JoinedStr(
value: JoinedStr(
ExprJoinedStr {
values: [
Attributed {
custom: (),
node: Constant(
Constant(
ExprConstant {
value: Str(
"\\",
@ -23,14 +17,9 @@ expression: parse_ast
range: 0..8,
},
),
},
Attributed {
custom: (),
node: FormattedValue(
FormattedValue(
ExprFormattedValue {
value: Attributed {
custom: (),
node: Name(
value: Name(
ExprName {
id: Identifier(
"x",
@ -39,7 +28,6 @@ expression: parse_ast
range: 5..6,
},
),
},
conversion: Int(
0,
),
@ -47,14 +35,11 @@ expression: parse_ast
range: 0..8,
},
),
},
],
range: 0..8,
},
),
},
range: 0..8,
},
),
},
]

View file

@ -3,18 +3,12 @@ source: parser/src/string.rs
expression: parse_ast
---
[
Attributed {
custom: (),
node: Expr(
Expr(
StmtExpr {
value: Attributed {
custom: (),
node: JoinedStr(
value: JoinedStr(
ExprJoinedStr {
values: [
Attributed {
custom: (),
node: Constant(
Constant(
ExprConstant {
value: Str(
"\n",
@ -23,14 +17,9 @@ expression: parse_ast
range: 0..8,
},
),
},
Attributed {
custom: (),
node: FormattedValue(
FormattedValue(
ExprFormattedValue {
value: Attributed {
custom: (),
node: Name(
value: Name(
ExprName {
id: Identifier(
"x",
@ -39,7 +28,6 @@ expression: parse_ast
range: 5..6,
},
),
},
conversion: Int(
0,
),
@ -47,14 +35,11 @@ expression: parse_ast
range: 0..8,
},
),
},
],
range: 0..8,
},
),
},
range: 0..8,
},
),
},
]

View file

@ -3,18 +3,12 @@ source: parser/src/string.rs
expression: parse_ast
---
[
Attributed {
custom: (),
node: Expr(
Expr(
StmtExpr {
value: Attributed {
custom: (),
node: JoinedStr(
value: JoinedStr(
ExprJoinedStr {
values: [
Attributed {
custom: (),
node: Constant(
Constant(
ExprConstant {
value: Str(
"\\\n",
@ -23,14 +17,9 @@ expression: parse_ast
range: 0..9,
},
),
},
Attributed {
custom: (),
node: FormattedValue(
FormattedValue(
ExprFormattedValue {
value: Attributed {
custom: (),
node: Name(
value: Name(
ExprName {
id: Identifier(
"x",
@ -39,7 +28,6 @@ expression: parse_ast
range: 6..7,
},
),
},
conversion: Int(
0,
),
@ -47,14 +35,11 @@ expression: parse_ast
range: 0..9,
},
),
},
],
range: 0..9,
},
),
},
range: 0..9,
},
),
},
]

View file

@ -3,9 +3,7 @@ source: parser/src/string.rs
expression: parse_ast
---
[
Attributed {
custom: (),
node: Constant(
Constant(
ExprConstant {
value: Str(
"user=",
@ -14,10 +12,7 @@ expression: parse_ast
range: 0..10,
},
),
},
Attributed {
custom: (),
node: Constant(
Constant(
ExprConstant {
value: Str(
"",
@ -26,14 +21,9 @@ expression: parse_ast
range: 0..10,
},
),
},
Attributed {
custom: (),
node: FormattedValue(
FormattedValue(
ExprFormattedValue {
value: Attributed {
custom: (),
node: Name(
value: Name(
ExprName {
id: Identifier(
"user",
@ -42,7 +32,6 @@ expression: parse_ast
range: 3..7,
},
),
},
conversion: Int(
114,
),
@ -50,5 +39,4 @@ expression: parse_ast
range: 0..10,
},
),
},
]

View file

@ -3,9 +3,7 @@ source: parser/src/string.rs
expression: parse_ast
---
[
Attributed {
custom: (),
node: Constant(
Constant(
ExprConstant {
value: Str(
"mix ",
@ -14,10 +12,7 @@ expression: parse_ast
range: 0..38,
},
),
},
Attributed {
custom: (),
node: Constant(
Constant(
ExprConstant {
value: Str(
"user=",
@ -26,10 +21,7 @@ expression: parse_ast
range: 0..38,
},
),
},
Attributed {
custom: (),
node: Constant(
Constant(
ExprConstant {
value: Str(
"",
@ -38,14 +30,9 @@ expression: parse_ast
range: 0..38,
},
),
},
Attributed {
custom: (),
node: FormattedValue(
FormattedValue(
ExprFormattedValue {
value: Attributed {
custom: (),
node: Name(
value: Name(
ExprName {
id: Identifier(
"user",
@ -54,7 +41,6 @@ expression: parse_ast
range: 7..11,
},
),
},
conversion: Int(
114,
),
@ -62,10 +48,7 @@ expression: parse_ast
range: 0..38,
},
),
},
Attributed {
custom: (),
node: Constant(
Constant(
ExprConstant {
value: Str(
" with text and ",
@ -74,10 +57,7 @@ expression: parse_ast
range: 0..38,
},
),
},
Attributed {
custom: (),
node: Constant(
Constant(
ExprConstant {
value: Str(
"second=",
@ -86,10 +66,7 @@ expression: parse_ast
range: 0..38,
},
),
},
Attributed {
custom: (),
node: Constant(
Constant(
ExprConstant {
value: Str(
"",
@ -98,14 +75,9 @@ expression: parse_ast
range: 0..38,
},
),
},
Attributed {
custom: (),
node: FormattedValue(
FormattedValue(
ExprFormattedValue {
value: Attributed {
custom: (),
node: Name(
value: Name(
ExprName {
id: Identifier(
"second",
@ -114,7 +86,6 @@ expression: parse_ast
range: 29..35,
},
),
},
conversion: Int(
114,
),
@ -122,5 +93,4 @@ expression: parse_ast
range: 0..38,
},
),
},
]

View file

@ -3,9 +3,7 @@ source: parser/src/string.rs
expression: parse_ast
---
[
Attributed {
custom: (),
node: Constant(
Constant(
ExprConstant {
value: Str(
"user=",
@ -14,10 +12,7 @@ expression: parse_ast
range: 0..14,
},
),
},
Attributed {
custom: (),
node: Constant(
Constant(
ExprConstant {
value: Str(
"",
@ -26,14 +21,9 @@ expression: parse_ast
range: 0..14,
},
),
},
Attributed {
custom: (),
node: FormattedValue(
FormattedValue(
ExprFormattedValue {
value: Attributed {
custom: (),
node: Name(
value: Name(
ExprName {
id: Identifier(
"user",
@ -42,19 +32,14 @@ expression: parse_ast
range: 3..7,
},
),
},
conversion: Int(
0,
),
format_spec: Some(
Attributed {
custom: (),
node: JoinedStr(
JoinedStr(
ExprJoinedStr {
values: [
Attributed {
custom: (),
node: Constant(
Constant(
ExprConstant {
value: Str(
">10",
@ -63,15 +48,12 @@ expression: parse_ast
range: 0..14,
},
),
},
],
range: 0..14,
},
),
},
),
range: 0..14,
},
),
},
]

View file

@ -3,18 +3,12 @@ source: parser/src/string.rs
expression: parse_ast
---
[
Attributed {
custom: (),
node: Expr(
Expr(
StmtExpr {
value: Attributed {
custom: (),
node: JoinedStr(
value: JoinedStr(
ExprJoinedStr {
values: [
Attributed {
custom: (),
node: Constant(
Constant(
ExprConstant {
value: Str(
"\n",
@ -23,14 +17,9 @@ expression: parse_ast
range: 0..11,
},
),
},
Attributed {
custom: (),
node: FormattedValue(
FormattedValue(
ExprFormattedValue {
value: Attributed {
custom: (),
node: Name(
value: Name(
ExprName {
id: Identifier(
"x",
@ -39,7 +28,6 @@ expression: parse_ast
range: 6..7,
},
),
},
conversion: Int(
0,
),
@ -47,14 +35,11 @@ expression: parse_ast
range: 0..11,
},
),
},
],
range: 0..11,
},
),
},
range: 0..11,
},
),
},
]

View file

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

View file

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

View file

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

View file

@ -3,18 +3,12 @@ source: parser/src/string.rs
expression: parse_ast
---
[
Attributed {
custom: (),
node: Expr(
Expr(
StmtExpr {
value: Attributed {
custom: (),
node: JoinedStr(
value: JoinedStr(
ExprJoinedStr {
values: [
Attributed {
custom: (),
node: Constant(
Constant(
ExprConstant {
value: Str(
"Hello world",
@ -23,14 +17,9 @@ expression: parse_ast
range: 0..22,
},
),
},
Attributed {
custom: (),
node: FormattedValue(
FormattedValue(
ExprFormattedValue {
value: Attributed {
custom: (),
node: Constant(
value: Constant(
ExprConstant {
value: Str(
"!",
@ -39,7 +28,6 @@ expression: parse_ast
range: 17..20,
},
),
},
conversion: Int(
0,
),
@ -47,14 +35,11 @@ expression: parse_ast
range: 9..22,
},
),
},
],
range: 0..22,
},
),
},
range: 0..22,
},
),
},
]

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