mirror of
https://github.com/RustPython/Parser.git
synced 2025-07-07 13:15:21 +00:00
Rename unconventional nodes (#74)
This commit is contained in:
parent
5270020423
commit
69d27d924c
19 changed files with 2407 additions and 2302 deletions
|
@ -520,7 +520,7 @@ impl PyNode for ast::ExprContextDel {
|
|||
}
|
||||
}
|
||||
|
||||
impl PyNode for ast::Boolop {
|
||||
impl PyNode for ast::BoolOp {
|
||||
#[inline]
|
||||
fn py_type_cache() -> &'static OnceCell<(Py<PyAny>, Py<PyAny>)> {
|
||||
static PY_TYPE: OnceCell<(Py<PyAny>, Py<PyAny>)> = OnceCell::new();
|
||||
|
@ -528,7 +528,7 @@ impl PyNode for ast::Boolop {
|
|||
}
|
||||
}
|
||||
|
||||
impl PyNode for ast::BoolopAnd {
|
||||
impl PyNode for ast::BoolOpAnd {
|
||||
#[inline]
|
||||
fn py_type_cache() -> &'static OnceCell<(Py<PyAny>, Py<PyAny>)> {
|
||||
static PY_TYPE: OnceCell<(Py<PyAny>, Py<PyAny>)> = OnceCell::new();
|
||||
|
@ -536,7 +536,7 @@ impl PyNode for ast::BoolopAnd {
|
|||
}
|
||||
}
|
||||
|
||||
impl PyNode for ast::BoolopOr {
|
||||
impl PyNode for ast::BoolOpOr {
|
||||
#[inline]
|
||||
fn py_type_cache() -> &'static OnceCell<(Py<PyAny>, Py<PyAny>)> {
|
||||
static PY_TYPE: OnceCell<(Py<PyAny>, Py<PyAny>)> = OnceCell::new();
|
||||
|
@ -656,7 +656,7 @@ impl PyNode for ast::OperatorFloorDiv {
|
|||
}
|
||||
}
|
||||
|
||||
impl PyNode for ast::Unaryop {
|
||||
impl PyNode for ast::UnaryOp {
|
||||
#[inline]
|
||||
fn py_type_cache() -> &'static OnceCell<(Py<PyAny>, Py<PyAny>)> {
|
||||
static PY_TYPE: OnceCell<(Py<PyAny>, Py<PyAny>)> = OnceCell::new();
|
||||
|
@ -664,7 +664,7 @@ impl PyNode for ast::Unaryop {
|
|||
}
|
||||
}
|
||||
|
||||
impl PyNode for ast::UnaryopInvert {
|
||||
impl PyNode for ast::UnaryOpInvert {
|
||||
#[inline]
|
||||
fn py_type_cache() -> &'static OnceCell<(Py<PyAny>, Py<PyAny>)> {
|
||||
static PY_TYPE: OnceCell<(Py<PyAny>, Py<PyAny>)> = OnceCell::new();
|
||||
|
@ -672,7 +672,7 @@ impl PyNode for ast::UnaryopInvert {
|
|||
}
|
||||
}
|
||||
|
||||
impl PyNode for ast::UnaryopNot {
|
||||
impl PyNode for ast::UnaryOpNot {
|
||||
#[inline]
|
||||
fn py_type_cache() -> &'static OnceCell<(Py<PyAny>, Py<PyAny>)> {
|
||||
static PY_TYPE: OnceCell<(Py<PyAny>, Py<PyAny>)> = OnceCell::new();
|
||||
|
@ -680,7 +680,7 @@ impl PyNode for ast::UnaryopNot {
|
|||
}
|
||||
}
|
||||
|
||||
impl PyNode for ast::UnaryopUAdd {
|
||||
impl PyNode for ast::UnaryOpUAdd {
|
||||
#[inline]
|
||||
fn py_type_cache() -> &'static OnceCell<(Py<PyAny>, Py<PyAny>)> {
|
||||
static PY_TYPE: OnceCell<(Py<PyAny>, Py<PyAny>)> = OnceCell::new();
|
||||
|
@ -688,7 +688,7 @@ impl PyNode for ast::UnaryopUAdd {
|
|||
}
|
||||
}
|
||||
|
||||
impl PyNode for ast::UnaryopUSub {
|
||||
impl PyNode for ast::UnaryOpUSub {
|
||||
#[inline]
|
||||
fn py_type_cache() -> &'static OnceCell<(Py<PyAny>, Py<PyAny>)> {
|
||||
static PY_TYPE: OnceCell<(Py<PyAny>, Py<PyAny>)> = OnceCell::new();
|
||||
|
@ -696,7 +696,7 @@ impl PyNode for ast::UnaryopUSub {
|
|||
}
|
||||
}
|
||||
|
||||
impl PyNode for ast::Cmpop {
|
||||
impl PyNode for ast::CmpOp {
|
||||
#[inline]
|
||||
fn py_type_cache() -> &'static OnceCell<(Py<PyAny>, Py<PyAny>)> {
|
||||
static PY_TYPE: OnceCell<(Py<PyAny>, Py<PyAny>)> = OnceCell::new();
|
||||
|
@ -704,7 +704,7 @@ impl PyNode for ast::Cmpop {
|
|||
}
|
||||
}
|
||||
|
||||
impl PyNode for ast::CmpopEq {
|
||||
impl PyNode for ast::CmpOpEq {
|
||||
#[inline]
|
||||
fn py_type_cache() -> &'static OnceCell<(Py<PyAny>, Py<PyAny>)> {
|
||||
static PY_TYPE: OnceCell<(Py<PyAny>, Py<PyAny>)> = OnceCell::new();
|
||||
|
@ -712,7 +712,7 @@ impl PyNode for ast::CmpopEq {
|
|||
}
|
||||
}
|
||||
|
||||
impl PyNode for ast::CmpopNotEq {
|
||||
impl PyNode for ast::CmpOpNotEq {
|
||||
#[inline]
|
||||
fn py_type_cache() -> &'static OnceCell<(Py<PyAny>, Py<PyAny>)> {
|
||||
static PY_TYPE: OnceCell<(Py<PyAny>, Py<PyAny>)> = OnceCell::new();
|
||||
|
@ -720,7 +720,7 @@ impl PyNode for ast::CmpopNotEq {
|
|||
}
|
||||
}
|
||||
|
||||
impl PyNode for ast::CmpopLt {
|
||||
impl PyNode for ast::CmpOpLt {
|
||||
#[inline]
|
||||
fn py_type_cache() -> &'static OnceCell<(Py<PyAny>, Py<PyAny>)> {
|
||||
static PY_TYPE: OnceCell<(Py<PyAny>, Py<PyAny>)> = OnceCell::new();
|
||||
|
@ -728,7 +728,7 @@ impl PyNode for ast::CmpopLt {
|
|||
}
|
||||
}
|
||||
|
||||
impl PyNode for ast::CmpopLtE {
|
||||
impl PyNode for ast::CmpOpLtE {
|
||||
#[inline]
|
||||
fn py_type_cache() -> &'static OnceCell<(Py<PyAny>, Py<PyAny>)> {
|
||||
static PY_TYPE: OnceCell<(Py<PyAny>, Py<PyAny>)> = OnceCell::new();
|
||||
|
@ -736,7 +736,7 @@ impl PyNode for ast::CmpopLtE {
|
|||
}
|
||||
}
|
||||
|
||||
impl PyNode for ast::CmpopGt {
|
||||
impl PyNode for ast::CmpOpGt {
|
||||
#[inline]
|
||||
fn py_type_cache() -> &'static OnceCell<(Py<PyAny>, Py<PyAny>)> {
|
||||
static PY_TYPE: OnceCell<(Py<PyAny>, Py<PyAny>)> = OnceCell::new();
|
||||
|
@ -744,7 +744,7 @@ impl PyNode for ast::CmpopGt {
|
|||
}
|
||||
}
|
||||
|
||||
impl PyNode for ast::CmpopGtE {
|
||||
impl PyNode for ast::CmpOpGtE {
|
||||
#[inline]
|
||||
fn py_type_cache() -> &'static OnceCell<(Py<PyAny>, Py<PyAny>)> {
|
||||
static PY_TYPE: OnceCell<(Py<PyAny>, Py<PyAny>)> = OnceCell::new();
|
||||
|
@ -752,7 +752,7 @@ impl PyNode for ast::CmpopGtE {
|
|||
}
|
||||
}
|
||||
|
||||
impl PyNode for ast::CmpopIs {
|
||||
impl PyNode for ast::CmpOpIs {
|
||||
#[inline]
|
||||
fn py_type_cache() -> &'static OnceCell<(Py<PyAny>, Py<PyAny>)> {
|
||||
static PY_TYPE: OnceCell<(Py<PyAny>, Py<PyAny>)> = OnceCell::new();
|
||||
|
@ -760,7 +760,7 @@ impl PyNode for ast::CmpopIs {
|
|||
}
|
||||
}
|
||||
|
||||
impl PyNode for ast::CmpopIsNot {
|
||||
impl PyNode for ast::CmpOpIsNot {
|
||||
#[inline]
|
||||
fn py_type_cache() -> &'static OnceCell<(Py<PyAny>, Py<PyAny>)> {
|
||||
static PY_TYPE: OnceCell<(Py<PyAny>, Py<PyAny>)> = OnceCell::new();
|
||||
|
@ -768,7 +768,7 @@ impl PyNode for ast::CmpopIsNot {
|
|||
}
|
||||
}
|
||||
|
||||
impl PyNode for ast::CmpopIn {
|
||||
impl PyNode for ast::CmpOpIn {
|
||||
#[inline]
|
||||
fn py_type_cache() -> &'static OnceCell<(Py<PyAny>, Py<PyAny>)> {
|
||||
static PY_TYPE: OnceCell<(Py<PyAny>, Py<PyAny>)> = OnceCell::new();
|
||||
|
@ -776,7 +776,7 @@ impl PyNode for ast::CmpopIn {
|
|||
}
|
||||
}
|
||||
|
||||
impl PyNode for ast::CmpopNotIn {
|
||||
impl PyNode for ast::CmpOpNotIn {
|
||||
#[inline]
|
||||
fn py_type_cache() -> &'static OnceCell<(Py<PyAny>, Py<PyAny>)> {
|
||||
static PY_TYPE: OnceCell<(Py<PyAny>, Py<PyAny>)> = OnceCell::new();
|
||||
|
@ -792,7 +792,7 @@ impl<R> PyNode for ast::Comprehension<R> {
|
|||
}
|
||||
}
|
||||
|
||||
impl<R> PyNode for ast::Excepthandler<R> {
|
||||
impl<R> PyNode for ast::ExceptHandler<R> {
|
||||
#[inline]
|
||||
fn py_type_cache() -> &'static OnceCell<(Py<PyAny>, Py<PyAny>)> {
|
||||
static PY_TYPE: OnceCell<(Py<PyAny>, Py<PyAny>)> = OnceCell::new();
|
||||
|
@ -800,7 +800,7 @@ impl<R> PyNode for ast::Excepthandler<R> {
|
|||
}
|
||||
}
|
||||
|
||||
impl<R> PyNode for ast::ExcepthandlerExceptHandler<R> {
|
||||
impl<R> PyNode for ast::ExceptHandlerExceptHandler<R> {
|
||||
#[inline]
|
||||
fn py_type_cache() -> &'static OnceCell<(Py<PyAny>, Py<PyAny>)> {
|
||||
static PY_TYPE: OnceCell<(Py<PyAny>, Py<PyAny>)> = OnceCell::new();
|
||||
|
@ -840,7 +840,7 @@ impl<R> PyNode for ast::Alias<R> {
|
|||
}
|
||||
}
|
||||
|
||||
impl<R> PyNode for ast::Withitem<R> {
|
||||
impl<R> PyNode for ast::WithItem<R> {
|
||||
#[inline]
|
||||
fn py_type_cache() -> &'static OnceCell<(Py<PyAny>, Py<PyAny>)> {
|
||||
static PY_TYPE: OnceCell<(Py<PyAny>, Py<PyAny>)> = OnceCell::new();
|
||||
|
@ -956,12 +956,12 @@ impl ToPyAst for ast::ExprContext {
|
|||
}
|
||||
}
|
||||
|
||||
impl ToPyAst for ast::Boolop {
|
||||
impl ToPyAst for ast::BoolOp {
|
||||
#[inline]
|
||||
fn to_py_ast<'py>(&self, py: Python<'py>) -> PyResult<&'py PyAny> {
|
||||
let cell = match &self {
|
||||
ast::Boolop::And => ast::BoolopAnd::py_type_cache(),
|
||||
ast::Boolop::Or => ast::BoolopOr::py_type_cache(),
|
||||
ast::BoolOp::And => ast::BoolOpAnd::py_type_cache(),
|
||||
ast::BoolOp::Or => ast::BoolOpOr::py_type_cache(),
|
||||
};
|
||||
Ok(Py::<PyAny>::as_ref(&cell.get().unwrap().1, py))
|
||||
}
|
||||
|
@ -989,33 +989,33 @@ impl ToPyAst for ast::Operator {
|
|||
}
|
||||
}
|
||||
|
||||
impl ToPyAst for ast::Unaryop {
|
||||
impl ToPyAst for ast::UnaryOp {
|
||||
#[inline]
|
||||
fn to_py_ast<'py>(&self, py: Python<'py>) -> PyResult<&'py PyAny> {
|
||||
let cell = match &self {
|
||||
ast::Unaryop::Invert => ast::UnaryopInvert::py_type_cache(),
|
||||
ast::Unaryop::Not => ast::UnaryopNot::py_type_cache(),
|
||||
ast::Unaryop::UAdd => ast::UnaryopUAdd::py_type_cache(),
|
||||
ast::Unaryop::USub => ast::UnaryopUSub::py_type_cache(),
|
||||
ast::UnaryOp::Invert => ast::UnaryOpInvert::py_type_cache(),
|
||||
ast::UnaryOp::Not => ast::UnaryOpNot::py_type_cache(),
|
||||
ast::UnaryOp::UAdd => ast::UnaryOpUAdd::py_type_cache(),
|
||||
ast::UnaryOp::USub => ast::UnaryOpUSub::py_type_cache(),
|
||||
};
|
||||
Ok(Py::<PyAny>::as_ref(&cell.get().unwrap().1, py))
|
||||
}
|
||||
}
|
||||
|
||||
impl ToPyAst for ast::Cmpop {
|
||||
impl ToPyAst for ast::CmpOp {
|
||||
#[inline]
|
||||
fn to_py_ast<'py>(&self, py: Python<'py>) -> PyResult<&'py PyAny> {
|
||||
let cell = match &self {
|
||||
ast::Cmpop::Eq => ast::CmpopEq::py_type_cache(),
|
||||
ast::Cmpop::NotEq => ast::CmpopNotEq::py_type_cache(),
|
||||
ast::Cmpop::Lt => ast::CmpopLt::py_type_cache(),
|
||||
ast::Cmpop::LtE => ast::CmpopLtE::py_type_cache(),
|
||||
ast::Cmpop::Gt => ast::CmpopGt::py_type_cache(),
|
||||
ast::Cmpop::GtE => ast::CmpopGtE::py_type_cache(),
|
||||
ast::Cmpop::Is => ast::CmpopIs::py_type_cache(),
|
||||
ast::Cmpop::IsNot => ast::CmpopIsNot::py_type_cache(),
|
||||
ast::Cmpop::In => ast::CmpopIn::py_type_cache(),
|
||||
ast::Cmpop::NotIn => ast::CmpopNotIn::py_type_cache(),
|
||||
ast::CmpOp::Eq => ast::CmpOpEq::py_type_cache(),
|
||||
ast::CmpOp::NotEq => ast::CmpOpNotEq::py_type_cache(),
|
||||
ast::CmpOp::Lt => ast::CmpOpLt::py_type_cache(),
|
||||
ast::CmpOp::LtE => ast::CmpOpLtE::py_type_cache(),
|
||||
ast::CmpOp::Gt => ast::CmpOpGt::py_type_cache(),
|
||||
ast::CmpOp::GtE => ast::CmpOpGtE::py_type_cache(),
|
||||
ast::CmpOp::Is => ast::CmpOpIs::py_type_cache(),
|
||||
ast::CmpOp::IsNot => ast::CmpOpIsNot::py_type_cache(),
|
||||
ast::CmpOp::In => ast::CmpOpIn::py_type_cache(),
|
||||
ast::CmpOp::NotIn => ast::CmpOpNotIn::py_type_cache(),
|
||||
};
|
||||
Ok(Py::<PyAny>::as_ref(&cell.get().unwrap().1, py))
|
||||
}
|
||||
|
@ -2256,17 +2256,17 @@ impl ToPyAst for ast::Comprehension<TextRange> {
|
|||
}
|
||||
}
|
||||
|
||||
impl ToPyAst for ast::Excepthandler<TextRange> {
|
||||
impl ToPyAst for ast::ExceptHandler<TextRange> {
|
||||
#[inline]
|
||||
fn to_py_ast<'py>(&self, py: Python<'py>) -> PyResult<&'py PyAny> {
|
||||
let instance = match &self {
|
||||
ast::Excepthandler::ExceptHandler(cons) => cons.to_py_ast(py)?,
|
||||
ast::ExceptHandler::ExceptHandler(cons) => cons.to_py_ast(py)?,
|
||||
};
|
||||
Ok(instance)
|
||||
}
|
||||
}
|
||||
|
||||
impl ToPyAst for ast::ExcepthandlerExceptHandler<TextRange> {
|
||||
impl ToPyAst for ast::ExceptHandlerExceptHandler<TextRange> {
|
||||
#[inline]
|
||||
fn to_py_ast<'py>(&self, py: Python<'py>) -> PyResult<&'py PyAny> {
|
||||
let cache = Self::py_type_cache().get().unwrap();
|
||||
|
@ -2376,7 +2376,7 @@ impl ToPyAst for ast::Alias<TextRange> {
|
|||
}
|
||||
}
|
||||
|
||||
impl ToPyAst for ast::Withitem<TextRange> {
|
||||
impl ToPyAst for ast::WithItem<TextRange> {
|
||||
#[inline]
|
||||
fn to_py_ast<'py>(&self, py: Python<'py>) -> PyResult<&'py PyAny> {
|
||||
let cache = Self::py_type_cache().get().unwrap();
|
||||
|
@ -4272,17 +4272,17 @@ impl ToPyAst for ast::Comprehension<SourceRange> {
|
|||
}
|
||||
}
|
||||
|
||||
impl ToPyAst for ast::Excepthandler<SourceRange> {
|
||||
impl ToPyAst for ast::ExceptHandler<SourceRange> {
|
||||
#[inline]
|
||||
fn to_py_ast<'py>(&self, py: Python<'py>) -> PyResult<&'py PyAny> {
|
||||
let instance = match &self {
|
||||
ast::Excepthandler::ExceptHandler(cons) => cons.to_py_ast(py)?,
|
||||
ast::ExceptHandler::ExceptHandler(cons) => cons.to_py_ast(py)?,
|
||||
};
|
||||
Ok(instance)
|
||||
}
|
||||
}
|
||||
|
||||
impl ToPyAst for ast::ExcepthandlerExceptHandler<SourceRange> {
|
||||
impl ToPyAst for ast::ExceptHandlerExceptHandler<SourceRange> {
|
||||
#[inline]
|
||||
fn to_py_ast<'py>(&self, py: Python<'py>) -> PyResult<&'py PyAny> {
|
||||
let cache = Self::py_type_cache().get().unwrap();
|
||||
|
@ -4424,7 +4424,7 @@ impl ToPyAst for ast::Alias<SourceRange> {
|
|||
}
|
||||
}
|
||||
|
||||
impl ToPyAst for ast::Withitem<SourceRange> {
|
||||
impl ToPyAst for ast::WithItem<SourceRange> {
|
||||
#[inline]
|
||||
fn to_py_ast<'py>(&self, py: Python<'py>) -> PyResult<&'py PyAny> {
|
||||
let cache = Self::py_type_cache().get().unwrap();
|
||||
|
@ -4784,9 +4784,9 @@ fn init_types(py: Python) -> PyResult<()> {
|
|||
cache_py_type::<ast::ExprContextLoad>(ast_module)?;
|
||||
cache_py_type::<ast::ExprContextStore>(ast_module)?;
|
||||
cache_py_type::<ast::ExprContextDel>(ast_module)?;
|
||||
cache_py_type::<ast::Boolop>(ast_module)?;
|
||||
cache_py_type::<ast::BoolopAnd>(ast_module)?;
|
||||
cache_py_type::<ast::BoolopOr>(ast_module)?;
|
||||
cache_py_type::<ast::BoolOp>(ast_module)?;
|
||||
cache_py_type::<ast::BoolOpAnd>(ast_module)?;
|
||||
cache_py_type::<ast::BoolOpOr>(ast_module)?;
|
||||
cache_py_type::<ast::Operator>(ast_module)?;
|
||||
cache_py_type::<ast::OperatorAdd>(ast_module)?;
|
||||
cache_py_type::<ast::OperatorSub>(ast_module)?;
|
||||
|
@ -4801,30 +4801,30 @@ fn init_types(py: Python) -> PyResult<()> {
|
|||
cache_py_type::<ast::OperatorBitXor>(ast_module)?;
|
||||
cache_py_type::<ast::OperatorBitAnd>(ast_module)?;
|
||||
cache_py_type::<ast::OperatorFloorDiv>(ast_module)?;
|
||||
cache_py_type::<ast::Unaryop>(ast_module)?;
|
||||
cache_py_type::<ast::UnaryopInvert>(ast_module)?;
|
||||
cache_py_type::<ast::UnaryopNot>(ast_module)?;
|
||||
cache_py_type::<ast::UnaryopUAdd>(ast_module)?;
|
||||
cache_py_type::<ast::UnaryopUSub>(ast_module)?;
|
||||
cache_py_type::<ast::Cmpop>(ast_module)?;
|
||||
cache_py_type::<ast::CmpopEq>(ast_module)?;
|
||||
cache_py_type::<ast::CmpopNotEq>(ast_module)?;
|
||||
cache_py_type::<ast::CmpopLt>(ast_module)?;
|
||||
cache_py_type::<ast::CmpopLtE>(ast_module)?;
|
||||
cache_py_type::<ast::CmpopGt>(ast_module)?;
|
||||
cache_py_type::<ast::CmpopGtE>(ast_module)?;
|
||||
cache_py_type::<ast::CmpopIs>(ast_module)?;
|
||||
cache_py_type::<ast::CmpopIsNot>(ast_module)?;
|
||||
cache_py_type::<ast::CmpopIn>(ast_module)?;
|
||||
cache_py_type::<ast::CmpopNotIn>(ast_module)?;
|
||||
cache_py_type::<ast::UnaryOp>(ast_module)?;
|
||||
cache_py_type::<ast::UnaryOpInvert>(ast_module)?;
|
||||
cache_py_type::<ast::UnaryOpNot>(ast_module)?;
|
||||
cache_py_type::<ast::UnaryOpUAdd>(ast_module)?;
|
||||
cache_py_type::<ast::UnaryOpUSub>(ast_module)?;
|
||||
cache_py_type::<ast::CmpOp>(ast_module)?;
|
||||
cache_py_type::<ast::CmpOpEq>(ast_module)?;
|
||||
cache_py_type::<ast::CmpOpNotEq>(ast_module)?;
|
||||
cache_py_type::<ast::CmpOpLt>(ast_module)?;
|
||||
cache_py_type::<ast::CmpOpLtE>(ast_module)?;
|
||||
cache_py_type::<ast::CmpOpGt>(ast_module)?;
|
||||
cache_py_type::<ast::CmpOpGtE>(ast_module)?;
|
||||
cache_py_type::<ast::CmpOpIs>(ast_module)?;
|
||||
cache_py_type::<ast::CmpOpIsNot>(ast_module)?;
|
||||
cache_py_type::<ast::CmpOpIn>(ast_module)?;
|
||||
cache_py_type::<ast::CmpOpNotIn>(ast_module)?;
|
||||
cache_py_type::<ast::Comprehension>(ast_module)?;
|
||||
cache_py_type::<ast::Excepthandler>(ast_module)?;
|
||||
cache_py_type::<ast::ExcepthandlerExceptHandler>(ast_module)?;
|
||||
cache_py_type::<ast::ExceptHandler>(ast_module)?;
|
||||
cache_py_type::<ast::ExceptHandlerExceptHandler>(ast_module)?;
|
||||
cache_py_type::<ast::PythonArguments>(ast_module)?;
|
||||
cache_py_type::<ast::Arg>(ast_module)?;
|
||||
cache_py_type::<ast::Keyword>(ast_module)?;
|
||||
cache_py_type::<ast::Alias>(ast_module)?;
|
||||
cache_py_type::<ast::Withitem>(ast_module)?;
|
||||
cache_py_type::<ast::WithItem>(ast_module)?;
|
||||
cache_py_type::<ast::MatchCase>(ast_module)?;
|
||||
cache_py_type::<ast::Pattern>(ast_module)?;
|
||||
cache_py_type::<ast::PatternMatchValue>(ast_module)?;
|
||||
|
|
|
@ -2714,47 +2714,47 @@ impl ToPyObject for ExprContextDel {
|
|||
|
||||
#[pyclass(module="rustpython_ast.located", name="_boolop", extends=super::Ast, frozen, subclass)]
|
||||
#[derive(Clone, Debug)]
|
||||
pub struct Boolop;
|
||||
pub struct BoolOp;
|
||||
|
||||
impl From<&'static ast::Boolop> for Boolop {
|
||||
fn from(_node: &'static ast::Boolop) -> Self {
|
||||
Boolop
|
||||
impl From<&'static ast::BoolOp> for BoolOp {
|
||||
fn from(_node: &'static ast::BoolOp) -> Self {
|
||||
BoolOp
|
||||
}
|
||||
}
|
||||
|
||||
#[pymethods]
|
||||
impl Boolop {
|
||||
impl BoolOp {
|
||||
#[new]
|
||||
fn new() -> PyClassInitializer<Self> {
|
||||
PyClassInitializer::from(Ast).add_subclass(Self)
|
||||
}
|
||||
}
|
||||
impl ToPyObject for Boolop {
|
||||
impl ToPyObject for BoolOp {
|
||||
fn to_object(&self, py: Python) -> PyObject {
|
||||
let initializer = Self::new();
|
||||
Py::new(py, initializer).unwrap().into_py(py)
|
||||
}
|
||||
}
|
||||
|
||||
#[pyclass(module="rustpython_ast.located", name="_And", extends=Boolop)]
|
||||
pub struct BoolopAnd;
|
||||
#[pyclass(module="rustpython_ast.located", name="_And", extends=BoolOp)]
|
||||
pub struct BoolOpAnd;
|
||||
|
||||
impl ToPyObject for BoolopAnd {
|
||||
impl ToPyObject for BoolOpAnd {
|
||||
fn to_object(&self, py: Python) -> PyObject {
|
||||
let initializer = PyClassInitializer::from(Ast)
|
||||
.add_subclass(Boolop)
|
||||
.add_subclass(BoolOp)
|
||||
.add_subclass(Self);
|
||||
Py::new(py, initializer).unwrap().into_py(py)
|
||||
}
|
||||
}
|
||||
|
||||
#[pyclass(module="rustpython_ast.located", name="_Or", extends=Boolop)]
|
||||
pub struct BoolopOr;
|
||||
#[pyclass(module="rustpython_ast.located", name="_Or", extends=BoolOp)]
|
||||
pub struct BoolOpOr;
|
||||
|
||||
impl ToPyObject for BoolopOr {
|
||||
impl ToPyObject for BoolOpOr {
|
||||
fn to_object(&self, py: Python) -> PyObject {
|
||||
let initializer = PyClassInitializer::from(Ast)
|
||||
.add_subclass(Boolop)
|
||||
.add_subclass(BoolOp)
|
||||
.add_subclass(Self);
|
||||
Py::new(py, initializer).unwrap().into_py(py)
|
||||
}
|
||||
|
@ -2942,71 +2942,71 @@ impl ToPyObject for OperatorFloorDiv {
|
|||
|
||||
#[pyclass(module="rustpython_ast.located", name="_unaryop", extends=super::Ast, frozen, subclass)]
|
||||
#[derive(Clone, Debug)]
|
||||
pub struct Unaryop;
|
||||
pub struct UnaryOp;
|
||||
|
||||
impl From<&'static ast::Unaryop> for Unaryop {
|
||||
fn from(_node: &'static ast::Unaryop) -> Self {
|
||||
Unaryop
|
||||
impl From<&'static ast::UnaryOp> for UnaryOp {
|
||||
fn from(_node: &'static ast::UnaryOp) -> Self {
|
||||
UnaryOp
|
||||
}
|
||||
}
|
||||
|
||||
#[pymethods]
|
||||
impl Unaryop {
|
||||
impl UnaryOp {
|
||||
#[new]
|
||||
fn new() -> PyClassInitializer<Self> {
|
||||
PyClassInitializer::from(Ast).add_subclass(Self)
|
||||
}
|
||||
}
|
||||
impl ToPyObject for Unaryop {
|
||||
impl ToPyObject for UnaryOp {
|
||||
fn to_object(&self, py: Python) -> PyObject {
|
||||
let initializer = Self::new();
|
||||
Py::new(py, initializer).unwrap().into_py(py)
|
||||
}
|
||||
}
|
||||
|
||||
#[pyclass(module="rustpython_ast.located", name="_Invert", extends=Unaryop)]
|
||||
pub struct UnaryopInvert;
|
||||
#[pyclass(module="rustpython_ast.located", name="_Invert", extends=UnaryOp)]
|
||||
pub struct UnaryOpInvert;
|
||||
|
||||
impl ToPyObject for UnaryopInvert {
|
||||
impl ToPyObject for UnaryOpInvert {
|
||||
fn to_object(&self, py: Python) -> PyObject {
|
||||
let initializer = PyClassInitializer::from(Ast)
|
||||
.add_subclass(Unaryop)
|
||||
.add_subclass(UnaryOp)
|
||||
.add_subclass(Self);
|
||||
Py::new(py, initializer).unwrap().into_py(py)
|
||||
}
|
||||
}
|
||||
|
||||
#[pyclass(module="rustpython_ast.located", name="_Not", extends=Unaryop)]
|
||||
pub struct UnaryopNot;
|
||||
#[pyclass(module="rustpython_ast.located", name="_Not", extends=UnaryOp)]
|
||||
pub struct UnaryOpNot;
|
||||
|
||||
impl ToPyObject for UnaryopNot {
|
||||
impl ToPyObject for UnaryOpNot {
|
||||
fn to_object(&self, py: Python) -> PyObject {
|
||||
let initializer = PyClassInitializer::from(Ast)
|
||||
.add_subclass(Unaryop)
|
||||
.add_subclass(UnaryOp)
|
||||
.add_subclass(Self);
|
||||
Py::new(py, initializer).unwrap().into_py(py)
|
||||
}
|
||||
}
|
||||
|
||||
#[pyclass(module="rustpython_ast.located", name="_UAdd", extends=Unaryop)]
|
||||
pub struct UnaryopUAdd;
|
||||
#[pyclass(module="rustpython_ast.located", name="_UAdd", extends=UnaryOp)]
|
||||
pub struct UnaryOpUAdd;
|
||||
|
||||
impl ToPyObject for UnaryopUAdd {
|
||||
impl ToPyObject for UnaryOpUAdd {
|
||||
fn to_object(&self, py: Python) -> PyObject {
|
||||
let initializer = PyClassInitializer::from(Ast)
|
||||
.add_subclass(Unaryop)
|
||||
.add_subclass(UnaryOp)
|
||||
.add_subclass(Self);
|
||||
Py::new(py, initializer).unwrap().into_py(py)
|
||||
}
|
||||
}
|
||||
|
||||
#[pyclass(module="rustpython_ast.located", name="_USub", extends=Unaryop)]
|
||||
pub struct UnaryopUSub;
|
||||
#[pyclass(module="rustpython_ast.located", name="_USub", extends=UnaryOp)]
|
||||
pub struct UnaryOpUSub;
|
||||
|
||||
impl ToPyObject for UnaryopUSub {
|
||||
impl ToPyObject for UnaryOpUSub {
|
||||
fn to_object(&self, py: Python) -> PyObject {
|
||||
let initializer = PyClassInitializer::from(Ast)
|
||||
.add_subclass(Unaryop)
|
||||
.add_subclass(UnaryOp)
|
||||
.add_subclass(Self);
|
||||
Py::new(py, initializer).unwrap().into_py(py)
|
||||
}
|
||||
|
@ -3014,143 +3014,143 @@ impl ToPyObject for UnaryopUSub {
|
|||
|
||||
#[pyclass(module="rustpython_ast.located", name="_cmpop", extends=super::Ast, frozen, subclass)]
|
||||
#[derive(Clone, Debug)]
|
||||
pub struct Cmpop;
|
||||
pub struct CmpOp;
|
||||
|
||||
impl From<&'static ast::Cmpop> for Cmpop {
|
||||
fn from(_node: &'static ast::Cmpop) -> Self {
|
||||
Cmpop
|
||||
impl From<&'static ast::CmpOp> for CmpOp {
|
||||
fn from(_node: &'static ast::CmpOp) -> Self {
|
||||
CmpOp
|
||||
}
|
||||
}
|
||||
|
||||
#[pymethods]
|
||||
impl Cmpop {
|
||||
impl CmpOp {
|
||||
#[new]
|
||||
fn new() -> PyClassInitializer<Self> {
|
||||
PyClassInitializer::from(Ast).add_subclass(Self)
|
||||
}
|
||||
}
|
||||
impl ToPyObject for Cmpop {
|
||||
impl ToPyObject for CmpOp {
|
||||
fn to_object(&self, py: Python) -> PyObject {
|
||||
let initializer = Self::new();
|
||||
Py::new(py, initializer).unwrap().into_py(py)
|
||||
}
|
||||
}
|
||||
|
||||
#[pyclass(module="rustpython_ast.located", name="_Eq", extends=Cmpop)]
|
||||
pub struct CmpopEq;
|
||||
#[pyclass(module="rustpython_ast.located", name="_Eq", extends=CmpOp)]
|
||||
pub struct CmpOpEq;
|
||||
|
||||
impl ToPyObject for CmpopEq {
|
||||
impl ToPyObject for CmpOpEq {
|
||||
fn to_object(&self, py: Python) -> PyObject {
|
||||
let initializer = PyClassInitializer::from(Ast)
|
||||
.add_subclass(Cmpop)
|
||||
.add_subclass(CmpOp)
|
||||
.add_subclass(Self);
|
||||
Py::new(py, initializer).unwrap().into_py(py)
|
||||
}
|
||||
}
|
||||
|
||||
#[pyclass(module="rustpython_ast.located", name="_NotEq", extends=Cmpop)]
|
||||
pub struct CmpopNotEq;
|
||||
#[pyclass(module="rustpython_ast.located", name="_NotEq", extends=CmpOp)]
|
||||
pub struct CmpOpNotEq;
|
||||
|
||||
impl ToPyObject for CmpopNotEq {
|
||||
impl ToPyObject for CmpOpNotEq {
|
||||
fn to_object(&self, py: Python) -> PyObject {
|
||||
let initializer = PyClassInitializer::from(Ast)
|
||||
.add_subclass(Cmpop)
|
||||
.add_subclass(CmpOp)
|
||||
.add_subclass(Self);
|
||||
Py::new(py, initializer).unwrap().into_py(py)
|
||||
}
|
||||
}
|
||||
|
||||
#[pyclass(module="rustpython_ast.located", name="_Lt", extends=Cmpop)]
|
||||
pub struct CmpopLt;
|
||||
#[pyclass(module="rustpython_ast.located", name="_Lt", extends=CmpOp)]
|
||||
pub struct CmpOpLt;
|
||||
|
||||
impl ToPyObject for CmpopLt {
|
||||
impl ToPyObject for CmpOpLt {
|
||||
fn to_object(&self, py: Python) -> PyObject {
|
||||
let initializer = PyClassInitializer::from(Ast)
|
||||
.add_subclass(Cmpop)
|
||||
.add_subclass(CmpOp)
|
||||
.add_subclass(Self);
|
||||
Py::new(py, initializer).unwrap().into_py(py)
|
||||
}
|
||||
}
|
||||
|
||||
#[pyclass(module="rustpython_ast.located", name="_LtE", extends=Cmpop)]
|
||||
pub struct CmpopLtE;
|
||||
#[pyclass(module="rustpython_ast.located", name="_LtE", extends=CmpOp)]
|
||||
pub struct CmpOpLtE;
|
||||
|
||||
impl ToPyObject for CmpopLtE {
|
||||
impl ToPyObject for CmpOpLtE {
|
||||
fn to_object(&self, py: Python) -> PyObject {
|
||||
let initializer = PyClassInitializer::from(Ast)
|
||||
.add_subclass(Cmpop)
|
||||
.add_subclass(CmpOp)
|
||||
.add_subclass(Self);
|
||||
Py::new(py, initializer).unwrap().into_py(py)
|
||||
}
|
||||
}
|
||||
|
||||
#[pyclass(module="rustpython_ast.located", name="_Gt", extends=Cmpop)]
|
||||
pub struct CmpopGt;
|
||||
#[pyclass(module="rustpython_ast.located", name="_Gt", extends=CmpOp)]
|
||||
pub struct CmpOpGt;
|
||||
|
||||
impl ToPyObject for CmpopGt {
|
||||
impl ToPyObject for CmpOpGt {
|
||||
fn to_object(&self, py: Python) -> PyObject {
|
||||
let initializer = PyClassInitializer::from(Ast)
|
||||
.add_subclass(Cmpop)
|
||||
.add_subclass(CmpOp)
|
||||
.add_subclass(Self);
|
||||
Py::new(py, initializer).unwrap().into_py(py)
|
||||
}
|
||||
}
|
||||
|
||||
#[pyclass(module="rustpython_ast.located", name="_GtE", extends=Cmpop)]
|
||||
pub struct CmpopGtE;
|
||||
#[pyclass(module="rustpython_ast.located", name="_GtE", extends=CmpOp)]
|
||||
pub struct CmpOpGtE;
|
||||
|
||||
impl ToPyObject for CmpopGtE {
|
||||
impl ToPyObject for CmpOpGtE {
|
||||
fn to_object(&self, py: Python) -> PyObject {
|
||||
let initializer = PyClassInitializer::from(Ast)
|
||||
.add_subclass(Cmpop)
|
||||
.add_subclass(CmpOp)
|
||||
.add_subclass(Self);
|
||||
Py::new(py, initializer).unwrap().into_py(py)
|
||||
}
|
||||
}
|
||||
|
||||
#[pyclass(module="rustpython_ast.located", name="_Is", extends=Cmpop)]
|
||||
pub struct CmpopIs;
|
||||
#[pyclass(module="rustpython_ast.located", name="_Is", extends=CmpOp)]
|
||||
pub struct CmpOpIs;
|
||||
|
||||
impl ToPyObject for CmpopIs {
|
||||
impl ToPyObject for CmpOpIs {
|
||||
fn to_object(&self, py: Python) -> PyObject {
|
||||
let initializer = PyClassInitializer::from(Ast)
|
||||
.add_subclass(Cmpop)
|
||||
.add_subclass(CmpOp)
|
||||
.add_subclass(Self);
|
||||
Py::new(py, initializer).unwrap().into_py(py)
|
||||
}
|
||||
}
|
||||
|
||||
#[pyclass(module="rustpython_ast.located", name="_IsNot", extends=Cmpop)]
|
||||
pub struct CmpopIsNot;
|
||||
#[pyclass(module="rustpython_ast.located", name="_IsNot", extends=CmpOp)]
|
||||
pub struct CmpOpIsNot;
|
||||
|
||||
impl ToPyObject for CmpopIsNot {
|
||||
impl ToPyObject for CmpOpIsNot {
|
||||
fn to_object(&self, py: Python) -> PyObject {
|
||||
let initializer = PyClassInitializer::from(Ast)
|
||||
.add_subclass(Cmpop)
|
||||
.add_subclass(CmpOp)
|
||||
.add_subclass(Self);
|
||||
Py::new(py, initializer).unwrap().into_py(py)
|
||||
}
|
||||
}
|
||||
|
||||
#[pyclass(module="rustpython_ast.located", name="_In", extends=Cmpop)]
|
||||
pub struct CmpopIn;
|
||||
#[pyclass(module="rustpython_ast.located", name="_In", extends=CmpOp)]
|
||||
pub struct CmpOpIn;
|
||||
|
||||
impl ToPyObject for CmpopIn {
|
||||
impl ToPyObject for CmpOpIn {
|
||||
fn to_object(&self, py: Python) -> PyObject {
|
||||
let initializer = PyClassInitializer::from(Ast)
|
||||
.add_subclass(Cmpop)
|
||||
.add_subclass(CmpOp)
|
||||
.add_subclass(Self);
|
||||
Py::new(py, initializer).unwrap().into_py(py)
|
||||
}
|
||||
}
|
||||
|
||||
#[pyclass(module="rustpython_ast.located", name="_NotIn", extends=Cmpop)]
|
||||
pub struct CmpopNotIn;
|
||||
#[pyclass(module="rustpython_ast.located", name="_NotIn", extends=CmpOp)]
|
||||
pub struct CmpOpNotIn;
|
||||
|
||||
impl ToPyObject for CmpopNotIn {
|
||||
impl ToPyObject for CmpOpNotIn {
|
||||
fn to_object(&self, py: Python) -> PyObject {
|
||||
let initializer = PyClassInitializer::from(Ast)
|
||||
.add_subclass(Cmpop)
|
||||
.add_subclass(CmpOp)
|
||||
.add_subclass(Self);
|
||||
Py::new(py, initializer).unwrap().into_py(py)
|
||||
}
|
||||
|
@ -3209,29 +3209,29 @@ impl Comprehension {
|
|||
|
||||
#[pyclass(module="rustpython_ast.located", name="_excepthandler", extends=super::Ast, frozen, subclass)]
|
||||
#[derive(Clone, Debug)]
|
||||
pub struct Excepthandler;
|
||||
pub struct ExceptHandler;
|
||||
|
||||
impl From<&'static ast::Excepthandler<SourceRange>> for Excepthandler {
|
||||
fn from(_node: &'static ast::Excepthandler<SourceRange>) -> Self {
|
||||
Excepthandler
|
||||
impl From<&'static ast::ExceptHandler<SourceRange>> for ExceptHandler {
|
||||
fn from(_node: &'static ast::ExceptHandler<SourceRange>) -> Self {
|
||||
ExceptHandler
|
||||
}
|
||||
}
|
||||
|
||||
#[pymethods]
|
||||
impl Excepthandler {
|
||||
impl ExceptHandler {
|
||||
#[new]
|
||||
fn new() -> PyClassInitializer<Self> {
|
||||
PyClassInitializer::from(Ast).add_subclass(Self)
|
||||
}
|
||||
}
|
||||
impl ToPyObject for Excepthandler {
|
||||
impl ToPyObject for ExceptHandler {
|
||||
fn to_object(&self, py: Python) -> PyObject {
|
||||
let initializer = Self::new();
|
||||
Py::new(py, initializer).unwrap().into_py(py)
|
||||
}
|
||||
}
|
||||
|
||||
impl ToPyWrapper for ast::Excepthandler<SourceRange> {
|
||||
impl ToPyWrapper for ast::ExceptHandler<SourceRange> {
|
||||
#[inline]
|
||||
fn to_py_wrapper(&'static self, py: Python) -> PyResult<Py<PyAny>> {
|
||||
match &self {
|
||||
|
@ -3240,34 +3240,34 @@ impl ToPyWrapper for ast::Excepthandler<SourceRange> {
|
|||
}
|
||||
}
|
||||
|
||||
#[pyclass(module="rustpython_ast.located", name="_ExceptHandler", extends=Excepthandler, frozen)]
|
||||
#[pyclass(module="rustpython_ast.located", name="_ExceptHandler", extends=ExceptHandler, frozen)]
|
||||
#[derive(Clone, Debug)]
|
||||
pub struct ExcepthandlerExceptHandler(pub &'static ast::ExcepthandlerExceptHandler<SourceRange>);
|
||||
pub struct ExceptHandlerExceptHandler(pub &'static ast::ExceptHandlerExceptHandler<SourceRange>);
|
||||
|
||||
impl From<&'static ast::ExcepthandlerExceptHandler<SourceRange>> for ExcepthandlerExceptHandler {
|
||||
fn from(node: &'static ast::ExcepthandlerExceptHandler<SourceRange>) -> Self {
|
||||
ExcepthandlerExceptHandler(node)
|
||||
impl From<&'static ast::ExceptHandlerExceptHandler<SourceRange>> for ExceptHandlerExceptHandler {
|
||||
fn from(node: &'static ast::ExceptHandlerExceptHandler<SourceRange>) -> Self {
|
||||
ExceptHandlerExceptHandler(node)
|
||||
}
|
||||
}
|
||||
|
||||
impl ToPyObject for ExcepthandlerExceptHandler {
|
||||
impl ToPyObject for ExceptHandlerExceptHandler {
|
||||
fn to_object(&self, py: Python) -> PyObject {
|
||||
let initializer = PyClassInitializer::from(Ast)
|
||||
.add_subclass(Excepthandler)
|
||||
.add_subclass(ExceptHandler)
|
||||
.add_subclass(self.clone());
|
||||
Py::new(py, initializer).unwrap().into_py(py)
|
||||
}
|
||||
}
|
||||
|
||||
impl ToPyWrapper for ast::ExcepthandlerExceptHandler<SourceRange> {
|
||||
impl ToPyWrapper for ast::ExceptHandlerExceptHandler<SourceRange> {
|
||||
#[inline]
|
||||
fn to_py_wrapper(&'static self, py: Python) -> PyResult<Py<PyAny>> {
|
||||
Ok(ExcepthandlerExceptHandler(self).to_object(py))
|
||||
Ok(ExceptHandlerExceptHandler(self).to_object(py))
|
||||
}
|
||||
}
|
||||
|
||||
#[pymethods]
|
||||
impl ExcepthandlerExceptHandler {
|
||||
impl ExceptHandlerExceptHandler {
|
||||
#[getter]
|
||||
#[inline]
|
||||
fn get_type(&self, py: Python) -> PyResult<PyObject> {
|
||||
|
@ -3481,30 +3481,30 @@ impl Alias {
|
|||
|
||||
#[pyclass(module="rustpython_ast.located", name="_withitem", extends=super::Ast, frozen)]
|
||||
#[derive(Clone, Debug)]
|
||||
pub struct Withitem(pub &'static ast::Withitem<SourceRange>);
|
||||
pub struct WithItem(pub &'static ast::WithItem<SourceRange>);
|
||||
|
||||
impl From<&'static ast::Withitem<SourceRange>> for Withitem {
|
||||
fn from(node: &'static ast::Withitem<SourceRange>) -> Self {
|
||||
Withitem(node)
|
||||
impl From<&'static ast::WithItem<SourceRange>> for WithItem {
|
||||
fn from(node: &'static ast::WithItem<SourceRange>) -> Self {
|
||||
WithItem(node)
|
||||
}
|
||||
}
|
||||
|
||||
impl ToPyObject for Withitem {
|
||||
impl ToPyObject for WithItem {
|
||||
fn to_object(&self, py: Python) -> PyObject {
|
||||
let initializer = PyClassInitializer::from(Ast).add_subclass(self.clone());
|
||||
Py::new(py, initializer).unwrap().into_py(py)
|
||||
}
|
||||
}
|
||||
|
||||
impl ToPyWrapper for ast::Withitem<SourceRange> {
|
||||
impl ToPyWrapper for ast::WithItem<SourceRange> {
|
||||
#[inline]
|
||||
fn to_py_wrapper(&'static self, py: Python) -> PyResult<Py<PyAny>> {
|
||||
Ok(Withitem(self).to_object(py))
|
||||
Ok(WithItem(self).to_object(py))
|
||||
}
|
||||
}
|
||||
|
||||
#[pymethods]
|
||||
impl Withitem {
|
||||
impl WithItem {
|
||||
#[getter]
|
||||
#[inline]
|
||||
fn get_context_expr(&self, py: Python) -> PyResult<PyObject> {
|
||||
|
@ -4025,27 +4025,27 @@ impl ToPyWrapper for ast::ExprContextDel {
|
|||
}
|
||||
}
|
||||
|
||||
impl ToPyWrapper for ast::Boolop {
|
||||
impl ToPyWrapper for ast::BoolOp {
|
||||
#[inline]
|
||||
fn to_py_wrapper(&self, py: Python) -> PyResult<Py<PyAny>> {
|
||||
match &self {
|
||||
Self::And => Ok(BoolopAnd.to_object(py)),
|
||||
Self::Or => Ok(BoolopOr.to_object(py)),
|
||||
Self::And => Ok(BoolOpAnd.to_object(py)),
|
||||
Self::Or => Ok(BoolOpOr.to_object(py)),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl ToPyWrapper for ast::BoolopAnd {
|
||||
impl ToPyWrapper for ast::BoolOpAnd {
|
||||
#[inline]
|
||||
fn to_py_wrapper(&self, py: Python) -> PyResult<Py<PyAny>> {
|
||||
Ok(BoolopAnd.to_object(py))
|
||||
Ok(BoolOpAnd.to_object(py))
|
||||
}
|
||||
}
|
||||
|
||||
impl ToPyWrapper for ast::BoolopOr {
|
||||
impl ToPyWrapper for ast::BoolOpOr {
|
||||
#[inline]
|
||||
fn to_py_wrapper(&self, py: Python) -> PyResult<Py<PyAny>> {
|
||||
Ok(BoolopOr.to_object(py))
|
||||
Ok(BoolOpOr.to_object(py))
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -4161,131 +4161,131 @@ impl ToPyWrapper for ast::OperatorFloorDiv {
|
|||
}
|
||||
}
|
||||
|
||||
impl ToPyWrapper for ast::Unaryop {
|
||||
impl ToPyWrapper for ast::UnaryOp {
|
||||
#[inline]
|
||||
fn to_py_wrapper(&self, py: Python) -> PyResult<Py<PyAny>> {
|
||||
match &self {
|
||||
Self::Invert => Ok(UnaryopInvert.to_object(py)),
|
||||
Self::Not => Ok(UnaryopNot.to_object(py)),
|
||||
Self::UAdd => Ok(UnaryopUAdd.to_object(py)),
|
||||
Self::USub => Ok(UnaryopUSub.to_object(py)),
|
||||
Self::Invert => Ok(UnaryOpInvert.to_object(py)),
|
||||
Self::Not => Ok(UnaryOpNot.to_object(py)),
|
||||
Self::UAdd => Ok(UnaryOpUAdd.to_object(py)),
|
||||
Self::USub => Ok(UnaryOpUSub.to_object(py)),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl ToPyWrapper for ast::UnaryopInvert {
|
||||
impl ToPyWrapper for ast::UnaryOpInvert {
|
||||
#[inline]
|
||||
fn to_py_wrapper(&self, py: Python) -> PyResult<Py<PyAny>> {
|
||||
Ok(UnaryopInvert.to_object(py))
|
||||
Ok(UnaryOpInvert.to_object(py))
|
||||
}
|
||||
}
|
||||
|
||||
impl ToPyWrapper for ast::UnaryopNot {
|
||||
impl ToPyWrapper for ast::UnaryOpNot {
|
||||
#[inline]
|
||||
fn to_py_wrapper(&self, py: Python) -> PyResult<Py<PyAny>> {
|
||||
Ok(UnaryopNot.to_object(py))
|
||||
Ok(UnaryOpNot.to_object(py))
|
||||
}
|
||||
}
|
||||
|
||||
impl ToPyWrapper for ast::UnaryopUAdd {
|
||||
impl ToPyWrapper for ast::UnaryOpUAdd {
|
||||
#[inline]
|
||||
fn to_py_wrapper(&self, py: Python) -> PyResult<Py<PyAny>> {
|
||||
Ok(UnaryopUAdd.to_object(py))
|
||||
Ok(UnaryOpUAdd.to_object(py))
|
||||
}
|
||||
}
|
||||
|
||||
impl ToPyWrapper for ast::UnaryopUSub {
|
||||
impl ToPyWrapper for ast::UnaryOpUSub {
|
||||
#[inline]
|
||||
fn to_py_wrapper(&self, py: Python) -> PyResult<Py<PyAny>> {
|
||||
Ok(UnaryopUSub.to_object(py))
|
||||
Ok(UnaryOpUSub.to_object(py))
|
||||
}
|
||||
}
|
||||
|
||||
impl ToPyWrapper for ast::Cmpop {
|
||||
impl ToPyWrapper for ast::CmpOp {
|
||||
#[inline]
|
||||
fn to_py_wrapper(&self, py: Python) -> PyResult<Py<PyAny>> {
|
||||
match &self {
|
||||
Self::Eq => Ok(CmpopEq.to_object(py)),
|
||||
Self::NotEq => Ok(CmpopNotEq.to_object(py)),
|
||||
Self::Lt => Ok(CmpopLt.to_object(py)),
|
||||
Self::LtE => Ok(CmpopLtE.to_object(py)),
|
||||
Self::Gt => Ok(CmpopGt.to_object(py)),
|
||||
Self::GtE => Ok(CmpopGtE.to_object(py)),
|
||||
Self::Is => Ok(CmpopIs.to_object(py)),
|
||||
Self::IsNot => Ok(CmpopIsNot.to_object(py)),
|
||||
Self::In => Ok(CmpopIn.to_object(py)),
|
||||
Self::NotIn => Ok(CmpopNotIn.to_object(py)),
|
||||
Self::Eq => Ok(CmpOpEq.to_object(py)),
|
||||
Self::NotEq => Ok(CmpOpNotEq.to_object(py)),
|
||||
Self::Lt => Ok(CmpOpLt.to_object(py)),
|
||||
Self::LtE => Ok(CmpOpLtE.to_object(py)),
|
||||
Self::Gt => Ok(CmpOpGt.to_object(py)),
|
||||
Self::GtE => Ok(CmpOpGtE.to_object(py)),
|
||||
Self::Is => Ok(CmpOpIs.to_object(py)),
|
||||
Self::IsNot => Ok(CmpOpIsNot.to_object(py)),
|
||||
Self::In => Ok(CmpOpIn.to_object(py)),
|
||||
Self::NotIn => Ok(CmpOpNotIn.to_object(py)),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl ToPyWrapper for ast::CmpopEq {
|
||||
impl ToPyWrapper for ast::CmpOpEq {
|
||||
#[inline]
|
||||
fn to_py_wrapper(&self, py: Python) -> PyResult<Py<PyAny>> {
|
||||
Ok(CmpopEq.to_object(py))
|
||||
Ok(CmpOpEq.to_object(py))
|
||||
}
|
||||
}
|
||||
|
||||
impl ToPyWrapper for ast::CmpopNotEq {
|
||||
impl ToPyWrapper for ast::CmpOpNotEq {
|
||||
#[inline]
|
||||
fn to_py_wrapper(&self, py: Python) -> PyResult<Py<PyAny>> {
|
||||
Ok(CmpopNotEq.to_object(py))
|
||||
Ok(CmpOpNotEq.to_object(py))
|
||||
}
|
||||
}
|
||||
|
||||
impl ToPyWrapper for ast::CmpopLt {
|
||||
impl ToPyWrapper for ast::CmpOpLt {
|
||||
#[inline]
|
||||
fn to_py_wrapper(&self, py: Python) -> PyResult<Py<PyAny>> {
|
||||
Ok(CmpopLt.to_object(py))
|
||||
Ok(CmpOpLt.to_object(py))
|
||||
}
|
||||
}
|
||||
|
||||
impl ToPyWrapper for ast::CmpopLtE {
|
||||
impl ToPyWrapper for ast::CmpOpLtE {
|
||||
#[inline]
|
||||
fn to_py_wrapper(&self, py: Python) -> PyResult<Py<PyAny>> {
|
||||
Ok(CmpopLtE.to_object(py))
|
||||
Ok(CmpOpLtE.to_object(py))
|
||||
}
|
||||
}
|
||||
|
||||
impl ToPyWrapper for ast::CmpopGt {
|
||||
impl ToPyWrapper for ast::CmpOpGt {
|
||||
#[inline]
|
||||
fn to_py_wrapper(&self, py: Python) -> PyResult<Py<PyAny>> {
|
||||
Ok(CmpopGt.to_object(py))
|
||||
Ok(CmpOpGt.to_object(py))
|
||||
}
|
||||
}
|
||||
|
||||
impl ToPyWrapper for ast::CmpopGtE {
|
||||
impl ToPyWrapper for ast::CmpOpGtE {
|
||||
#[inline]
|
||||
fn to_py_wrapper(&self, py: Python) -> PyResult<Py<PyAny>> {
|
||||
Ok(CmpopGtE.to_object(py))
|
||||
Ok(CmpOpGtE.to_object(py))
|
||||
}
|
||||
}
|
||||
|
||||
impl ToPyWrapper for ast::CmpopIs {
|
||||
impl ToPyWrapper for ast::CmpOpIs {
|
||||
#[inline]
|
||||
fn to_py_wrapper(&self, py: Python) -> PyResult<Py<PyAny>> {
|
||||
Ok(CmpopIs.to_object(py))
|
||||
Ok(CmpOpIs.to_object(py))
|
||||
}
|
||||
}
|
||||
|
||||
impl ToPyWrapper for ast::CmpopIsNot {
|
||||
impl ToPyWrapper for ast::CmpOpIsNot {
|
||||
#[inline]
|
||||
fn to_py_wrapper(&self, py: Python) -> PyResult<Py<PyAny>> {
|
||||
Ok(CmpopIsNot.to_object(py))
|
||||
Ok(CmpOpIsNot.to_object(py))
|
||||
}
|
||||
}
|
||||
|
||||
impl ToPyWrapper for ast::CmpopIn {
|
||||
impl ToPyWrapper for ast::CmpOpIn {
|
||||
#[inline]
|
||||
fn to_py_wrapper(&self, py: Python) -> PyResult<Py<PyAny>> {
|
||||
Ok(CmpopIn.to_object(py))
|
||||
Ok(CmpOpIn.to_object(py))
|
||||
}
|
||||
}
|
||||
|
||||
impl ToPyWrapper for ast::CmpopNotIn {
|
||||
impl ToPyWrapper for ast::CmpOpNotIn {
|
||||
#[inline]
|
||||
fn to_py_wrapper(&self, py: Python) -> PyResult<Py<PyAny>> {
|
||||
Ok(CmpopNotIn.to_object(py))
|
||||
Ok(CmpOpNotIn.to_object(py))
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -4356,9 +4356,9 @@ pub fn add_to_module(py: Python, m: &PyModule) -> PyResult<()> {
|
|||
super::init_type::<ExprContextLoad, ast::ExprContextLoad>(py, m)?;
|
||||
super::init_type::<ExprContextStore, ast::ExprContextStore>(py, m)?;
|
||||
super::init_type::<ExprContextDel, ast::ExprContextDel>(py, m)?;
|
||||
super::init_type::<Boolop, ast::Boolop>(py, m)?;
|
||||
super::init_type::<BoolopAnd, ast::BoolopAnd>(py, m)?;
|
||||
super::init_type::<BoolopOr, ast::BoolopOr>(py, m)?;
|
||||
super::init_type::<BoolOp, ast::BoolOp>(py, m)?;
|
||||
super::init_type::<BoolOpAnd, ast::BoolOpAnd>(py, m)?;
|
||||
super::init_type::<BoolOpOr, ast::BoolOpOr>(py, m)?;
|
||||
super::init_type::<Operator, ast::Operator>(py, m)?;
|
||||
super::init_type::<OperatorAdd, ast::OperatorAdd>(py, m)?;
|
||||
super::init_type::<OperatorSub, ast::OperatorSub>(py, m)?;
|
||||
|
@ -4373,30 +4373,30 @@ pub fn add_to_module(py: Python, m: &PyModule) -> PyResult<()> {
|
|||
super::init_type::<OperatorBitXor, ast::OperatorBitXor>(py, m)?;
|
||||
super::init_type::<OperatorBitAnd, ast::OperatorBitAnd>(py, m)?;
|
||||
super::init_type::<OperatorFloorDiv, ast::OperatorFloorDiv>(py, m)?;
|
||||
super::init_type::<Unaryop, ast::Unaryop>(py, m)?;
|
||||
super::init_type::<UnaryopInvert, ast::UnaryopInvert>(py, m)?;
|
||||
super::init_type::<UnaryopNot, ast::UnaryopNot>(py, m)?;
|
||||
super::init_type::<UnaryopUAdd, ast::UnaryopUAdd>(py, m)?;
|
||||
super::init_type::<UnaryopUSub, ast::UnaryopUSub>(py, m)?;
|
||||
super::init_type::<Cmpop, ast::Cmpop>(py, m)?;
|
||||
super::init_type::<CmpopEq, ast::CmpopEq>(py, m)?;
|
||||
super::init_type::<CmpopNotEq, ast::CmpopNotEq>(py, m)?;
|
||||
super::init_type::<CmpopLt, ast::CmpopLt>(py, m)?;
|
||||
super::init_type::<CmpopLtE, ast::CmpopLtE>(py, m)?;
|
||||
super::init_type::<CmpopGt, ast::CmpopGt>(py, m)?;
|
||||
super::init_type::<CmpopGtE, ast::CmpopGtE>(py, m)?;
|
||||
super::init_type::<CmpopIs, ast::CmpopIs>(py, m)?;
|
||||
super::init_type::<CmpopIsNot, ast::CmpopIsNot>(py, m)?;
|
||||
super::init_type::<CmpopIn, ast::CmpopIn>(py, m)?;
|
||||
super::init_type::<CmpopNotIn, ast::CmpopNotIn>(py, m)?;
|
||||
super::init_type::<UnaryOp, ast::UnaryOp>(py, m)?;
|
||||
super::init_type::<UnaryOpInvert, ast::UnaryOpInvert>(py, m)?;
|
||||
super::init_type::<UnaryOpNot, ast::UnaryOpNot>(py, m)?;
|
||||
super::init_type::<UnaryOpUAdd, ast::UnaryOpUAdd>(py, m)?;
|
||||
super::init_type::<UnaryOpUSub, ast::UnaryOpUSub>(py, m)?;
|
||||
super::init_type::<CmpOp, ast::CmpOp>(py, m)?;
|
||||
super::init_type::<CmpOpEq, ast::CmpOpEq>(py, m)?;
|
||||
super::init_type::<CmpOpNotEq, ast::CmpOpNotEq>(py, m)?;
|
||||
super::init_type::<CmpOpLt, ast::CmpOpLt>(py, m)?;
|
||||
super::init_type::<CmpOpLtE, ast::CmpOpLtE>(py, m)?;
|
||||
super::init_type::<CmpOpGt, ast::CmpOpGt>(py, m)?;
|
||||
super::init_type::<CmpOpGtE, ast::CmpOpGtE>(py, m)?;
|
||||
super::init_type::<CmpOpIs, ast::CmpOpIs>(py, m)?;
|
||||
super::init_type::<CmpOpIsNot, ast::CmpOpIsNot>(py, m)?;
|
||||
super::init_type::<CmpOpIn, ast::CmpOpIn>(py, m)?;
|
||||
super::init_type::<CmpOpNotIn, ast::CmpOpNotIn>(py, m)?;
|
||||
super::init_type::<Comprehension, ast::Comprehension>(py, m)?;
|
||||
super::init_type::<Excepthandler, ast::Excepthandler>(py, m)?;
|
||||
super::init_type::<ExcepthandlerExceptHandler, ast::ExcepthandlerExceptHandler>(py, m)?;
|
||||
super::init_type::<ExceptHandler, ast::ExceptHandler>(py, m)?;
|
||||
super::init_type::<ExceptHandlerExceptHandler, ast::ExceptHandlerExceptHandler>(py, m)?;
|
||||
super::init_type::<Arguments, ast::PythonArguments>(py, m)?;
|
||||
super::init_type::<Arg, ast::Arg>(py, m)?;
|
||||
super::init_type::<Keyword, ast::Keyword>(py, m)?;
|
||||
super::init_type::<Alias, ast::Alias>(py, m)?;
|
||||
super::init_type::<Withitem, ast::Withitem>(py, m)?;
|
||||
super::init_type::<WithItem, ast::WithItem>(py, m)?;
|
||||
super::init_type::<MatchCase, ast::MatchCase>(py, m)?;
|
||||
super::init_type::<Pattern, ast::Pattern>(py, m)?;
|
||||
super::init_type::<PatternMatchValue, ast::PatternMatchValue>(py, m)?;
|
||||
|
|
|
@ -2714,47 +2714,47 @@ impl ToPyObject for ExprContextDel {
|
|||
|
||||
#[pyclass(module="rustpython_ast.ranged", name="_boolop", extends=super::Ast, frozen, subclass)]
|
||||
#[derive(Clone, Debug)]
|
||||
pub struct Boolop;
|
||||
pub struct BoolOp;
|
||||
|
||||
impl From<&'static ast::Boolop> for Boolop {
|
||||
fn from(_node: &'static ast::Boolop) -> Self {
|
||||
Boolop
|
||||
impl From<&'static ast::BoolOp> for BoolOp {
|
||||
fn from(_node: &'static ast::BoolOp) -> Self {
|
||||
BoolOp
|
||||
}
|
||||
}
|
||||
|
||||
#[pymethods]
|
||||
impl Boolop {
|
||||
impl BoolOp {
|
||||
#[new]
|
||||
fn new() -> PyClassInitializer<Self> {
|
||||
PyClassInitializer::from(Ast).add_subclass(Self)
|
||||
}
|
||||
}
|
||||
impl ToPyObject for Boolop {
|
||||
impl ToPyObject for BoolOp {
|
||||
fn to_object(&self, py: Python) -> PyObject {
|
||||
let initializer = Self::new();
|
||||
Py::new(py, initializer).unwrap().into_py(py)
|
||||
}
|
||||
}
|
||||
|
||||
#[pyclass(module="rustpython_ast.ranged", name="_And", extends=Boolop)]
|
||||
pub struct BoolopAnd;
|
||||
#[pyclass(module="rustpython_ast.ranged", name="_And", extends=BoolOp)]
|
||||
pub struct BoolOpAnd;
|
||||
|
||||
impl ToPyObject for BoolopAnd {
|
||||
impl ToPyObject for BoolOpAnd {
|
||||
fn to_object(&self, py: Python) -> PyObject {
|
||||
let initializer = PyClassInitializer::from(Ast)
|
||||
.add_subclass(Boolop)
|
||||
.add_subclass(BoolOp)
|
||||
.add_subclass(Self);
|
||||
Py::new(py, initializer).unwrap().into_py(py)
|
||||
}
|
||||
}
|
||||
|
||||
#[pyclass(module="rustpython_ast.ranged", name="_Or", extends=Boolop)]
|
||||
pub struct BoolopOr;
|
||||
#[pyclass(module="rustpython_ast.ranged", name="_Or", extends=BoolOp)]
|
||||
pub struct BoolOpOr;
|
||||
|
||||
impl ToPyObject for BoolopOr {
|
||||
impl ToPyObject for BoolOpOr {
|
||||
fn to_object(&self, py: Python) -> PyObject {
|
||||
let initializer = PyClassInitializer::from(Ast)
|
||||
.add_subclass(Boolop)
|
||||
.add_subclass(BoolOp)
|
||||
.add_subclass(Self);
|
||||
Py::new(py, initializer).unwrap().into_py(py)
|
||||
}
|
||||
|
@ -2942,71 +2942,71 @@ impl ToPyObject for OperatorFloorDiv {
|
|||
|
||||
#[pyclass(module="rustpython_ast.ranged", name="_unaryop", extends=super::Ast, frozen, subclass)]
|
||||
#[derive(Clone, Debug)]
|
||||
pub struct Unaryop;
|
||||
pub struct UnaryOp;
|
||||
|
||||
impl From<&'static ast::Unaryop> for Unaryop {
|
||||
fn from(_node: &'static ast::Unaryop) -> Self {
|
||||
Unaryop
|
||||
impl From<&'static ast::UnaryOp> for UnaryOp {
|
||||
fn from(_node: &'static ast::UnaryOp) -> Self {
|
||||
UnaryOp
|
||||
}
|
||||
}
|
||||
|
||||
#[pymethods]
|
||||
impl Unaryop {
|
||||
impl UnaryOp {
|
||||
#[new]
|
||||
fn new() -> PyClassInitializer<Self> {
|
||||
PyClassInitializer::from(Ast).add_subclass(Self)
|
||||
}
|
||||
}
|
||||
impl ToPyObject for Unaryop {
|
||||
impl ToPyObject for UnaryOp {
|
||||
fn to_object(&self, py: Python) -> PyObject {
|
||||
let initializer = Self::new();
|
||||
Py::new(py, initializer).unwrap().into_py(py)
|
||||
}
|
||||
}
|
||||
|
||||
#[pyclass(module="rustpython_ast.ranged", name="_Invert", extends=Unaryop)]
|
||||
pub struct UnaryopInvert;
|
||||
#[pyclass(module="rustpython_ast.ranged", name="_Invert", extends=UnaryOp)]
|
||||
pub struct UnaryOpInvert;
|
||||
|
||||
impl ToPyObject for UnaryopInvert {
|
||||
impl ToPyObject for UnaryOpInvert {
|
||||
fn to_object(&self, py: Python) -> PyObject {
|
||||
let initializer = PyClassInitializer::from(Ast)
|
||||
.add_subclass(Unaryop)
|
||||
.add_subclass(UnaryOp)
|
||||
.add_subclass(Self);
|
||||
Py::new(py, initializer).unwrap().into_py(py)
|
||||
}
|
||||
}
|
||||
|
||||
#[pyclass(module="rustpython_ast.ranged", name="_Not", extends=Unaryop)]
|
||||
pub struct UnaryopNot;
|
||||
#[pyclass(module="rustpython_ast.ranged", name="_Not", extends=UnaryOp)]
|
||||
pub struct UnaryOpNot;
|
||||
|
||||
impl ToPyObject for UnaryopNot {
|
||||
impl ToPyObject for UnaryOpNot {
|
||||
fn to_object(&self, py: Python) -> PyObject {
|
||||
let initializer = PyClassInitializer::from(Ast)
|
||||
.add_subclass(Unaryop)
|
||||
.add_subclass(UnaryOp)
|
||||
.add_subclass(Self);
|
||||
Py::new(py, initializer).unwrap().into_py(py)
|
||||
}
|
||||
}
|
||||
|
||||
#[pyclass(module="rustpython_ast.ranged", name="_UAdd", extends=Unaryop)]
|
||||
pub struct UnaryopUAdd;
|
||||
#[pyclass(module="rustpython_ast.ranged", name="_UAdd", extends=UnaryOp)]
|
||||
pub struct UnaryOpUAdd;
|
||||
|
||||
impl ToPyObject for UnaryopUAdd {
|
||||
impl ToPyObject for UnaryOpUAdd {
|
||||
fn to_object(&self, py: Python) -> PyObject {
|
||||
let initializer = PyClassInitializer::from(Ast)
|
||||
.add_subclass(Unaryop)
|
||||
.add_subclass(UnaryOp)
|
||||
.add_subclass(Self);
|
||||
Py::new(py, initializer).unwrap().into_py(py)
|
||||
}
|
||||
}
|
||||
|
||||
#[pyclass(module="rustpython_ast.ranged", name="_USub", extends=Unaryop)]
|
||||
pub struct UnaryopUSub;
|
||||
#[pyclass(module="rustpython_ast.ranged", name="_USub", extends=UnaryOp)]
|
||||
pub struct UnaryOpUSub;
|
||||
|
||||
impl ToPyObject for UnaryopUSub {
|
||||
impl ToPyObject for UnaryOpUSub {
|
||||
fn to_object(&self, py: Python) -> PyObject {
|
||||
let initializer = PyClassInitializer::from(Ast)
|
||||
.add_subclass(Unaryop)
|
||||
.add_subclass(UnaryOp)
|
||||
.add_subclass(Self);
|
||||
Py::new(py, initializer).unwrap().into_py(py)
|
||||
}
|
||||
|
@ -3014,143 +3014,143 @@ impl ToPyObject for UnaryopUSub {
|
|||
|
||||
#[pyclass(module="rustpython_ast.ranged", name="_cmpop", extends=super::Ast, frozen, subclass)]
|
||||
#[derive(Clone, Debug)]
|
||||
pub struct Cmpop;
|
||||
pub struct CmpOp;
|
||||
|
||||
impl From<&'static ast::Cmpop> for Cmpop {
|
||||
fn from(_node: &'static ast::Cmpop) -> Self {
|
||||
Cmpop
|
||||
impl From<&'static ast::CmpOp> for CmpOp {
|
||||
fn from(_node: &'static ast::CmpOp) -> Self {
|
||||
CmpOp
|
||||
}
|
||||
}
|
||||
|
||||
#[pymethods]
|
||||
impl Cmpop {
|
||||
impl CmpOp {
|
||||
#[new]
|
||||
fn new() -> PyClassInitializer<Self> {
|
||||
PyClassInitializer::from(Ast).add_subclass(Self)
|
||||
}
|
||||
}
|
||||
impl ToPyObject for Cmpop {
|
||||
impl ToPyObject for CmpOp {
|
||||
fn to_object(&self, py: Python) -> PyObject {
|
||||
let initializer = Self::new();
|
||||
Py::new(py, initializer).unwrap().into_py(py)
|
||||
}
|
||||
}
|
||||
|
||||
#[pyclass(module="rustpython_ast.ranged", name="_Eq", extends=Cmpop)]
|
||||
pub struct CmpopEq;
|
||||
#[pyclass(module="rustpython_ast.ranged", name="_Eq", extends=CmpOp)]
|
||||
pub struct CmpOpEq;
|
||||
|
||||
impl ToPyObject for CmpopEq {
|
||||
impl ToPyObject for CmpOpEq {
|
||||
fn to_object(&self, py: Python) -> PyObject {
|
||||
let initializer = PyClassInitializer::from(Ast)
|
||||
.add_subclass(Cmpop)
|
||||
.add_subclass(CmpOp)
|
||||
.add_subclass(Self);
|
||||
Py::new(py, initializer).unwrap().into_py(py)
|
||||
}
|
||||
}
|
||||
|
||||
#[pyclass(module="rustpython_ast.ranged", name="_NotEq", extends=Cmpop)]
|
||||
pub struct CmpopNotEq;
|
||||
#[pyclass(module="rustpython_ast.ranged", name="_NotEq", extends=CmpOp)]
|
||||
pub struct CmpOpNotEq;
|
||||
|
||||
impl ToPyObject for CmpopNotEq {
|
||||
impl ToPyObject for CmpOpNotEq {
|
||||
fn to_object(&self, py: Python) -> PyObject {
|
||||
let initializer = PyClassInitializer::from(Ast)
|
||||
.add_subclass(Cmpop)
|
||||
.add_subclass(CmpOp)
|
||||
.add_subclass(Self);
|
||||
Py::new(py, initializer).unwrap().into_py(py)
|
||||
}
|
||||
}
|
||||
|
||||
#[pyclass(module="rustpython_ast.ranged", name="_Lt", extends=Cmpop)]
|
||||
pub struct CmpopLt;
|
||||
#[pyclass(module="rustpython_ast.ranged", name="_Lt", extends=CmpOp)]
|
||||
pub struct CmpOpLt;
|
||||
|
||||
impl ToPyObject for CmpopLt {
|
||||
impl ToPyObject for CmpOpLt {
|
||||
fn to_object(&self, py: Python) -> PyObject {
|
||||
let initializer = PyClassInitializer::from(Ast)
|
||||
.add_subclass(Cmpop)
|
||||
.add_subclass(CmpOp)
|
||||
.add_subclass(Self);
|
||||
Py::new(py, initializer).unwrap().into_py(py)
|
||||
}
|
||||
}
|
||||
|
||||
#[pyclass(module="rustpython_ast.ranged", name="_LtE", extends=Cmpop)]
|
||||
pub struct CmpopLtE;
|
||||
#[pyclass(module="rustpython_ast.ranged", name="_LtE", extends=CmpOp)]
|
||||
pub struct CmpOpLtE;
|
||||
|
||||
impl ToPyObject for CmpopLtE {
|
||||
impl ToPyObject for CmpOpLtE {
|
||||
fn to_object(&self, py: Python) -> PyObject {
|
||||
let initializer = PyClassInitializer::from(Ast)
|
||||
.add_subclass(Cmpop)
|
||||
.add_subclass(CmpOp)
|
||||
.add_subclass(Self);
|
||||
Py::new(py, initializer).unwrap().into_py(py)
|
||||
}
|
||||
}
|
||||
|
||||
#[pyclass(module="rustpython_ast.ranged", name="_Gt", extends=Cmpop)]
|
||||
pub struct CmpopGt;
|
||||
#[pyclass(module="rustpython_ast.ranged", name="_Gt", extends=CmpOp)]
|
||||
pub struct CmpOpGt;
|
||||
|
||||
impl ToPyObject for CmpopGt {
|
||||
impl ToPyObject for CmpOpGt {
|
||||
fn to_object(&self, py: Python) -> PyObject {
|
||||
let initializer = PyClassInitializer::from(Ast)
|
||||
.add_subclass(Cmpop)
|
||||
.add_subclass(CmpOp)
|
||||
.add_subclass(Self);
|
||||
Py::new(py, initializer).unwrap().into_py(py)
|
||||
}
|
||||
}
|
||||
|
||||
#[pyclass(module="rustpython_ast.ranged", name="_GtE", extends=Cmpop)]
|
||||
pub struct CmpopGtE;
|
||||
#[pyclass(module="rustpython_ast.ranged", name="_GtE", extends=CmpOp)]
|
||||
pub struct CmpOpGtE;
|
||||
|
||||
impl ToPyObject for CmpopGtE {
|
||||
impl ToPyObject for CmpOpGtE {
|
||||
fn to_object(&self, py: Python) -> PyObject {
|
||||
let initializer = PyClassInitializer::from(Ast)
|
||||
.add_subclass(Cmpop)
|
||||
.add_subclass(CmpOp)
|
||||
.add_subclass(Self);
|
||||
Py::new(py, initializer).unwrap().into_py(py)
|
||||
}
|
||||
}
|
||||
|
||||
#[pyclass(module="rustpython_ast.ranged", name="_Is", extends=Cmpop)]
|
||||
pub struct CmpopIs;
|
||||
#[pyclass(module="rustpython_ast.ranged", name="_Is", extends=CmpOp)]
|
||||
pub struct CmpOpIs;
|
||||
|
||||
impl ToPyObject for CmpopIs {
|
||||
impl ToPyObject for CmpOpIs {
|
||||
fn to_object(&self, py: Python) -> PyObject {
|
||||
let initializer = PyClassInitializer::from(Ast)
|
||||
.add_subclass(Cmpop)
|
||||
.add_subclass(CmpOp)
|
||||
.add_subclass(Self);
|
||||
Py::new(py, initializer).unwrap().into_py(py)
|
||||
}
|
||||
}
|
||||
|
||||
#[pyclass(module="rustpython_ast.ranged", name="_IsNot", extends=Cmpop)]
|
||||
pub struct CmpopIsNot;
|
||||
#[pyclass(module="rustpython_ast.ranged", name="_IsNot", extends=CmpOp)]
|
||||
pub struct CmpOpIsNot;
|
||||
|
||||
impl ToPyObject for CmpopIsNot {
|
||||
impl ToPyObject for CmpOpIsNot {
|
||||
fn to_object(&self, py: Python) -> PyObject {
|
||||
let initializer = PyClassInitializer::from(Ast)
|
||||
.add_subclass(Cmpop)
|
||||
.add_subclass(CmpOp)
|
||||
.add_subclass(Self);
|
||||
Py::new(py, initializer).unwrap().into_py(py)
|
||||
}
|
||||
}
|
||||
|
||||
#[pyclass(module="rustpython_ast.ranged", name="_In", extends=Cmpop)]
|
||||
pub struct CmpopIn;
|
||||
#[pyclass(module="rustpython_ast.ranged", name="_In", extends=CmpOp)]
|
||||
pub struct CmpOpIn;
|
||||
|
||||
impl ToPyObject for CmpopIn {
|
||||
impl ToPyObject for CmpOpIn {
|
||||
fn to_object(&self, py: Python) -> PyObject {
|
||||
let initializer = PyClassInitializer::from(Ast)
|
||||
.add_subclass(Cmpop)
|
||||
.add_subclass(CmpOp)
|
||||
.add_subclass(Self);
|
||||
Py::new(py, initializer).unwrap().into_py(py)
|
||||
}
|
||||
}
|
||||
|
||||
#[pyclass(module="rustpython_ast.ranged", name="_NotIn", extends=Cmpop)]
|
||||
pub struct CmpopNotIn;
|
||||
#[pyclass(module="rustpython_ast.ranged", name="_NotIn", extends=CmpOp)]
|
||||
pub struct CmpOpNotIn;
|
||||
|
||||
impl ToPyObject for CmpopNotIn {
|
||||
impl ToPyObject for CmpOpNotIn {
|
||||
fn to_object(&self, py: Python) -> PyObject {
|
||||
let initializer = PyClassInitializer::from(Ast)
|
||||
.add_subclass(Cmpop)
|
||||
.add_subclass(CmpOp)
|
||||
.add_subclass(Self);
|
||||
Py::new(py, initializer).unwrap().into_py(py)
|
||||
}
|
||||
|
@ -3209,29 +3209,29 @@ impl Comprehension {
|
|||
|
||||
#[pyclass(module="rustpython_ast.ranged", name="_excepthandler", extends=super::Ast, frozen, subclass)]
|
||||
#[derive(Clone, Debug)]
|
||||
pub struct Excepthandler;
|
||||
pub struct ExceptHandler;
|
||||
|
||||
impl From<&'static ast::Excepthandler<TextRange>> for Excepthandler {
|
||||
fn from(_node: &'static ast::Excepthandler<TextRange>) -> Self {
|
||||
Excepthandler
|
||||
impl From<&'static ast::ExceptHandler<TextRange>> for ExceptHandler {
|
||||
fn from(_node: &'static ast::ExceptHandler<TextRange>) -> Self {
|
||||
ExceptHandler
|
||||
}
|
||||
}
|
||||
|
||||
#[pymethods]
|
||||
impl Excepthandler {
|
||||
impl ExceptHandler {
|
||||
#[new]
|
||||
fn new() -> PyClassInitializer<Self> {
|
||||
PyClassInitializer::from(Ast).add_subclass(Self)
|
||||
}
|
||||
}
|
||||
impl ToPyObject for Excepthandler {
|
||||
impl ToPyObject for ExceptHandler {
|
||||
fn to_object(&self, py: Python) -> PyObject {
|
||||
let initializer = Self::new();
|
||||
Py::new(py, initializer).unwrap().into_py(py)
|
||||
}
|
||||
}
|
||||
|
||||
impl ToPyWrapper for ast::Excepthandler<TextRange> {
|
||||
impl ToPyWrapper for ast::ExceptHandler<TextRange> {
|
||||
#[inline]
|
||||
fn to_py_wrapper(&'static self, py: Python) -> PyResult<Py<PyAny>> {
|
||||
match &self {
|
||||
|
@ -3240,34 +3240,34 @@ impl ToPyWrapper for ast::Excepthandler<TextRange> {
|
|||
}
|
||||
}
|
||||
|
||||
#[pyclass(module="rustpython_ast.ranged", name="_ExceptHandler", extends=Excepthandler, frozen)]
|
||||
#[pyclass(module="rustpython_ast.ranged", name="_ExceptHandler", extends=ExceptHandler, frozen)]
|
||||
#[derive(Clone, Debug)]
|
||||
pub struct ExcepthandlerExceptHandler(pub &'static ast::ExcepthandlerExceptHandler<TextRange>);
|
||||
pub struct ExceptHandlerExceptHandler(pub &'static ast::ExceptHandlerExceptHandler<TextRange>);
|
||||
|
||||
impl From<&'static ast::ExcepthandlerExceptHandler<TextRange>> for ExcepthandlerExceptHandler {
|
||||
fn from(node: &'static ast::ExcepthandlerExceptHandler<TextRange>) -> Self {
|
||||
ExcepthandlerExceptHandler(node)
|
||||
impl From<&'static ast::ExceptHandlerExceptHandler<TextRange>> for ExceptHandlerExceptHandler {
|
||||
fn from(node: &'static ast::ExceptHandlerExceptHandler<TextRange>) -> Self {
|
||||
ExceptHandlerExceptHandler(node)
|
||||
}
|
||||
}
|
||||
|
||||
impl ToPyObject for ExcepthandlerExceptHandler {
|
||||
impl ToPyObject for ExceptHandlerExceptHandler {
|
||||
fn to_object(&self, py: Python) -> PyObject {
|
||||
let initializer = PyClassInitializer::from(Ast)
|
||||
.add_subclass(Excepthandler)
|
||||
.add_subclass(ExceptHandler)
|
||||
.add_subclass(self.clone());
|
||||
Py::new(py, initializer).unwrap().into_py(py)
|
||||
}
|
||||
}
|
||||
|
||||
impl ToPyWrapper for ast::ExcepthandlerExceptHandler<TextRange> {
|
||||
impl ToPyWrapper for ast::ExceptHandlerExceptHandler<TextRange> {
|
||||
#[inline]
|
||||
fn to_py_wrapper(&'static self, py: Python) -> PyResult<Py<PyAny>> {
|
||||
Ok(ExcepthandlerExceptHandler(self).to_object(py))
|
||||
Ok(ExceptHandlerExceptHandler(self).to_object(py))
|
||||
}
|
||||
}
|
||||
|
||||
#[pymethods]
|
||||
impl ExcepthandlerExceptHandler {
|
||||
impl ExceptHandlerExceptHandler {
|
||||
#[getter]
|
||||
#[inline]
|
||||
fn get_type(&self, py: Python) -> PyResult<PyObject> {
|
||||
|
@ -3481,30 +3481,30 @@ impl Alias {
|
|||
|
||||
#[pyclass(module="rustpython_ast.ranged", name="_withitem", extends=super::Ast, frozen)]
|
||||
#[derive(Clone, Debug)]
|
||||
pub struct Withitem(pub &'static ast::Withitem<TextRange>);
|
||||
pub struct WithItem(pub &'static ast::WithItem<TextRange>);
|
||||
|
||||
impl From<&'static ast::Withitem<TextRange>> for Withitem {
|
||||
fn from(node: &'static ast::Withitem<TextRange>) -> Self {
|
||||
Withitem(node)
|
||||
impl From<&'static ast::WithItem<TextRange>> for WithItem {
|
||||
fn from(node: &'static ast::WithItem<TextRange>) -> Self {
|
||||
WithItem(node)
|
||||
}
|
||||
}
|
||||
|
||||
impl ToPyObject for Withitem {
|
||||
impl ToPyObject for WithItem {
|
||||
fn to_object(&self, py: Python) -> PyObject {
|
||||
let initializer = PyClassInitializer::from(Ast).add_subclass(self.clone());
|
||||
Py::new(py, initializer).unwrap().into_py(py)
|
||||
}
|
||||
}
|
||||
|
||||
impl ToPyWrapper for ast::Withitem<TextRange> {
|
||||
impl ToPyWrapper for ast::WithItem<TextRange> {
|
||||
#[inline]
|
||||
fn to_py_wrapper(&'static self, py: Python) -> PyResult<Py<PyAny>> {
|
||||
Ok(Withitem(self).to_object(py))
|
||||
Ok(WithItem(self).to_object(py))
|
||||
}
|
||||
}
|
||||
|
||||
#[pymethods]
|
||||
impl Withitem {
|
||||
impl WithItem {
|
||||
#[getter]
|
||||
#[inline]
|
||||
fn get_context_expr(&self, py: Python) -> PyResult<PyObject> {
|
||||
|
@ -4060,9 +4060,9 @@ pub fn add_to_module(py: Python, m: &PyModule) -> PyResult<()> {
|
|||
super::init_type::<ExprContextLoad, ast::ExprContextLoad>(py, m)?;
|
||||
super::init_type::<ExprContextStore, ast::ExprContextStore>(py, m)?;
|
||||
super::init_type::<ExprContextDel, ast::ExprContextDel>(py, m)?;
|
||||
super::init_type::<Boolop, ast::Boolop>(py, m)?;
|
||||
super::init_type::<BoolopAnd, ast::BoolopAnd>(py, m)?;
|
||||
super::init_type::<BoolopOr, ast::BoolopOr>(py, m)?;
|
||||
super::init_type::<BoolOp, ast::BoolOp>(py, m)?;
|
||||
super::init_type::<BoolOpAnd, ast::BoolOpAnd>(py, m)?;
|
||||
super::init_type::<BoolOpOr, ast::BoolOpOr>(py, m)?;
|
||||
super::init_type::<Operator, ast::Operator>(py, m)?;
|
||||
super::init_type::<OperatorAdd, ast::OperatorAdd>(py, m)?;
|
||||
super::init_type::<OperatorSub, ast::OperatorSub>(py, m)?;
|
||||
|
@ -4077,30 +4077,30 @@ pub fn add_to_module(py: Python, m: &PyModule) -> PyResult<()> {
|
|||
super::init_type::<OperatorBitXor, ast::OperatorBitXor>(py, m)?;
|
||||
super::init_type::<OperatorBitAnd, ast::OperatorBitAnd>(py, m)?;
|
||||
super::init_type::<OperatorFloorDiv, ast::OperatorFloorDiv>(py, m)?;
|
||||
super::init_type::<Unaryop, ast::Unaryop>(py, m)?;
|
||||
super::init_type::<UnaryopInvert, ast::UnaryopInvert>(py, m)?;
|
||||
super::init_type::<UnaryopNot, ast::UnaryopNot>(py, m)?;
|
||||
super::init_type::<UnaryopUAdd, ast::UnaryopUAdd>(py, m)?;
|
||||
super::init_type::<UnaryopUSub, ast::UnaryopUSub>(py, m)?;
|
||||
super::init_type::<Cmpop, ast::Cmpop>(py, m)?;
|
||||
super::init_type::<CmpopEq, ast::CmpopEq>(py, m)?;
|
||||
super::init_type::<CmpopNotEq, ast::CmpopNotEq>(py, m)?;
|
||||
super::init_type::<CmpopLt, ast::CmpopLt>(py, m)?;
|
||||
super::init_type::<CmpopLtE, ast::CmpopLtE>(py, m)?;
|
||||
super::init_type::<CmpopGt, ast::CmpopGt>(py, m)?;
|
||||
super::init_type::<CmpopGtE, ast::CmpopGtE>(py, m)?;
|
||||
super::init_type::<CmpopIs, ast::CmpopIs>(py, m)?;
|
||||
super::init_type::<CmpopIsNot, ast::CmpopIsNot>(py, m)?;
|
||||
super::init_type::<CmpopIn, ast::CmpopIn>(py, m)?;
|
||||
super::init_type::<CmpopNotIn, ast::CmpopNotIn>(py, m)?;
|
||||
super::init_type::<UnaryOp, ast::UnaryOp>(py, m)?;
|
||||
super::init_type::<UnaryOpInvert, ast::UnaryOpInvert>(py, m)?;
|
||||
super::init_type::<UnaryOpNot, ast::UnaryOpNot>(py, m)?;
|
||||
super::init_type::<UnaryOpUAdd, ast::UnaryOpUAdd>(py, m)?;
|
||||
super::init_type::<UnaryOpUSub, ast::UnaryOpUSub>(py, m)?;
|
||||
super::init_type::<CmpOp, ast::CmpOp>(py, m)?;
|
||||
super::init_type::<CmpOpEq, ast::CmpOpEq>(py, m)?;
|
||||
super::init_type::<CmpOpNotEq, ast::CmpOpNotEq>(py, m)?;
|
||||
super::init_type::<CmpOpLt, ast::CmpOpLt>(py, m)?;
|
||||
super::init_type::<CmpOpLtE, ast::CmpOpLtE>(py, m)?;
|
||||
super::init_type::<CmpOpGt, ast::CmpOpGt>(py, m)?;
|
||||
super::init_type::<CmpOpGtE, ast::CmpOpGtE>(py, m)?;
|
||||
super::init_type::<CmpOpIs, ast::CmpOpIs>(py, m)?;
|
||||
super::init_type::<CmpOpIsNot, ast::CmpOpIsNot>(py, m)?;
|
||||
super::init_type::<CmpOpIn, ast::CmpOpIn>(py, m)?;
|
||||
super::init_type::<CmpOpNotIn, ast::CmpOpNotIn>(py, m)?;
|
||||
super::init_type::<Comprehension, ast::Comprehension>(py, m)?;
|
||||
super::init_type::<Excepthandler, ast::Excepthandler>(py, m)?;
|
||||
super::init_type::<ExcepthandlerExceptHandler, ast::ExcepthandlerExceptHandler>(py, m)?;
|
||||
super::init_type::<ExceptHandler, ast::ExceptHandler>(py, m)?;
|
||||
super::init_type::<ExceptHandlerExceptHandler, ast::ExceptHandlerExceptHandler>(py, m)?;
|
||||
super::init_type::<Arguments, ast::PythonArguments>(py, m)?;
|
||||
super::init_type::<Arg, ast::Arg>(py, m)?;
|
||||
super::init_type::<Keyword, ast::Keyword>(py, m)?;
|
||||
super::init_type::<Alias, ast::Alias>(py, m)?;
|
||||
super::init_type::<Withitem, ast::Withitem>(py, m)?;
|
||||
super::init_type::<WithItem, ast::WithItem>(py, m)?;
|
||||
super::init_type::<MatchCase, ast::MatchCase>(py, m)?;
|
||||
super::init_type::<Pattern, ast::Pattern>(py, m)?;
|
||||
super::init_type::<PatternMatchValue, ast::PatternMatchValue>(py, m)?;
|
||||
|
|
|
@ -31,6 +31,14 @@ BUILTIN_INT_NAMES = {
|
|||
"conversion": "ConversionFlag",
|
||||
}
|
||||
|
||||
RENAME_MAP = {
|
||||
"cmpop": "cmp_op",
|
||||
"unaryop": "unary_op",
|
||||
"boolop": "bool_op",
|
||||
"excepthandler": "except_handler",
|
||||
"withitem": "with_item",
|
||||
}
|
||||
|
||||
RUST_KEYWORDS = {
|
||||
"if",
|
||||
"while",
|
||||
|
@ -124,6 +132,7 @@ def rust_type_name(name):
|
|||
|
||||
This function special cases the default types provided by asdl.
|
||||
"""
|
||||
name = RENAME_MAP.get(name, name)
|
||||
if name in asdl.builtin_types:
|
||||
builtin = BUILTIN_TYPE_NAMES[name]
|
||||
return builtin
|
||||
|
@ -444,7 +453,9 @@ class StructVisitor(EmitVisitor):
|
|||
def visitType(self, type, depth=0):
|
||||
if hasattr(type, "doc"):
|
||||
doc = "/// " + type.doc.replace("\n", "\n/// ") + "\n"
|
||||
self.emit(doc, depth)
|
||||
else:
|
||||
doc = f"/// See also [{type.name}](https://docs.python.org/3/library/ast.html#ast.{type.name})"
|
||||
self.emit(doc, depth)
|
||||
self.visit(type.value, type, depth)
|
||||
|
||||
def visitSum(self, sum, type, depth):
|
||||
|
@ -525,11 +536,6 @@ class StructVisitor(EmitVisitor):
|
|||
def sum_with_constructors(self, sum, type, depth):
|
||||
type_info = self.type_info[type.name]
|
||||
rust_name = rust_type_name(type.name)
|
||||
# all the attributes right now are for location, so if it has attrs we
|
||||
# can just wrap it in Attributed<>
|
||||
|
||||
for t in sum.types:
|
||||
self.sum_subtype_struct(type_info, t, rust_name, depth)
|
||||
|
||||
self.emit_attrs(depth)
|
||||
self.emit("#[derive(is_macro::Is)]", depth)
|
||||
|
@ -545,7 +551,12 @@ class StructVisitor(EmitVisitor):
|
|||
self.emit("}", depth)
|
||||
self.emit("", depth)
|
||||
|
||||
for t in sum.types:
|
||||
self.sum_subtype_struct(type_info, t, rust_name, depth)
|
||||
|
||||
|
||||
def sum_subtype_struct(self, sum_type_info, t, rust_name, depth):
|
||||
self.emit(f"""/// See also [{t.name}](https://docs.python.org/3/library/ast.html#ast.{t.name})""", depth)
|
||||
self.emit_attrs(depth)
|
||||
payload_name = f"{rust_name}{t.name}"
|
||||
self.emit(f"pub struct {payload_name}<R = TextRange> {{", depth)
|
||||
|
|
|
@ -390,16 +390,16 @@ pub trait Fold<U> {
|
|||
fn fold_expr_context(&mut self, node: ExprContext) -> Result<ExprContext, Self::Error> {
|
||||
fold_expr_context(self, node)
|
||||
}
|
||||
fn fold_boolop(&mut self, node: Boolop) -> Result<Boolop, Self::Error> {
|
||||
fn fold_boolop(&mut self, node: BoolOp) -> Result<BoolOp, Self::Error> {
|
||||
fold_boolop(self, node)
|
||||
}
|
||||
fn fold_operator(&mut self, node: Operator) -> Result<Operator, Self::Error> {
|
||||
fold_operator(self, node)
|
||||
}
|
||||
fn fold_unaryop(&mut self, node: Unaryop) -> Result<Unaryop, Self::Error> {
|
||||
fn fold_unaryop(&mut self, node: UnaryOp) -> Result<UnaryOp, Self::Error> {
|
||||
fold_unaryop(self, node)
|
||||
}
|
||||
fn fold_cmpop(&mut self, node: Cmpop) -> Result<Cmpop, Self::Error> {
|
||||
fn fold_cmpop(&mut self, node: CmpOp) -> Result<CmpOp, Self::Error> {
|
||||
fold_cmpop(self, node)
|
||||
}
|
||||
fn fold_comprehension(
|
||||
|
@ -410,14 +410,14 @@ pub trait Fold<U> {
|
|||
}
|
||||
fn fold_excepthandler(
|
||||
&mut self,
|
||||
node: Excepthandler<U>,
|
||||
) -> Result<Excepthandler<Self::TargetU>, Self::Error> {
|
||||
node: ExceptHandler<U>,
|
||||
) -> Result<ExceptHandler<Self::TargetU>, Self::Error> {
|
||||
fold_excepthandler(self, node)
|
||||
}
|
||||
fn fold_excepthandler_except_handler(
|
||||
&mut self,
|
||||
node: ExcepthandlerExceptHandler<U>,
|
||||
) -> Result<ExcepthandlerExceptHandler<Self::TargetU>, Self::Error> {
|
||||
node: ExceptHandlerExceptHandler<U>,
|
||||
) -> Result<ExceptHandlerExceptHandler<Self::TargetU>, Self::Error> {
|
||||
fold_excepthandler_except_handler(self, node)
|
||||
}
|
||||
fn fold_arguments(
|
||||
|
@ -435,7 +435,7 @@ pub trait Fold<U> {
|
|||
fn fold_alias(&mut self, node: Alias<U>) -> Result<Alias<Self::TargetU>, Self::Error> {
|
||||
fold_alias(self, node)
|
||||
}
|
||||
fn fold_withitem(&mut self, node: Withitem<U>) -> Result<Withitem<Self::TargetU>, Self::Error> {
|
||||
fn fold_withitem(&mut self, node: WithItem<U>) -> Result<WithItem<Self::TargetU>, Self::Error> {
|
||||
fold_withitem(self, node)
|
||||
}
|
||||
fn fold_match_case(
|
||||
|
@ -2210,8 +2210,8 @@ pub fn fold_expr_context<U, F: Fold<U> + ?Sized>(
|
|||
) -> Result<ExprContext, F::Error> {
|
||||
Ok(node)
|
||||
}
|
||||
impl<T, U> Foldable<T, U> for Boolop {
|
||||
type Mapped = Boolop;
|
||||
impl<T, U> Foldable<T, U> for BoolOp {
|
||||
type Mapped = BoolOp;
|
||||
fn fold<F: Fold<T, TargetU = U> + ?Sized>(
|
||||
self,
|
||||
folder: &mut F,
|
||||
|
@ -2221,8 +2221,8 @@ impl<T, U> Foldable<T, U> for Boolop {
|
|||
}
|
||||
pub fn fold_boolop<U, F: Fold<U> + ?Sized>(
|
||||
#[allow(unused)] folder: &mut F,
|
||||
node: Boolop,
|
||||
) -> Result<Boolop, F::Error> {
|
||||
node: BoolOp,
|
||||
) -> Result<BoolOp, F::Error> {
|
||||
Ok(node)
|
||||
}
|
||||
impl<T, U> Foldable<T, U> for Operator {
|
||||
|
@ -2240,8 +2240,8 @@ pub fn fold_operator<U, F: Fold<U> + ?Sized>(
|
|||
) -> Result<Operator, F::Error> {
|
||||
Ok(node)
|
||||
}
|
||||
impl<T, U> Foldable<T, U> for Unaryop {
|
||||
type Mapped = Unaryop;
|
||||
impl<T, U> Foldable<T, U> for UnaryOp {
|
||||
type Mapped = UnaryOp;
|
||||
fn fold<F: Fold<T, TargetU = U> + ?Sized>(
|
||||
self,
|
||||
folder: &mut F,
|
||||
|
@ -2251,12 +2251,12 @@ impl<T, U> Foldable<T, U> for Unaryop {
|
|||
}
|
||||
pub fn fold_unaryop<U, F: Fold<U> + ?Sized>(
|
||||
#[allow(unused)] folder: &mut F,
|
||||
node: Unaryop,
|
||||
) -> Result<Unaryop, F::Error> {
|
||||
node: UnaryOp,
|
||||
) -> Result<UnaryOp, F::Error> {
|
||||
Ok(node)
|
||||
}
|
||||
impl<T, U> Foldable<T, U> for Cmpop {
|
||||
type Mapped = Cmpop;
|
||||
impl<T, U> Foldable<T, U> for CmpOp {
|
||||
type Mapped = CmpOp;
|
||||
fn fold<F: Fold<T, TargetU = U> + ?Sized>(
|
||||
self,
|
||||
folder: &mut F,
|
||||
|
@ -2266,8 +2266,8 @@ impl<T, U> Foldable<T, U> for Cmpop {
|
|||
}
|
||||
pub fn fold_cmpop<U, F: Fold<U> + ?Sized>(
|
||||
#[allow(unused)] folder: &mut F,
|
||||
node: Cmpop,
|
||||
) -> Result<Cmpop, F::Error> {
|
||||
node: CmpOp,
|
||||
) -> Result<CmpOp, F::Error> {
|
||||
Ok(node)
|
||||
}
|
||||
impl<T, U> Foldable<T, U> for Comprehension<T> {
|
||||
|
@ -2304,8 +2304,8 @@ pub fn fold_comprehension<U, F: Fold<U> + ?Sized>(
|
|||
range,
|
||||
})
|
||||
}
|
||||
impl<T, U> Foldable<T, U> for Excepthandler<T> {
|
||||
type Mapped = Excepthandler<U>;
|
||||
impl<T, U> Foldable<T, U> for ExceptHandler<T> {
|
||||
type Mapped = ExceptHandler<U>;
|
||||
fn fold<F: Fold<T, TargetU = U> + ?Sized>(
|
||||
self,
|
||||
folder: &mut F,
|
||||
|
@ -2315,17 +2315,17 @@ impl<T, U> Foldable<T, U> for Excepthandler<T> {
|
|||
}
|
||||
pub fn fold_excepthandler<U, F: Fold<U> + ?Sized>(
|
||||
#[allow(unused)] folder: &mut F,
|
||||
node: Excepthandler<U>,
|
||||
) -> Result<Excepthandler<F::TargetU>, F::Error> {
|
||||
node: ExceptHandler<U>,
|
||||
) -> Result<ExceptHandler<F::TargetU>, F::Error> {
|
||||
let folded = match node {
|
||||
Excepthandler::ExceptHandler(cons) => {
|
||||
Excepthandler::ExceptHandler(Foldable::fold(cons, folder)?)
|
||||
ExceptHandler::ExceptHandler(cons) => {
|
||||
ExceptHandler::ExceptHandler(Foldable::fold(cons, folder)?)
|
||||
}
|
||||
};
|
||||
Ok(folded)
|
||||
}
|
||||
impl<T, U> Foldable<T, U> for ExcepthandlerExceptHandler<T> {
|
||||
type Mapped = ExcepthandlerExceptHandler<U>;
|
||||
impl<T, U> Foldable<T, U> for ExceptHandlerExceptHandler<T> {
|
||||
type Mapped = ExceptHandlerExceptHandler<U>;
|
||||
fn fold<F: Fold<T, TargetU = U> + ?Sized>(
|
||||
self,
|
||||
folder: &mut F,
|
||||
|
@ -2335,9 +2335,9 @@ impl<T, U> Foldable<T, U> for ExcepthandlerExceptHandler<T> {
|
|||
}
|
||||
pub fn fold_excepthandler_except_handler<U, F: Fold<U> + ?Sized>(
|
||||
#[allow(unused)] folder: &mut F,
|
||||
node: ExcepthandlerExceptHandler<U>,
|
||||
) -> Result<ExcepthandlerExceptHandler<F::TargetU>, F::Error> {
|
||||
let ExcepthandlerExceptHandler {
|
||||
node: ExceptHandlerExceptHandler<U>,
|
||||
) -> Result<ExceptHandlerExceptHandler<F::TargetU>, F::Error> {
|
||||
let ExceptHandlerExceptHandler {
|
||||
type_,
|
||||
name,
|
||||
body,
|
||||
|
@ -2349,7 +2349,7 @@ pub fn fold_excepthandler_except_handler<U, F: Fold<U> + ?Sized>(
|
|||
let name = Foldable::fold(name, folder)?;
|
||||
let body = Foldable::fold(body, folder)?;
|
||||
let range = folder.map_user(range, context)?;
|
||||
Ok(ExcepthandlerExceptHandler {
|
||||
Ok(ExceptHandlerExceptHandler {
|
||||
type_,
|
||||
name,
|
||||
body,
|
||||
|
@ -2472,8 +2472,8 @@ pub fn fold_alias<U, F: Fold<U> + ?Sized>(
|
|||
range,
|
||||
})
|
||||
}
|
||||
impl<T, U> Foldable<T, U> for Withitem<T> {
|
||||
type Mapped = Withitem<U>;
|
||||
impl<T, U> Foldable<T, U> for WithItem<T> {
|
||||
type Mapped = WithItem<U>;
|
||||
fn fold<F: Fold<T, TargetU = U> + ?Sized>(
|
||||
self,
|
||||
folder: &mut F,
|
||||
|
@ -2483,9 +2483,9 @@ impl<T, U> Foldable<T, U> for Withitem<T> {
|
|||
}
|
||||
pub fn fold_withitem<U, F: Fold<U> + ?Sized>(
|
||||
#[allow(unused)] folder: &mut F,
|
||||
node: Withitem<U>,
|
||||
) -> Result<Withitem<F::TargetU>, F::Error> {
|
||||
let Withitem {
|
||||
node: WithItem<U>,
|
||||
) -> Result<WithItem<F::TargetU>, F::Error> {
|
||||
let WithItem {
|
||||
context_expr,
|
||||
optional_vars,
|
||||
range,
|
||||
|
@ -2494,7 +2494,7 @@ pub fn fold_withitem<U, F: Fold<U> + ?Sized>(
|
|||
let context_expr = Foldable::fold(context_expr, folder)?;
|
||||
let optional_vars = Foldable::fold(optional_vars, folder)?;
|
||||
let range = folder.map_user_cfg(range, context)?;
|
||||
Ok(Withitem {
|
||||
Ok(WithItem {
|
||||
context_expr,
|
||||
optional_vars,
|
||||
range,
|
||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -989,11 +989,11 @@ pub type ExprContextStore = crate::generic::ExprContextStore;
|
|||
|
||||
pub type ExprContextDel = crate::generic::ExprContextDel;
|
||||
|
||||
pub type Boolop = crate::generic::Boolop;
|
||||
pub type BoolOp = crate::generic::BoolOp;
|
||||
|
||||
pub type BoolopAnd = crate::generic::BoolopAnd;
|
||||
pub type BoolOpAnd = crate::generic::BoolOpAnd;
|
||||
|
||||
pub type BoolopOr = crate::generic::BoolopOr;
|
||||
pub type BoolOpOr = crate::generic::BoolOpOr;
|
||||
|
||||
pub type Operator = crate::generic::Operator;
|
||||
|
||||
|
@ -1023,37 +1023,37 @@ pub type OperatorBitAnd = crate::generic::OperatorBitAnd;
|
|||
|
||||
pub type OperatorFloorDiv = crate::generic::OperatorFloorDiv;
|
||||
|
||||
pub type Unaryop = crate::generic::Unaryop;
|
||||
pub type UnaryOp = crate::generic::UnaryOp;
|
||||
|
||||
pub type UnaryopInvert = crate::generic::UnaryopInvert;
|
||||
pub type UnaryOpInvert = crate::generic::UnaryOpInvert;
|
||||
|
||||
pub type UnaryopNot = crate::generic::UnaryopNot;
|
||||
pub type UnaryOpNot = crate::generic::UnaryOpNot;
|
||||
|
||||
pub type UnaryopUAdd = crate::generic::UnaryopUAdd;
|
||||
pub type UnaryOpUAdd = crate::generic::UnaryOpUAdd;
|
||||
|
||||
pub type UnaryopUSub = crate::generic::UnaryopUSub;
|
||||
pub type UnaryOpUSub = crate::generic::UnaryOpUSub;
|
||||
|
||||
pub type Cmpop = crate::generic::Cmpop;
|
||||
pub type CmpOp = crate::generic::CmpOp;
|
||||
|
||||
pub type CmpopEq = crate::generic::CmpopEq;
|
||||
pub type CmpOpEq = crate::generic::CmpOpEq;
|
||||
|
||||
pub type CmpopNotEq = crate::generic::CmpopNotEq;
|
||||
pub type CmpOpNotEq = crate::generic::CmpOpNotEq;
|
||||
|
||||
pub type CmpopLt = crate::generic::CmpopLt;
|
||||
pub type CmpOpLt = crate::generic::CmpOpLt;
|
||||
|
||||
pub type CmpopLtE = crate::generic::CmpopLtE;
|
||||
pub type CmpOpLtE = crate::generic::CmpOpLtE;
|
||||
|
||||
pub type CmpopGt = crate::generic::CmpopGt;
|
||||
pub type CmpOpGt = crate::generic::CmpOpGt;
|
||||
|
||||
pub type CmpopGtE = crate::generic::CmpopGtE;
|
||||
pub type CmpOpGtE = crate::generic::CmpOpGtE;
|
||||
|
||||
pub type CmpopIs = crate::generic::CmpopIs;
|
||||
pub type CmpOpIs = crate::generic::CmpOpIs;
|
||||
|
||||
pub type CmpopIsNot = crate::generic::CmpopIsNot;
|
||||
pub type CmpOpIsNot = crate::generic::CmpOpIsNot;
|
||||
|
||||
pub type CmpopIn = crate::generic::CmpopIn;
|
||||
pub type CmpOpIn = crate::generic::CmpOpIn;
|
||||
|
||||
pub type CmpopNotIn = crate::generic::CmpopNotIn;
|
||||
pub type CmpOpNotIn = crate::generic::CmpOpNotIn;
|
||||
|
||||
pub type Comprehension = crate::generic::Comprehension<SourceRange>;
|
||||
|
||||
|
@ -1070,23 +1070,23 @@ impl LocatedMut for Comprehension {
|
|||
}
|
||||
}
|
||||
|
||||
pub type Excepthandler = crate::generic::Excepthandler<SourceRange>;
|
||||
pub type ExceptHandler = crate::generic::ExceptHandler<SourceRange>;
|
||||
|
||||
pub type ExcepthandlerExceptHandler = crate::generic::ExcepthandlerExceptHandler<SourceRange>;
|
||||
pub type ExceptHandlerExceptHandler = crate::generic::ExceptHandlerExceptHandler<SourceRange>;
|
||||
|
||||
impl Located for ExcepthandlerExceptHandler {
|
||||
impl Located for ExceptHandlerExceptHandler {
|
||||
fn range(&self) -> SourceRange {
|
||||
self.range
|
||||
}
|
||||
}
|
||||
|
||||
impl LocatedMut for ExcepthandlerExceptHandler {
|
||||
impl LocatedMut for ExceptHandlerExceptHandler {
|
||||
fn range_mut(&mut self) -> &mut SourceRange {
|
||||
&mut self.range
|
||||
}
|
||||
}
|
||||
|
||||
impl Located for Excepthandler {
|
||||
impl Located for ExceptHandler {
|
||||
fn range(&self) -> SourceRange {
|
||||
match self {
|
||||
Self::ExceptHandler(node) => node.range(),
|
||||
|
@ -1094,7 +1094,7 @@ impl Located for Excepthandler {
|
|||
}
|
||||
}
|
||||
|
||||
impl LocatedMut for Excepthandler {
|
||||
impl LocatedMut for ExceptHandler {
|
||||
fn range_mut(&mut self) -> &mut SourceRange {
|
||||
match self {
|
||||
Self::ExceptHandler(node) => node.range_mut(),
|
||||
|
@ -1159,16 +1159,16 @@ impl LocatedMut for Alias {
|
|||
}
|
||||
}
|
||||
|
||||
pub type Withitem = crate::generic::Withitem<SourceRange>;
|
||||
pub type WithItem = crate::generic::WithItem<SourceRange>;
|
||||
|
||||
#[cfg(feature = "all-nodes-with-ranges")]
|
||||
impl Located for Withitem {
|
||||
impl Located for WithItem {
|
||||
fn range(&self) -> SourceRange {
|
||||
self.range
|
||||
}
|
||||
}
|
||||
#[cfg(feature = "all-nodes-with-ranges")]
|
||||
impl LocatedMut for Withitem {
|
||||
impl LocatedMut for WithItem {
|
||||
fn range_mut(&mut self) -> &mut SourceRange {
|
||||
&mut self.range
|
||||
}
|
||||
|
|
|
@ -380,12 +380,12 @@ impl Ranged for crate::generic::Comprehension<TextRange> {
|
|||
self.range
|
||||
}
|
||||
}
|
||||
impl Ranged for crate::generic::ExcepthandlerExceptHandler<TextRange> {
|
||||
impl Ranged for crate::generic::ExceptHandlerExceptHandler<TextRange> {
|
||||
fn range(&self) -> TextRange {
|
||||
self.range
|
||||
}
|
||||
}
|
||||
impl Ranged for crate::Excepthandler {
|
||||
impl Ranged for crate::ExceptHandler {
|
||||
fn range(&self) -> TextRange {
|
||||
match self {
|
||||
Self::ExceptHandler(node) => node.range(),
|
||||
|
@ -415,7 +415,7 @@ impl Ranged for crate::generic::Alias<TextRange> {
|
|||
}
|
||||
}
|
||||
#[cfg(feature = "all-nodes-with-ranges")]
|
||||
impl Ranged for crate::generic::Withitem<TextRange> {
|
||||
impl Ranged for crate::generic::WithItem<TextRange> {
|
||||
fn range(&self) -> TextRange {
|
||||
self.range
|
||||
}
|
||||
|
|
|
@ -665,38 +665,38 @@ pub trait Visitor<R = crate::text_size::TextRange> {
|
|||
self.generic_visit_expr_context(node)
|
||||
}
|
||||
fn generic_visit_expr_context(&mut self, node: ExprContext) {}
|
||||
fn visit_boolop(&mut self, node: Boolop) {
|
||||
fn visit_boolop(&mut self, node: BoolOp) {
|
||||
self.generic_visit_boolop(node)
|
||||
}
|
||||
fn generic_visit_boolop(&mut self, node: Boolop) {}
|
||||
fn generic_visit_boolop(&mut self, node: BoolOp) {}
|
||||
fn visit_operator(&mut self, node: Operator) {
|
||||
self.generic_visit_operator(node)
|
||||
}
|
||||
fn generic_visit_operator(&mut self, node: Operator) {}
|
||||
fn visit_unaryop(&mut self, node: Unaryop) {
|
||||
fn visit_unaryop(&mut self, node: UnaryOp) {
|
||||
self.generic_visit_unaryop(node)
|
||||
}
|
||||
fn generic_visit_unaryop(&mut self, node: Unaryop) {}
|
||||
fn visit_cmpop(&mut self, node: Cmpop) {
|
||||
fn generic_visit_unaryop(&mut self, node: UnaryOp) {}
|
||||
fn visit_cmpop(&mut self, node: CmpOp) {
|
||||
self.generic_visit_cmpop(node)
|
||||
}
|
||||
fn generic_visit_cmpop(&mut self, node: Cmpop) {}
|
||||
fn generic_visit_cmpop(&mut self, node: CmpOp) {}
|
||||
fn visit_comprehension(&mut self, node: Comprehension<R>) {
|
||||
self.generic_visit_comprehension(node)
|
||||
}
|
||||
fn generic_visit_comprehension(&mut self, node: Comprehension<R>) {}
|
||||
fn visit_excepthandler(&mut self, node: Excepthandler<R>) {
|
||||
fn visit_excepthandler(&mut self, node: ExceptHandler<R>) {
|
||||
self.generic_visit_excepthandler(node)
|
||||
}
|
||||
fn generic_visit_excepthandler(&mut self, node: Excepthandler<R>) {
|
||||
fn generic_visit_excepthandler(&mut self, node: ExceptHandler<R>) {
|
||||
match node {
|
||||
Excepthandler::ExceptHandler(data) => self.visit_excepthandler_except_handler(data),
|
||||
ExceptHandler::ExceptHandler(data) => self.visit_excepthandler_except_handler(data),
|
||||
}
|
||||
}
|
||||
fn visit_excepthandler_except_handler(&mut self, node: ExcepthandlerExceptHandler<R>) {
|
||||
fn visit_excepthandler_except_handler(&mut self, node: ExceptHandlerExceptHandler<R>) {
|
||||
self.generic_visit_excepthandler_except_handler(node)
|
||||
}
|
||||
fn generic_visit_excepthandler_except_handler(&mut self, node: ExcepthandlerExceptHandler<R>) {
|
||||
fn generic_visit_excepthandler_except_handler(&mut self, node: ExceptHandlerExceptHandler<R>) {
|
||||
if let Some(value) = node.type_ {
|
||||
self.visit_expr(*value);
|
||||
}
|
||||
|
@ -720,10 +720,10 @@ pub trait Visitor<R = crate::text_size::TextRange> {
|
|||
self.generic_visit_alias(node)
|
||||
}
|
||||
fn generic_visit_alias(&mut self, node: Alias<R>) {}
|
||||
fn visit_withitem(&mut self, node: Withitem<R>) {
|
||||
fn visit_withitem(&mut self, node: WithItem<R>) {
|
||||
self.generic_visit_withitem(node)
|
||||
}
|
||||
fn generic_visit_withitem(&mut self, node: Withitem<R>) {}
|
||||
fn generic_visit_withitem(&mut self, node: WithItem<R>) {}
|
||||
fn visit_match_case(&mut self, node: MatchCase<R>) {
|
||||
self.generic_visit_match_case(node)
|
||||
}
|
||||
|
|
|
@ -54,19 +54,19 @@ impl<R> Default for EmptyRange<R> {
|
|||
}
|
||||
}
|
||||
|
||||
impl Cmpop {
|
||||
impl CmpOp {
|
||||
pub fn as_str(&self) -> &'static str {
|
||||
match self {
|
||||
Cmpop::Eq => "==",
|
||||
Cmpop::NotEq => "!=",
|
||||
Cmpop::Lt => "<",
|
||||
Cmpop::LtE => "<=",
|
||||
Cmpop::Gt => ">",
|
||||
Cmpop::GtE => ">=",
|
||||
Cmpop::Is => "is",
|
||||
Cmpop::IsNot => "is not",
|
||||
Cmpop::In => "in",
|
||||
Cmpop::NotIn => "not in",
|
||||
CmpOp::Eq => "==",
|
||||
CmpOp::NotEq => "!=",
|
||||
CmpOp::Lt => "<",
|
||||
CmpOp::LtE => "<=",
|
||||
CmpOp::Gt => ">",
|
||||
CmpOp::GtE => ">=",
|
||||
CmpOp::Is => "is",
|
||||
CmpOp::IsNot => "is not",
|
||||
CmpOp::In => "in",
|
||||
CmpOp::NotIn => "not in",
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -61,4 +61,4 @@ static_assertions::assert_eq_size!(crate::Stmt, [u8; 136]);
|
|||
#[cfg(target_arch = "x86_64")]
|
||||
static_assertions::assert_eq_size!(crate::Pattern, [u8; 96]);
|
||||
#[cfg(target_arch = "x86_64")]
|
||||
static_assertions::assert_eq_size!(crate::Excepthandler, [u8; 64]);
|
||||
static_assertions::assert_eq_size!(crate::ExceptHandler, [u8; 64]);
|
||||
|
|
|
@ -6,6 +6,14 @@
|
|||
//!
|
||||
//! [PythonArguments] is replaced by [Arguments]. The new [Arguments] type representation uses a new type
|
||||
//! [ArgWithDefault] to represent arguments with default values. See each type documentation for more details.
|
||||
//!
|
||||
//! A few top-level sum types are renamed to human friendly names.
|
||||
//! [CmpOp] refers `cmpop`
|
||||
//! [UnaryOp] refers `unaryop`
|
||||
//! [BoolOp] refers `boolop`
|
||||
//! [WithItem] refers `withitem`
|
||||
//! [ExceptHandler] refers `excepthandler`
|
||||
//!
|
||||
|
||||
mod builtin;
|
||||
mod generic;
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
use crate::{
|
||||
Arg, ArgWithDefault, Arguments, Boolop, Comprehension, Constant, ConversionFlag, Expr,
|
||||
Arg, ArgWithDefault, Arguments, BoolOp, Comprehension, Constant, ConversionFlag, Expr,
|
||||
Identifier, Operator, PythonArguments,
|
||||
};
|
||||
use std::fmt;
|
||||
|
@ -79,7 +79,7 @@ impl<'a> Unparser<'a> {
|
|||
values,
|
||||
range: _range,
|
||||
}) => {
|
||||
let (op, prec) = op_prec!(bin, op, Boolop, And("and", AND), Or("or", OR));
|
||||
let (op, prec) = op_prec!(bin, op, BoolOp, And("and", AND), Or("or", OR));
|
||||
group_if!(prec, {
|
||||
let mut first = true;
|
||||
for val in values {
|
||||
|
@ -138,7 +138,7 @@ impl<'a> Unparser<'a> {
|
|||
let (op, prec) = op_prec!(
|
||||
un,
|
||||
op,
|
||||
crate::Unaryop,
|
||||
crate::UnaryOp,
|
||||
Invert("~", FACTOR),
|
||||
Not("not ", NOT),
|
||||
UAdd("+", FACTOR),
|
||||
|
|
|
@ -509,7 +509,7 @@ ConstantExpr: ast::Expr = {
|
|||
ConstantAtom,
|
||||
<location:@L> "-" <operand:ConstantAtom> <end_location:@R> => ast::Expr::UnaryOp(
|
||||
ast::ExprUnaryOp {
|
||||
op: ast::Unaryop::USub,
|
||||
op: ast::UnaryOp::USub,
|
||||
operand: Box::new(operand),
|
||||
range: (location..end_location).into()
|
||||
}
|
||||
|
@ -875,11 +875,11 @@ TryStatement: ast::Stmt = {
|
|||
},
|
||||
};
|
||||
|
||||
ExceptStarClause: ast::Excepthandler = {
|
||||
ExceptStarClause: ast::ExceptHandler = {
|
||||
<location:@L> "except" "*" <typ:Test<"all">> ":" <body:Suite> => {
|
||||
let end_location = body.last().unwrap().end();
|
||||
ast::Excepthandler::ExceptHandler(
|
||||
ast::ExcepthandlerExceptHandler {
|
||||
ast::ExceptHandler::ExceptHandler(
|
||||
ast::ExceptHandlerExceptHandler {
|
||||
type_: Some(Box::new(typ)),
|
||||
name: None,
|
||||
body,
|
||||
|
@ -889,8 +889,8 @@ ExceptStarClause: ast::Excepthandler = {
|
|||
},
|
||||
<location:@L> "except" "*" <x:(<Test<"all">> "as" <Identifier>)> ":" <body:Suite> => {
|
||||
let end_location = body.last().unwrap().end();
|
||||
ast::Excepthandler::ExceptHandler(
|
||||
ast::ExcepthandlerExceptHandler {
|
||||
ast::ExceptHandler::ExceptHandler(
|
||||
ast::ExceptHandlerExceptHandler {
|
||||
type_: Some(Box::new(x.0)),
|
||||
name: Some(x.1),
|
||||
body,
|
||||
|
@ -901,11 +901,11 @@ ExceptStarClause: ast::Excepthandler = {
|
|||
};
|
||||
|
||||
|
||||
ExceptClause: ast::Excepthandler = {
|
||||
ExceptClause: ast::ExceptHandler = {
|
||||
<location:@L> "except" <typ:Test<"all">?> ":" <body:Suite> => {
|
||||
let end_location = body.last().unwrap().end();
|
||||
ast::Excepthandler::ExceptHandler(
|
||||
ast::ExcepthandlerExceptHandler {
|
||||
ast::ExceptHandler::ExceptHandler(
|
||||
ast::ExceptHandlerExceptHandler {
|
||||
type_: typ.map(Box::new),
|
||||
name: None,
|
||||
body,
|
||||
|
@ -915,8 +915,8 @@ ExceptClause: ast::Excepthandler = {
|
|||
},
|
||||
<location:@L> "except" <x:(<Test<"all">> "as" <Identifier>)> ":" <body:Suite> => {
|
||||
let end_location = body.last().unwrap().end();
|
||||
ast::Excepthandler::ExceptHandler(
|
||||
ast::ExcepthandlerExceptHandler {
|
||||
ast::ExceptHandler::ExceptHandler(
|
||||
ast::ExceptHandlerExceptHandler {
|
||||
type_: Some(Box::new(x.0)),
|
||||
name: Some(x.1),
|
||||
body,
|
||||
|
@ -938,7 +938,7 @@ WithStatement: ast::Stmt = {
|
|||
},
|
||||
};
|
||||
|
||||
WithItems: Vec<ast::Withitem> = {
|
||||
WithItems: Vec<ast::WithItem> = {
|
||||
"(" <WithItemsNoAs> ","? ")",
|
||||
"(" <left:(<WithItemsNoAs> ",")?> <mid:WithItem<"as">> <right:("," <WithItem<"all">>)*> ","? ")" => {
|
||||
left.into_iter().flatten().chain([mid]).chain(right).collect()
|
||||
|
@ -950,17 +950,17 @@ WithItems: Vec<ast::Withitem> = {
|
|||
};
|
||||
|
||||
#[inline]
|
||||
WithItemsNoAs: Vec<ast::Withitem> = {
|
||||
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: optional_range(location, end_location) }).collect()
|
||||
all.into_iter().map(|context_expr| ast::WithItem { context_expr, optional_vars: None, range: optional_range(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: optional_range(location, end_location) },
|
||||
WithItem<Goal>: ast::WithItem = {
|
||||
<location:@L> <context_expr: Test<Goal>> <end_location:@R> if Goal != "as" => ast::WithItem { context_expr, optional_vars: None, range: optional_range(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: optional_range(location, end_location) }
|
||||
ast::WithItem { context_expr, optional_vars, range: optional_range(location, end_location) }
|
||||
},
|
||||
};
|
||||
|
||||
|
@ -1212,7 +1212,7 @@ OrTest<Goal>: ast::Expr = {
|
|||
<location:@L> <mut values:(<AndTest<"all">> "or")+> <last: AndTest<"all">> <end_location:@R> => {
|
||||
values.push(last);
|
||||
ast::Expr::BoolOp(
|
||||
ast::ExprBoolOp { op: ast::Boolop::Or, values, range: (location..end_location).into() }
|
||||
ast::ExprBoolOp { op: ast::BoolOp::Or, values, range: (location..end_location).into() }
|
||||
)
|
||||
},
|
||||
AndTest<Goal>,
|
||||
|
@ -1222,7 +1222,7 @@ AndTest<Goal>: ast::Expr = {
|
|||
<location:@L> <mut values:(<NotTest<"all">> "and")+> <last:NotTest<"all">> <end_location:@R> => {
|
||||
values.push(last);
|
||||
ast::Expr::BoolOp(
|
||||
ast::ExprBoolOp { op: ast::Boolop::And, values, range: (location..end_location).into() }
|
||||
ast::ExprBoolOp { op: ast::BoolOp::And, values, range: (location..end_location).into() }
|
||||
)
|
||||
},
|
||||
NotTest<Goal>,
|
||||
|
@ -1230,7 +1230,7 @@ AndTest<Goal>: ast::Expr = {
|
|||
|
||||
NotTest<Goal>: ast::Expr = {
|
||||
<location:@L> "not" <e:NotTest<"all">> <end_location:@R> => ast::Expr::UnaryOp(
|
||||
ast::ExprUnaryOp { operand: Box::new(e), op: ast::Unaryop::Not, range: (location..end_location).into() }
|
||||
ast::ExprUnaryOp { operand: Box::new(e), op: ast::UnaryOp::Not, range: (location..end_location).into() }
|
||||
),
|
||||
Comparison<Goal>,
|
||||
};
|
||||
|
@ -1245,17 +1245,17 @@ Comparison<Goal>: ast::Expr = {
|
|||
Expression<Goal>,
|
||||
};
|
||||
|
||||
CompOp: ast::Cmpop = {
|
||||
"==" => ast::Cmpop::Eq,
|
||||
"!=" => ast::Cmpop::NotEq,
|
||||
"<" => ast::Cmpop::Lt,
|
||||
"<=" => ast::Cmpop::LtE,
|
||||
">" => ast::Cmpop::Gt,
|
||||
">=" => ast::Cmpop::GtE,
|
||||
"in" => ast::Cmpop::In,
|
||||
"not" "in" => ast::Cmpop::NotIn,
|
||||
"is" => ast::Cmpop::Is,
|
||||
"is" "not" => ast::Cmpop::IsNot,
|
||||
CompOp: ast::CmpOp = {
|
||||
"==" => ast::CmpOp::Eq,
|
||||
"!=" => ast::CmpOp::NotEq,
|
||||
"<" => ast::CmpOp::Lt,
|
||||
"<=" => ast::CmpOp::LtE,
|
||||
">" => ast::CmpOp::Gt,
|
||||
">=" => ast::CmpOp::GtE,
|
||||
"in" => ast::CmpOp::In,
|
||||
"not" "in" => ast::CmpOp::NotIn,
|
||||
"is" => ast::CmpOp::Is,
|
||||
"is" "not" => ast::CmpOp::IsNot,
|
||||
};
|
||||
|
||||
Expression<Goal>: ast::Expr = {
|
||||
|
@ -1325,10 +1325,10 @@ Factor<Goal>: ast::Expr = {
|
|||
Power<Goal>,
|
||||
};
|
||||
|
||||
UnaryOp: ast::Unaryop = {
|
||||
"+" => ast::Unaryop::UAdd,
|
||||
"-" => ast::Unaryop::USub,
|
||||
"~" => ast::Unaryop::Invert,
|
||||
UnaryOp: ast::UnaryOp = {
|
||||
"+" => ast::UnaryOp::UAdd,
|
||||
"-" => ast::UnaryOp::USub,
|
||||
"~" => ast::UnaryOp::Invert,
|
||||
};
|
||||
|
||||
Power<Goal>: ast::Expr = {
|
||||
|
|
484
parser/src/python.rs
generated
484
parser/src/python.rs
generated
File diff suppressed because it is too large
Load diff
|
@ -7,7 +7,7 @@ expression: parse_ast
|
|||
StmtWith {
|
||||
range: 0..17,
|
||||
items: [
|
||||
Withitem {
|
||||
WithItem {
|
||||
range: 5..11,
|
||||
context_expr: Constant(
|
||||
ExprConstant {
|
||||
|
|
|
@ -44,7 +44,7 @@ expression: parse_ast
|
|||
],
|
||||
handlers: [
|
||||
ExceptHandler(
|
||||
ExcepthandlerExceptHandler {
|
||||
ExceptHandlerExceptHandler {
|
||||
range: 29..82,
|
||||
type_: Some(
|
||||
Name(
|
||||
|
@ -138,7 +138,7 @@ expression: parse_ast
|
|||
},
|
||||
),
|
||||
ExceptHandler(
|
||||
ExcepthandlerExceptHandler {
|
||||
ExceptHandlerExceptHandler {
|
||||
range: 83..134,
|
||||
type_: Some(
|
||||
Name(
|
||||
|
|
|
@ -156,7 +156,7 @@ expression: parse_ast
|
|||
],
|
||||
handlers: [
|
||||
ExceptHandler(
|
||||
ExcepthandlerExceptHandler {
|
||||
ExceptHandlerExceptHandler {
|
||||
range: 99..180,
|
||||
type_: Some(
|
||||
Name(
|
||||
|
@ -284,7 +284,7 @@ expression: parse_ast
|
|||
},
|
||||
),
|
||||
ExceptHandler(
|
||||
ExcepthandlerExceptHandler {
|
||||
ExceptHandlerExceptHandler {
|
||||
range: 181..260,
|
||||
type_: Some(
|
||||
Name(
|
||||
|
|
|
@ -1,13 +1,13 @@
|
|||
---
|
||||
source: parser/src/parser.rs
|
||||
expression: "parse_program(source, \"<test>\").unwrap()"
|
||||
expression: "ast::Suite::parse(source, \"<test>\").unwrap()"
|
||||
---
|
||||
[
|
||||
With(
|
||||
StmtWith {
|
||||
range: 0..12,
|
||||
items: [
|
||||
Withitem {
|
||||
WithItem {
|
||||
range: 5..6,
|
||||
context_expr: Constant(
|
||||
ExprConstant {
|
||||
|
@ -35,7 +35,7 @@ expression: "parse_program(source, \"<test>\").unwrap()"
|
|||
StmtWith {
|
||||
range: 13..30,
|
||||
items: [
|
||||
Withitem {
|
||||
WithItem {
|
||||
range: 18..24,
|
||||
context_expr: Constant(
|
||||
ExprConstant {
|
||||
|
@ -73,7 +73,7 @@ expression: "parse_program(source, \"<test>\").unwrap()"
|
|||
StmtWith {
|
||||
range: 31..46,
|
||||
items: [
|
||||
Withitem {
|
||||
WithItem {
|
||||
range: 36..37,
|
||||
context_expr: Constant(
|
||||
ExprConstant {
|
||||
|
@ -86,7 +86,7 @@ expression: "parse_program(source, \"<test>\").unwrap()"
|
|||
),
|
||||
optional_vars: None,
|
||||
},
|
||||
Withitem {
|
||||
WithItem {
|
||||
range: 39..40,
|
||||
context_expr: Constant(
|
||||
ExprConstant {
|
||||
|
@ -114,7 +114,7 @@ expression: "parse_program(source, \"<test>\").unwrap()"
|
|||
StmtWith {
|
||||
range: 47..72,
|
||||
items: [
|
||||
Withitem {
|
||||
WithItem {
|
||||
range: 52..58,
|
||||
context_expr: Constant(
|
||||
ExprConstant {
|
||||
|
@ -137,7 +137,7 @@ expression: "parse_program(source, \"<test>\").unwrap()"
|
|||
),
|
||||
),
|
||||
},
|
||||
Withitem {
|
||||
WithItem {
|
||||
range: 60..66,
|
||||
context_expr: Constant(
|
||||
ExprConstant {
|
||||
|
@ -175,7 +175,7 @@ expression: "parse_program(source, \"<test>\").unwrap()"
|
|||
StmtWith {
|
||||
range: 73..97,
|
||||
items: [
|
||||
Withitem {
|
||||
WithItem {
|
||||
range: 78..91,
|
||||
context_expr: IfExp(
|
||||
ExprIfExp {
|
||||
|
@ -226,7 +226,7 @@ expression: "parse_program(source, \"<test>\").unwrap()"
|
|||
StmtWith {
|
||||
range: 98..127,
|
||||
items: [
|
||||
Withitem {
|
||||
WithItem {
|
||||
range: 103..121,
|
||||
context_expr: IfExp(
|
||||
ExprIfExp {
|
||||
|
@ -287,7 +287,7 @@ expression: "parse_program(source, \"<test>\").unwrap()"
|
|||
StmtWith {
|
||||
range: 128..141,
|
||||
items: [
|
||||
Withitem {
|
||||
WithItem {
|
||||
range: 133..135,
|
||||
context_expr: Tuple(
|
||||
ExprTuple {
|
||||
|
@ -313,7 +313,7 @@ expression: "parse_program(source, \"<test>\").unwrap()"
|
|||
StmtWith {
|
||||
range: 142..160,
|
||||
items: [
|
||||
Withitem {
|
||||
WithItem {
|
||||
range: 147..154,
|
||||
context_expr: Tuple(
|
||||
ExprTuple {
|
||||
|
@ -349,7 +349,7 @@ expression: "parse_program(source, \"<test>\").unwrap()"
|
|||
StmtWith {
|
||||
range: 161..175,
|
||||
items: [
|
||||
Withitem {
|
||||
WithItem {
|
||||
range: 167..168,
|
||||
context_expr: Constant(
|
||||
ExprConstant {
|
||||
|
@ -377,7 +377,7 @@ expression: "parse_program(source, \"<test>\").unwrap()"
|
|||
StmtWith {
|
||||
range: 176..195,
|
||||
items: [
|
||||
Withitem {
|
||||
WithItem {
|
||||
range: 181..189,
|
||||
context_expr: Constant(
|
||||
ExprConstant {
|
||||
|
@ -415,7 +415,7 @@ expression: "parse_program(source, \"<test>\").unwrap()"
|
|||
StmtWith {
|
||||
range: 196..211,
|
||||
items: [
|
||||
Withitem {
|
||||
WithItem {
|
||||
range: 202..203,
|
||||
context_expr: Constant(
|
||||
ExprConstant {
|
||||
|
@ -443,7 +443,7 @@ expression: "parse_program(source, \"<test>\").unwrap()"
|
|||
StmtWith {
|
||||
range: 212..232,
|
||||
items: [
|
||||
Withitem {
|
||||
WithItem {
|
||||
range: 217..226,
|
||||
context_expr: Tuple(
|
||||
ExprTuple {
|
||||
|
@ -489,7 +489,7 @@ expression: "parse_program(source, \"<test>\").unwrap()"
|
|||
StmtWith {
|
||||
range: 233..250,
|
||||
items: [
|
||||
Withitem {
|
||||
WithItem {
|
||||
range: 239..243,
|
||||
context_expr: Constant(
|
||||
ExprConstant {
|
||||
|
@ -502,7 +502,7 @@ expression: "parse_program(source, \"<test>\").unwrap()"
|
|||
),
|
||||
optional_vars: None,
|
||||
},
|
||||
Withitem {
|
||||
WithItem {
|
||||
range: 239..243,
|
||||
context_expr: Constant(
|
||||
ExprConstant {
|
||||
|
@ -530,7 +530,7 @@ expression: "parse_program(source, \"<test>\").unwrap()"
|
|||
StmtWith {
|
||||
range: 251..273,
|
||||
items: [
|
||||
Withitem {
|
||||
WithItem {
|
||||
range: 256..267,
|
||||
context_expr: Tuple(
|
||||
ExprTuple {
|
||||
|
@ -585,7 +585,7 @@ expression: "parse_program(source, \"<test>\").unwrap()"
|
|||
StmtWith {
|
||||
range: 274..290,
|
||||
items: [
|
||||
Withitem {
|
||||
WithItem {
|
||||
range: 279..284,
|
||||
context_expr: Tuple(
|
||||
ExprTuple {
|
||||
|
@ -627,7 +627,7 @@ expression: "parse_program(source, \"<test>\").unwrap()"
|
|||
StmtWith {
|
||||
range: 291..312,
|
||||
items: [
|
||||
Withitem {
|
||||
WithItem {
|
||||
range: 296..306,
|
||||
context_expr: Tuple(
|
||||
ExprTuple {
|
||||
|
@ -679,7 +679,7 @@ expression: "parse_program(source, \"<test>\").unwrap()"
|
|||
StmtWith {
|
||||
range: 313..331,
|
||||
items: [
|
||||
Withitem {
|
||||
WithItem {
|
||||
range: 318..325,
|
||||
context_expr: Tuple(
|
||||
ExprTuple {
|
||||
|
@ -730,7 +730,7 @@ expression: "parse_program(source, \"<test>\").unwrap()"
|
|||
StmtWith {
|
||||
range: 332..355,
|
||||
items: [
|
||||
Withitem {
|
||||
WithItem {
|
||||
range: 337..349,
|
||||
context_expr: Tuple(
|
||||
ExprTuple {
|
||||
|
@ -791,7 +791,7 @@ expression: "parse_program(source, \"<test>\").unwrap()"
|
|||
StmtWith {
|
||||
range: 356..375,
|
||||
items: [
|
||||
Withitem {
|
||||
WithItem {
|
||||
range: 361..369,
|
||||
context_expr: NamedExpr(
|
||||
ExprNamedExpr {
|
||||
|
@ -833,7 +833,7 @@ expression: "parse_program(source, \"<test>\").unwrap()"
|
|||
StmtWith {
|
||||
range: 376..400,
|
||||
items: [
|
||||
Withitem {
|
||||
WithItem {
|
||||
range: 381..394,
|
||||
context_expr: NamedExpr(
|
||||
ExprNamedExpr {
|
||||
|
@ -885,7 +885,7 @@ expression: "parse_program(source, \"<test>\").unwrap()"
|
|||
StmtWith {
|
||||
range: 401..428,
|
||||
items: [
|
||||
Withitem {
|
||||
WithItem {
|
||||
range: 406..422,
|
||||
context_expr: Tuple(
|
||||
ExprTuple {
|
||||
|
@ -958,7 +958,7 @@ expression: "parse_program(source, \"<test>\").unwrap()"
|
|||
StmtWith {
|
||||
range: 429..461,
|
||||
items: [
|
||||
Withitem {
|
||||
WithItem {
|
||||
range: 434..455,
|
||||
context_expr: Tuple(
|
||||
ExprTuple {
|
||||
|
@ -1041,7 +1041,7 @@ expression: "parse_program(source, \"<test>\").unwrap()"
|
|||
StmtWith {
|
||||
range: 462..481,
|
||||
items: [
|
||||
Withitem {
|
||||
WithItem {
|
||||
range: 468..474,
|
||||
context_expr: Constant(
|
||||
ExprConstant {
|
||||
|
@ -1079,7 +1079,7 @@ expression: "parse_program(source, \"<test>\").unwrap()"
|
|||
StmtWith {
|
||||
range: 482..502,
|
||||
items: [
|
||||
Withitem {
|
||||
WithItem {
|
||||
range: 488..494,
|
||||
context_expr: Constant(
|
||||
ExprConstant {
|
||||
|
@ -1117,7 +1117,7 @@ expression: "parse_program(source, \"<test>\").unwrap()"
|
|||
StmtWith {
|
||||
range: 503..530,
|
||||
items: [
|
||||
Withitem {
|
||||
WithItem {
|
||||
range: 509..515,
|
||||
context_expr: Constant(
|
||||
ExprConstant {
|
||||
|
@ -1140,7 +1140,7 @@ expression: "parse_program(source, \"<test>\").unwrap()"
|
|||
),
|
||||
),
|
||||
},
|
||||
Withitem {
|
||||
WithItem {
|
||||
range: 517..523,
|
||||
context_expr: Constant(
|
||||
ExprConstant {
|
||||
|
@ -1178,7 +1178,7 @@ expression: "parse_program(source, \"<test>\").unwrap()"
|
|||
StmtWith {
|
||||
range: 531..559,
|
||||
items: [
|
||||
Withitem {
|
||||
WithItem {
|
||||
range: 537..543,
|
||||
context_expr: Constant(
|
||||
ExprConstant {
|
||||
|
@ -1201,7 +1201,7 @@ expression: "parse_program(source, \"<test>\").unwrap()"
|
|||
),
|
||||
),
|
||||
},
|
||||
Withitem {
|
||||
WithItem {
|
||||
range: 545..551,
|
||||
context_expr: Constant(
|
||||
ExprConstant {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue