Give identifier and int ast types

This commit is contained in:
Jeong YunWon 2023-05-10 19:17:11 +09:00
parent d495cd9129
commit 455bcc01a0
88 changed files with 3288 additions and 2300 deletions

View file

@ -17,9 +17,9 @@ TABSIZE = 4
AUTO_GEN_MESSAGE = "// File automatically generated by {}.\n\n"
builtin_type_mapping = {
"identifier": "Ident",
"identifier": "Identifier",
"string": "String",
"int": "u32",
"int": "Int",
"constant": "Constant",
}
assert builtin_type_mapping.keys() == asdl.builtin_types

View file

@ -1,76 +0,0 @@
use rustpython_parser_core::{
source_code::{SourceLocation, SourceRange},
text_size::{TextRange, TextSize},
};
#[derive(Clone, Debug, PartialEq)]
pub struct Attributed<T, U = ()> {
pub range: TextRange,
pub custom: U,
pub node: T,
}
impl<T, U> Attributed<T, U> {
/// Returns the node
#[inline]
pub fn node(&self) -> &T {
&self.node
}
/// Returns the `range` of the node. The range offsets are absolute to the start of the document.
#[inline]
pub const fn range(&self) -> TextRange {
self.range
}
/// Returns the absolute start position of the node from the beginning of the document.
#[inline]
pub const fn start(&self) -> TextSize {
self.range.start()
}
/// Returns the absolute position at which the node ends in the source document.
#[inline]
pub const fn end(&self) -> TextSize {
self.range.end()
}
}
impl<T> Attributed<T, ()> {
/// Creates a new node that spans the position specified by `range`.
pub fn new(range: impl Into<TextRange>, node: T) -> Self {
Self {
range: range.into(),
custom: (),
node,
}
}
/// Consumes self and returns the node.
#[inline]
pub fn into_node(self) -> T {
self.node
}
}
impl<T> Attributed<T, SourceRange> {
/// Returns the absolute start position of the node from the beginning of the document.
#[inline]
pub const fn location(&self) -> SourceLocation {
self.custom.start
}
/// Returns the absolute position at which the node ends in the source document.
#[inline]
pub const fn end_location(&self) -> Option<SourceLocation> {
self.custom.end
}
}
impl<T, U> std::ops::Deref for Attributed<T, U> {
type Target = T;
fn deref(&self) -> &Self::Target {
&self.node
}
}

186
ast/src/builtin.rs Normal file
View file

@ -0,0 +1,186 @@
//! `builtin_types` in asdl.py and Attributed
use num_bigint::BigInt;
use rustpython_parser_core::text_size::{TextRange, TextSize};
pub type String = std::string::String;
#[derive(Clone, Debug, PartialEq, Eq, Hash)]
pub struct Identifier(String);
impl Identifier {
#[inline]
pub fn new(s: impl Into<String>) -> Self {
Self(s.into())
}
#[inline]
pub fn as_str(&self) -> &str {
self.0.as_str()
}
}
impl std::string::ToString for Identifier {
#[inline]
fn to_string(&self) -> String {
self.0.clone()
}
}
impl From<Identifier> for String {
#[inline]
fn from(id: Identifier) -> String {
id.0
}
}
#[derive(Clone, Debug, PartialEq, Eq, PartialOrd, Ord, Hash)]
pub struct Int(u32);
impl Int {
pub fn new(i: u32) -> Self {
Self(i)
}
pub fn new_bool(i: bool) -> Self {
Self(i as u32)
}
pub fn to_u32(&self) -> u32 {
self.0
}
pub fn to_bool(&self) -> bool {
self.0 > 0
}
}
#[derive(Clone, Debug, PartialEq)]
pub enum Constant {
None,
Bool(bool),
Str(String),
Bytes(Vec<u8>),
Int(BigInt),
Tuple(Vec<Constant>),
Float(f64),
Complex { real: f64, imag: f64 },
Ellipsis,
}
impl From<String> for Constant {
fn from(s: String) -> Constant {
Self::Str(s)
}
}
impl From<Vec<u8>> for Constant {
fn from(b: Vec<u8>) -> Constant {
Self::Bytes(b)
}
}
impl From<bool> for Constant {
fn from(b: bool) -> Constant {
Self::Bool(b)
}
}
impl From<BigInt> for Constant {
fn from(i: BigInt) -> Constant {
Self::Int(i)
}
}
#[cfg(feature = "rustpython-literal")]
impl std::fmt::Display for Constant {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
match self {
Constant::None => f.pad("None"),
Constant::Bool(b) => f.pad(if *b { "True" } else { "False" }),
Constant::Str(s) => rustpython_literal::escape::UnicodeEscape::new_repr(s.as_str())
.str_repr()
.write(f),
Constant::Bytes(b) => {
let escape = rustpython_literal::escape::AsciiEscape::new_repr(b);
let repr = escape.bytes_repr().to_string().unwrap();
f.pad(&repr)
}
Constant::Int(i) => i.fmt(f),
Constant::Tuple(tup) => {
if let [elt] = &**tup {
write!(f, "({elt},)")
} else {
f.write_str("(")?;
for (i, elt) in tup.iter().enumerate() {
if i != 0 {
f.write_str(", ")?;
}
elt.fmt(f)?;
}
f.write_str(")")
}
}
Constant::Float(fp) => f.pad(&rustpython_literal::float::to_string(*fp)),
Constant::Complex { real, imag } => {
if *real == 0.0 {
write!(f, "{imag}j")
} else {
write!(f, "({real}{imag:+}j)")
}
}
Constant::Ellipsis => f.pad("..."),
}
}
}
#[derive(Clone, Debug, PartialEq)]
pub struct Attributed<T, U = ()> {
pub range: TextRange,
pub custom: U,
pub node: T,
}
impl<T, U> Attributed<T, U> {
/// Returns the node
#[inline]
pub fn node(&self) -> &T {
&self.node
}
/// Returns the `range` of the node. The range offsets are absolute to the start of the document.
#[inline]
pub const fn range(&self) -> TextRange {
self.range
}
/// Returns the absolute start position of the node from the beginning of the document.
#[inline]
pub const fn start(&self) -> TextSize {
self.range.start()
}
/// Returns the absolute position at which the node ends in the source document.
#[inline]
pub const fn end(&self) -> TextSize {
self.range.end()
}
}
impl<T> Attributed<T, ()> {
/// Creates a new node that spans the position specified by `range`.
pub fn new(range: impl Into<TextRange>, node: T) -> Self {
Self {
range: range.into(),
custom: (),
node,
}
}
/// Consumes self and returns the node.
#[inline]
pub fn into_node(self) -> T {
self.node
}
}
impl<T, U> std::ops::Deref for Attributed<T, U> {
type Target = T;
fn deref(&self) -> &Self::Target {
&self.node
}
}

View file

@ -1,4 +1,4 @@
use crate::{constant, fold::Fold};
use crate::{builtin, fold::Fold};
pub trait Foldable<T, U> {
type Mapped;
@ -62,4 +62,10 @@ macro_rules! simple_fold {
};
}
simple_fold!(u32, String, bool, constant::Constant);
simple_fold!(
builtin::Int,
builtin::String,
builtin::Identifier,
bool,
builtin::Constant
);

View file

@ -56,7 +56,7 @@ pub enum Mod<U = ()> {
#[derive(Clone, Debug, PartialEq)]
pub struct StmtFunctionDef<U = ()> {
pub name: Ident,
pub name: Identifier,
pub args: Box<Arguments<U>>,
pub body: Vec<Stmt<U>>,
pub decorator_list: Vec<Expr<U>>,
@ -72,7 +72,7 @@ impl<U> From<StmtFunctionDef<U>> for StmtKind<U> {
#[derive(Clone, Debug, PartialEq)]
pub struct StmtAsyncFunctionDef<U = ()> {
pub name: Ident,
pub name: Identifier,
pub args: Box<Arguments<U>>,
pub body: Vec<Stmt<U>>,
pub decorator_list: Vec<Expr<U>>,
@ -88,7 +88,7 @@ impl<U> From<StmtAsyncFunctionDef<U>> for StmtKind<U> {
#[derive(Clone, Debug, PartialEq)]
pub struct StmtClassDef<U = ()> {
pub name: Ident,
pub name: Identifier,
pub bases: Vec<Expr<U>>,
pub keywords: Vec<Keyword<U>>,
pub body: Vec<Stmt<U>>,
@ -154,7 +154,7 @@ pub struct StmtAnnAssign<U = ()> {
pub target: Box<Expr<U>>,
pub annotation: Box<Expr<U>>,
pub value: Option<Box<Expr<U>>>,
pub simple: u32,
pub simple: Int,
}
impl<U> From<StmtAnnAssign<U>> for StmtKind<U> {
@ -322,9 +322,9 @@ impl<U> From<StmtImport<U>> for StmtKind<U> {
#[derive(Clone, Debug, PartialEq)]
pub struct StmtImportFrom<U = ()> {
pub module: Option<Ident>,
pub module: Option<Identifier>,
pub names: Vec<Alias<U>>,
pub level: Option<u32>,
pub level: Option<Int>,
}
impl<U> From<StmtImportFrom<U>> for StmtKind<U> {
@ -335,7 +335,7 @@ impl<U> From<StmtImportFrom<U>> for StmtKind<U> {
#[derive(Clone, Debug, PartialEq)]
pub struct StmtGlobal {
pub names: Vec<Ident>,
pub names: Vec<Identifier>,
}
impl From<StmtGlobal> for StmtKind {
@ -346,7 +346,7 @@ impl From<StmtGlobal> for StmtKind {
#[derive(Clone, Debug, PartialEq)]
pub struct StmtNonlocal {
pub names: Vec<Ident>,
pub names: Vec<Identifier>,
}
impl From<StmtNonlocal> for StmtKind {
@ -606,7 +606,7 @@ impl<U> From<ExprCall<U>> for ExprKind<U> {
#[derive(Clone, Debug, PartialEq)]
pub struct ExprFormattedValue<U = ()> {
pub value: Box<Expr<U>>,
pub conversion: u32,
pub conversion: Int,
pub format_spec: Option<Box<Expr<U>>>,
}
@ -642,7 +642,7 @@ impl From<ExprConstant> for ExprKind {
#[derive(Clone, Debug, PartialEq)]
pub struct ExprAttribute<U = ()> {
pub value: Box<Expr<U>>,
pub attr: Ident,
pub attr: Identifier,
pub ctx: ExprContext,
}
@ -679,7 +679,7 @@ impl<U> From<ExprStarred<U>> for ExprKind<U> {
#[derive(Clone, Debug, PartialEq)]
pub struct ExprName {
pub id: Ident,
pub id: Identifier,
pub ctx: ExprContext,
}
@ -815,13 +815,13 @@ pub struct Comprehension<U = ()> {
pub target: Expr<U>,
pub iter: Expr<U>,
pub ifs: Vec<Expr<U>>,
pub is_async: u32,
pub is_async: Int,
}
#[derive(Clone, Debug, PartialEq)]
pub struct ExcepthandlerExceptHandler<U = ()> {
pub type_: Option<Box<Expr<U>>>,
pub name: Option<Ident>,
pub name: Option<Identifier>,
pub body: Vec<Stmt<U>>,
}
@ -850,7 +850,7 @@ pub struct Arguments<U = ()> {
#[derive(Clone, Debug, PartialEq)]
pub struct ArgData<U = ()> {
pub arg: Ident,
pub arg: Identifier,
pub annotation: Option<Box<Expr<U>>>,
pub type_comment: Option<String>,
}
@ -858,15 +858,15 @@ pub type Arg<U = ()> = Attributed<ArgData<U>, U>;
#[derive(Clone, Debug, PartialEq)]
pub struct KeywordData<U = ()> {
pub arg: Option<Ident>,
pub arg: Option<Identifier>,
pub value: Expr<U>,
}
pub type Keyword<U = ()> = Attributed<KeywordData<U>, U>;
#[derive(Clone, Debug, PartialEq)]
pub struct AliasData {
pub name: Ident,
pub asname: Option<Ident>,
pub name: Identifier,
pub asname: Option<Identifier>,
}
pub type Alias<U = ()> = Attributed<AliasData, U>;
@ -920,7 +920,7 @@ impl<U> From<PatternMatchSequence<U>> for PatternKind<U> {
pub struct PatternMatchMapping<U = ()> {
pub keys: Vec<Expr<U>>,
pub patterns: Vec<Pattern<U>>,
pub rest: Option<Ident>,
pub rest: Option<Identifier>,
}
impl<U> From<PatternMatchMapping<U>> for PatternKind<U> {
@ -933,7 +933,7 @@ impl<U> From<PatternMatchMapping<U>> for PatternKind<U> {
pub struct PatternMatchClass<U = ()> {
pub cls: Box<Expr<U>>,
pub patterns: Vec<Pattern<U>>,
pub kwd_attrs: Vec<Ident>,
pub kwd_attrs: Vec<Identifier>,
pub kwd_patterns: Vec<Pattern<U>>,
}
@ -945,7 +945,7 @@ impl<U> From<PatternMatchClass<U>> for PatternKind<U> {
#[derive(Clone, Debug, PartialEq)]
pub struct PatternMatchStar {
pub name: Option<Ident>,
pub name: Option<Identifier>,
}
impl From<PatternMatchStar> for PatternKind {
@ -957,7 +957,7 @@ impl From<PatternMatchStar> for PatternKind {
#[derive(Clone, Debug, PartialEq)]
pub struct PatternMatchAs<U = ()> {
pub pattern: Option<Box<Pattern<U>>>,
pub name: Option<Ident>,
pub name: Option<Identifier>,
}
impl<U> From<PatternMatchAs<U>> for PatternKind<U> {
@ -992,7 +992,7 @@ pub type Pattern<U = ()> = Attributed<PatternKind<U>, U>;
#[derive(Clone, Debug, PartialEq)]
pub struct TypeIgnoreTypeIgnore {
pub lineno: u32,
pub lineno: Int,
pub tag: String,
}

View file

@ -1,12 +1,9 @@
mod attributed;
mod constant;
mod builtin;
#[cfg(feature = "fold")]
mod fold_helpers;
mod generic {
#![allow(clippy::derive_partial_eq_without_eq)]
pub use crate::{constant::*, Attributed};
type Ident = String;
pub use crate::builtin::*;
include!("gen/generic.rs");
}
@ -16,8 +13,7 @@ mod source_locator;
#[cfg(feature = "unparse")]
mod unparse;
pub use attributed::Attributed;
pub use constant::Constant;
pub use builtin::*;
pub use generic::*;
pub use rustpython_parser_core::{text_size, ConversionFlag};
@ -44,3 +40,9 @@ pub mod located {
pub use rustpython_parser_core::source_code;
#[cfg(feature = "visitor")]
pub use visitor::Visitor;
#[cfg(feature = "constant-optimization")]
mod optimizer;
#[cfg(feature = "constant-optimization")]
pub use optimizer::ConstantOptimizer;

View file

@ -1,87 +1,9 @@
use num_bigint::BigInt;
use crate::builtin::Constant;
#[derive(Clone, Debug, PartialEq)]
pub enum Constant {
None,
Bool(bool),
Str(String),
Bytes(Vec<u8>),
Int(BigInt),
Tuple(Vec<Constant>),
Float(f64),
Complex { real: f64, imag: f64 },
Ellipsis,
}
impl From<String> for Constant {
fn from(s: String) -> Constant {
Self::Str(s)
}
}
impl From<Vec<u8>> for Constant {
fn from(b: Vec<u8>) -> Constant {
Self::Bytes(b)
}
}
impl From<bool> for Constant {
fn from(b: bool) -> Constant {
Self::Bool(b)
}
}
impl From<BigInt> for Constant {
fn from(i: BigInt) -> Constant {
Self::Int(i)
}
}
#[cfg(feature = "rustpython-literal")]
impl std::fmt::Display for Constant {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
match self {
Constant::None => f.pad("None"),
Constant::Bool(b) => f.pad(if *b { "True" } else { "False" }),
Constant::Str(s) => rustpython_literal::escape::UnicodeEscape::new_repr(s.as_str())
.str_repr()
.write(f),
Constant::Bytes(b) => {
let escape = rustpython_literal::escape::AsciiEscape::new_repr(b);
let repr = escape.bytes_repr().to_string().unwrap();
f.pad(&repr)
}
Constant::Int(i) => i.fmt(f),
Constant::Tuple(tup) => {
if let [elt] = &**tup {
write!(f, "({elt},)")
} else {
f.write_str("(")?;
for (i, elt) in tup.iter().enumerate() {
if i != 0 {
f.write_str(", ")?;
}
elt.fmt(f)?;
}
f.write_str(")")
}
}
Constant::Float(fp) => f.pad(&rustpython_literal::float::to_string(*fp)),
Constant::Complex { real, imag } => {
if *real == 0.0 {
write!(f, "{imag}j")
} else {
write!(f, "({real}{imag:+}j)")
}
}
Constant::Ellipsis => f.pad("..."),
}
}
}
#[cfg(feature = "constant-optimization")]
#[non_exhaustive]
#[derive(Default)]
pub struct ConstantOptimizer {}
#[cfg(feature = "constant-optimization")]
impl ConstantOptimizer {
#[inline]
pub fn new() -> Self {
@ -135,7 +57,7 @@ impl<U> crate::fold::Fold<U> for ConstantOptimizer {
#[cfg(test)]
mod tests {
use super::*;
use num_bigint::BigInt;
use rustpython_parser_core::text_size::TextRange;
#[cfg(feature = "constant-optimization")]

View file

@ -1,5 +1,5 @@
use crate::attributed::Attributed;
use rustpython_parser_core::source_code::{SourceLocator, SourceRange};
use crate::builtin::Attributed;
use rustpython_parser_core::source_code::{SourceLocation, SourceLocator, SourceRange};
impl crate::fold::Fold<()> for SourceLocator<'_> {
type TargetU = SourceRange;
@ -23,3 +23,17 @@ impl crate::fold::Fold<()> for SourceLocator<'_> {
})
}
}
impl<T> Attributed<T, SourceRange> {
/// Returns the absolute start position of the node from the beginning of the document.
#[inline]
pub const fn location(&self) -> SourceLocation {
self.custom.start
}
/// Returns the absolute position at which the node ends in the source document.
#[inline]
pub const fn end_location(&self) -> Option<SourceLocation> {
self.custom.end
}
}

View file

@ -1,5 +1,7 @@
use crate::ConversionFlag;
use crate::{Arg, Arguments, Boolop, Cmpop, Comprehension, Constant, Expr, ExprKind, Operator};
use crate::{
Arg, Arguments, Boolop, Cmpop, Comprehension, Constant, Expr, ExprKind, Identifier, Operator,
};
use std::fmt;
mod precedence {
@ -32,6 +34,9 @@ impl<'a> Unparser<'a> {
fn p(&mut self, s: &str) -> fmt::Result {
self.f.write_str(s)
}
fn p_id(&mut self, s: &Identifier) -> fmt::Result {
self.f.write_str(s.as_str())
}
fn p_if(&mut self, cond: bool, s: &str) -> fmt::Result {
if cond {
self.f.write_str(s)?;
@ -270,7 +275,7 @@ impl<'a> Unparser<'a> {
for kw in keywords {
self.p_delim(&mut first, ", ")?;
if let Some(arg) = &kw.node.arg {
self.p(arg)?;
self.p_id(arg)?;
self.p("=")?;
} else {
self.p("**")?;
@ -284,7 +289,7 @@ impl<'a> Unparser<'a> {
value,
conversion,
format_spec,
}) => self.unparse_formatted(value, *conversion, format_spec.as_deref())?,
}) => self.unparse_formatted(value, conversion.to_u32(), format_spec.as_deref())?,
ExprKind::JoinedStr(crate::ExprJoinedStr { values }) => {
self.unparse_joined_str(values, false)?
}
@ -316,7 +321,7 @@ impl<'a> Unparser<'a> {
"."
};
self.p(period)?;
self.p(attr)?;
self.p_id(attr)?;
}
ExprKind::Subscript(crate::ExprSubscript { value, slice, .. }) => {
self.unparse_expr(value, precedence::ATOM)?;
@ -337,7 +342,7 @@ impl<'a> Unparser<'a> {
self.p("*")?;
self.unparse_expr(value, precedence::EXPR)?;
}
ExprKind::Name(crate::ExprName { id, .. }) => self.p(id)?,
ExprKind::Name(crate::ExprName { id, .. }) => self.p_id(id)?,
ExprKind::List(crate::ExprList { elts, .. }) => {
self.p("[")?;
let mut first = true;
@ -415,7 +420,7 @@ impl<'a> Unparser<'a> {
Ok(())
}
fn unparse_arg<U>(&mut self, arg: &Arg<U>) -> fmt::Result {
self.p(&arg.node.arg)?;
self.p_id(&arg.node.arg)?;
if let Some(ann) = &arg.node.annotation {
write!(self, ": {}", **ann)?;
}
@ -424,7 +429,7 @@ impl<'a> Unparser<'a> {
fn unparse_comp<U>(&mut self, generators: &[Comprehension<U>]) -> fmt::Result {
for comp in generators {
self.p(if comp.is_async > 0 {
self.p(if comp.is_async.to_bool() {
" async for "
} else {
" for "
@ -497,7 +502,7 @@ impl<'a> Unparser<'a> {
value,
conversion,
format_spec,
}) => self.unparse_formatted(value, *conversion, format_spec.as_deref()),
}) => self.unparse_formatted(value, conversion.to_u32(), format_spec.as_deref()),
_ => unreachable!(),
}
}

View file

@ -84,7 +84,10 @@ pub(crate) fn parse_params(
Ok((pos_only, names, defaults))
}
type FunctionArgument = (Option<(TextSize, TextSize, Option<String>)>, ast::Expr);
type FunctionArgument = (
Option<(TextSize, TextSize, Option<ast::Identifier>)>,
ast::Expr,
);
// Parse arguments as supplied during a function/lambda *call*.
pub(crate) fn parse_args(func_args: Vec<FunctionArgument>) -> Result<ArgumentList, LexicalError> {
@ -115,7 +118,10 @@ pub(crate) fn parse_args(func_args: Vec<FunctionArgument>) -> Result<ArgumentLis
keywords.push(ast::Keyword::new(
start..end,
ast::KeywordData { arg: name, value },
ast::KeywordData {
arg: name.map(ast::Identifier::new),
value,
},
));
}
None => {

View file

@ -132,7 +132,7 @@ ExpressionStatement: ast::Stmt = {
target: Box::new(set_context(target, ast::ExprContext::Store)),
annotation: Box::new(annotation),
value: rhs.map(Box::new),
simple: if simple { 1 } else { 0 },
simple: ast::Int::new_bool(simple),
}.into(),
)
},
@ -255,18 +255,18 @@ ImportStatement: ast::Stmt = {
},
};
ImportFromLocation: (Option<u32>, Option<String>) = {
ImportFromLocation: (Option<ast::Int>, Option<ast::Identifier>) = {
<dots: ImportDots*> <name:DottedName> => {
(Some(dots.iter().sum()), Some(name))
(Some(ast::Int::new(dots.iter().map(ast::Int::to_u32).sum())), Some(name))
},
<dots: ImportDots+> => {
(Some(dots.iter().sum()), None)
(Some(ast::Int::new(dots.iter().map(ast::Int::to_u32).sum())), None)
},
};
ImportDots: u32 = {
"..." => 3,
"." => 1,
ImportDots: ast::Int = {
"..." => ast::Int::new(3),
"." => ast::Int::new(3),
};
ImportAsNames: Vec<ast::Alias> = {
@ -274,7 +274,7 @@ 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(location..end_location, ast::AliasData { name: "*".to_string(), asname: None })]
vec![ast::Alias::new(location..end_location, ast::AliasData { name: ast::Identifier::new("*"), asname: None })]
},
};
@ -285,15 +285,15 @@ ImportAsAlias<I>: ast::Alias = {
}
// A name like abc or abc.def.ghi
DottedName: String = {
<n:name> => n,
DottedName: ast::Identifier = {
<n:name> => ast::Identifier::new(n),
<n:name> <n2: ("." Identifier)+> => {
let mut r = n.to_string();
for x in n2 {
r.push_str(".");
r.push_str(&x.1);
r.push('.');
r.push_str(x.1.as_str());
}
r
ast::Identifier::new(r)
},
};
@ -449,7 +449,7 @@ Pattern: ast::Pattern = {
AsPattern: ast::Pattern = {
<location:@L> <pattern:OrPattern> "as" <name:Identifier> <end_location:@R> =>? {
if name == "_" {
if name.as_str() == "_" {
Err(LexicalError {
error: LexicalErrorType::OtherError("cannot use '_' as a target".to_string()),
location,
@ -538,7 +538,7 @@ SequencePattern: ast::PatternKind = {
StarPattern: ast::PatternKind = {
<location:@L> "*" <name:Identifier> <end_location:@R> => ast::PatternMatchStar {
name: if name == "_" { None } else { Some(name) }
name: if name.as_str() == "_" { None } else { Some(name) }
}.into(),
}
@ -598,7 +598,7 @@ LiteralPattern: ast::PatternKind = {
CapturePattern: ast::PatternKind = {
<location:@L> <name:Identifier> <end_location:@R> => ast::PatternMatchAs {
pattern: None,
name: if name == "_" { None } else { Some(name) }
name: if name.as_str() == "_" { None } else { Some(name) }
}.into(),
}
@ -709,7 +709,7 @@ MappingPattern: ast::PatternKind = {
},
}
MatchKeywordEntry: (String, ast::Pattern) = {
MatchKeywordEntry: (ast::Identifier, ast::Pattern) = {
<k:Identifier> "=" <v:Pattern> => (k, v),
};
@ -1707,7 +1707,7 @@ SingleForComprehension: ast::Comprehension = {
target: set_context(target, ast::ExprContext::Store),
iter,
ifs,
is_async: if is_async { 1 } else { 0 },
is_async: ast::Int::new_bool(is_async),
}
}
};
@ -1722,7 +1722,7 @@ ArgumentList: ArgumentList = {
}
};
FunctionArgument: (Option<(TextSize, TextSize, Option<String>)>, ast::Expr) = {
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(
@ -1772,7 +1772,9 @@ Constant: ast::Constant = {
<s:complex> => ast::Constant::Complex { real: s.0, imag: s.1 },
};
Identifier: String = <s:name> => s;
Identifier: ast::Identifier = {
<s:name> => ast::Identifier::new(s)
};
// Hook external lexer:
extern {

3241
parser/src/python.rs generated

File diff suppressed because it is too large Load diff

View file

@ -13,7 +13,9 @@ expression: parse_ast
custom: (),
node: Name(
ExprName {
id: "x",
id: Identifier(
"x",
),
ctx: Store,
},
),
@ -23,7 +25,9 @@ expression: parse_ast
custom: (),
node: Name(
ExprName {
id: "int",
id: Identifier(
"int",
),
ctx: Load,
},
),
@ -42,7 +46,9 @@ expression: parse_ast
),
},
),
simple: 1,
simple: Int(
1,
),
},
),
},

View file

@ -19,12 +19,16 @@ expression: parse_ast
custom: (),
node: Name(
ExprName {
id: "x",
id: Identifier(
"x",
),
ctx: Load,
},
),
},
attr: "y",
attr: Identifier(
"y",
),
ctx: Store,
},
),

View file

@ -13,7 +13,9 @@ expression: parse_ast
custom: (),
node: Name(
ExprName {
id: "x",
id: Identifier(
"x",
),
ctx: Store,
},
),

View file

@ -20,7 +20,9 @@ expression: parse_ast
custom: (),
node: Name(
ExprName {
id: "x",
id: Identifier(
"x",
),
ctx: Store,
},
),
@ -30,7 +32,9 @@ expression: parse_ast
custom: (),
node: Name(
ExprName {
id: "y",
id: Identifier(
"y",
),
ctx: Store,
},
),

View file

@ -14,7 +14,9 @@ expression: parse_ast
custom: (),
node: Name(
ExprName {
id: "x",
id: Identifier(
"x",
),
ctx: Store,
},
),
@ -30,7 +32,9 @@ expression: parse_ast
custom: (),
node: Name(
ExprName {
id: "y",
id: Identifier(
"y",
),
ctx: Load,
},
),
@ -42,7 +46,9 @@ expression: parse_ast
custom: (),
node: Name(
ExprName {
id: "y",
id: Identifier(
"y",
),
ctx: Store,
},
),
@ -95,7 +101,9 @@ expression: parse_ast
),
},
ifs: [],
is_async: 0,
is_async: Int(
0,
),
},
],
},

View file

@ -14,7 +14,9 @@ expression: parse_ast
custom: (),
node: Name(
ExprName {
id: "x",
id: Identifier(
"x",
),
ctx: Store,
},
),

View file

@ -18,7 +18,9 @@ expression: parse_ast
custom: (),
node: Name(
ExprName {
id: "x",
id: Identifier(
"x",
),
ctx: Store,
},
),

View file

@ -14,7 +14,9 @@ expression: parse_ast
custom: (),
node: Name(
ExprName {
id: "x",
id: Identifier(
"x",
),
ctx: Store,
},
),
@ -30,7 +32,9 @@ expression: parse_ast
custom: (),
node: Name(
ExprName {
id: "y",
id: Identifier(
"y",
),
ctx: Load,
},
),
@ -42,7 +46,9 @@ expression: parse_ast
custom: (),
node: Name(
ExprName {
id: "y",
id: Identifier(
"y",
),
ctx: Store,
},
),
@ -95,7 +101,9 @@ expression: parse_ast
),
},
ifs: [],
is_async: 0,
is_async: Int(
0,
),
},
],
},

View file

@ -20,7 +20,9 @@ expression: parse_ast
custom: (),
node: Name(
ExprName {
id: "x",
id: Identifier(
"x",
),
ctx: Store,
},
),
@ -35,7 +37,9 @@ expression: parse_ast
custom: (),
node: Name(
ExprName {
id: "y",
id: Identifier(
"y",
),
ctx: Store,
},
),

View file

@ -19,7 +19,9 @@ expression: parse_ast
custom: (),
node: Name(
ExprName {
id: "x",
id: Identifier(
"x",
),
ctx: Load,
},
),
@ -29,7 +31,9 @@ expression: parse_ast
custom: (),
node: Name(
ExprName {
id: "y",
id: Identifier(
"y",
),
ctx: Load,
},
),

View file

@ -20,7 +20,9 @@ expression: parse_ast
custom: (),
node: Name(
ExprName {
id: "x",
id: Identifier(
"x",
),
ctx: Store,
},
),
@ -30,7 +32,9 @@ expression: parse_ast
custom: (),
node: Name(
ExprName {
id: "y",
id: Identifier(
"y",
),
ctx: Store,
},
),

View file

@ -28,7 +28,9 @@ expression: parse_ast
custom: (),
node: Name(
ExprName {
id: "x",
id: Identifier(
"x",
),
ctx: Store,
},
),

View file

@ -18,12 +18,16 @@ expression: parse_ast
custom: (),
node: Name(
ExprName {
id: "x",
id: Identifier(
"x",
),
ctx: Load,
},
),
},
attr: "y",
attr: Identifier(
"y",
),
ctx: Store,
},
),

View file

@ -13,7 +13,9 @@ expression: parse_ast
custom: (),
node: Name(
ExprName {
id: "x",
id: Identifier(
"x",
),
ctx: Store,
},
),

View file

@ -18,7 +18,9 @@ expression: parse_ast
custom: (),
node: Name(
ExprName {
id: "x",
id: Identifier(
"x",
),
ctx: Load,
},
),
@ -28,7 +30,9 @@ expression: parse_ast
custom: (),
node: Name(
ExprName {
id: "y",
id: Identifier(
"y",
),
ctx: Load,
},
),

View file

@ -19,12 +19,16 @@ expression: parse_ast
custom: (),
node: Name(
ExprName {
id: "x",
id: Identifier(
"x",
),
ctx: Load,
},
),
},
attr: "y",
attr: Identifier(
"y",
),
ctx: Del,
},
),

View file

@ -14,7 +14,9 @@ expression: parse_ast
custom: (),
node: Name(
ExprName {
id: "x",
id: Identifier(
"x",
),
ctx: Del,
},
),

View file

@ -19,7 +19,9 @@ expression: parse_ast
custom: (),
node: Name(
ExprName {
id: "x",
id: Identifier(
"x",
),
ctx: Load,
},
),
@ -29,7 +31,9 @@ expression: parse_ast
custom: (),
node: Name(
ExprName {
id: "y",
id: Identifier(
"y",
),
ctx: Load,
},
),

View file

@ -9,7 +9,9 @@ Ok(
custom: (),
node: FunctionDef(
StmtFunctionDef {
name: "f",
name: Identifier(
"f",
),
args: Arguments {
posonlyargs: [],
args: [],
@ -19,7 +21,9 @@ Ok(
range: 9..10,
custom: (),
node: ArgData {
arg: "a",
arg: Identifier(
"a",
),
annotation: None,
type_comment: None,
},
@ -28,7 +32,9 @@ Ok(
range: 12..13,
custom: (),
node: ArgData {
arg: "b",
arg: Identifier(
"b",
),
annotation: None,
type_comment: None,
},
@ -37,7 +43,9 @@ Ok(
range: 15..16,
custom: (),
node: ArgData {
arg: "c",
arg: Identifier(
"c",
),
annotation: None,
type_comment: None,
},

View file

@ -9,7 +9,9 @@ Ok(
custom: (),
node: FunctionDef(
StmtFunctionDef {
name: "f",
name: Identifier(
"f",
),
args: Arguments {
posonlyargs: [],
args: [],
@ -19,7 +21,9 @@ Ok(
range: 9..10,
custom: (),
node: ArgData {
arg: "a",
arg: Identifier(
"a",
),
annotation: None,
type_comment: None,
},
@ -28,7 +32,9 @@ Ok(
range: 12..13,
custom: (),
node: ArgData {
arg: "b",
arg: Identifier(
"b",
),
annotation: None,
type_comment: None,
},
@ -37,7 +43,9 @@ Ok(
range: 18..19,
custom: (),
node: ArgData {
arg: "c",
arg: Identifier(
"c",
),
annotation: None,
type_comment: None,
},

View file

@ -9,7 +9,9 @@ Ok(
custom: (),
node: FunctionDef(
StmtFunctionDef {
name: "f",
name: Identifier(
"f",
),
args: Arguments {
posonlyargs: [],
args: [],

View file

@ -9,7 +9,9 @@ Ok(
custom: (),
node: FunctionDef(
StmtFunctionDef {
name: "f",
name: Identifier(
"f",
),
args: Arguments {
posonlyargs: [],
args: [
@ -17,7 +19,9 @@ Ok(
range: 6..7,
custom: (),
node: ArgData {
arg: "a",
arg: Identifier(
"a",
),
annotation: None,
type_comment: None,
},
@ -26,7 +30,9 @@ Ok(
range: 9..10,
custom: (),
node: ArgData {
arg: "b",
arg: Identifier(
"b",
),
annotation: None,
type_comment: None,
},
@ -35,7 +41,9 @@ Ok(
range: 12..13,
custom: (),
node: ArgData {
arg: "c",
arg: Identifier(
"c",
),
annotation: None,
type_comment: None,
},
@ -47,7 +55,9 @@ Ok(
range: 18..19,
custom: (),
node: ArgData {
arg: "d",
arg: Identifier(
"d",
),
annotation: None,
type_comment: None,
},
@ -56,7 +66,9 @@ Ok(
range: 21..22,
custom: (),
node: ArgData {
arg: "e",
arg: Identifier(
"e",
),
annotation: None,
type_comment: None,
},
@ -65,7 +77,9 @@ Ok(
range: 24..25,
custom: (),
node: ArgData {
arg: "f",
arg: Identifier(
"f",
),
annotation: None,
type_comment: None,
},

View file

@ -9,7 +9,9 @@ Ok(
custom: (),
node: FunctionDef(
StmtFunctionDef {
name: "f",
name: Identifier(
"f",
),
args: Arguments {
posonlyargs: [],
args: [
@ -17,7 +19,9 @@ Ok(
range: 6..7,
custom: (),
node: ArgData {
arg: "a",
arg: Identifier(
"a",
),
annotation: None,
type_comment: None,
},
@ -26,7 +30,9 @@ Ok(
range: 9..10,
custom: (),
node: ArgData {
arg: "b",
arg: Identifier(
"b",
),
annotation: None,
type_comment: None,
},
@ -35,7 +41,9 @@ Ok(
range: 12..13,
custom: (),
node: ArgData {
arg: "c",
arg: Identifier(
"c",
),
annotation: None,
type_comment: None,
},
@ -47,7 +55,9 @@ Ok(
range: 18..19,
custom: (),
node: ArgData {
arg: "d",
arg: Identifier(
"d",
),
annotation: None,
type_comment: None,
},
@ -56,7 +66,9 @@ Ok(
range: 21..22,
custom: (),
node: ArgData {
arg: "e",
arg: Identifier(
"e",
),
annotation: None,
type_comment: None,
},
@ -65,7 +77,9 @@ Ok(
range: 27..28,
custom: (),
node: ArgData {
arg: "f",
arg: Identifier(
"f",
),
annotation: None,
type_comment: None,
},

View file

@ -9,7 +9,9 @@ Ok(
custom: (),
node: FunctionDef(
StmtFunctionDef {
name: "f",
name: Identifier(
"f",
),
args: Arguments {
posonlyargs: [],
args: [
@ -17,7 +19,9 @@ Ok(
range: 6..7,
custom: (),
node: ArgData {
arg: "a",
arg: Identifier(
"a",
),
annotation: None,
type_comment: None,
},
@ -26,7 +30,9 @@ Ok(
range: 9..10,
custom: (),
node: ArgData {
arg: "b",
arg: Identifier(
"b",
),
annotation: None,
type_comment: None,
},
@ -35,7 +41,9 @@ Ok(
range: 12..13,
custom: (),
node: ArgData {
arg: "c",
arg: Identifier(
"c",
),
annotation: None,
type_comment: None,
},
@ -46,7 +54,9 @@ Ok(
range: 16..20,
custom: (),
node: ArgData {
arg: "args",
arg: Identifier(
"args",
),
annotation: None,
type_comment: None,
},
@ -57,7 +67,9 @@ Ok(
range: 22..23,
custom: (),
node: ArgData {
arg: "d",
arg: Identifier(
"d",
),
annotation: None,
type_comment: None,
},
@ -66,7 +78,9 @@ Ok(
range: 25..26,
custom: (),
node: ArgData {
arg: "e",
arg: Identifier(
"e",
),
annotation: None,
type_comment: None,
},
@ -75,7 +89,9 @@ Ok(
range: 31..32,
custom: (),
node: ArgData {
arg: "f",
arg: Identifier(
"f",
),
annotation: None,
type_comment: None,
},

View file

@ -9,7 +9,9 @@ Ok(
custom: (),
node: FunctionDef(
StmtFunctionDef {
name: "f",
name: Identifier(
"f",
),
args: Arguments {
posonlyargs: [],
args: [
@ -17,7 +19,9 @@ Ok(
range: 6..7,
custom: (),
node: ArgData {
arg: "a",
arg: Identifier(
"a",
),
annotation: None,
type_comment: None,
},
@ -26,7 +30,9 @@ Ok(
range: 9..10,
custom: (),
node: ArgData {
arg: "b",
arg: Identifier(
"b",
),
annotation: None,
type_comment: None,
},
@ -35,7 +41,9 @@ Ok(
range: 12..13,
custom: (),
node: ArgData {
arg: "c",
arg: Identifier(
"c",
),
annotation: None,
type_comment: None,
},
@ -46,7 +54,9 @@ Ok(
range: 16..20,
custom: (),
node: ArgData {
arg: "args",
arg: Identifier(
"args",
),
annotation: None,
type_comment: None,
},
@ -57,7 +67,9 @@ Ok(
range: 22..23,
custom: (),
node: ArgData {
arg: "d",
arg: Identifier(
"d",
),
annotation: None,
type_comment: None,
},
@ -66,7 +78,9 @@ Ok(
range: 25..26,
custom: (),
node: ArgData {
arg: "e",
arg: Identifier(
"e",
),
annotation: None,
type_comment: None,
},
@ -75,7 +89,9 @@ Ok(
range: 31..32,
custom: (),
node: ArgData {
arg: "f",
arg: Identifier(
"f",
),
annotation: None,
type_comment: None,
},
@ -112,7 +128,9 @@ Ok(
range: 39..45,
custom: (),
node: ArgData {
arg: "kwargs",
arg: Identifier(
"kwargs",
),
annotation: None,
type_comment: None,
},

View file

@ -9,7 +9,9 @@ Ok(
custom: (),
node: FunctionDef(
StmtFunctionDef {
name: "f",
name: Identifier(
"f",
),
args: Arguments {
posonlyargs: [],
args: [
@ -17,7 +19,9 @@ Ok(
range: 6..7,
custom: (),
node: ArgData {
arg: "a",
arg: Identifier(
"a",
),
annotation: None,
type_comment: None,
},
@ -26,7 +30,9 @@ Ok(
range: 9..10,
custom: (),
node: ArgData {
arg: "b",
arg: Identifier(
"b",
),
annotation: None,
type_comment: None,
},
@ -35,7 +41,9 @@ Ok(
range: 12..13,
custom: (),
node: ArgData {
arg: "c",
arg: Identifier(
"c",
),
annotation: None,
type_comment: None,
},

View file

@ -9,7 +9,9 @@ Ok(
custom: (),
node: FunctionDef(
StmtFunctionDef {
name: "f",
name: Identifier(
"f",
),
args: Arguments {
posonlyargs: [],
args: [
@ -17,7 +19,9 @@ Ok(
range: 6..7,
custom: (),
node: ArgData {
arg: "a",
arg: Identifier(
"a",
),
annotation: None,
type_comment: None,
},
@ -26,7 +30,9 @@ Ok(
range: 9..10,
custom: (),
node: ArgData {
arg: "b",
arg: Identifier(
"b",
),
annotation: None,
type_comment: None,
},
@ -35,7 +41,9 @@ Ok(
range: 15..16,
custom: (),
node: ArgData {
arg: "c",
arg: Identifier(
"c",
),
annotation: None,
type_comment: None,
},

View file

@ -23,7 +23,9 @@ Ok(
range: 10..11,
custom: (),
node: ArgData {
arg: "a",
arg: Identifier(
"a",
),
annotation: None,
type_comment: None,
},
@ -32,7 +34,9 @@ Ok(
range: 13..14,
custom: (),
node: ArgData {
arg: "b",
arg: Identifier(
"b",
),
annotation: None,
type_comment: None,
},
@ -41,7 +45,9 @@ Ok(
range: 16..17,
custom: (),
node: ArgData {
arg: "c",
arg: Identifier(
"c",
),
annotation: None,
type_comment: None,
},

View file

@ -23,7 +23,9 @@ Ok(
range: 10..11,
custom: (),
node: ArgData {
arg: "a",
arg: Identifier(
"a",
),
annotation: None,
type_comment: None,
},
@ -32,7 +34,9 @@ Ok(
range: 13..14,
custom: (),
node: ArgData {
arg: "b",
arg: Identifier(
"b",
),
annotation: None,
type_comment: None,
},
@ -41,7 +45,9 @@ Ok(
range: 19..20,
custom: (),
node: ArgData {
arg: "c",
arg: Identifier(
"c",
),
annotation: None,
type_comment: None,
},

View file

@ -21,7 +21,9 @@ Ok(
range: 7..8,
custom: (),
node: ArgData {
arg: "a",
arg: Identifier(
"a",
),
annotation: None,
type_comment: None,
},
@ -30,7 +32,9 @@ Ok(
range: 10..11,
custom: (),
node: ArgData {
arg: "b",
arg: Identifier(
"b",
),
annotation: None,
type_comment: None,
},
@ -39,7 +43,9 @@ Ok(
range: 13..14,
custom: (),
node: ArgData {
arg: "c",
arg: Identifier(
"c",
),
annotation: None,
type_comment: None,
},
@ -51,7 +57,9 @@ Ok(
range: 19..20,
custom: (),
node: ArgData {
arg: "d",
arg: Identifier(
"d",
),
annotation: None,
type_comment: None,
},
@ -60,7 +68,9 @@ Ok(
range: 22..23,
custom: (),
node: ArgData {
arg: "e",
arg: Identifier(
"e",
),
annotation: None,
type_comment: None,
},

View file

@ -21,7 +21,9 @@ Ok(
range: 7..8,
custom: (),
node: ArgData {
arg: "a",
arg: Identifier(
"a",
),
annotation: None,
type_comment: None,
},
@ -30,7 +32,9 @@ Ok(
range: 10..11,
custom: (),
node: ArgData {
arg: "b",
arg: Identifier(
"b",
),
annotation: None,
type_comment: None,
},
@ -39,7 +43,9 @@ Ok(
range: 13..14,
custom: (),
node: ArgData {
arg: "c",
arg: Identifier(
"c",
),
annotation: None,
type_comment: None,
},

View file

@ -21,7 +21,9 @@ Ok(
range: 7..8,
custom: (),
node: ArgData {
arg: "a",
arg: Identifier(
"a",
),
annotation: None,
type_comment: None,
},
@ -30,7 +32,9 @@ Ok(
range: 10..11,
custom: (),
node: ArgData {
arg: "b",
arg: Identifier(
"b",
),
annotation: None,
type_comment: None,
},
@ -39,7 +43,9 @@ Ok(
range: 16..17,
custom: (),
node: ArgData {
arg: "c",
arg: Identifier(
"c",
),
annotation: None,
type_comment: None,
},

View file

@ -56,7 +56,9 @@ Attributed {
custom: (),
node: Name(
ExprName {
id: "c",
id: Identifier(
"c",
),
ctx: Load,
},
),

View file

@ -24,7 +24,9 @@ Attributed {
},
),
},
attr: "join",
attr: Identifier(
"join",
),
ctx: Load,
},
),
@ -40,7 +42,9 @@ Attributed {
custom: (),
node: Name(
ExprName {
id: "sql",
id: Identifier(
"sql",
),
ctx: Load,
},
),
@ -52,7 +56,9 @@ Attributed {
custom: (),
node: Name(
ExprName {
id: "sql",
id: Identifier(
"sql",
),
ctx: Store,
},
),
@ -73,7 +79,9 @@ Attributed {
custom: (),
node: Name(
ExprName {
id: "limit",
id: Identifier(
"limit",
),
ctx: Load,
},
),
@ -101,7 +109,9 @@ Attributed {
custom: (),
node: Name(
ExprName {
id: "limit",
id: Identifier(
"limit",
),
ctx: Load,
},
),
@ -132,7 +142,9 @@ Attributed {
custom: (),
node: Name(
ExprName {
id: "offset",
id: Identifier(
"offset",
),
ctx: Load,
},
),
@ -160,7 +172,9 @@ Attributed {
custom: (),
node: Name(
ExprName {
id: "offset",
id: Identifier(
"offset",
),
ctx: Load,
},
),
@ -187,7 +201,9 @@ Attributed {
),
},
ifs: [],
is_async: 0,
is_async: Int(
0,
),
},
],
},

View file

@ -56,7 +56,9 @@ expression: parse_ast
keys: [],
patterns: [],
rest: Some(
"rest",
Identifier(
"rest",
),
),
},
),
@ -78,7 +80,9 @@ expression: parse_ast
custom: (),
node: Name(
ExprName {
id: "print",
id: Identifier(
"print",
),
ctx: Load,
},
),
@ -89,7 +93,9 @@ expression: parse_ast
custom: (),
node: Name(
ExprName {
id: "rest",
id: Identifier(
"rest",
),
ctx: Load,
},
),
@ -195,7 +201,9 @@ expression: parse_ast
custom: (),
node: Name(
ExprName {
id: "str",
id: Identifier(
"str",
),
ctx: Load,
},
),
@ -221,7 +229,9 @@ expression: parse_ast
},
),
name: Some(
"label",
Identifier(
"label",
),
),
},
),
@ -248,7 +258,9 @@ expression: parse_ast
custom: (),
node: Name(
ExprName {
id: "print",
id: Identifier(
"print",
),
ctx: Load,
},
),
@ -259,7 +271,9 @@ expression: parse_ast
custom: (),
node: Name(
ExprName {
id: "label",
id: Identifier(
"label",
),
ctx: Load,
},
),
@ -288,7 +302,9 @@ expression: parse_ast
custom: (),
node: Name(
ExprName {
id: "x",
id: Identifier(
"x",
),
ctx: Load,
},
),
@ -358,7 +374,9 @@ expression: parse_ast
custom: (),
node: Name(
ExprName {
id: "y",
id: Identifier(
"y",
),
ctx: Store,
},
),
@ -396,7 +414,9 @@ expression: parse_ast
custom: (),
node: Name(
ExprName {
id: "x",
id: Identifier(
"x",
),
ctx: Load,
},
),
@ -466,7 +486,9 @@ expression: parse_ast
custom: (),
node: Name(
ExprName {
id: "y",
id: Identifier(
"y",
),
ctx: Store,
},
),
@ -504,7 +526,9 @@ expression: parse_ast
custom: (),
node: Name(
ExprName {
id: "x",
id: Identifier(
"x",
),
ctx: Load,
},
),
@ -554,7 +578,9 @@ expression: parse_ast
custom: (),
node: Name(
ExprName {
id: "y",
id: Identifier(
"y",
),
ctx: Store,
},
),

View file

@ -29,7 +29,9 @@ expression: parse_ast
custom: (),
node: Name(
ExprName {
id: "match",
id: Identifier(
"match",
),
ctx: Load,
},
),
@ -40,7 +42,9 @@ expression: parse_ast
custom: (),
node: Name(
ExprName {
id: "a",
id: Identifier(
"a",
),
ctx: Load,
},
),
@ -54,7 +58,9 @@ expression: parse_ast
custom: (),
node: Name(
ExprName {
id: "b",
id: Identifier(
"b",
),
ctx: Load,
},
),
@ -67,7 +73,9 @@ expression: parse_ast
custom: (),
node: Name(
ExprName {
id: "c",
id: Identifier(
"c",
),
ctx: Load,
},
),
@ -101,7 +109,9 @@ expression: parse_ast
custom: (),
node: Name(
ExprName {
id: "match",
id: Identifier(
"match",
),
ctx: Load,
},
),
@ -117,7 +127,9 @@ expression: parse_ast
custom: (),
node: Name(
ExprName {
id: "a",
id: Identifier(
"a",
),
ctx: Load,
},
),
@ -128,7 +140,9 @@ expression: parse_ast
custom: (),
node: Name(
ExprName {
id: "b",
id: Identifier(
"b",
),
ctx: Load,
},
),
@ -144,7 +158,9 @@ expression: parse_ast
custom: (),
node: Name(
ExprName {
id: "c",
id: Identifier(
"c",
),
ctx: Load,
},
),
@ -172,7 +188,9 @@ expression: parse_ast
custom: (),
node: Name(
ExprName {
id: "match",
id: Identifier(
"match",
),
ctx: Load,
},
),
@ -193,7 +211,9 @@ expression: parse_ast
custom: (),
node: Name(
ExprName {
id: "a",
id: Identifier(
"a",
),
ctx: Load,
},
),
@ -204,7 +224,9 @@ expression: parse_ast
custom: (),
node: Name(
ExprName {
id: "b",
id: Identifier(
"b",
),
ctx: Load,
},
),
@ -221,7 +243,9 @@ expression: parse_ast
custom: (),
node: Name(
ExprName {
id: "c",
id: Identifier(
"c",
),
ctx: Load,
},
),
@ -254,7 +278,9 @@ expression: parse_ast
custom: (),
node: Name(
ExprName {
id: "match",
id: Identifier(
"match",
),
ctx: Load,
},
),
@ -270,7 +296,9 @@ expression: parse_ast
custom: (),
node: Name(
ExprName {
id: "a",
id: Identifier(
"a",
),
ctx: Load,
},
),
@ -281,7 +309,9 @@ expression: parse_ast
custom: (),
node: Name(
ExprName {
id: "b",
id: Identifier(
"b",
),
ctx: Load,
},
),
@ -298,7 +328,9 @@ expression: parse_ast
custom: (),
node: Name(
ExprName {
id: "c",
id: Identifier(
"c",
),
ctx: Load,
},
),
@ -329,7 +361,9 @@ expression: parse_ast
custom: (),
node: Name(
ExprName {
id: "match",
id: Identifier(
"match",
),
ctx: Load,
},
),
@ -345,7 +379,9 @@ expression: parse_ast
custom: (),
node: Name(
ExprName {
id: "a",
id: Identifier(
"a",
),
ctx: Load,
},
),
@ -356,7 +392,9 @@ expression: parse_ast
custom: (),
node: Name(
ExprName {
id: "b",
id: Identifier(
"b",
),
ctx: Load,
},
),
@ -373,7 +411,9 @@ expression: parse_ast
custom: (),
node: Name(
ExprName {
id: "c",
id: Identifier(
"c",
),
ctx: Load,
},
),
@ -409,7 +449,9 @@ expression: parse_ast
custom: (),
node: Name(
ExprName {
id: "match",
id: Identifier(
"match",
),
ctx: Load,
},
),
@ -426,7 +468,9 @@ expression: parse_ast
custom: (),
node: Name(
ExprName {
id: "a",
id: Identifier(
"a",
),
ctx: Load,
},
),
@ -445,7 +489,9 @@ expression: parse_ast
custom: (),
node: Name(
ExprName {
id: "b",
id: Identifier(
"b",
),
ctx: Load,
},
),
@ -459,7 +505,9 @@ expression: parse_ast
custom: (),
node: Name(
ExprName {
id: "c",
id: Identifier(
"c",
),
ctx: Load,
},
),
@ -490,7 +538,9 @@ expression: parse_ast
custom: (),
node: Name(
ExprName {
id: "match",
id: Identifier(
"match",
),
ctx: Load,
},
),
@ -500,7 +550,9 @@ expression: parse_ast
},
),
},
attr: "a",
attr: Identifier(
"a",
),
ctx: Load,
},
),
@ -528,7 +580,9 @@ expression: parse_ast
custom: (),
node: Name(
ExprName {
id: "match",
id: Identifier(
"match",
),
ctx: Load,
},
),
@ -549,7 +603,9 @@ expression: parse_ast
},
),
},
attr: "a",
attr: Identifier(
"a",
),
ctx: Load,
},
),
@ -577,7 +633,9 @@ expression: parse_ast
custom: (),
node: Name(
ExprName {
id: "match",
id: Identifier(
"match",
),
ctx: Load,
},
),
@ -598,7 +656,9 @@ expression: parse_ast
},
),
},
attr: "a",
attr: Identifier(
"a",
),
ctx: Load,
},
),
@ -626,7 +686,9 @@ expression: parse_ast
custom: (),
node: Name(
ExprName {
id: "match",
id: Identifier(
"match",
),
ctx: Load,
},
),
@ -636,7 +698,9 @@ expression: parse_ast
custom: (),
node: Name(
ExprName {
id: "a",
id: Identifier(
"a",
),
ctx: Load,
},
),
@ -645,7 +709,9 @@ expression: parse_ast
},
),
},
attr: "b",
attr: Identifier(
"b",
),
ctx: Load,
},
),
@ -673,7 +739,9 @@ expression: parse_ast
custom: (),
node: Name(
ExprName {
id: "match",
id: Identifier(
"match",
),
ctx: Load,
},
),
@ -689,7 +757,9 @@ expression: parse_ast
custom: (),
node: Name(
ExprName {
id: "a",
id: Identifier(
"a",
),
ctx: Load,
},
),
@ -703,7 +773,9 @@ expression: parse_ast
},
),
},
attr: "b",
attr: Identifier(
"b",
),
ctx: Load,
},
),
@ -731,7 +803,9 @@ expression: parse_ast
custom: (),
node: Name(
ExprName {
id: "match",
id: Identifier(
"match",
),
ctx: Load,
},
),
@ -747,7 +821,9 @@ expression: parse_ast
custom: (),
node: Name(
ExprName {
id: "a",
id: Identifier(
"a",
),
ctx: Load,
},
),
@ -761,7 +837,9 @@ expression: parse_ast
},
),
},
attr: "b",
attr: Identifier(
"b",
),
ctx: Load,
},
),
@ -789,7 +867,9 @@ expression: parse_ast
custom: (),
node: Name(
ExprName {
id: "match",
id: Identifier(
"match",
),
ctx: Load,
},
),
@ -810,7 +890,9 @@ expression: parse_ast
custom: (),
node: Name(
ExprName {
id: "a",
id: Identifier(
"a",
),
ctx: Load,
},
),
@ -822,7 +904,9 @@ expression: parse_ast
custom: (),
node: Name(
ExprName {
id: "b",
id: Identifier(
"b",
),
ctx: Load,
},
),
@ -854,7 +938,9 @@ expression: parse_ast
custom: (),
node: Name(
ExprName {
id: "match",
id: Identifier(
"match",
),
ctx: Store,
},
),
@ -895,7 +981,9 @@ expression: parse_ast
custom: (),
node: Name(
ExprName {
id: "match",
id: Identifier(
"match",
),
ctx: Load,
},
),
@ -976,7 +1064,9 @@ expression: parse_ast
custom: (),
node: Name(
ExprName {
id: "match",
id: Identifier(
"match",
),
ctx: Store,
},
),
@ -994,7 +1084,9 @@ expression: parse_ast
range: 597..602,
custom: (),
node: ArgData {
arg: "query",
arg: Identifier(
"query",
),
annotation: None,
type_comment: None,
},
@ -1016,7 +1108,9 @@ expression: parse_ast
custom: (),
node: Name(
ExprName {
id: "query",
id: Identifier(
"query",
),
ctx: Load,
},
),
@ -1030,7 +1124,9 @@ expression: parse_ast
custom: (),
node: Name(
ExprName {
id: "event",
id: Identifier(
"event",
),
ctx: Load,
},
),
@ -1061,7 +1157,9 @@ expression: parse_ast
custom: (),
node: Name(
ExprName {
id: "print",
id: Identifier(
"print",
),
ctx: Load,
},
),
@ -1077,7 +1175,9 @@ expression: parse_ast
custom: (),
node: Name(
ExprName {
id: "match",
id: Identifier(
"match",
),
ctx: Load,
},
),

View file

@ -14,7 +14,9 @@ Attributed {
custom: (),
node: Name(
ExprName {
id: "x",
id: Identifier(
"x",
),
ctx: Load,
},
),
@ -24,7 +26,9 @@ Attributed {
custom: (),
node: Name(
ExprName {
id: "y",
id: Identifier(
"y",
),
ctx: Load,
},
),

View file

@ -14,7 +14,9 @@ Attributed {
custom: (),
node: Name(
ExprName {
id: "x",
id: Identifier(
"x",
),
ctx: Load,
},
),
@ -24,7 +26,9 @@ Attributed {
custom: (),
node: Name(
ExprName {
id: "y",
id: Identifier(
"y",
),
ctx: Load,
},
),

View file

@ -8,14 +8,18 @@ expression: "parse_program(source, \"<test>\").unwrap()"
custom: (),
node: ClassDef(
StmtClassDef {
name: "Foo",
name: Identifier(
"Foo",
),
bases: [
Attributed {
range: 10..11,
custom: (),
node: Name(
ExprName {
id: "A",
id: Identifier(
"A",
),
ctx: Load,
},
),
@ -25,7 +29,9 @@ expression: "parse_program(source, \"<test>\").unwrap()"
custom: (),
node: Name(
ExprName {
id: "B",
id: Identifier(
"B",
),
ctx: Load,
},
),
@ -38,7 +44,9 @@ expression: "parse_program(source, \"<test>\").unwrap()"
custom: (),
node: FunctionDef(
StmtFunctionDef {
name: "__init__",
name: Identifier(
"__init__",
),
args: Arguments {
posonlyargs: [],
args: [
@ -46,7 +54,9 @@ expression: "parse_program(source, \"<test>\").unwrap()"
range: 31..35,
custom: (),
node: ArgData {
arg: "self",
arg: Identifier(
"self",
),
annotation: None,
type_comment: None,
},
@ -76,7 +86,9 @@ expression: "parse_program(source, \"<test>\").unwrap()"
custom: (),
node: FunctionDef(
StmtFunctionDef {
name: "method_with_default",
name: Identifier(
"method_with_default",
),
args: Arguments {
posonlyargs: [],
args: [
@ -84,7 +96,9 @@ expression: "parse_program(source, \"<test>\").unwrap()"
range: 70..74,
custom: (),
node: ArgData {
arg: "self",
arg: Identifier(
"self",
),
annotation: None,
type_comment: None,
},
@ -93,7 +107,9 @@ expression: "parse_program(source, \"<test>\").unwrap()"
range: 76..79,
custom: (),
node: ArgData {
arg: "arg",
arg: Identifier(
"arg",
),
annotation: None,
type_comment: None,
},

View file

@ -12,7 +12,9 @@ Attributed {
custom: (),
node: Name(
ExprName {
id: "x1",
id: Identifier(
"x1",
),
ctx: Load,
},
),
@ -22,7 +24,9 @@ Attributed {
custom: (),
node: Name(
ExprName {
id: "x2",
id: Identifier(
"x2",
),
ctx: Load,
},
),
@ -34,7 +38,9 @@ Attributed {
custom: (),
node: Name(
ExprName {
id: "y",
id: Identifier(
"y",
),
ctx: Store,
},
),
@ -44,13 +50,17 @@ Attributed {
custom: (),
node: Name(
ExprName {
id: "z",
id: Identifier(
"z",
),
ctx: Load,
},
),
},
ifs: [],
is_async: 0,
is_async: Int(
0,
),
},
],
},

View file

@ -12,7 +12,9 @@ Attributed {
custom: (),
node: Name(
ExprName {
id: "x",
id: Identifier(
"x",
),
ctx: Load,
},
),
@ -30,7 +32,9 @@ Attributed {
custom: (),
node: Name(
ExprName {
id: "y",
id: Identifier(
"y",
),
ctx: Store,
},
),
@ -40,7 +44,9 @@ Attributed {
custom: (),
node: Name(
ExprName {
id: "y2",
id: Identifier(
"y2",
),
ctx: Store,
},
),
@ -55,13 +61,17 @@ Attributed {
custom: (),
node: Name(
ExprName {
id: "z",
id: Identifier(
"z",
),
ctx: Load,
},
),
},
ifs: [],
is_async: 0,
is_async: Int(
0,
),
},
Comprehension {
target: Attributed {
@ -69,7 +79,9 @@ Attributed {
custom: (),
node: Name(
ExprName {
id: "a",
id: Identifier(
"a",
),
ctx: Store,
},
),
@ -79,7 +91,9 @@ Attributed {
custom: (),
node: Name(
ExprName {
id: "b",
id: Identifier(
"b",
),
ctx: Load,
},
),
@ -95,7 +109,9 @@ Attributed {
custom: (),
node: Name(
ExprName {
id: "a",
id: Identifier(
"a",
),
ctx: Load,
},
),
@ -130,7 +146,9 @@ Attributed {
custom: (),
node: Name(
ExprName {
id: "a",
id: Identifier(
"a",
),
ctx: Load,
},
),
@ -156,7 +174,9 @@ Attributed {
),
},
],
is_async: 0,
is_async: Int(
0,
),
},
],
},

View file

@ -12,7 +12,9 @@ Attributed {
custom: (),
node: Name(
ExprName {
id: "x",
id: Identifier(
"x",
),
ctx: Load,
},
),
@ -24,7 +26,9 @@ Attributed {
custom: (),
node: Name(
ExprName {
id: "y",
id: Identifier(
"y",
),
ctx: Store,
},
),
@ -34,13 +38,17 @@ Attributed {
custom: (),
node: Name(
ExprName {
id: "z",
id: Identifier(
"z",
),
ctx: Load,
},
),
},
ifs: [],
is_async: 0,
is_async: Int(
0,
),
},
],
},

View file

@ -17,7 +17,9 @@ Attributed {
custom: (),
node: Name(
ExprName {
id: "y",
id: Identifier(
"y",
),
ctx: Load,
},
),
@ -27,7 +29,9 @@ Attributed {
custom: (),
node: Name(
ExprName {
id: "x",
id: Identifier(
"x",
),
ctx: Load,
},
),
@ -37,7 +41,9 @@ Attributed {
custom: (),
node: Name(
ExprName {
id: "y",
id: Identifier(
"y",
),
ctx: Load,
},
),
@ -52,7 +58,9 @@ Attributed {
custom: (),
node: Name(
ExprName {
id: "y",
id: Identifier(
"y",
),
ctx: Store,
},
),
@ -62,13 +70,17 @@ Attributed {
custom: (),
node: Name(
ExprName {
id: "z",
id: Identifier(
"z",
),
ctx: Load,
},
),
},
ifs: [],
is_async: 0,
is_async: Int(
0,
),
},
],
},

View file

@ -18,7 +18,9 @@ expression: parse_ast
custom: (),
node: Name(
ExprName {
id: "my_func",
id: Identifier(
"my_func",
),
ctx: Load,
},
),
@ -43,7 +45,9 @@ expression: parse_ast
custom: (),
node: KeywordData {
arg: Some(
"keyword",
Identifier(
"keyword",
),
),
value: Attributed {
range: 30..31,

View file

@ -20,7 +20,9 @@ expression: parse_ast
range: 7..8,
custom: (),
node: ArgData {
arg: "x",
arg: Identifier(
"x",
),
annotation: None,
type_comment: None,
},
@ -29,7 +31,9 @@ expression: parse_ast
range: 10..11,
custom: (),
node: ArgData {
arg: "y",
arg: Identifier(
"y",
),
annotation: None,
type_comment: None,
},
@ -51,7 +55,9 @@ expression: parse_ast
custom: (),
node: Name(
ExprName {
id: "x",
id: Identifier(
"x",
),
ctx: Load,
},
),
@ -62,7 +68,9 @@ expression: parse_ast
custom: (),
node: Name(
ExprName {
id: "y",
id: Identifier(
"y",
),
ctx: Load,
},
),

View file

@ -12,7 +12,9 @@ Attributed {
custom: (),
node: Name(
ExprName {
id: "x",
id: Identifier(
"x",
),
ctx: Load,
},
),
@ -24,7 +26,9 @@ Attributed {
custom: (),
node: Name(
ExprName {
id: "y",
id: Identifier(
"y",
),
ctx: Store,
},
),
@ -34,13 +38,17 @@ Attributed {
custom: (),
node: Name(
ExprName {
id: "z",
id: Identifier(
"z",
),
ctx: Load,
},
),
},
ifs: [],
is_async: 0,
is_async: Int(
0,
),
},
],
},

View file

@ -17,7 +17,9 @@ Attributed {
custom: (),
node: Name(
ExprName {
id: "x",
id: Identifier(
"x",
),
ctx: Store,
},
),
@ -32,7 +34,9 @@ Attributed {
custom: (),
node: Name(
ExprName {
id: "y",
id: Identifier(
"y",
),
ctx: Load,
},
),
@ -63,7 +67,9 @@ Attributed {
custom: (),
node: Name(
ExprName {
id: "y",
id: Identifier(
"y",
),
ctx: Store,
},
),
@ -73,13 +79,17 @@ Attributed {
custom: (),
node: Name(
ExprName {
id: "z",
id: Identifier(
"z",
),
ctx: Load,
},
),
},
ifs: [],
is_async: 0,
is_async: Int(
0,
),
},
],
},

View file

@ -18,7 +18,9 @@ expression: parse_ast
custom: (),
node: Name(
ExprName {
id: "print",
id: Identifier(
"print",
),
ctx: Load,
},
),

View file

@ -18,7 +18,9 @@ expression: parse_ast
custom: (),
node: Name(
ExprName {
id: "print",
id: Identifier(
"print",
),
ctx: Load,
},
),

View file

@ -20,7 +20,9 @@ expression: "parse_program(source, \"<test>\").unwrap()"
custom: (),
node: Name(
ExprName {
id: "a",
id: Identifier(
"a",
),
ctx: Store,
},
),
@ -30,7 +32,9 @@ expression: "parse_program(source, \"<test>\").unwrap()"
custom: (),
node: Name(
ExprName {
id: "b",
id: Identifier(
"b",
),
ctx: Store,
},
),

File diff suppressed because it is too large Load diff

View file

@ -12,7 +12,9 @@ Attributed {
custom: (),
node: Name(
ExprName {
id: "x",
id: Identifier(
"x",
),
ctx: Load,
},
),

View file

@ -14,7 +14,9 @@ expression: parse_ast
custom: (),
node: Name(
ExprName {
id: "array_slice",
id: Identifier(
"array_slice",
),
ctx: Store,
},
),
@ -30,7 +32,9 @@ expression: parse_ast
custom: (),
node: Name(
ExprName {
id: "array",
id: Identifier(
"array",
),
ctx: Load,
},
),
@ -63,7 +67,9 @@ expression: parse_ast
custom: (),
node: Name(
ExprName {
id: "indexes",
id: Identifier(
"indexes",
),
ctx: Load,
},
),
@ -122,7 +128,9 @@ expression: parse_ast
custom: (),
node: Name(
ExprName {
id: "array",
id: Identifier(
"array",
),
ctx: Load,
},
),
@ -155,7 +163,9 @@ expression: parse_ast
custom: (),
node: Name(
ExprName {
id: "indexes",
id: Identifier(
"indexes",
),
ctx: Load,
},
),
@ -200,7 +210,9 @@ expression: parse_ast
custom: (),
node: Name(
ExprName {
id: "array_slice",
id: Identifier(
"array_slice",
),
ctx: Load,
},
),
@ -224,7 +236,9 @@ expression: parse_ast
custom: (),
node: Name(
ExprName {
id: "array",
id: Identifier(
"array",
),
ctx: Load,
},
),
@ -245,7 +259,9 @@ expression: parse_ast
custom: (),
node: Name(
ExprName {
id: "indexes_to_select",
id: Identifier(
"indexes_to_select",
),
ctx: Load,
},
),
@ -264,7 +280,9 @@ expression: parse_ast
custom: (),
node: Name(
ExprName {
id: "indexes_to_select",
id: Identifier(
"indexes_to_select",
),
ctx: Load,
},
),
@ -300,7 +318,9 @@ expression: parse_ast
custom: (),
node: Name(
ExprName {
id: "array",
id: Identifier(
"array",
),
ctx: Load,
},
),
@ -358,7 +378,9 @@ expression: parse_ast
custom: (),
node: Name(
ExprName {
id: "indexes_to_select",
id: Identifier(
"indexes_to_select",
),
ctx: Load,
},
),

View file

@ -25,7 +25,9 @@ expression: parse_ast
custom: (),
node: Name(
ExprName {
id: "ValueError",
id: Identifier(
"ValueError",
),
ctx: Load,
},
),
@ -66,14 +68,18 @@ expression: parse_ast
custom: (),
node: Name(
ExprName {
id: "TypeError",
id: Identifier(
"TypeError",
),
ctx: Load,
},
),
},
),
name: Some(
"e",
Identifier(
"e",
),
),
body: [
Attributed {
@ -91,7 +97,9 @@ expression: parse_ast
custom: (),
node: Name(
ExprName {
id: "print",
id: Identifier(
"print",
),
ctx: Load,
},
),
@ -130,7 +138,9 @@ expression: parse_ast
custom: (),
node: Name(
ExprName {
id: "type",
id: Identifier(
"type",
),
ctx: Load,
},
),
@ -141,7 +151,9 @@ expression: parse_ast
custom: (),
node: Name(
ExprName {
id: "e",
id: Identifier(
"e",
),
ctx: Load,
},
),
@ -151,7 +163,9 @@ expression: parse_ast
},
),
},
conversion: 0,
conversion: Int(
0,
),
format_spec: None,
},
),
@ -183,14 +197,18 @@ expression: parse_ast
custom: (),
node: Name(
ExprName {
id: "OSError",
id: Identifier(
"OSError",
),
ctx: Load,
},
),
},
),
name: Some(
"e",
Identifier(
"e",
),
),
body: [
Attributed {
@ -208,7 +226,9 @@ expression: parse_ast
custom: (),
node: Name(
ExprName {
id: "print",
id: Identifier(
"print",
),
ctx: Load,
},
),
@ -247,7 +267,9 @@ expression: parse_ast
custom: (),
node: Name(
ExprName {
id: "type",
id: Identifier(
"type",
),
ctx: Load,
},
),
@ -258,7 +280,9 @@ expression: parse_ast
custom: (),
node: Name(
ExprName {
id: "e",
id: Identifier(
"e",
),
ctx: Load,
},
),
@ -268,7 +292,9 @@ expression: parse_ast
},
),
},
conversion: 0,
conversion: Int(
0,
),
format_spec: None,
},
),

View file

@ -25,7 +25,9 @@ expression: parse_ast
custom: (),
node: Name(
ExprName {
id: "ExceptionGroup",
id: Identifier(
"ExceptionGroup",
),
ctx: Load,
},
),
@ -59,7 +61,9 @@ expression: parse_ast
custom: (),
node: Name(
ExprName {
id: "ValueError",
id: Identifier(
"ValueError",
),
ctx: Load,
},
),
@ -92,7 +96,9 @@ expression: parse_ast
custom: (),
node: Name(
ExprName {
id: "TypeError",
id: Identifier(
"TypeError",
),
ctx: Load,
},
),
@ -125,7 +131,9 @@ expression: parse_ast
custom: (),
node: Name(
ExprName {
id: "OSError",
id: Identifier(
"OSError",
),
ctx: Load,
},
),
@ -158,7 +166,9 @@ expression: parse_ast
custom: (),
node: Name(
ExprName {
id: "OSError",
id: Identifier(
"OSError",
),
ctx: Load,
},
),
@ -209,14 +219,18 @@ expression: parse_ast
custom: (),
node: Name(
ExprName {
id: "TypeError",
id: Identifier(
"TypeError",
),
ctx: Load,
},
),
},
),
name: Some(
"e",
Identifier(
"e",
),
),
body: [
Attributed {
@ -234,7 +248,9 @@ expression: parse_ast
custom: (),
node: Name(
ExprName {
id: "print",
id: Identifier(
"print",
),
ctx: Load,
},
),
@ -273,7 +289,9 @@ expression: parse_ast
custom: (),
node: Name(
ExprName {
id: "type",
id: Identifier(
"type",
),
ctx: Load,
},
),
@ -284,7 +302,9 @@ expression: parse_ast
custom: (),
node: Name(
ExprName {
id: "e",
id: Identifier(
"e",
),
ctx: Load,
},
),
@ -294,7 +314,9 @@ expression: parse_ast
},
),
},
conversion: 0,
conversion: Int(
0,
),
format_spec: None,
},
),
@ -326,17 +348,23 @@ expression: parse_ast
custom: (),
node: Name(
ExprName {
id: "e",
id: Identifier(
"e",
),
ctx: Load,
},
),
},
attr: "exceptions",
attr: Identifier(
"exceptions",
),
ctx: Load,
},
),
},
conversion: 0,
conversion: Int(
0,
),
format_spec: None,
},
),
@ -368,14 +396,18 @@ expression: parse_ast
custom: (),
node: Name(
ExprName {
id: "OSError",
id: Identifier(
"OSError",
),
ctx: Load,
},
),
},
),
name: Some(
"e",
Identifier(
"e",
),
),
body: [
Attributed {
@ -393,7 +425,9 @@ expression: parse_ast
custom: (),
node: Name(
ExprName {
id: "print",
id: Identifier(
"print",
),
ctx: Load,
},
),
@ -432,7 +466,9 @@ expression: parse_ast
custom: (),
node: Name(
ExprName {
id: "type",
id: Identifier(
"type",
),
ctx: Load,
},
),
@ -443,7 +479,9 @@ expression: parse_ast
custom: (),
node: Name(
ExprName {
id: "e",
id: Identifier(
"e",
),
ctx: Load,
},
),
@ -453,7 +491,9 @@ expression: parse_ast
},
),
},
conversion: 0,
conversion: Int(
0,
),
format_spec: None,
},
),
@ -485,17 +525,23 @@ expression: parse_ast
custom: (),
node: Name(
ExprName {
id: "e",
id: Identifier(
"e",
),
ctx: Load,
},
),
},
attr: "exceptions",
attr: Identifier(
"exceptions",
),
ctx: Load,
},
),
},
conversion: 0,
conversion: Int(
0,
),
format_spec: None,
},
),

View file

@ -8,7 +8,9 @@ expression: parse_ast
custom: (),
node: FunctionDef(
StmtFunctionDef {
name: "args_to_tuple",
name: Identifier(
"args_to_tuple",
),
args: Arguments {
posonlyargs: [],
args: [],
@ -17,7 +19,9 @@ expression: parse_ast
range: 20..29,
custom: (),
node: ArgData {
arg: "args",
arg: Identifier(
"args",
),
annotation: Some(
Attributed {
range: 26..29,
@ -29,7 +33,9 @@ expression: parse_ast
custom: (),
node: Name(
ExprName {
id: "Ts",
id: Identifier(
"Ts",
),
ctx: Load,
},
),
@ -80,7 +86,9 @@ expression: parse_ast
custom: (),
node: Name(
ExprName {
id: "Tuple",
id: Identifier(
"Tuple",
),
ctx: Load,
},
),
@ -95,7 +103,9 @@ expression: parse_ast
custom: (),
node: Name(
ExprName {
id: "Ts",
id: Identifier(
"Ts",
),
ctx: Load,
},
),

View file

@ -61,7 +61,9 @@ expression: "parse_program(source, \"<test>\").unwrap()"
custom: (),
node: Name(
ExprName {
id: "x",
id: Identifier(
"x",
),
ctx: Store,
},
),
@ -153,7 +155,9 @@ expression: "parse_program(source, \"<test>\").unwrap()"
custom: (),
node: Name(
ExprName {
id: "x",
id: Identifier(
"x",
),
ctx: Store,
},
),
@ -179,7 +183,9 @@ expression: "parse_program(source, \"<test>\").unwrap()"
custom: (),
node: Name(
ExprName {
id: "y",
id: Identifier(
"y",
),
ctx: Store,
},
),
@ -320,7 +326,9 @@ expression: "parse_program(source, \"<test>\").unwrap()"
custom: (),
node: Name(
ExprName {
id: "x",
id: Identifier(
"x",
),
ctx: Store,
},
),
@ -393,7 +401,9 @@ expression: "parse_program(source, \"<test>\").unwrap()"
custom: (),
node: Name(
ExprName {
id: "x",
id: Identifier(
"x",
),
ctx: Store,
},
),
@ -470,7 +480,9 @@ expression: "parse_program(source, \"<test>\").unwrap()"
custom: (),
node: Name(
ExprName {
id: "x",
id: Identifier(
"x",
),
ctx: Store,
},
),
@ -558,7 +570,9 @@ expression: "parse_program(source, \"<test>\").unwrap()"
custom: (),
node: Name(
ExprName {
id: "x",
id: Identifier(
"x",
),
ctx: Store,
},
),
@ -673,7 +687,9 @@ expression: "parse_program(source, \"<test>\").unwrap()"
custom: (),
node: Name(
ExprName {
id: "x",
id: Identifier(
"x",
),
ctx: Store,
},
),
@ -715,7 +731,9 @@ expression: "parse_program(source, \"<test>\").unwrap()"
custom: (),
node: Name(
ExprName {
id: "a",
id: Identifier(
"a",
),
ctx: Load,
},
),
@ -766,7 +784,9 @@ expression: "parse_program(source, \"<test>\").unwrap()"
custom: (),
node: Name(
ExprName {
id: "a",
id: Identifier(
"a",
),
ctx: Load,
},
),
@ -786,7 +806,9 @@ expression: "parse_program(source, \"<test>\").unwrap()"
custom: (),
node: Name(
ExprName {
id: "x",
id: Identifier(
"x",
),
ctx: Store,
},
),
@ -840,7 +862,9 @@ expression: "parse_program(source, \"<test>\").unwrap()"
custom: (),
node: Name(
ExprName {
id: "a",
id: Identifier(
"a",
),
ctx: Load,
},
),
@ -903,7 +927,9 @@ expression: "parse_program(source, \"<test>\").unwrap()"
custom: (),
node: Name(
ExprName {
id: "a",
id: Identifier(
"a",
),
ctx: Load,
},
),
@ -923,7 +949,9 @@ expression: "parse_program(source, \"<test>\").unwrap()"
custom: (),
node: Name(
ExprName {
id: "x",
id: Identifier(
"x",
),
ctx: Store,
},
),
@ -959,7 +987,9 @@ expression: "parse_program(source, \"<test>\").unwrap()"
custom: (),
node: Name(
ExprName {
id: "a",
id: Identifier(
"a",
),
ctx: Store,
},
),
@ -1010,7 +1040,9 @@ expression: "parse_program(source, \"<test>\").unwrap()"
custom: (),
node: Name(
ExprName {
id: "a",
id: Identifier(
"a",
),
ctx: Store,
},
),
@ -1036,7 +1068,9 @@ expression: "parse_program(source, \"<test>\").unwrap()"
custom: (),
node: Name(
ExprName {
id: "x",
id: Identifier(
"x",
),
ctx: Store,
},
),
@ -1078,7 +1112,9 @@ expression: "parse_program(source, \"<test>\").unwrap()"
custom: (),
node: Name(
ExprName {
id: "a",
id: Identifier(
"a",
),
ctx: Store,
},
),
@ -1108,7 +1144,9 @@ expression: "parse_program(source, \"<test>\").unwrap()"
custom: (),
node: Name(
ExprName {
id: "b",
id: Identifier(
"b",
),
ctx: Store,
},
),
@ -1170,7 +1208,9 @@ expression: "parse_program(source, \"<test>\").unwrap()"
custom: (),
node: Name(
ExprName {
id: "a",
id: Identifier(
"a",
),
ctx: Store,
},
),
@ -1200,7 +1240,9 @@ expression: "parse_program(source, \"<test>\").unwrap()"
custom: (),
node: Name(
ExprName {
id: "b",
id: Identifier(
"b",
),
ctx: Store,
},
),
@ -1231,7 +1273,9 @@ expression: "parse_program(source, \"<test>\").unwrap()"
custom: (),
node: Name(
ExprName {
id: "x",
id: Identifier(
"x",
),
ctx: Store,
},
),
@ -1275,7 +1319,9 @@ expression: "parse_program(source, \"<test>\").unwrap()"
custom: (),
node: Name(
ExprName {
id: "a",
id: Identifier(
"a",
),
ctx: Store,
},
),
@ -1319,7 +1365,9 @@ expression: "parse_program(source, \"<test>\").unwrap()"
custom: (),
node: Name(
ExprName {
id: "a",
id: Identifier(
"a",
),
ctx: Store,
},
),
@ -1363,7 +1411,9 @@ expression: "parse_program(source, \"<test>\").unwrap()"
custom: (),
node: Name(
ExprName {
id: "a",
id: Identifier(
"a",
),
ctx: Store,
},
),
@ -1389,7 +1439,9 @@ expression: "parse_program(source, \"<test>\").unwrap()"
custom: (),
node: Name(
ExprName {
id: "b",
id: Identifier(
"b",
),
ctx: Store,
},
),
@ -1433,7 +1485,9 @@ expression: "parse_program(source, \"<test>\").unwrap()"
custom: (),
node: Name(
ExprName {
id: "a",
id: Identifier(
"a",
),
ctx: Store,
},
),
@ -1459,7 +1513,9 @@ expression: "parse_program(source, \"<test>\").unwrap()"
custom: (),
node: Name(
ExprName {
id: "b",
id: Identifier(
"b",
),
ctx: Store,
},
),

View file

@ -36,12 +36,16 @@ expression: parse_ast
custom: (),
node: Name(
ExprName {
id: "x",
id: Identifier(
"x",
),
ctx: Load,
},
),
},
conversion: 0,
conversion: Int(
0,
),
format_spec: None,
},
),

View file

@ -36,12 +36,16 @@ expression: parse_ast
custom: (),
node: Name(
ExprName {
id: "x",
id: Identifier(
"x",
),
ctx: Load,
},
),
},
conversion: 0,
conversion: Int(
0,
),
format_spec: None,
},
),

View file

@ -36,12 +36,16 @@ expression: parse_ast
custom: (),
node: Name(
ExprName {
id: "x",
id: Identifier(
"x",
),
ctx: Load,
},
),
},
conversion: 0,
conversion: Int(
0,
),
format_spec: None,
},
),

View file

@ -37,12 +37,16 @@ expression: parse_ast
custom: (),
node: Name(
ExprName {
id: "user",
id: Identifier(
"user",
),
ctx: Load,
},
),
},
conversion: 114,
conversion: Int(
114,
),
format_spec: None,
},
),

View file

@ -49,12 +49,16 @@ expression: parse_ast
custom: (),
node: Name(
ExprName {
id: "user",
id: Identifier(
"user",
),
ctx: Load,
},
),
},
conversion: 114,
conversion: Int(
114,
),
format_spec: None,
},
),
@ -105,12 +109,16 @@ expression: parse_ast
custom: (),
node: Name(
ExprName {
id: "second",
id: Identifier(
"second",
),
ctx: Load,
},
),
},
conversion: 114,
conversion: Int(
114,
),
format_spec: None,
},
),

View file

@ -37,12 +37,16 @@ expression: parse_ast
custom: (),
node: Name(
ExprName {
id: "user",
id: Identifier(
"user",
),
ctx: Load,
},
),
},
conversion: 0,
conversion: Int(
0,
),
format_spec: Some(
Attributed {
range: 0..14,

View file

@ -36,12 +36,16 @@ expression: parse_ast
custom: (),
node: Name(
ExprName {
id: "x",
id: Identifier(
"x",
),
ctx: Load,
},
),
},
conversion: 0,
conversion: Int(
0,
),
format_spec: None,
},
),

View file

@ -43,7 +43,9 @@ expression: parse_ast
},
),
},
conversion: 0,
conversion: Int(
0,
),
format_spec: None,
},
),

View file

@ -13,12 +13,16 @@ expression: parse_ast
custom: (),
node: Name(
ExprName {
id: "a",
id: Identifier(
"a",
),
ctx: Load,
},
),
},
conversion: 0,
conversion: Int(
0,
),
format_spec: None,
},
),
@ -33,12 +37,16 @@ expression: parse_ast
custom: (),
node: Name(
ExprName {
id: "b",
id: Identifier(
"b",
),
ctx: Load,
},
),
},
conversion: 0,
conversion: Int(
0,
),
format_spec: None,
},
),

View file

@ -45,7 +45,9 @@ expression: parse_ast
},
),
},
conversion: 0,
conversion: Int(
0,
),
format_spec: None,
},
),

View file

@ -13,12 +13,16 @@ expression: parse_ast
custom: (),
node: Name(
ExprName {
id: "foo",
id: Identifier(
"foo",
),
ctx: Load,
},
),
},
conversion: 0,
conversion: Int(
0,
),
format_spec: Some(
Attributed {
range: 0..15,
@ -36,12 +40,16 @@ expression: parse_ast
custom: (),
node: Name(
ExprName {
id: "spec",
id: Identifier(
"spec",
),
ctx: Load,
},
),
},
conversion: 0,
conversion: Int(
0,
),
format_spec: None,
},
),

View file

@ -45,7 +45,9 @@ expression: parse_ast
},
),
},
conversion: 0,
conversion: Int(
0,
),
format_spec: None,
},
),

View file

@ -13,12 +13,16 @@ expression: parse_ast
custom: (),
node: Name(
ExprName {
id: "foo",
id: Identifier(
"foo",
),
ctx: Load,
},
),
},
conversion: 0,
conversion: Int(
0,
),
format_spec: Some(
Attributed {
range: 0..13,

View file

@ -37,12 +37,16 @@ expression: parse_ast
custom: (),
node: Name(
ExprName {
id: "x",
id: Identifier(
"x",
),
ctx: Load,
},
),
},
conversion: 114,
conversion: Int(
114,
),
format_spec: None,
},
),

View file

@ -37,12 +37,16 @@ expression: parse_ast
custom: (),
node: Name(
ExprName {
id: "x",
id: Identifier(
"x",
),
ctx: Load,
},
),
},
conversion: 114,
conversion: Int(
114,
),
format_spec: None,
},
),

View file

@ -17,7 +17,9 @@ expression: parse_ast
},
),
},
conversion: 0,
conversion: Int(
0,
),
format_spec: None,
},
),

View file

@ -24,12 +24,16 @@ expression: parse_ast
custom: (),
node: Name(
ExprName {
id: "x",
id: Identifier(
"x",
),
ctx: Load,
},
),
},
conversion: 0,
conversion: Int(
0,
),
format_spec: None,
},
),

View file

@ -24,12 +24,16 @@ expression: parse_ast
custom: (),
node: Name(
ExprName {
id: "x",
id: Identifier(
"x",
),
ctx: Load,
},
),
},
conversion: 0,
conversion: Int(
0,
),
format_spec: None,
},
),

View file

@ -4,7 +4,7 @@
// regular strings. Since the parser has no definition of f-string formats (Pending PEP 701)
// we have to do the parsing here, manually.
use crate::{
ast::{self, Constant, Expr, ExprKind},
ast::{self, Constant, Expr, ExprKind, Int},
lexer::{LexicalError, LexicalErrorType},
parser::{parse_expression_at, LalrpopError, ParseError, ParseErrorType},
token::{StringKind, Tok},
@ -314,7 +314,7 @@ impl<'a> StringParser<'a> {
)
})?,
),
conversion: conversion as _,
conversion: Int::new(conversion as _),
format_spec: spec,
}
.into(),
@ -345,13 +345,13 @@ impl<'a> StringParser<'a> {
)
})?,
),
conversion: (if conversion == ConversionFlag::None
&& spec.is_none()
{
ConversionFlag::Repr
} else {
conversion
}) as _,
conversion: ast::Int::new(
(if conversion == ConversionFlag::None && spec.is_none() {
ConversionFlag::Repr
} else {
conversion
}) as _,
),
format_spec: spec,
}
.into(),