From 6a64f2289b1b4a091e1a7124eaa43198ce8fa819 Mon Sep 17 00:00:00 2001 From: Dhruv Manilawala Date: Wed, 9 Aug 2023 18:58:18 +0530 Subject: [PATCH] Rename `Magic*` to `IpyEscape*` (#6395) ## Summary This PR renames the `MagicCommand` token to `IpyEscapeCommand` token and `MagicKind` to `IpyEscapeKind` type to better reflect the purpose of the token and type. Similarly, it renames the AST nodes from `LineMagic` to `IpyEscapeCommand` prefixed with `Stmt`/`Expr` wherever necessary. It also makes renames from using `jupyter_magic` to `ipython_escape_commands` in various function names. The mode value is still `Mode::Jupyter` because the escape commands are part of the IPython syntax but the lexing/parsing is done for a Jupyter notebook. ### Motivation behind the rename: * IPython codebase defines it as "EscapeCommand" / "Escape Sequences": * Escape Sequences: https://github.com/ipython/ipython/blob/292e3a23459ca965b8c1bfe2c3707044c510209a/IPython/core/inputtransformer2.py#L329-L333 * Escape command: https://github.com/ipython/ipython/blob/292e3a23459ca965b8c1bfe2c3707044c510209a/IPython/core/inputtransformer2.py#L410-L411 * The word "magic" is used mainly for the actual magic commands i.e., the ones starting with `%`/`%%` (https://ipython.readthedocs.io/en/stable/interactive/reference.html#magic-command-system). So, this avoids any confusion between the Magic token (`%`, `%%`) and the escape command itself. ## Test Plan * `cargo test` to make sure all renames are done correctly. * `grep` for `jupyter_escape`/`magic` to make sure all renames are done correctly. --- ..._magics.ipynb => ipy_escape_command.ipynb} | 0 ...pynb => ipy_escape_command_expected.ipynb} | 0 crates/ruff/src/jupyter/notebook.rs | 6 +- ..._notebook__tests__ipy_escape_command.snap} | 2 +- .../ruff/src/rules/ruff/rules/unreachable.rs | 8 +- crates/ruff_python_ast/src/comparable.rs | 20 +- crates/ruff_python_ast/src/helpers.rs | 6 +- crates/ruff_python_ast/src/node.rs | 116 +-- crates/ruff_python_ast/src/nodes.rs | 126 +-- crates/ruff_python_ast/src/relocate.rs | 2 +- crates/ruff_python_ast/src/visitor.rs | 4 +- .../ruff_python_ast/src/visitor/preorder.rs | 4 +- crates/ruff_python_codegen/src/generator.rs | 4 +- .../src/expression/expr_ipy_escape_command.rs | 12 + .../src/expression/expr_line_magic.rs | 12 - .../src/expression/mod.rs | 8 +- crates/ruff_python_formatter/src/generated.rs | 48 +- .../src/statement/mod.rs | 4 +- .../src/statement/stmt_ipy_escape_command.rs | 12 + .../src/statement/stmt_line_magic.rs | 12 - crates/ruff_python_parser/src/lexer.rs | 265 +++--- crates/ruff_python_parser/src/parser.rs | 12 +- crates/ruff_python_parser/src/python.lalrpop | 58 +- crates/ruff_python_parser/src/python.rs | 798 +++++++++--------- ...rser__tests__ipython_escape_commands.snap} | 174 ++-- crates/ruff_python_parser/src/token.rs | 18 +- 26 files changed, 867 insertions(+), 864 deletions(-) rename crates/ruff/resources/test/fixtures/jupyter/{line_magics.ipynb => ipy_escape_command.ipynb} (100%) rename crates/ruff/resources/test/fixtures/jupyter/{line_magics_expected.ipynb => ipy_escape_command_expected.ipynb} (100%) rename crates/ruff/src/jupyter/snapshots/{ruff__jupyter__notebook__tests__line_magics.snap => ruff__jupyter__notebook__tests__ipy_escape_command.snap} (79%) create mode 100644 crates/ruff_python_formatter/src/expression/expr_ipy_escape_command.rs delete mode 100644 crates/ruff_python_formatter/src/expression/expr_line_magic.rs create mode 100644 crates/ruff_python_formatter/src/statement/stmt_ipy_escape_command.rs delete mode 100644 crates/ruff_python_formatter/src/statement/stmt_line_magic.rs rename crates/ruff_python_parser/src/snapshots/{ruff_python_parser__parser__tests__jupyter_magic.snap => ruff_python_parser__parser__tests__ipython_escape_commands.snap} (75%) diff --git a/crates/ruff/resources/test/fixtures/jupyter/line_magics.ipynb b/crates/ruff/resources/test/fixtures/jupyter/ipy_escape_command.ipynb similarity index 100% rename from crates/ruff/resources/test/fixtures/jupyter/line_magics.ipynb rename to crates/ruff/resources/test/fixtures/jupyter/ipy_escape_command.ipynb diff --git a/crates/ruff/resources/test/fixtures/jupyter/line_magics_expected.ipynb b/crates/ruff/resources/test/fixtures/jupyter/ipy_escape_command_expected.ipynb similarity index 100% rename from crates/ruff/resources/test/fixtures/jupyter/line_magics_expected.ipynb rename to crates/ruff/resources/test/fixtures/jupyter/ipy_escape_command_expected.ipynb diff --git a/crates/ruff/src/jupyter/notebook.rs b/crates/ruff/src/jupyter/notebook.rs index 4aaff0b1ff734..43238f5e2b549 100644 --- a/crates/ruff/src/jupyter/notebook.rs +++ b/crates/ruff/src/jupyter/notebook.rs @@ -571,11 +571,11 @@ print("after empty cells") } #[test] - fn test_line_magics() -> Result<()> { - let path = "line_magics.ipynb".to_string(); + fn test_ipy_escape_command() -> Result<()> { + let path = "ipy_escape_command.ipynb".to_string(); let (diagnostics, source_kind, _) = test_notebook_path( &path, - Path::new("line_magics_expected.ipynb"), + Path::new("ipy_escape_command_expected.ipynb"), &settings::Settings::for_rule(Rule::UnusedImport), )?; assert_messages!(diagnostics, path, source_kind); diff --git a/crates/ruff/src/jupyter/snapshots/ruff__jupyter__notebook__tests__line_magics.snap b/crates/ruff/src/jupyter/snapshots/ruff__jupyter__notebook__tests__ipy_escape_command.snap similarity index 79% rename from crates/ruff/src/jupyter/snapshots/ruff__jupyter__notebook__tests__line_magics.snap rename to crates/ruff/src/jupyter/snapshots/ruff__jupyter__notebook__tests__ipy_escape_command.snap index 61211b2c18edb..57f92d184e1d1 100644 --- a/crates/ruff/src/jupyter/snapshots/ruff__jupyter__notebook__tests__line_magics.snap +++ b/crates/ruff/src/jupyter/snapshots/ruff__jupyter__notebook__tests__ipy_escape_command.snap @@ -1,7 +1,7 @@ --- source: crates/ruff/src/jupyter/notebook.rs --- -line_magics.ipynb:cell 1:5:8: F401 [*] `os` imported but unused +ipy_escape_command.ipynb:cell 1:5:8: F401 [*] `os` imported but unused | 3 | %matplotlib inline 4 | diff --git a/crates/ruff/src/rules/ruff/rules/unreachable.rs b/crates/ruff/src/rules/ruff/rules/unreachable.rs index 300110fe6f9c8..7549d910537e4 100644 --- a/crates/ruff/src/rules/ruff/rules/unreachable.rs +++ b/crates/ruff/src/rules/ruff/rules/unreachable.rs @@ -653,13 +653,13 @@ impl<'stmt> BasicBlocksBuilder<'stmt> { | Expr::Await(_) | Expr::Yield(_) | Expr::YieldFrom(_) => self.unconditional_next_block(after), - Expr::LineMagic(_) => todo!(), + Expr::IpyEscapeCommand(_) => todo!(), } } // The tough branches are done, here is an easy one. Stmt::Return(_) => NextBlock::Terminate, Stmt::TypeAlias(_) => todo!(), - Stmt::LineMagic(_) => todo!(), + Stmt::IpyEscapeCommand(_) => todo!(), }; // Include any statements in the block that don't divert the control flow. @@ -903,7 +903,7 @@ fn needs_next_block(stmts: &[Stmt]) -> bool { | Stmt::TryStar(_) | Stmt::Assert(_) => true, Stmt::TypeAlias(_) => todo!(), - Stmt::LineMagic(_) => todo!(), + Stmt::IpyEscapeCommand(_) => todo!(), } } @@ -936,7 +936,7 @@ fn is_control_flow_stmt(stmt: &Stmt) -> bool { | Stmt::Break(_) | Stmt::Continue(_) => true, Stmt::TypeAlias(_) => todo!(), - Stmt::LineMagic(_) => todo!(), + Stmt::IpyEscapeCommand(_) => todo!(), } } diff --git a/crates/ruff_python_ast/src/comparable.rs b/crates/ruff_python_ast/src/comparable.rs index f042fe3707cd7..00a6ef87d27d2 100644 --- a/crates/ruff_python_ast/src/comparable.rs +++ b/crates/ruff_python_ast/src/comparable.rs @@ -672,8 +672,8 @@ pub struct ExprSlice<'a> { } #[derive(Debug, PartialEq, Eq, Hash)] -pub struct ExprLineMagic<'a> { - kind: ast::MagicKind, +pub struct ExprIpyEscapeCommand<'a> { + kind: ast::IpyEscapeKind, value: &'a str, } @@ -706,7 +706,7 @@ pub enum ComparableExpr<'a> { List(ExprList<'a>), Tuple(ExprTuple<'a>), Slice(ExprSlice<'a>), - LineMagic(ExprLineMagic<'a>), + IpyEscapeCommand(ExprIpyEscapeCommand<'a>), } impl<'a> From<&'a Box> for Box> { @@ -936,11 +936,11 @@ impl<'a> From<&'a ast::Expr> for ComparableExpr<'a> { upper: upper.as_ref().map(Into::into), step: step.as_ref().map(Into::into), }), - ast::Expr::LineMagic(ast::ExprLineMagic { + ast::Expr::IpyEscapeCommand(ast::ExprIpyEscapeCommand { kind, value, range: _, - }) => Self::LineMagic(ExprLineMagic { + }) => Self::IpyEscapeCommand(ExprIpyEscapeCommand { kind: *kind, value: value.as_str(), }), @@ -1165,8 +1165,8 @@ pub struct StmtExpr<'a> { } #[derive(Debug, PartialEq, Eq, Hash)] -pub struct StmtLineMagic<'a> { - kind: ast::MagicKind, +pub struct StmtIpyEscapeCommand<'a> { + kind: ast::IpyEscapeKind, value: &'a str, } @@ -1193,7 +1193,7 @@ pub enum ComparableStmt<'a> { ImportFrom(StmtImportFrom<'a>), Global(StmtGlobal<'a>), Nonlocal(StmtNonlocal<'a>), - LineMagic(StmtLineMagic<'a>), + IpyEscapeCommand(StmtIpyEscapeCommand<'a>), Expr(StmtExpr<'a>), Pass, Break, @@ -1394,11 +1394,11 @@ impl<'a> From<&'a ast::Stmt> for ComparableStmt<'a> { names: names.iter().map(ast::Identifier::as_str).collect(), }) } - ast::Stmt::LineMagic(ast::StmtLineMagic { + ast::Stmt::IpyEscapeCommand(ast::StmtIpyEscapeCommand { kind, value, range: _, - }) => Self::LineMagic(StmtLineMagic { + }) => Self::IpyEscapeCommand(StmtIpyEscapeCommand { kind: *kind, value: value.as_str(), }), diff --git a/crates/ruff_python_ast/src/helpers.rs b/crates/ruff_python_ast/src/helpers.rs index f5fa0a5c48c74..5af9a38dcb6cc 100644 --- a/crates/ruff_python_ast/src/helpers.rs +++ b/crates/ruff_python_ast/src/helpers.rs @@ -108,7 +108,7 @@ where | Expr::Subscript(_) | Expr::Yield(_) | Expr::YieldFrom(_) - | Expr::LineMagic(_) + | Expr::IpyEscapeCommand(_) ) }) } @@ -247,7 +247,7 @@ where .is_some_and(|value| any_over_expr(value, func)) } Expr::Name(_) | Expr::Constant(_) => false, - Expr::LineMagic(_) => false, + Expr::IpyEscapeCommand(_) => false, } } @@ -534,7 +534,7 @@ where Stmt::Nonlocal(_) => false, Stmt::Expr(ast::StmtExpr { value, range: _ }) => any_over_expr(value, func), Stmt::Pass(_) | Stmt::Break(_) | Stmt::Continue(_) => false, - Stmt::LineMagic(_) => false, + Stmt::IpyEscapeCommand(_) => false, } } diff --git a/crates/ruff_python_ast/src/node.rs b/crates/ruff_python_ast/src/node.rs index cc3748d62a5e2..2bc1642af61c7 100644 --- a/crates/ruff_python_ast/src/node.rs +++ b/crates/ruff_python_ast/src/node.rs @@ -48,7 +48,7 @@ pub enum AnyNode { StmtPass(ast::StmtPass), StmtBreak(ast::StmtBreak), StmtContinue(ast::StmtContinue), - StmtLineMagic(ast::StmtLineMagic), + StmtIpyEscapeCommand(ast::StmtIpyEscapeCommand), ExprBoolOp(ast::ExprBoolOp), ExprNamedExpr(ast::ExprNamedExpr), ExprBinOp(ast::ExprBinOp), @@ -76,7 +76,7 @@ pub enum AnyNode { ExprList(ast::ExprList), ExprTuple(ast::ExprTuple), ExprSlice(ast::ExprSlice), - ExprLineMagic(ast::ExprLineMagic), + ExprIpyEscapeCommand(ast::ExprIpyEscapeCommand), ExceptHandlerExceptHandler(ast::ExceptHandlerExceptHandler), PatternMatchValue(ast::PatternMatchValue), PatternMatchSingleton(ast::PatternMatchSingleton), @@ -131,7 +131,7 @@ impl AnyNode { AnyNode::StmtPass(node) => Some(Stmt::Pass(node)), AnyNode::StmtBreak(node) => Some(Stmt::Break(node)), AnyNode::StmtContinue(node) => Some(Stmt::Continue(node)), - AnyNode::StmtLineMagic(node) => Some(Stmt::LineMagic(node)), + AnyNode::StmtIpyEscapeCommand(node) => Some(Stmt::IpyEscapeCommand(node)), AnyNode::ModModule(_) | AnyNode::ModExpression(_) @@ -162,7 +162,7 @@ impl AnyNode { | AnyNode::ExprList(_) | AnyNode::ExprTuple(_) | AnyNode::ExprSlice(_) - | AnyNode::ExprLineMagic(_) + | AnyNode::ExprIpyEscapeCommand(_) | AnyNode::ExceptHandlerExceptHandler(_) | AnyNode::PatternMatchValue(_) | AnyNode::PatternMatchSingleton(_) @@ -219,7 +219,7 @@ impl AnyNode { AnyNode::ExprList(node) => Some(Expr::List(node)), AnyNode::ExprTuple(node) => Some(Expr::Tuple(node)), AnyNode::ExprSlice(node) => Some(Expr::Slice(node)), - AnyNode::ExprLineMagic(node) => Some(Expr::LineMagic(node)), + AnyNode::ExprIpyEscapeCommand(node) => Some(Expr::IpyEscapeCommand(node)), AnyNode::ModModule(_) | AnyNode::ModExpression(_) @@ -248,7 +248,7 @@ impl AnyNode { | AnyNode::StmtPass(_) | AnyNode::StmtBreak(_) | AnyNode::StmtContinue(_) - | AnyNode::StmtLineMagic(_) + | AnyNode::StmtIpyEscapeCommand(_) | AnyNode::ExceptHandlerExceptHandler(_) | AnyNode::PatternMatchValue(_) | AnyNode::PatternMatchSingleton(_) @@ -306,7 +306,7 @@ impl AnyNode { | AnyNode::StmtPass(_) | AnyNode::StmtBreak(_) | AnyNode::StmtContinue(_) - | AnyNode::StmtLineMagic(_) + | AnyNode::StmtIpyEscapeCommand(_) | AnyNode::ExprBoolOp(_) | AnyNode::ExprNamedExpr(_) | AnyNode::ExprBinOp(_) @@ -334,7 +334,7 @@ impl AnyNode { | AnyNode::ExprList(_) | AnyNode::ExprTuple(_) | AnyNode::ExprSlice(_) - | AnyNode::ExprLineMagic(_) + | AnyNode::ExprIpyEscapeCommand(_) | AnyNode::ExceptHandlerExceptHandler(_) | AnyNode::PatternMatchValue(_) | AnyNode::PatternMatchSingleton(_) @@ -400,7 +400,7 @@ impl AnyNode { | AnyNode::StmtPass(_) | AnyNode::StmtBreak(_) | AnyNode::StmtContinue(_) - | AnyNode::StmtLineMagic(_) + | AnyNode::StmtIpyEscapeCommand(_) | AnyNode::ExprBoolOp(_) | AnyNode::ExprNamedExpr(_) | AnyNode::ExprBinOp(_) @@ -428,7 +428,7 @@ impl AnyNode { | AnyNode::ExprList(_) | AnyNode::ExprTuple(_) | AnyNode::ExprSlice(_) - | AnyNode::ExprLineMagic(_) + | AnyNode::ExprIpyEscapeCommand(_) | AnyNode::ExceptHandlerExceptHandler(_) | AnyNode::Comprehension(_) | AnyNode::Arguments(_) @@ -479,7 +479,7 @@ impl AnyNode { | AnyNode::StmtPass(_) | AnyNode::StmtBreak(_) | AnyNode::StmtContinue(_) - | AnyNode::StmtLineMagic(_) + | AnyNode::StmtIpyEscapeCommand(_) | AnyNode::ExprBoolOp(_) | AnyNode::ExprNamedExpr(_) | AnyNode::ExprBinOp(_) @@ -507,7 +507,7 @@ impl AnyNode { | AnyNode::ExprList(_) | AnyNode::ExprTuple(_) | AnyNode::ExprSlice(_) - | AnyNode::ExprLineMagic(_) + | AnyNode::ExprIpyEscapeCommand(_) | AnyNode::PatternMatchValue(_) | AnyNode::PatternMatchSingleton(_) | AnyNode::PatternMatchSequence(_) @@ -583,7 +583,7 @@ impl AnyNode { Self::StmtPass(node) => AnyNodeRef::StmtPass(node), Self::StmtBreak(node) => AnyNodeRef::StmtBreak(node), Self::StmtContinue(node) => AnyNodeRef::StmtContinue(node), - Self::StmtLineMagic(node) => AnyNodeRef::StmtLineMagic(node), + Self::StmtIpyEscapeCommand(node) => AnyNodeRef::StmtIpyEscapeCommand(node), Self::ExprBoolOp(node) => AnyNodeRef::ExprBoolOp(node), Self::ExprNamedExpr(node) => AnyNodeRef::ExprNamedExpr(node), Self::ExprBinOp(node) => AnyNodeRef::ExprBinOp(node), @@ -611,7 +611,7 @@ impl AnyNode { Self::ExprList(node) => AnyNodeRef::ExprList(node), Self::ExprTuple(node) => AnyNodeRef::ExprTuple(node), Self::ExprSlice(node) => AnyNodeRef::ExprSlice(node), - Self::ExprLineMagic(node) => AnyNodeRef::ExprLineMagic(node), + Self::ExprIpyEscapeCommand(node) => AnyNodeRef::ExprIpyEscapeCommand(node), Self::ExceptHandlerExceptHandler(node) => AnyNodeRef::ExceptHandlerExceptHandler(node), Self::PatternMatchValue(node) => AnyNodeRef::PatternMatchValue(node), Self::PatternMatchSingleton(node) => AnyNodeRef::PatternMatchSingleton(node), @@ -1429,12 +1429,12 @@ impl AstNode for ast::StmtContinue { AnyNode::from(self) } } -impl AstNode for ast::StmtLineMagic { +impl AstNode for ast::StmtIpyEscapeCommand { fn cast(kind: AnyNode) -> Option where Self: Sized, { - if let AnyNode::StmtLineMagic(node) = kind { + if let AnyNode::StmtIpyEscapeCommand(node) = kind { Some(node) } else { None @@ -1442,7 +1442,7 @@ impl AstNode for ast::StmtLineMagic { } fn cast_ref(kind: AnyNodeRef) -> Option<&Self> { - if let AnyNodeRef::StmtLineMagic(node) = kind { + if let AnyNodeRef::StmtIpyEscapeCommand(node) = kind { Some(node) } else { None @@ -2213,12 +2213,12 @@ impl AstNode for ast::ExprSlice { AnyNode::from(self) } } -impl AstNode for ast::ExprLineMagic { +impl AstNode for ast::ExprIpyEscapeCommand { fn cast(kind: AnyNode) -> Option where Self: Sized, { - if let AnyNode::ExprLineMagic(node) = kind { + if let AnyNode::ExprIpyEscapeCommand(node) = kind { Some(node) } else { None @@ -2226,7 +2226,7 @@ impl AstNode for ast::ExprLineMagic { } fn cast_ref(kind: AnyNodeRef) -> Option<&Self> { - if let AnyNodeRef::ExprLineMagic(node) = kind { + if let AnyNodeRef::ExprIpyEscapeCommand(node) = kind { Some(node) } else { None @@ -2915,7 +2915,7 @@ impl From for AnyNode { Stmt::Pass(node) => AnyNode::StmtPass(node), Stmt::Break(node) => AnyNode::StmtBreak(node), Stmt::Continue(node) => AnyNode::StmtContinue(node), - Stmt::LineMagic(node) => AnyNode::StmtLineMagic(node), + Stmt::IpyEscapeCommand(node) => AnyNode::StmtIpyEscapeCommand(node), } } } @@ -2950,7 +2950,7 @@ impl From for AnyNode { Expr::List(node) => AnyNode::ExprList(node), Expr::Tuple(node) => AnyNode::ExprTuple(node), Expr::Slice(node) => AnyNode::ExprSlice(node), - Expr::LineMagic(node) => AnyNode::ExprLineMagic(node), + Expr::IpyEscapeCommand(node) => AnyNode::ExprIpyEscapeCommand(node), } } } @@ -3155,9 +3155,9 @@ impl From for AnyNode { } } -impl From for AnyNode { - fn from(node: ast::StmtLineMagic) -> Self { - AnyNode::StmtLineMagic(node) +impl From for AnyNode { + fn from(node: ast::StmtIpyEscapeCommand) -> Self { + AnyNode::StmtIpyEscapeCommand(node) } } @@ -3323,9 +3323,9 @@ impl From for AnyNode { } } -impl From for AnyNode { - fn from(node: ast::ExprLineMagic) -> Self { - AnyNode::ExprLineMagic(node) +impl From for AnyNode { + fn from(node: ast::ExprIpyEscapeCommand) -> Self { + AnyNode::ExprIpyEscapeCommand(node) } } @@ -3486,7 +3486,7 @@ impl Ranged for AnyNode { AnyNode::StmtPass(node) => node.range(), AnyNode::StmtBreak(node) => node.range(), AnyNode::StmtContinue(node) => node.range(), - AnyNode::StmtLineMagic(node) => node.range(), + AnyNode::StmtIpyEscapeCommand(node) => node.range(), AnyNode::ExprBoolOp(node) => node.range(), AnyNode::ExprNamedExpr(node) => node.range(), AnyNode::ExprBinOp(node) => node.range(), @@ -3514,7 +3514,7 @@ impl Ranged for AnyNode { AnyNode::ExprList(node) => node.range(), AnyNode::ExprTuple(node) => node.range(), AnyNode::ExprSlice(node) => node.range(), - AnyNode::ExprLineMagic(node) => node.range(), + AnyNode::ExprIpyEscapeCommand(node) => node.range(), AnyNode::ExceptHandlerExceptHandler(node) => node.range(), AnyNode::PatternMatchValue(node) => node.range(), AnyNode::PatternMatchSingleton(node) => node.range(), @@ -3572,7 +3572,7 @@ pub enum AnyNodeRef<'a> { StmtPass(&'a ast::StmtPass), StmtBreak(&'a ast::StmtBreak), StmtContinue(&'a ast::StmtContinue), - StmtLineMagic(&'a ast::StmtLineMagic), + StmtIpyEscapeCommand(&'a ast::StmtIpyEscapeCommand), ExprBoolOp(&'a ast::ExprBoolOp), ExprNamedExpr(&'a ast::ExprNamedExpr), ExprBinOp(&'a ast::ExprBinOp), @@ -3600,7 +3600,7 @@ pub enum AnyNodeRef<'a> { ExprList(&'a ast::ExprList), ExprTuple(&'a ast::ExprTuple), ExprSlice(&'a ast::ExprSlice), - ExprLineMagic(&'a ast::ExprLineMagic), + ExprIpyEscapeCommand(&'a ast::ExprIpyEscapeCommand), ExceptHandlerExceptHandler(&'a ast::ExceptHandlerExceptHandler), PatternMatchValue(&'a ast::PatternMatchValue), PatternMatchSingleton(&'a ast::PatternMatchSingleton), @@ -3657,7 +3657,7 @@ impl AnyNodeRef<'_> { AnyNodeRef::StmtPass(node) => NonNull::from(*node).cast(), AnyNodeRef::StmtBreak(node) => NonNull::from(*node).cast(), AnyNodeRef::StmtContinue(node) => NonNull::from(*node).cast(), - AnyNodeRef::StmtLineMagic(node) => NonNull::from(*node).cast(), + AnyNodeRef::StmtIpyEscapeCommand(node) => NonNull::from(*node).cast(), AnyNodeRef::ExprBoolOp(node) => NonNull::from(*node).cast(), AnyNodeRef::ExprNamedExpr(node) => NonNull::from(*node).cast(), AnyNodeRef::ExprBinOp(node) => NonNull::from(*node).cast(), @@ -3685,7 +3685,7 @@ impl AnyNodeRef<'_> { AnyNodeRef::ExprList(node) => NonNull::from(*node).cast(), AnyNodeRef::ExprTuple(node) => NonNull::from(*node).cast(), AnyNodeRef::ExprSlice(node) => NonNull::from(*node).cast(), - AnyNodeRef::ExprLineMagic(node) => NonNull::from(*node).cast(), + AnyNodeRef::ExprIpyEscapeCommand(node) => NonNull::from(*node).cast(), AnyNodeRef::ExceptHandlerExceptHandler(node) => NonNull::from(*node).cast(), AnyNodeRef::PatternMatchValue(node) => NonNull::from(*node).cast(), AnyNodeRef::PatternMatchSingleton(node) => NonNull::from(*node).cast(), @@ -3748,7 +3748,7 @@ impl AnyNodeRef<'_> { AnyNodeRef::StmtPass(_) => NodeKind::StmtPass, AnyNodeRef::StmtBreak(_) => NodeKind::StmtBreak, AnyNodeRef::StmtContinue(_) => NodeKind::StmtContinue, - AnyNodeRef::StmtLineMagic(_) => NodeKind::StmtLineMagic, + AnyNodeRef::StmtIpyEscapeCommand(_) => NodeKind::StmtIpyEscapeCommand, AnyNodeRef::ExprBoolOp(_) => NodeKind::ExprBoolOp, AnyNodeRef::ExprNamedExpr(_) => NodeKind::ExprNamedExpr, AnyNodeRef::ExprBinOp(_) => NodeKind::ExprBinOp, @@ -3776,7 +3776,7 @@ impl AnyNodeRef<'_> { AnyNodeRef::ExprList(_) => NodeKind::ExprList, AnyNodeRef::ExprTuple(_) => NodeKind::ExprTuple, AnyNodeRef::ExprSlice(_) => NodeKind::ExprSlice, - AnyNodeRef::ExprLineMagic(_) => NodeKind::ExprLineMagic, + AnyNodeRef::ExprIpyEscapeCommand(_) => NodeKind::ExprIpyEscapeCommand, AnyNodeRef::ExceptHandlerExceptHandler(_) => NodeKind::ExceptHandlerExceptHandler, AnyNodeRef::PatternMatchValue(_) => NodeKind::PatternMatchValue, AnyNodeRef::PatternMatchSingleton(_) => NodeKind::PatternMatchSingleton, @@ -3831,7 +3831,7 @@ impl AnyNodeRef<'_> { | AnyNodeRef::StmtPass(_) | AnyNodeRef::StmtBreak(_) | AnyNodeRef::StmtContinue(_) - | AnyNodeRef::StmtLineMagic(_) => true, + | AnyNodeRef::StmtIpyEscapeCommand(_) => true, AnyNodeRef::ModModule(_) | AnyNodeRef::ModExpression(_) @@ -3862,7 +3862,7 @@ impl AnyNodeRef<'_> { | AnyNodeRef::ExprList(_) | AnyNodeRef::ExprTuple(_) | AnyNodeRef::ExprSlice(_) - | AnyNodeRef::ExprLineMagic(_) + | AnyNodeRef::ExprIpyEscapeCommand(_) | AnyNodeRef::ExceptHandlerExceptHandler(_) | AnyNodeRef::PatternMatchValue(_) | AnyNodeRef::PatternMatchSingleton(_) @@ -3919,7 +3919,7 @@ impl AnyNodeRef<'_> { | AnyNodeRef::ExprList(_) | AnyNodeRef::ExprTuple(_) | AnyNodeRef::ExprSlice(_) - | AnyNodeRef::ExprLineMagic(_) => true, + | AnyNodeRef::ExprIpyEscapeCommand(_) => true, AnyNodeRef::ModModule(_) | AnyNodeRef::ModExpression(_) @@ -3948,7 +3948,7 @@ impl AnyNodeRef<'_> { | AnyNodeRef::StmtPass(_) | AnyNodeRef::StmtBreak(_) | AnyNodeRef::StmtContinue(_) - | AnyNodeRef::StmtLineMagic(_) + | AnyNodeRef::StmtIpyEscapeCommand(_) | AnyNodeRef::ExceptHandlerExceptHandler(_) | AnyNodeRef::PatternMatchValue(_) | AnyNodeRef::PatternMatchSingleton(_) @@ -4005,7 +4005,7 @@ impl AnyNodeRef<'_> { | AnyNodeRef::StmtPass(_) | AnyNodeRef::StmtBreak(_) | AnyNodeRef::StmtContinue(_) - | AnyNodeRef::StmtLineMagic(_) + | AnyNodeRef::StmtIpyEscapeCommand(_) | AnyNodeRef::ExprBoolOp(_) | AnyNodeRef::ExprNamedExpr(_) | AnyNodeRef::ExprBinOp(_) @@ -4033,7 +4033,7 @@ impl AnyNodeRef<'_> { | AnyNodeRef::ExprList(_) | AnyNodeRef::ExprTuple(_) | AnyNodeRef::ExprSlice(_) - | AnyNodeRef::ExprLineMagic(_) + | AnyNodeRef::ExprIpyEscapeCommand(_) | AnyNodeRef::ExceptHandlerExceptHandler(_) | AnyNodeRef::PatternMatchValue(_) | AnyNodeRef::PatternMatchSingleton(_) @@ -4099,7 +4099,7 @@ impl AnyNodeRef<'_> { | AnyNodeRef::StmtPass(_) | AnyNodeRef::StmtBreak(_) | AnyNodeRef::StmtContinue(_) - | AnyNodeRef::StmtLineMagic(_) + | AnyNodeRef::StmtIpyEscapeCommand(_) | AnyNodeRef::ExprBoolOp(_) | AnyNodeRef::ExprNamedExpr(_) | AnyNodeRef::ExprBinOp(_) @@ -4127,7 +4127,7 @@ impl AnyNodeRef<'_> { | AnyNodeRef::ExprList(_) | AnyNodeRef::ExprTuple(_) | AnyNodeRef::ExprSlice(_) - | AnyNodeRef::ExprLineMagic(_) + | AnyNodeRef::ExprIpyEscapeCommand(_) | AnyNodeRef::ExceptHandlerExceptHandler(_) | AnyNodeRef::Comprehension(_) | AnyNodeRef::Arguments(_) @@ -4178,7 +4178,7 @@ impl AnyNodeRef<'_> { | AnyNodeRef::StmtPass(_) | AnyNodeRef::StmtBreak(_) | AnyNodeRef::StmtContinue(_) - | AnyNodeRef::StmtLineMagic(_) + | AnyNodeRef::StmtIpyEscapeCommand(_) | AnyNodeRef::ExprBoolOp(_) | AnyNodeRef::ExprNamedExpr(_) | AnyNodeRef::ExprBinOp(_) @@ -4206,7 +4206,7 @@ impl AnyNodeRef<'_> { | AnyNodeRef::ExprList(_) | AnyNodeRef::ExprTuple(_) | AnyNodeRef::ExprSlice(_) - | AnyNodeRef::ExprLineMagic(_) + | AnyNodeRef::ExprIpyEscapeCommand(_) | AnyNodeRef::PatternMatchValue(_) | AnyNodeRef::PatternMatchSingleton(_) | AnyNodeRef::PatternMatchSequence(_) @@ -4429,9 +4429,9 @@ impl<'a> From<&'a ast::StmtContinue> for AnyNodeRef<'a> { } } -impl<'a> From<&'a ast::StmtLineMagic> for AnyNodeRef<'a> { - fn from(node: &'a ast::StmtLineMagic) -> Self { - AnyNodeRef::StmtLineMagic(node) +impl<'a> From<&'a ast::StmtIpyEscapeCommand> for AnyNodeRef<'a> { + fn from(node: &'a ast::StmtIpyEscapeCommand) -> Self { + AnyNodeRef::StmtIpyEscapeCommand(node) } } @@ -4597,9 +4597,9 @@ impl<'a> From<&'a ast::ExprSlice> for AnyNodeRef<'a> { } } -impl<'a> From<&'a ast::ExprLineMagic> for AnyNodeRef<'a> { - fn from(node: &'a ast::ExprLineMagic) -> Self { - AnyNodeRef::ExprLineMagic(node) +impl<'a> From<&'a ast::ExprIpyEscapeCommand> for AnyNodeRef<'a> { + fn from(node: &'a ast::ExprIpyEscapeCommand) -> Self { + AnyNodeRef::ExprIpyEscapeCommand(node) } } @@ -4714,7 +4714,7 @@ impl<'a> From<&'a Stmt> for AnyNodeRef<'a> { Stmt::Pass(node) => AnyNodeRef::StmtPass(node), Stmt::Break(node) => AnyNodeRef::StmtBreak(node), Stmt::Continue(node) => AnyNodeRef::StmtContinue(node), - Stmt::LineMagic(node) => AnyNodeRef::StmtLineMagic(node), + Stmt::IpyEscapeCommand(node) => AnyNodeRef::StmtIpyEscapeCommand(node), } } } @@ -4749,7 +4749,7 @@ impl<'a> From<&'a Expr> for AnyNodeRef<'a> { Expr::List(node) => AnyNodeRef::ExprList(node), Expr::Tuple(node) => AnyNodeRef::ExprTuple(node), Expr::Slice(node) => AnyNodeRef::ExprSlice(node), - Expr::LineMagic(node) => AnyNodeRef::ExprLineMagic(node), + Expr::IpyEscapeCommand(node) => AnyNodeRef::ExprIpyEscapeCommand(node), } } } @@ -4874,7 +4874,7 @@ impl Ranged for AnyNodeRef<'_> { AnyNodeRef::StmtPass(node) => node.range(), AnyNodeRef::StmtBreak(node) => node.range(), AnyNodeRef::StmtContinue(node) => node.range(), - AnyNodeRef::StmtLineMagic(node) => node.range(), + AnyNodeRef::StmtIpyEscapeCommand(node) => node.range(), AnyNodeRef::ExprBoolOp(node) => node.range(), AnyNodeRef::ExprNamedExpr(node) => node.range(), AnyNodeRef::ExprBinOp(node) => node.range(), @@ -4902,7 +4902,7 @@ impl Ranged for AnyNodeRef<'_> { AnyNodeRef::ExprList(node) => node.range(), AnyNodeRef::ExprTuple(node) => node.range(), AnyNodeRef::ExprSlice(node) => node.range(), - AnyNodeRef::ExprLineMagic(node) => node.range(), + AnyNodeRef::ExprIpyEscapeCommand(node) => node.range(), AnyNodeRef::ExceptHandlerExceptHandler(node) => node.range(), AnyNodeRef::PatternMatchValue(node) => node.range(), AnyNodeRef::PatternMatchSingleton(node) => node.range(), @@ -4958,7 +4958,7 @@ pub enum NodeKind { StmtImportFrom, StmtGlobal, StmtNonlocal, - StmtLineMagic, + StmtIpyEscapeCommand, StmtExpr, StmtPass, StmtBreak, @@ -4990,7 +4990,7 @@ pub enum NodeKind { ExprList, ExprTuple, ExprSlice, - ExprLineMagic, + ExprIpyEscapeCommand, ExceptHandlerExceptHandler, PatternMatchValue, PatternMatchSingleton, diff --git a/crates/ruff_python_ast/src/nodes.rs b/crates/ruff_python_ast/src/nodes.rs index 94c93c82b1c6d..46efa5b09807f 100644 --- a/crates/ruff_python_ast/src/nodes.rs +++ b/crates/ruff_python_ast/src/nodes.rs @@ -95,20 +95,20 @@ pub enum Stmt { Continue(StmtContinue), // Jupyter notebook specific - #[is(name = "line_magic_stmt")] - LineMagic(StmtLineMagic), + #[is(name = "ipy_escape_command_stmt")] + IpyEscapeCommand(StmtIpyEscapeCommand), } #[derive(Clone, Debug, PartialEq)] -pub struct StmtLineMagic { +pub struct StmtIpyEscapeCommand { pub range: TextRange, - pub kind: MagicKind, + pub kind: IpyEscapeKind, pub value: String, } -impl From for Stmt { - fn from(payload: StmtLineMagic) -> Self { - Stmt::LineMagic(payload) +impl From for Stmt { + fn from(payload: StmtIpyEscapeCommand) -> Self { + Stmt::IpyEscapeCommand(payload) } } @@ -570,20 +570,20 @@ pub enum Expr { Slice(ExprSlice), // Jupyter notebook specific - #[is(name = "line_magic_expr")] - LineMagic(ExprLineMagic), + #[is(name = "ipy_escape_command_expr")] + IpyEscapeCommand(ExprIpyEscapeCommand), } #[derive(Clone, Debug, PartialEq)] -pub struct ExprLineMagic { +pub struct ExprIpyEscapeCommand { pub range: TextRange, - pub kind: MagicKind, + pub kind: IpyEscapeKind, pub value: String, } -impl From for Expr { - fn from(payload: ExprLineMagic) -> Self { - Expr::LineMagic(payload) +impl From for Expr { + fn from(payload: ExprIpyEscapeCommand) -> Self { + Expr::IpyEscapeCommand(payload) } } @@ -2253,103 +2253,103 @@ impl Parameters { } } -/// The kind of magic command as defined in [IPython Syntax] in the IPython codebase. +/// The kind of escape command as defined in [IPython Syntax] in the IPython codebase. /// /// [IPython Syntax]: https://github.com/ipython/ipython/blob/635815e8f1ded5b764d66cacc80bbe25e9e2587f/IPython/core/inputtransformer2.py#L335-L343 #[derive(PartialEq, Eq, Debug, Clone, Hash, Copy)] -pub enum MagicKind { - /// Send line to underlying system shell. +pub enum IpyEscapeKind { + /// Send line to underlying system shell (`!`). Shell, - /// Send line to system shell and capture output. + /// Send line to system shell and capture output (`!!`). ShCap, - /// Show help on object. + /// Show help on object (`?`). Help, - /// Show help on object, with extra verbosity. + /// Show help on object, with extra verbosity (`??`). Help2, - /// Call magic function. + /// Call magic function (`%`). Magic, - /// Call cell magic function. + /// Call cell magic function (`%%`). Magic2, /// Call first argument with rest of line as arguments after splitting on whitespace - /// and quote each as string. + /// and quote each as string (`,`). Quote, - /// Call first argument with rest of line as an argument quoted as a single string. + /// Call first argument with rest of line as an argument quoted as a single string (`;`). Quote2, - /// Call first argument with rest of line as arguments. + /// Call first argument with rest of line as arguments (`/`). Paren, } -impl TryFrom for MagicKind { +impl TryFrom for IpyEscapeKind { type Error = String; fn try_from(ch: char) -> Result { match ch { - '!' => Ok(MagicKind::Shell), - '?' => Ok(MagicKind::Help), - '%' => Ok(MagicKind::Magic), - ',' => Ok(MagicKind::Quote), - ';' => Ok(MagicKind::Quote2), - '/' => Ok(MagicKind::Paren), + '!' => Ok(IpyEscapeKind::Shell), + '?' => Ok(IpyEscapeKind::Help), + '%' => Ok(IpyEscapeKind::Magic), + ',' => Ok(IpyEscapeKind::Quote), + ';' => Ok(IpyEscapeKind::Quote2), + '/' => Ok(IpyEscapeKind::Paren), _ => Err(format!("Unexpected magic escape: {ch}")), } } } -impl TryFrom<[char; 2]> for MagicKind { +impl TryFrom<[char; 2]> for IpyEscapeKind { type Error = String; fn try_from(ch: [char; 2]) -> Result { match ch { - ['!', '!'] => Ok(MagicKind::ShCap), - ['?', '?'] => Ok(MagicKind::Help2), - ['%', '%'] => Ok(MagicKind::Magic2), + ['!', '!'] => Ok(IpyEscapeKind::ShCap), + ['?', '?'] => Ok(IpyEscapeKind::Help2), + ['%', '%'] => Ok(IpyEscapeKind::Magic2), [c1, c2] => Err(format!("Unexpected magic escape: {c1}{c2}")), } } } -impl fmt::Display for MagicKind { +impl fmt::Display for IpyEscapeKind { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { f.write_str(self.as_str()) } } -impl MagicKind { - /// Returns the length of the magic command prefix. +impl IpyEscapeKind { + /// Returns the length of the escape kind token. pub fn prefix_len(self) -> TextSize { let len = match self { - MagicKind::Shell - | MagicKind::Magic - | MagicKind::Help - | MagicKind::Quote - | MagicKind::Quote2 - | MagicKind::Paren => 1, - MagicKind::ShCap | MagicKind::Magic2 | MagicKind::Help2 => 2, + IpyEscapeKind::Shell + | IpyEscapeKind::Magic + | IpyEscapeKind::Help + | IpyEscapeKind::Quote + | IpyEscapeKind::Quote2 + | IpyEscapeKind::Paren => 1, + IpyEscapeKind::ShCap | IpyEscapeKind::Magic2 | IpyEscapeKind::Help2 => 2, }; len.into() } - /// Returns `true` if the kind is a help command i.e., `?` or `??`. + /// Returns `true` if the escape kind is help i.e., `?` or `??`. pub const fn is_help(self) -> bool { - matches!(self, MagicKind::Help | MagicKind::Help2) + matches!(self, IpyEscapeKind::Help | IpyEscapeKind::Help2) } - /// Returns `true` if the kind is a magic command i.e., `%` or `%%`. + /// Returns `true` if the escape kind is magic i.e., `%` or `%%`. pub const fn is_magic(self) -> bool { - matches!(self, MagicKind::Magic | MagicKind::Magic2) + matches!(self, IpyEscapeKind::Magic | IpyEscapeKind::Magic2) } pub fn as_str(self) -> &'static str { match self { - MagicKind::Shell => "!", - MagicKind::ShCap => "!!", - MagicKind::Help => "?", - MagicKind::Help2 => "??", - MagicKind::Magic => "%", - MagicKind::Magic2 => "%%", - MagicKind::Quote => ",", - MagicKind::Quote2 => ";", - MagicKind::Paren => "/", + IpyEscapeKind::Shell => "!", + IpyEscapeKind::ShCap => "!!", + IpyEscapeKind::Help => "?", + IpyEscapeKind::Help2 => "??", + IpyEscapeKind::Magic => "%", + IpyEscapeKind::Magic2 => "%%", + IpyEscapeKind::Quote => ",", + IpyEscapeKind::Quote2 => ";", + IpyEscapeKind::Paren => "/", } } } @@ -2686,7 +2686,7 @@ impl Ranged for crate::nodes::StmtContinue { self.range } } -impl Ranged for StmtLineMagic { +impl Ranged for StmtIpyEscapeCommand { fn range(&self) -> TextRange { self.range } @@ -2719,7 +2719,7 @@ impl Ranged for crate::Stmt { Self::Pass(node) => node.range(), Self::Break(node) => node.range(), Self::Continue(node) => node.range(), - Stmt::LineMagic(node) => node.range(), + Stmt::IpyEscapeCommand(node) => node.range(), } } } @@ -2859,7 +2859,7 @@ impl Ranged for crate::nodes::ExprSlice { self.range } } -impl Ranged for ExprLineMagic { +impl Ranged for ExprIpyEscapeCommand { fn range(&self) -> TextRange { self.range } @@ -2894,7 +2894,7 @@ impl Ranged for crate::Expr { Self::List(node) => node.range(), Self::Tuple(node) => node.range(), Self::Slice(node) => node.range(), - Expr::LineMagic(node) => node.range(), + Expr::IpyEscapeCommand(node) => node.range(), } } } diff --git a/crates/ruff_python_ast/src/relocate.rs b/crates/ruff_python_ast/src/relocate.rs index daf02214b0aa5..292101e66468d 100644 --- a/crates/ruff_python_ast/src/relocate.rs +++ b/crates/ruff_python_ast/src/relocate.rs @@ -199,7 +199,7 @@ pub fn relocate_expr(expr: &mut Expr, location: TextRange) { relocate_expr(expr, location); } } - Expr::LineMagic(nodes::ExprLineMagic { range, .. }) => { + Expr::IpyEscapeCommand(nodes::ExprIpyEscapeCommand { range, .. }) => { *range = location; } } diff --git a/crates/ruff_python_ast/src/visitor.rs b/crates/ruff_python_ast/src/visitor.rs index 527c7e187ae42..a4a517026b9b6 100644 --- a/crates/ruff_python_ast/src/visitor.rs +++ b/crates/ruff_python_ast/src/visitor.rs @@ -312,7 +312,7 @@ pub fn walk_stmt<'a, V: Visitor<'a> + ?Sized>(visitor: &mut V, stmt: &'a Stmt) { Stmt::Global(_) => {} Stmt::Nonlocal(_) => {} Stmt::Expr(ast::StmtExpr { value, range: _ }) => visitor.visit_expr(value), - Stmt::Pass(_) | Stmt::Break(_) | Stmt::Continue(_) | Stmt::LineMagic(_) => {} + Stmt::Pass(_) | Stmt::Break(_) | Stmt::Continue(_) | Stmt::IpyEscapeCommand(_) => {} } } @@ -543,7 +543,7 @@ pub fn walk_expr<'a, V: Visitor<'a> + ?Sized>(visitor: &mut V, expr: &'a Expr) { visitor.visit_expr(expr); } } - Expr::LineMagic(_) => {} + Expr::IpyEscapeCommand(_) => {} } } diff --git a/crates/ruff_python_ast/src/visitor/preorder.rs b/crates/ruff_python_ast/src/visitor/preorder.rs index 1e18bf25442b9..b96b5228b181d 100644 --- a/crates/ruff_python_ast/src/visitor/preorder.rs +++ b/crates/ruff_python_ast/src/visitor/preorder.rs @@ -418,7 +418,7 @@ where | Stmt::Continue(_) | Stmt::Global(_) | Stmt::Nonlocal(_) - | Stmt::LineMagic(_) => {} + | Stmt::IpyEscapeCommand(_) => {} } } @@ -719,7 +719,7 @@ where visitor.visit_expr(expr); } } - Expr::LineMagic(_) => (), + Expr::IpyEscapeCommand(_) => (), } } diff --git a/crates/ruff_python_codegen/src/generator.rs b/crates/ruff_python_codegen/src/generator.rs index e67b76d2d792d..65a12802729ae 100644 --- a/crates/ruff_python_codegen/src/generator.rs +++ b/crates/ruff_python_codegen/src/generator.rs @@ -656,7 +656,7 @@ impl<'a> Generator<'a> { self.p("continue"); }); } - Stmt::LineMagic(ast::StmtLineMagic { kind, value, .. }) => { + Stmt::IpyEscapeCommand(ast::StmtIpyEscapeCommand { kind, value, .. }) => { statement!({ self.p(&format!("{kind}{value}")); }); @@ -1184,7 +1184,7 @@ impl<'a> Generator<'a> { self.unparse_expr(step, precedence::SLICE); } } - Expr::LineMagic(ast::ExprLineMagic { kind, value, .. }) => { + Expr::IpyEscapeCommand(ast::ExprIpyEscapeCommand { kind, value, .. }) => { self.p(&format!("{kind}{value}")); } } diff --git a/crates/ruff_python_formatter/src/expression/expr_ipy_escape_command.rs b/crates/ruff_python_formatter/src/expression/expr_ipy_escape_command.rs new file mode 100644 index 0000000000000..ab087df6855ee --- /dev/null +++ b/crates/ruff_python_formatter/src/expression/expr_ipy_escape_command.rs @@ -0,0 +1,12 @@ +use crate::{verbatim_text, FormatNodeRule, PyFormatter}; +use ruff_formatter::{write, Buffer, FormatResult}; +use ruff_python_ast::ExprIpyEscapeCommand; + +#[derive(Default)] +pub struct FormatExprIpyEscapeCommand; + +impl FormatNodeRule for FormatExprIpyEscapeCommand { + fn fmt_fields(&self, item: &ExprIpyEscapeCommand, f: &mut PyFormatter) -> FormatResult<()> { + write!(f, [verbatim_text(item)]) + } +} diff --git a/crates/ruff_python_formatter/src/expression/expr_line_magic.rs b/crates/ruff_python_formatter/src/expression/expr_line_magic.rs deleted file mode 100644 index 5d1d93d5653e3..0000000000000 --- a/crates/ruff_python_formatter/src/expression/expr_line_magic.rs +++ /dev/null @@ -1,12 +0,0 @@ -use crate::{verbatim_text, FormatNodeRule, PyFormatter}; -use ruff_formatter::{write, Buffer, FormatResult}; -use ruff_python_ast::ExprLineMagic; - -#[derive(Default)] -pub struct FormatExprLineMagic; - -impl FormatNodeRule for FormatExprLineMagic { - fn fmt_fields(&self, item: &ExprLineMagic, f: &mut PyFormatter) -> FormatResult<()> { - write!(f, [verbatim_text(item)]) - } -} diff --git a/crates/ruff_python_formatter/src/expression/mod.rs b/crates/ruff_python_formatter/src/expression/mod.rs index 8fc5fe6a04b60..672e7f4c728bc 100644 --- a/crates/ruff_python_formatter/src/expression/mod.rs +++ b/crates/ruff_python_formatter/src/expression/mod.rs @@ -31,8 +31,8 @@ pub(crate) mod expr_f_string; pub(crate) mod expr_formatted_value; pub(crate) mod expr_generator_exp; pub(crate) mod expr_if_exp; +pub(crate) mod expr_ipy_escape_command; pub(crate) mod expr_lambda; -pub(crate) mod expr_line_magic; pub(crate) mod expr_list; pub(crate) mod expr_list_comp; pub(crate) mod expr_name; @@ -102,7 +102,7 @@ impl FormatRule> for FormatExpr { Expr::List(expr) => expr.format().fmt(f), Expr::Tuple(expr) => expr.format().fmt(f), Expr::Slice(expr) => expr.format().fmt(f), - Expr::LineMagic(_) => todo!(), + Expr::IpyEscapeCommand(_) => todo!(), }); let parenthesize = match parentheses { @@ -240,7 +240,7 @@ impl NeedsParentheses for Expr { Expr::List(expr) => expr.needs_parentheses(parent, context), Expr::Tuple(expr) => expr.needs_parentheses(parent, context), Expr::Slice(expr) => expr.needs_parentheses(parent, context), - Expr::LineMagic(_) => todo!(), + Expr::IpyEscapeCommand(_) => todo!(), } } } @@ -434,7 +434,7 @@ impl<'input> CanOmitOptionalParenthesesVisitor<'input> { | Expr::Starred(_) | Expr::Name(_) | Expr::Slice(_) => {} - Expr::LineMagic(_) => todo!(), + Expr::IpyEscapeCommand(_) => todo!(), }; walk_expr(self, expr); diff --git a/crates/ruff_python_formatter/src/generated.rs b/crates/ruff_python_formatter/src/generated.rs index b5c3e08042431..13617df622f9b 100644 --- a/crates/ruff_python_formatter/src/generated.rs +++ b/crates/ruff_python_formatter/src/generated.rs @@ -930,38 +930,38 @@ impl<'ast> IntoFormat> for ast::StmtContinue { } } -impl FormatRule> - for crate::statement::stmt_line_magic::FormatStmtLineMagic +impl FormatRule> + for crate::statement::stmt_ipy_escape_command::FormatStmtIpyEscapeCommand { #[inline] - fn fmt(&self, node: &ast::StmtLineMagic, f: &mut PyFormatter) -> FormatResult<()> { - FormatNodeRule::::fmt(self, node, f) + fn fmt(&self, node: &ast::StmtIpyEscapeCommand, f: &mut PyFormatter) -> FormatResult<()> { + FormatNodeRule::::fmt(self, node, f) } } -impl<'ast> AsFormat> for ast::StmtLineMagic { +impl<'ast> AsFormat> for ast::StmtIpyEscapeCommand { type Format<'a> = FormatRefWithRule< 'a, - ast::StmtLineMagic, - crate::statement::stmt_line_magic::FormatStmtLineMagic, + ast::StmtIpyEscapeCommand, + crate::statement::stmt_ipy_escape_command::FormatStmtIpyEscapeCommand, PyFormatContext<'ast>, >; fn format(&self) -> Self::Format<'_> { FormatRefWithRule::new( self, - crate::statement::stmt_line_magic::FormatStmtLineMagic::default(), + crate::statement::stmt_ipy_escape_command::FormatStmtIpyEscapeCommand::default(), ) } } -impl<'ast> IntoFormat> for ast::StmtLineMagic { +impl<'ast> IntoFormat> for ast::StmtIpyEscapeCommand { type Format = FormatOwnedWithRule< - ast::StmtLineMagic, - crate::statement::stmt_line_magic::FormatStmtLineMagic, + ast::StmtIpyEscapeCommand, + crate::statement::stmt_ipy_escape_command::FormatStmtIpyEscapeCommand, PyFormatContext<'ast>, >; fn into_format(self) -> Self::Format { FormatOwnedWithRule::new( self, - crate::statement::stmt_line_magic::FormatStmtLineMagic::default(), + crate::statement::stmt_ipy_escape_command::FormatStmtIpyEscapeCommand::default(), ) } } @@ -1930,38 +1930,38 @@ impl<'ast> IntoFormat> for ast::ExprSlice { } } -impl FormatRule> - for crate::expression::expr_line_magic::FormatExprLineMagic +impl FormatRule> + for crate::expression::expr_ipy_escape_command::FormatExprIpyEscapeCommand { #[inline] - fn fmt(&self, node: &ast::ExprLineMagic, f: &mut PyFormatter) -> FormatResult<()> { - FormatNodeRule::::fmt(self, node, f) + fn fmt(&self, node: &ast::ExprIpyEscapeCommand, f: &mut PyFormatter) -> FormatResult<()> { + FormatNodeRule::::fmt(self, node, f) } } -impl<'ast> AsFormat> for ast::ExprLineMagic { +impl<'ast> AsFormat> for ast::ExprIpyEscapeCommand { type Format<'a> = FormatRefWithRule< 'a, - ast::ExprLineMagic, - crate::expression::expr_line_magic::FormatExprLineMagic, + ast::ExprIpyEscapeCommand, + crate::expression::expr_ipy_escape_command::FormatExprIpyEscapeCommand, PyFormatContext<'ast>, >; fn format(&self) -> Self::Format<'_> { FormatRefWithRule::new( self, - crate::expression::expr_line_magic::FormatExprLineMagic::default(), + crate::expression::expr_ipy_escape_command::FormatExprIpyEscapeCommand::default(), ) } } -impl<'ast> IntoFormat> for ast::ExprLineMagic { +impl<'ast> IntoFormat> for ast::ExprIpyEscapeCommand { type Format = FormatOwnedWithRule< - ast::ExprLineMagic, - crate::expression::expr_line_magic::FormatExprLineMagic, + ast::ExprIpyEscapeCommand, + crate::expression::expr_ipy_escape_command::FormatExprIpyEscapeCommand, PyFormatContext<'ast>, >; fn into_format(self) -> Self::Format { FormatOwnedWithRule::new( self, - crate::expression::expr_line_magic::FormatExprLineMagic::default(), + crate::expression::expr_ipy_escape_command::FormatExprIpyEscapeCommand::default(), ) } } diff --git a/crates/ruff_python_formatter/src/statement/mod.rs b/crates/ruff_python_formatter/src/statement/mod.rs index 1a92f03e39ea4..aeaf272ab79c5 100644 --- a/crates/ruff_python_formatter/src/statement/mod.rs +++ b/crates/ruff_python_formatter/src/statement/mod.rs @@ -17,7 +17,7 @@ pub(crate) mod stmt_global; pub(crate) mod stmt_if; pub(crate) mod stmt_import; pub(crate) mod stmt_import_from; -pub(crate) mod stmt_line_magic; +pub(crate) mod stmt_ipy_escape_command; pub(crate) mod stmt_match; pub(crate) mod stmt_nonlocal; pub(crate) mod stmt_pass; @@ -61,7 +61,7 @@ impl FormatRule> for FormatStmt { Stmt::Break(x) => x.format().fmt(f), Stmt::Continue(x) => x.format().fmt(f), Stmt::TypeAlias(x) => x.format().fmt(f), - Stmt::LineMagic(_) => todo!(), + Stmt::IpyEscapeCommand(_) => todo!(), } } } diff --git a/crates/ruff_python_formatter/src/statement/stmt_ipy_escape_command.rs b/crates/ruff_python_formatter/src/statement/stmt_ipy_escape_command.rs new file mode 100644 index 0000000000000..008c22b7934f1 --- /dev/null +++ b/crates/ruff_python_formatter/src/statement/stmt_ipy_escape_command.rs @@ -0,0 +1,12 @@ +use crate::{verbatim_text, FormatNodeRule, PyFormatter}; +use ruff_formatter::{write, Buffer, FormatResult}; +use ruff_python_ast::StmtIpyEscapeCommand; + +#[derive(Default)] +pub struct FormatStmtIpyEscapeCommand; + +impl FormatNodeRule for FormatStmtIpyEscapeCommand { + fn fmt_fields(&self, item: &StmtIpyEscapeCommand, f: &mut PyFormatter) -> FormatResult<()> { + write!(f, [verbatim_text(item)]) + } +} diff --git a/crates/ruff_python_formatter/src/statement/stmt_line_magic.rs b/crates/ruff_python_formatter/src/statement/stmt_line_magic.rs deleted file mode 100644 index 906bd9a148d91..0000000000000 --- a/crates/ruff_python_formatter/src/statement/stmt_line_magic.rs +++ /dev/null @@ -1,12 +0,0 @@ -use crate::{verbatim_text, FormatNodeRule, PyFormatter}; -use ruff_formatter::{write, Buffer, FormatResult}; -use ruff_python_ast::StmtLineMagic; - -#[derive(Default)] -pub struct FormatStmtLineMagic; - -impl FormatNodeRule for FormatStmtLineMagic { - fn fmt_fields(&self, item: &StmtLineMagic, f: &mut PyFormatter) -> FormatResult<()> { - write!(f, [verbatim_text(item)]) - } -} diff --git a/crates/ruff_python_parser/src/lexer.rs b/crates/ruff_python_parser/src/lexer.rs index 23664711793a5..6bb9c79e555b7 100644 --- a/crates/ruff_python_parser/src/lexer.rs +++ b/crates/ruff_python_parser/src/lexer.rs @@ -34,7 +34,7 @@ use std::{char, cmp::Ordering, str::FromStr}; use num_bigint::BigInt; use num_traits::{Num, Zero}; -use ruff_python_ast::MagicKind; +use ruff_python_ast::IpyEscapeKind; use ruff_text_size::{TextLen, TextRange, TextSize}; use unic_emoji_char::is_emoji_presentation; use unic_ucd_ident::{is_xid_continue, is_xid_start}; @@ -398,8 +398,8 @@ impl<'source> Lexer<'source> { Tok::Comment(self.token_text().to_string()) } - /// Lex a single magic command. - fn lex_magic_command(&mut self, kind: MagicKind) -> Tok { + /// Lex a single IPython escape command. + fn lex_ipython_escape_command(&mut self, escape_kind: IpyEscapeKind) -> Tok { let mut value = String::new(); loop { @@ -457,7 +457,7 @@ impl<'source> Lexer<'source> { // Now, the whitespace and empty value check also makes sure that an empty // command (e.g. `%?` or `? ??`, no value after/between the escape tokens) // is not recognized as a help end escape command. So, `%?` and `? ??` are - // `MagicKind::Magic` and `MagicKind::Help` because of the initial `%` and `??` + // `IpyEscapeKind::Magic` and `IpyEscapeKind::Help` because of the initial `%` and `??` // tokens. if question_count > 2 || value.chars().last().map_or(true, is_python_whitespace) @@ -471,31 +471,34 @@ impl<'source> Lexer<'source> { continue; } - if kind.is_help() { + if escape_kind.is_help() { // If we've recognize this as a help end escape command, then // any question mark token / whitespaces at the start are not // considered as part of the value. // - // For example, `??foo?` is recognized as `MagicKind::Help` and + // For example, `??foo?` is recognized as `IpyEscapeKind::Help` and // `value` is `foo` instead of `??foo`. value = value.trim_start_matches([' ', '?']).to_string(); - } else if kind.is_magic() { + } else if escape_kind.is_magic() { // Between `%` and `?` (at the end), the `?` takes priority - // over the `%` so `%foo?` is recognized as `MagicKind::Help` + // over the `%` so `%foo?` is recognized as `IpyEscapeKind::Help` // and `value` is `%foo` instead of `foo`. So, we need to // insert the magic escape token at the start. - value.insert_str(0, kind.as_str()); + value.insert_str(0, escape_kind.as_str()); } let kind = match question_count { - 1 => MagicKind::Help, - 2 => MagicKind::Help2, + 1 => IpyEscapeKind::Help, + 2 => IpyEscapeKind::Help2, _ => unreachable!("`question_count` is always 1 or 2"), }; - return Tok::MagicCommand { kind, value }; + return Tok::IpyEscapeCommand { kind, value }; } '\n' | '\r' | EOF_CHAR => { - return Tok::MagicCommand { kind, value }; + return Tok::IpyEscapeCommand { + kind: escape_kind, + value, + }; } c => { self.cursor.bump(); @@ -763,22 +766,22 @@ impl<'source> Lexer<'source> { && self.state.is_after_equal() && self.nesting == 0 => { - // SAFETY: Safe because `c` has been matched against one of the possible magic command prefix - self.lex_magic_command(MagicKind::try_from(c).unwrap()) + // SAFETY: Safe because `c` has been matched against one of the possible escape command token + self.lex_ipython_escape_command(IpyEscapeKind::try_from(c).unwrap()) } c @ ('%' | '!' | '?' | '/' | ';' | ',') if self.mode == Mode::Jupyter && self.state.is_new_logical_line() => { - let kind = if let Ok(kind) = MagicKind::try_from([c, self.cursor.first()]) { + let kind = if let Ok(kind) = IpyEscapeKind::try_from([c, self.cursor.first()]) { self.cursor.bump(); kind } else { - // SAFETY: Safe because `c` has been matched against one of the possible magic command prefix - MagicKind::try_from(c).unwrap() + // SAFETY: Safe because `c` has been matched against one of the possible escape command token + IpyEscapeKind::try_from(c).unwrap() }; - self.lex_magic_command(kind) + self.lex_ipython_escape_command(kind) } '?' if self.mode == Mode::Jupyter => Tok::Question, @@ -1208,7 +1211,7 @@ const fn is_python_whitespace(c: char) -> bool { #[cfg(test)] mod tests { use num_bigint::BigInt; - use ruff_python_ast::MagicKind; + use ruff_python_ast::IpyEscapeKind; use super::*; @@ -1242,15 +1245,15 @@ mod tests { } } - fn assert_jupyter_magic_line_continuation_with_eol(eol: &str) { + fn assert_ipython_escape_command_line_continuation_with_eol(eol: &str) { let source = format!("%matplotlib \\{eol} --inline"); let tokens = lex_jupyter_source(&source); assert_eq!( tokens, vec![ - Tok::MagicCommand { + Tok::IpyEscapeCommand { value: "matplotlib --inline".to_string(), - kind: MagicKind::Magic + kind: IpyEscapeKind::Magic }, Tok::Newline ] @@ -1258,29 +1261,29 @@ mod tests { } #[test] - fn test_jupyter_magic_line_continuation_unix_eol() { - assert_jupyter_magic_line_continuation_with_eol(UNIX_EOL); + fn test_ipython_escape_command_line_continuation_unix_eol() { + assert_ipython_escape_command_line_continuation_with_eol(UNIX_EOL); } #[test] - fn test_jupyter_magic_line_continuation_mac_eol() { - assert_jupyter_magic_line_continuation_with_eol(MAC_EOL); + fn test_ipython_escape_command_line_continuation_mac_eol() { + assert_ipython_escape_command_line_continuation_with_eol(MAC_EOL); } #[test] - fn test_jupyter_magic_line_continuation_windows_eol() { - assert_jupyter_magic_line_continuation_with_eol(WINDOWS_EOL); + fn test_ipython_escape_command_line_continuation_windows_eol() { + assert_ipython_escape_command_line_continuation_with_eol(WINDOWS_EOL); } - fn assert_jupyter_magic_line_continuation_with_eol_and_eof(eol: &str) { + fn assert_ipython_escape_command_line_continuation_with_eol_and_eof(eol: &str) { let source = format!("%matplotlib \\{eol}"); let tokens = lex_jupyter_source(&source); assert_eq!( tokens, vec![ - Tok::MagicCommand { + Tok::IpyEscapeCommand { value: "matplotlib ".to_string(), - kind: MagicKind::Magic + kind: IpyEscapeKind::Magic }, Tok::Newline ] @@ -1288,70 +1291,70 @@ mod tests { } #[test] - fn test_jupyter_magic_line_continuation_unix_eol_and_eof() { - assert_jupyter_magic_line_continuation_with_eol_and_eof(UNIX_EOL); + fn test_ipython_escape_command_line_continuation_unix_eol_and_eof() { + assert_ipython_escape_command_line_continuation_with_eol_and_eof(UNIX_EOL); } #[test] - fn test_jupyter_magic_line_continuation_mac_eol_and_eof() { - assert_jupyter_magic_line_continuation_with_eol_and_eof(MAC_EOL); + fn test_ipython_escape_command_line_continuation_mac_eol_and_eof() { + assert_ipython_escape_command_line_continuation_with_eol_and_eof(MAC_EOL); } #[test] - fn test_jupyter_magic_line_continuation_windows_eol_and_eof() { - assert_jupyter_magic_line_continuation_with_eol_and_eof(WINDOWS_EOL); + fn test_ipython_escape_command_line_continuation_windows_eol_and_eof() { + assert_ipython_escape_command_line_continuation_with_eol_and_eof(WINDOWS_EOL); } #[test] - fn test_empty_jupyter_magic() { + fn test_empty_ipython_escape_command() { let source = "%\n%%\n!\n!!\n?\n??\n/\n,\n;"; let tokens = lex_jupyter_source(source); assert_eq!( tokens, vec![ - Tok::MagicCommand { + Tok::IpyEscapeCommand { value: String::new(), - kind: MagicKind::Magic, + kind: IpyEscapeKind::Magic, }, Tok::Newline, - Tok::MagicCommand { + Tok::IpyEscapeCommand { value: String::new(), - kind: MagicKind::Magic2, + kind: IpyEscapeKind::Magic2, }, Tok::Newline, - Tok::MagicCommand { + Tok::IpyEscapeCommand { value: String::new(), - kind: MagicKind::Shell, + kind: IpyEscapeKind::Shell, }, Tok::Newline, - Tok::MagicCommand { + Tok::IpyEscapeCommand { value: String::new(), - kind: MagicKind::ShCap, + kind: IpyEscapeKind::ShCap, }, Tok::Newline, - Tok::MagicCommand { + Tok::IpyEscapeCommand { value: String::new(), - kind: MagicKind::Help, + kind: IpyEscapeKind::Help, }, Tok::Newline, - Tok::MagicCommand { + Tok::IpyEscapeCommand { value: String::new(), - kind: MagicKind::Help2, + kind: IpyEscapeKind::Help2, }, Tok::Newline, - Tok::MagicCommand { + Tok::IpyEscapeCommand { value: String::new(), - kind: MagicKind::Paren, + kind: IpyEscapeKind::Paren, }, Tok::Newline, - Tok::MagicCommand { + Tok::IpyEscapeCommand { value: String::new(), - kind: MagicKind::Quote, + kind: IpyEscapeKind::Quote, }, Tok::Newline, - Tok::MagicCommand { + Tok::IpyEscapeCommand { value: String::new(), - kind: MagicKind::Quote2, + kind: IpyEscapeKind::Quote2, }, Tok::Newline, ] @@ -1359,7 +1362,7 @@ mod tests { } #[test] - fn test_jupyter_magic() { + fn test_ipython_escape_command() { let source = r" ?foo ??foo @@ -1380,59 +1383,59 @@ mod tests { assert_eq!( tokens, vec![ - Tok::MagicCommand { + Tok::IpyEscapeCommand { value: "foo".to_string(), - kind: MagicKind::Help, + kind: IpyEscapeKind::Help, }, Tok::Newline, - Tok::MagicCommand { + Tok::IpyEscapeCommand { value: "foo".to_string(), - kind: MagicKind::Help2, + kind: IpyEscapeKind::Help2, }, Tok::Newline, - Tok::MagicCommand { + Tok::IpyEscapeCommand { value: "timeit a = b".to_string(), - kind: MagicKind::Magic, + kind: IpyEscapeKind::Magic, }, Tok::Newline, - Tok::MagicCommand { + Tok::IpyEscapeCommand { value: "timeit a % 3".to_string(), - kind: MagicKind::Magic, + kind: IpyEscapeKind::Magic, }, Tok::Newline, - Tok::MagicCommand { + Tok::IpyEscapeCommand { value: "matplotlib --inline".to_string(), - kind: MagicKind::Magic, + kind: IpyEscapeKind::Magic, }, Tok::Newline, - Tok::MagicCommand { + Tok::IpyEscapeCommand { value: "pwd && ls -a | sed 's/^/\\\\ /'".to_string(), - kind: MagicKind::Shell, + kind: IpyEscapeKind::Shell, }, Tok::Newline, - Tok::MagicCommand { + Tok::IpyEscapeCommand { value: "cd /Users/foo/Library/Application\\ Support/".to_string(), - kind: MagicKind::ShCap, + kind: IpyEscapeKind::ShCap, }, Tok::Newline, - Tok::MagicCommand { + Tok::IpyEscapeCommand { value: "foo 1 2".to_string(), - kind: MagicKind::Paren, + kind: IpyEscapeKind::Paren, }, Tok::Newline, - Tok::MagicCommand { + Tok::IpyEscapeCommand { value: "foo 1 2".to_string(), - kind: MagicKind::Quote, + kind: IpyEscapeKind::Quote, }, Tok::Newline, - Tok::MagicCommand { + Tok::IpyEscapeCommand { value: "foo 1 2".to_string(), - kind: MagicKind::Quote2, + kind: IpyEscapeKind::Quote2, }, Tok::Newline, - Tok::MagicCommand { + Tok::IpyEscapeCommand { value: "ls".to_string(), - kind: MagicKind::Shell, + kind: IpyEscapeKind::Shell, }, Tok::Newline, ] @@ -1440,7 +1443,7 @@ mod tests { } #[test] - fn test_jupyter_magic_help_end() { + fn test_ipython_help_end_escape_command() { let source = r" ?foo? ?? foo? @@ -1465,84 +1468,84 @@ mod tests { assert_eq!( tokens, [ - Tok::MagicCommand { + Tok::IpyEscapeCommand { value: "foo".to_string(), - kind: MagicKind::Help, + kind: IpyEscapeKind::Help, }, Tok::Newline, - Tok::MagicCommand { + Tok::IpyEscapeCommand { value: "foo".to_string(), - kind: MagicKind::Help, + kind: IpyEscapeKind::Help, }, Tok::Newline, - Tok::MagicCommand { + Tok::IpyEscapeCommand { value: " foo ?".to_string(), - kind: MagicKind::Help2, + kind: IpyEscapeKind::Help2, }, Tok::Newline, - Tok::MagicCommand { + Tok::IpyEscapeCommand { value: "foo".to_string(), - kind: MagicKind::Help2, + kind: IpyEscapeKind::Help2, }, Tok::Newline, - Tok::MagicCommand { + Tok::IpyEscapeCommand { value: "foo".to_string(), - kind: MagicKind::Help2, + kind: IpyEscapeKind::Help2, }, Tok::Newline, - Tok::MagicCommand { + Tok::IpyEscapeCommand { value: "foo".to_string(), - kind: MagicKind::Help, + kind: IpyEscapeKind::Help, }, Tok::Newline, - Tok::MagicCommand { + Tok::IpyEscapeCommand { value: "foo".to_string(), - kind: MagicKind::Help2, + kind: IpyEscapeKind::Help2, }, Tok::Newline, - Tok::MagicCommand { + Tok::IpyEscapeCommand { value: "foo???".to_string(), - kind: MagicKind::Help2, + kind: IpyEscapeKind::Help2, }, Tok::Newline, - Tok::MagicCommand { + Tok::IpyEscapeCommand { value: "?foo???".to_string(), - kind: MagicKind::Help2, + kind: IpyEscapeKind::Help2, }, Tok::Newline, - Tok::MagicCommand { + Tok::IpyEscapeCommand { value: "foo".to_string(), - kind: MagicKind::Help, + kind: IpyEscapeKind::Help, }, Tok::Newline, - Tok::MagicCommand { + Tok::IpyEscapeCommand { value: " ?".to_string(), - kind: MagicKind::Help2, + kind: IpyEscapeKind::Help2, }, Tok::Newline, - Tok::MagicCommand { + Tok::IpyEscapeCommand { value: "??".to_string(), - kind: MagicKind::Help2, + kind: IpyEscapeKind::Help2, }, Tok::Newline, - Tok::MagicCommand { + Tok::IpyEscapeCommand { value: "%foo".to_string(), - kind: MagicKind::Help, + kind: IpyEscapeKind::Help, }, Tok::Newline, - Tok::MagicCommand { + Tok::IpyEscapeCommand { value: "%foo".to_string(), - kind: MagicKind::Help2, + kind: IpyEscapeKind::Help2, }, Tok::Newline, - Tok::MagicCommand { + Tok::IpyEscapeCommand { value: "foo???".to_string(), - kind: MagicKind::Magic2, + kind: IpyEscapeKind::Magic2, }, Tok::Newline, - Tok::MagicCommand { + Tok::IpyEscapeCommand { value: "pwd".to_string(), - kind: MagicKind::Help, + kind: IpyEscapeKind::Help, }, Tok::Newline, ] @@ -1550,7 +1553,7 @@ mod tests { } #[test] - fn test_jupyter_magic_indentation() { + fn test_ipython_escape_command_indentation() { let source = r" if True: %matplotlib \ @@ -1565,9 +1568,9 @@ if True: Tok::Colon, Tok::Newline, Tok::Indent, - Tok::MagicCommand { + Tok::IpyEscapeCommand { value: "matplotlib --inline".to_string(), - kind: MagicKind::Magic, + kind: IpyEscapeKind::Magic, }, Tok::Newline, Tok::Dedent, @@ -1576,7 +1579,7 @@ if True: } #[test] - fn test_jupyter_magic_assignment() { + fn test_ipython_escape_command_assignment() { let source = r" pwd = !pwd foo = %timeit a = b @@ -1592,54 +1595,54 @@ baz = %matplotlib \ name: "pwd".to_string() }, Tok::Equal, - Tok::MagicCommand { + Tok::IpyEscapeCommand { value: "pwd".to_string(), - kind: MagicKind::Shell, + kind: IpyEscapeKind::Shell, }, Tok::Newline, Tok::Name { name: "foo".to_string() }, Tok::Equal, - Tok::MagicCommand { + Tok::IpyEscapeCommand { value: "timeit a = b".to_string(), - kind: MagicKind::Magic, + kind: IpyEscapeKind::Magic, }, Tok::Newline, Tok::Name { name: "bar".to_string() }, Tok::Equal, - Tok::MagicCommand { + Tok::IpyEscapeCommand { value: "timeit a % 3".to_string(), - kind: MagicKind::Magic, + kind: IpyEscapeKind::Magic, }, Tok::Newline, Tok::Name { name: "baz".to_string() }, Tok::Equal, - Tok::MagicCommand { + Tok::IpyEscapeCommand { value: "matplotlib inline".to_string(), - kind: MagicKind::Magic, + kind: IpyEscapeKind::Magic, }, Tok::Newline, ] ); } - fn assert_no_jupyter_magic(tokens: &[Tok]) { + fn assert_no_ipython_escape_command(tokens: &[Tok]) { for tok in tokens { - if let Tok::MagicCommand { .. } = tok { - panic!("Unexpected magic command token: {tok:?}") + if let Tok::IpyEscapeCommand { .. } = tok { + panic!("Unexpected escape command token: {tok:?}") } } } #[test] - fn test_jupyter_magic_not_an_assignment() { + fn test_ipython_escape_command_not_an_assignment() { let source = r" -# Other magic kinds are not valid here (can't test `foo = ?str` because '?' is not a valid token) +# Other escape kinds are not valid here (can't test `foo = ?str` because '?' is not a valid token) foo = /func foo = ;func foo = ,func @@ -1650,7 +1653,7 @@ def f(arg=%timeit a = b): pass" .trim(); let tokens = lex_jupyter_source(source); - assert_no_jupyter_magic(&tokens); + assert_no_ipython_escape_command(&tokens); } #[test] diff --git a/crates/ruff_python_parser/src/parser.rs b/crates/ruff_python_parser/src/parser.rs index b1b5b4488e82b..f87093ccaf9f9 100644 --- a/crates/ruff_python_parser/src/parser.rs +++ b/crates/ruff_python_parser/src/parser.rs @@ -117,7 +117,7 @@ pub fn parse_expression_starts_at( /// /// This function is the most general function to parse Python code. Based on the [`Mode`] supplied, /// it can be used to parse a single expression, a full Python program, an interactive expression -/// or a Python program containing Jupyter magics. +/// or a Python program containing IPython escape commands. /// /// # Example /// @@ -146,7 +146,7 @@ pub fn parse_expression_starts_at( /// assert!(program.is_ok()); /// ``` /// -/// Additionally, we can parse a Python program containing Jupyter magics: +/// Additionally, we can parse a Python program containing IPython escapes: /// /// ``` /// use ruff_python_parser::{Mode, parse}; @@ -1122,7 +1122,7 @@ class Abcd: } #[test] - fn test_jupyter_magic() { + fn test_ipython_escape_commands() { let parse_ast = parse( r#" # Normal Python code @@ -1169,7 +1169,7 @@ def foo(): ;foo 1 2 ,foo 1 2 -# Indented magic +# Indented escape commands for a in range(5): !ls @@ -1199,7 +1199,7 @@ foo.bar[0].baz[2].egg?? } #[test] - fn test_jupyter_magic_parse_error() { + fn test_ipython_escape_command_parse_error() { let source = r#" a = 1 %timeit a == 1 @@ -1209,7 +1209,7 @@ a = 1 let parse_err = parse_tokens(lxr, Mode::Module, "").unwrap_err(); assert_eq!( parse_err.to_string(), - "line magics are only allowed in Jupyter mode at byte offset 6".to_string() + "IPython escape commands are only allowed in Jupyter mode at byte offset 6".to_string() ); } } diff --git a/crates/ruff_python_parser/src/python.lalrpop b/crates/ruff_python_parser/src/python.lalrpop index a98a2317f3cf2..15ab75db65be8 100644 --- a/crates/ruff_python_parser/src/python.lalrpop +++ b/crates/ruff_python_parser/src/python.lalrpop @@ -5,7 +5,7 @@ use num_bigint::BigInt; use ruff_text_size::TextSize; -use ruff_python_ast::{self as ast, Ranged, MagicKind}; +use ruff_python_ast::{self as ast, Ranged, IpyEscapeKind}; use crate::{ Mode, lexer::{LexicalError, LexicalErrorType}, @@ -89,8 +89,8 @@ SmallStatement: ast::Stmt = { NonlocalStatement, AssertStatement, TypeAliasStatement, - LineMagicStatement, - HelpEndLineMagic, + IpyEscapeCommandStatement, + IpyHelpEndEscapeCommandStatement, }; PassStatement: ast::Stmt = { @@ -155,7 +155,7 @@ ExpressionStatement: ast::Stmt = { AssignSuffix: ast::Expr = { "=" => e, - "=" => e + "=" => e }; TestListOrYieldExpr: ast::Expr = { @@ -323,52 +323,52 @@ AssertStatement: ast::Stmt = { }, }; -LineMagicStatement: ast::Stmt = { - =>? { +IpyEscapeCommandStatement: ast::Stmt = { + =>? { if mode == Mode::Jupyter { - Ok(ast::Stmt::LineMagic( - ast::StmtLineMagic { - kind: m.0, - value: m.1, + Ok(ast::Stmt::IpyEscapeCommand( + ast::StmtIpyEscapeCommand { + kind: c.0, + value: c.1, range: (location..end_location).into() } )) } else { Err(LexicalError { - error: LexicalErrorType::OtherError("line magics are only allowed in Jupyter mode".to_string()), + error: LexicalErrorType::OtherError("IPython escape commands are only allowed in Jupyter mode".to_string()), location, })? } } } -LineMagicExpr: ast::Expr = { - =>? { +IpyEscapeCommandExpr: ast::Expr = { + =>? { if mode == Mode::Jupyter { // This should never occur as the lexer won't allow it. - if !matches!(m.0, MagicKind::Magic | MagicKind::Shell) { + if !matches!(c.0, IpyEscapeKind::Magic | IpyEscapeKind::Shell) { return Err(LexicalError { - error: LexicalErrorType::OtherError("expr line magics are only allowed for % and !".to_string()), + error: LexicalErrorType::OtherError("IPython escape command expr is only allowed for % and !".to_string()), location, })?; } - Ok(ast::Expr::LineMagic( - ast::ExprLineMagic { - kind: m.0, - value: m.1, + Ok(ast::Expr::IpyEscapeCommand( + ast::ExprIpyEscapeCommand { + kind: c.0, + value: c.1, range: (location..end_location).into() } )) } else { Err(LexicalError { - error: LexicalErrorType::OtherError("line magics are only allowed in Jupyter mode".to_string()), + error: LexicalErrorType::OtherError("IPython escape commands are only allowed in Jupyter mode".to_string()), location, })? } } } -HelpEndLineMagic: ast::Stmt = { +IpyHelpEndEscapeCommandStatement: ast::Stmt = { // We are permissive than the original implementation because we would allow whitespace // between the expression and the suffix while the IPython implementation doesn't allow it. // For example, `foo ?` would be valid in our case but invalid from IPython. @@ -404,7 +404,7 @@ HelpEndLineMagic: ast::Stmt = { } Ok(()) } - + if mode != Mode::Jupyter { return Err(ParseError::User { error: LexicalError { @@ -415,8 +415,8 @@ HelpEndLineMagic: ast::Stmt = { } let kind = match suffix.len() { - 1 => MagicKind::Help, - 2 => MagicKind::Help2, + 1 => IpyEscapeKind::Help, + 2 => IpyEscapeKind::Help2, _ => { return Err(ParseError::User { error: LexicalError { @@ -429,9 +429,9 @@ HelpEndLineMagic: ast::Stmt = { let mut value = String::new(); unparse_expr(&e, &mut value)?; - - Ok(ast::Stmt::LineMagic( - ast::StmtLineMagic { + + Ok(ast::Stmt::IpyEscapeCommand( + ast::StmtIpyEscapeCommand { kind, value, range: (location..end_location).into() @@ -1900,8 +1900,8 @@ extern { triple_quoted: }, name => token::Tok::Name { name: }, - line_magic => token::Tok::MagicCommand { - kind: , + ipy_escape_command => token::Tok::IpyEscapeCommand { + kind: , value: }, "\n" => token::Tok::Newline, diff --git a/crates/ruff_python_parser/src/python.rs b/crates/ruff_python_parser/src/python.rs index da4a9a1ce9984..209f8c89a1652 100644 --- a/crates/ruff_python_parser/src/python.rs +++ b/crates/ruff_python_parser/src/python.rs @@ -1,8 +1,8 @@ // auto-generated: "lalrpop 0.20.0" -// sha3: dec845ec3261934e0c3a17a15f53b12d397b19cee9a45f9d8868c93484de3fe3 +// sha3: eea7f30d1f9d5648f73bb9aeb9c0d61be448c1d648b743eb3155da459e4e6038 use num_bigint::BigInt; use ruff_text_size::TextSize; -use ruff_python_ast::{self as ast, Ranged, MagicKind}; +use ruff_python_ast::{self as ast, Ranged, IpyEscapeKind}; use crate::{ Mode, lexer::{LexicalError, LexicalErrorType}, @@ -25,7 +25,7 @@ mod __parse__Top { use num_bigint::BigInt; use ruff_text_size::TextSize; - use ruff_python_ast::{self as ast, Ranged, MagicKind}; + use ruff_python_ast::{self as ast, Ranged, IpyEscapeKind}; use crate::{ Mode, lexer::{LexicalError, LexicalErrorType}, @@ -49,7 +49,7 @@ mod __parse__Top { Variant1((f64, f64)), Variant2(f64), Variant3(BigInt), - Variant4((MagicKind, String)), + Variant4((IpyEscapeKind, String)), Variant5(String), Variant6((String, StringKind, bool)), Variant7(core::option::Option), @@ -224,7 +224,7 @@ mod __parse__Top { // State 40 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 98, 0, 0, 0, 0, 0, 0, 0, 0, 0, -752, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0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 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 457, 0, // State 238 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 457, 0, // State 239 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 457, 0, // State 240 - -471, 0, 0, 0, 0, 0, -471, 0, -471, 0, 0, 0, -471, 0, 0, -471, 0, 0, 0, -471, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -471, 0, -471, -471, -471, -471, 0, 0, 0, 0, 0, -471, -471, -471, -471, 0, -471, -471, -471, -471, 283, 927, 0, 0, -471, -471, -471, -471, -471, 0, 0, -471, -471, -471, -471, 0, -471, -471, -471, -471, -471, -471, -471, -471, -471, 0, 0, 0, -471, -471, 0, 0, 0, -471, -471, -471, -471, -471, -471, + -470, 0, 0, 0, 0, 0, -470, 0, -470, 0, 0, 0, -470, 0, 0, -470, 0, 0, 0, -470, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -470, 0, -470, -470, -470, -470, 0, 0, 0, 0, 0, -470, -470, -470, -470, 0, -470, -470, -470, -470, 283, 927, 0, 0, -470, -470, -470, -470, -470, 0, 0, -470, -470, -470, -470, 0, -470, -470, -470, -470, -470, -470, -470, -470, -470, 0, 0, 0, -470, -470, 0, 0, 0, -470, -470, -470, -470, -470, -470, // State 241 -909, 0, 0, 0, 0, 0, -909, 0, -909, 0, 0, 0, -909, 0, 0, -909, 0, 0, 0, -909, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -909, 0, -909, -909, -909, -909, 0, 0, 0, 0, 0, -909, -909, -909, -909, 0, -909, -909, -909, -909, 0, 934, 287, 935, -909, -909, -909, -909, -909, 0, 0, -909, -909, -909, -909, 0, -909, -909, -909, -909, -909, -909, -909, -909, -909, 0, 0, 0, -909, -909, 0, 0, 0, -909, -909, -909, -909, -909, -909, // State 242 @@ -1054,7 +1054,7 @@ mod __parse__Top { // State 455 -372, -372, -372, -372, -372, -372, -372, -372, -372, -372, -372, -372, -372, -372, -372, -372, -372, 0, -372, 0, -372, -372, -372, -372, -372, 0, -372, -372, -372, -372, -372, -372, -372, -372, -372, -372, -372, -372, -372, -372, 0, 0, 0, -372, -372, -372, -372, -372, -372, 0, -372, 0, 0, 0, 0, 0, 0, 0, 0, -372, 0, 0, -372, -372, 0, -372, 0, -372, -372, 0, 0, 0, -372, -372, 0, 0, 0, 0, 0, 0, 0, 0, 0, -372, -372, -372, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // State 456 - -469, -469, -469, -469, -469, -469, -469, -469, -469, -469, -469, -469, -469, -469, -469, -469, -469, 0, -469, 0, -469, -469, -469, -469, -469, -469, -469, -469, -469, -469, -469, -469, -469, -469, -469, -469, -469, -469, -469, -469, 0, 0, 0, -469, -469, -469, -469, -469, -469, 0, -469, 0, 0, 0, 0, 0, 0, 0, 0, -469, 0, 0, -469, -469, 0, -469, -469, -469, -469, 0, 0, 0, -469, -469, 0, 0, 0, 0, 0, 0, 0, 0, 0, -469, -469, -469, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + -468, -468, -468, -468, -468, -468, -468, -468, -468, -468, -468, -468, -468, -468, -468, -468, -468, 0, -468, 0, -468, -468, -468, -468, -468, -468, -468, -468, -468, -468, -468, -468, -468, -468, -468, -468, -468, -468, -468, -468, 0, 0, 0, -468, -468, -468, -468, -468, -468, 0, -468, 0, 0, 0, 0, 0, 0, 0, 0, -468, 0, 0, -468, -468, 0, -468, -468, -468, -468, 0, 0, 0, -468, -468, 0, 0, 0, 0, 0, 0, 0, 0, 0, -468, -468, -468, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // State 457 -139, -139, -139, -139, -139, -139, -139, -139, -139, -139, -139, -139, -139, -139, -139, -139, -139, 0, -139, 0, -139, -139, -139, -139, -139, 0, -139, -139, -139, -139, -139, -139, -139, -139, -139, -139, -139, -139, -139, -139, 0, 0, 0, -139, -139, -139, -139, -139, -139, 0, -139, 0, 0, 0, 0, 0, 0, 0, 0, -139, 0, 0, -139, -139, 0, -139, 0, -139, -139, 0, 0, 0, -139, -139, 0, 0, 0, 0, 0, 0, 0, 0, 0, -139, -139, -139, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -139, // State 458 @@ -1212,15 +1212,15 @@ mod __parse__Top { // State 534 -836, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -836, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // State 535 - -841, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -841, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - // State 536 -219, -219, -219, -219, -219, -219, -219, 0, -219, -219, -219, -219, -219, -219, -219, -219, -219, 0, -219, 0, -219, -219, -219, -219, -219, 0, -219, -219, -219, -219, -219, -219, -219, -219, -219, -219, -219, -190, -219, -219, 0, 0, 0, -219, 0, -219, -219, -219, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -219, 0, -219, -219, 0, 0, 0, -219, -219, 0, 0, 0, 0, 0, 0, 0, 0, 0, -219, -219, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - // State 537 + // State 536 -360, 0, 0, 0, 0, 0, -360, 0, -360, 0, 0, 0, -360, 0, 0, -360, 0, 0, 0, -360, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -360, 0, -360, -360, -360, -360, 0, 0, 0, 0, 0, -360, -360, -360, -360, 0, -360, -360, -360, -360, 0, 0, 0, 0, -360, -360, -360, -360, -360, 0, 0, -360, -360, -360, -360, 0, -360, -360, -360, -360, -360, -360, -360, -360, -360, 0, 0, 0, -360, -360, 0, 0, 0, -360, -360, -360, -360, -360, -360, - // State 538 + // State 537 -835, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -835, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - // State 539 + // State 538 -840, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -840, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + // State 539 + -841, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -841, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // State 540 -359, 0, 0, 0, 0, 0, -359, 0, -359, 0, 0, 0, -359, 0, 0, -359, 0, 0, 0, -359, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -359, 0, -359, -359, -359, -359, 0, 0, 0, 0, 0, -359, -359, -359, -359, 0, -359, -359, -359, -359, 0, 0, 0, 0, -359, -359, -359, -359, -359, 0, 0, -359, -359, -359, -359, 0, -359, -359, -359, -359, -359, -359, -359, -359, -359, 0, 0, 0, -359, -359, 0, 0, 0, -359, -359, -359, -359, -359, -359, // State 541 @@ -1274,7 +1274,7 @@ mod __parse__Top { // State 565 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 129, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // State 566 - -500, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -500, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + -493, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -493, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // State 567 0, 0, 0, 0, 0, 0, -112, 0, 0, 0, 0, 0, -112, 0, 0, -112, 0, 0, 0, -112, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -112, -112, -112, -112, 0, 0, 0, 0, 0, 0, 0, -112, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -112, 0, 0, 0, 0, 0, 0, 0, 0, 0, -112, 0, 0, 0, -112, 0, 0, 0, 0, -112, -112, -112, 0, -112, -112, // State 568 @@ -1346,9 +1346,9 @@ mod __parse__Top { // State 601 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -848, 0, 0, 0, 0, 0, 0, 0, 0, 0, -848, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // State 602 - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -495, 0, 0, 0, 0, 0, 0, 0, 0, 0, -495, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -497, 0, 0, 0, 0, 0, 0, 0, 0, 0, -497, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // State 603 - -498, 0, 0, -498, 0, -498, 0, -498, 0, 0, -498, -498, 0, -498, -498, 0, -498, 0, 0, 0, 0, 0, -498, -498, -498, 0, -498, 0, 0, -498, 0, -498, 0, 0, 0, 0, -498, 0, 0, -498, 0, 0, 0, 0, -498, 0, -498, 0, -498, 0, -498, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -498, -498, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -498, -498, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + -500, 0, 0, -500, 0, -500, 0, -500, 0, 0, -500, -500, 0, -500, -500, 0, -500, 0, 0, 0, 0, 0, -500, -500, -500, 0, -500, 0, 0, -500, 0, -500, 0, 0, 0, 0, -500, 0, 0, -500, 0, 0, 0, 0, -500, 0, -500, 0, -500, 0, -500, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -500, -500, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -500, -500, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // State 604 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 730, 0, 0, 0, 0, 0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 0, 0, 0, 0, 0, // State 657 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 186, 0, 0, 0, 0, 0, 0, 0, 0, 0, 769, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // State 658 @@ -1590,7 +1590,7 @@ mod __parse__Top { // State 723 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -574, 0, 0, 0, 0, 0, 0, 0, 0, 0, -574, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // State 724 - -497, 0, 0, -497, 0, -497, 0, -497, 0, 0, -497, -497, 0, -497, -497, 0, -497, 0, 0, 0, 0, 0, -497, -497, -497, 0, -497, 0, 0, -497, 0, -497, 0, 0, 0, 0, -497, 0, 0, -497, 0, 0, 0, 0, -497, 0, -497, 0, -497, 0, -497, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -497, -497, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -497, -497, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + -499, 0, 0, -499, 0, -499, 0, -499, 0, 0, -499, -499, 0, -499, -499, 0, -499, 0, 0, 0, 0, 0, -499, -499, -499, 0, -499, 0, 0, -499, 0, -499, 0, 0, 0, 0, -499, 0, 0, -499, 0, 0, 0, 0, -499, 0, -499, 0, -499, 0, -499, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -499, -499, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -499, -499, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // State 725 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -594, 0, 0, 0, 0, 0, 0, 0, 0, 0, -594, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // State 726 @@ -1638,7 +1638,7 @@ mod __parse__Top { // State 747 -180, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -180, 0, 0, 0, 0, -180, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // State 748 - -499, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -499, 0, 0, 0, 0, -499, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + -492, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -492, 0, 0, 0, 0, -492, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // State 749 -794, 0, 0, 0, 0, 0, -794, 0, -794, 0, 0, 0, -794, 0, 0, -794, 0, 0, 0, -794, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -794, 0, -794, -794, -794, -794, 0, 0, 0, 0, 0, -794, -794, -794, -794, 0, -794, -794, -794, -794, 0, 0, 0, 0, -794, -794, -794, -794, -794, 0, 0, -794, -794, -794, -794, 0, -794, -794, -794, -794, -794, -794, -794, -794, -794, 0, 0, 0, -794, 0, 0, 0, 0, -794, -794, -794, -794, -794, -794, // State 750 @@ -1672,9 +1672,9 @@ mod __parse__Top { // State 764 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 235, 0, 0, 0, 0, 0, 0, 236, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // State 765 - 0, 0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 0, 0, 0, 0, 0, 0, 0, 0, -75, 0, 0, 0, -75, 0, 0, 0, 0, 0, 0, 0, -75, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -75, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -75, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // State 925 - -473, 0, 0, 0, 0, 0, -473, 0, -473, 0, 0, 0, -473, 0, 0, -473, 0, 0, 0, -473, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -473, 0, -473, -473, -473, -473, 0, 0, 0, 0, 0, -473, -473, -473, -473, 0, -473, -473, -473, -473, 323, 994, 0, 0, -473, -473, -473, -473, -473, 0, 0, -473, -473, -473, -473, 0, -473, -473, -473, -473, -473, -473, -473, -473, -473, 0, 0, 0, -473, -473, 0, 0, 0, -473, -473, -473, -473, -473, -473, + -472, 0, 0, 0, 0, 0, -472, 0, -472, 0, 0, 0, -472, 0, 0, -472, 0, 0, 0, -472, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -472, 0, -472, -472, -472, -472, 0, 0, 0, 0, 0, -472, -472, -472, -472, 0, -472, -472, -472, -472, 323, 994, 0, 0, -472, -472, -472, -472, -472, 0, 0, -472, -472, -472, -472, 0, -472, -472, -472, -472, -472, -472, -472, -472, -472, 0, 0, 0, -472, -472, 0, 0, 0, -472, -472, -472, -472, -472, -472, // State 926 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 324, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0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0, -478, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // State 1046 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 381, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // State 1047 - -470, 0, 0, 0, 0, 0, -470, 0, -470, 0, 0, 0, -470, 0, 0, -470, 0, 0, 0, -470, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -470, 0, -470, -470, -470, -470, 0, 0, 0, 0, 0, -470, -470, -470, -470, 0, -470, -470, -470, -470, 0, 0, 0, 0, -470, -470, -470, -470, -470, 0, 0, -470, -470, -470, -470, 0, -470, -470, -470, -470, -470, -470, -470, -470, -470, 0, 0, 0, -470, -470, 0, 0, 0, -470, -470, -470, -470, -470, -470, + -469, 0, 0, 0, 0, 0, -469, 0, -469, 0, 0, 0, -469, 0, 0, -469, 0, 0, 0, -469, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -469, 0, -469, -469, -469, -469, 0, 0, 0, 0, 0, -469, -469, -469, -469, 0, -469, -469, -469, -469, 0, 0, 0, 0, -469, -469, -469, -469, -469, 0, 0, -469, -469, -469, -469, 0, -469, -469, -469, -469, -469, -469, -469, -469, -469, 0, 0, 0, -469, -469, 0, 0, 0, -469, -469, -469, -469, -469, -469, // State 1048 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -528, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -528, 0, 0, 0, 0, 0, 0, 0, 0, 0, // State 1049 @@ -2362,7 +2362,7 @@ mod __parse__Top { // State 1109 -565, 0, 0, 0, 0, 0, 0, -565, 0, 0, 0, 0, 0, 0, -565, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -565, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // State 1110 - -472, 0, 0, 0, 0, 0, -472, 0, -472, 0, 0, 0, -472, 0, 0, -472, 0, 0, 0, -472, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -472, 0, -472, -472, -472, -472, 0, 0, 0, 0, 0, -472, -472, -472, -472, 0, -472, -472, -472, -472, 0, 0, 0, 0, -472, -472, -472, -472, -472, 0, 0, -472, -472, -472, -472, 0, -472, -472, -472, -472, -472, -472, -472, -472, -472, 0, 0, 0, -472, -472, 0, 0, 0, -472, -472, -472, -472, -472, -472, + -471, 0, 0, 0, 0, 0, -471, 0, -471, 0, 0, 0, -471, 0, 0, -471, 0, 0, 0, -471, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -471, 0, -471, -471, -471, -471, 0, 0, 0, 0, 0, -471, -471, -471, -471, 0, -471, -471, -471, -471, 0, 0, 0, 0, -471, -471, -471, -471, -471, 0, 0, -471, -471, -471, -471, 0, -471, -471, -471, -471, -471, -471, -471, -471, -471, 0, 0, 0, -471, -471, 0, 0, 0, -471, -471, -471, -471, -471, -471, // State 1111 -105, 0, 0, 0, 0, 0, -105, 0, -105, 0, 0, 0, -105, 0, 0, -105, 0, 0, 0, -105, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -105, 0, -105, -105, -105, -105, 0, 0, 0, 0, 0, -105, -105, -105, -105, 0, -105, -105, -105, -105, -105, -105, 0, 0, -105, -105, -105, -105, -105, 0, 0, -105, -105, -105, -105, 0, -105, -105, -105, -105, -105, -105, -105, -105, -105, 0, 0, 0, -105, -105, 0, 0, 0, -105, -105, -105, -105, -105, -105, // State 1112 @@ -3147,7 +3147,7 @@ mod __parse__Top { // State 239 0, // State 240 - -471, + -470, // State 241 -909, // State 242 @@ -3579,7 +3579,7 @@ mod __parse__Top { // State 455 -372, // State 456 - -469, + -468, // State 457 -139, // State 458 @@ -3739,9 +3739,9 @@ mod __parse__Top { // State 535 0, // State 536 - 0, - // State 537 -360, + // State 537 + 0, // State 538 0, // State 539 @@ -3873,7 +3873,7 @@ mod __parse__Top { // State 602 0, // State 603 - -498, + -500, // State 604 0, // State 605 @@ -4115,7 +4115,7 @@ mod __parse__Top { // State 723 0, // State 724 - -497, + -499, // State 725 0, // State 726 @@ -4517,7 +4517,7 @@ mod __parse__Top { // State 924 0, // State 925 - -473, + -472, // State 926 0, // State 927 @@ -4761,7 +4761,7 @@ mod __parse__Top { // State 1046 0, // State 1047 - -470, + -469, // State 1048 0, // State 1049 @@ -4887,7 +4887,7 @@ mod __parse__Top { // State 1109 0, // State 1110 - -472, + -471, // State 1111 -105, // State 1112 @@ -5491,8 +5491,7 @@ mod __parse__Top { }, 158 => 534, 159 => 1113, - 160 => 535, - 161 => match state { + 160 => match state { 61 => 124, 62 => 125, 106 => 163, @@ -5501,7 +5500,7 @@ mod __parse__Top { 162 => 221, 12 | 14 | 18 | 24 | 56..=58 | 67 | 69 | 74 | 76 | 89..=90 | 92 | 99 | 104 | 139..=140 | 143 | 147 | 149 | 154 | 167..=168 | 185..=186 | 195 | 216 | 225 | 250..=251 | 256 | 266 | 282 | 294 | 310 | 322 | 337 | 367 | 390 => 485, 16 | 93 | 97 | 158..=159 | 218..=220 | 257..=259 | 301 | 304 | 341..=343 | 369..=371 | 398 => 500, - 19 | 46 | 128 | 172 | 182 | 188 | 191 | 204 | 223 | 229..=231 | 235 | 244 | 262..=263 | 265 | 268..=269 | 273 | 279 | 288..=291 | 306..=307 | 309 | 312..=314 | 323 | 329..=333 | 335..=336 | 345..=348 | 354..=355 | 365 | 372..=374 | 379..=380 | 389 | 397 | 399..=400 | 405 | 408..=410 => 536, + 19 | 46 | 128 | 172 | 182 | 188 | 191 | 204 | 223 | 229..=231 | 235 | 244 | 262..=263 | 265 | 268..=269 | 273 | 279 | 288..=291 | 306..=307 | 309 | 312..=314 | 323 | 329..=333 | 335..=336 | 345..=348 | 354..=355 | 365 | 372..=374 | 379..=380 | 389 | 397 | 399..=400 | 405 | 408..=410 => 535, 22 | 79 => 570, 23 => 572, 40..=41 | 156 | 260 | 302 => 601, @@ -5539,16 +5538,19 @@ mod __parse__Top { 420 => 1240, _ => 436, }, - 162 => 537, - 165 => 842, - 166 => match state { + 161 => 536, + 164 => 842, + 165 => match state { 126 => 766, _ => 648, }, - 168 => 126, - 169 => 649, - 170 => 538, - 171 => match state { + 167 => 126, + 168 => 649, + 169 => 537, + 170 => 746, + 171 => 538, + 172 => 539, + 173 => match state { 275 => 983, 278 => 987, 317 => 1038, @@ -5570,7 +5572,7 @@ mod __parse__Top { 424 => 1253, _ => 833, }, - 172 => match state { + 174 => match state { 93 => 722, 97 => 727, 158 => 809, @@ -5592,12 +5594,10 @@ mod __parse__Top { 398 => 1192, _ => 501, }, - 173 => match state { + 175 => match state { 75 | 122 => 678, _ => 437, }, - 174 => 746, - 175 => 539, 176 => match state { 58 => 636, 140 => 782, @@ -6138,7 +6138,7 @@ mod __parse__Top { r###"complex"###, r###"float"###, r###"int"###, - r###"line_magic"###, + r###"ipy_escape_command"###, r###"name"###, r###"string"###, ]; @@ -6368,7 +6368,7 @@ mod __parse__Top { token::Tok::Complex { real: _, imag: _ } if true => Some(91), token::Tok::Float { value: _ } if true => Some(92), token::Tok::Int { value: _ } if true => Some(93), - token::Tok::MagicCommand { kind: _, value: _ } if true => Some(94), + token::Tok::IpyEscapeCommand { kind: _, value: _ } if true => Some(94), token::Tok::Name { name: _ } if true => Some(95), token::Tok::String { value: _, kind: _, triple_quoted: _ } if true => Some(96), _ => None, @@ -6396,7 +6396,7 @@ mod __parse__Top { _ => unreachable!(), }, 94 => match __token { - token::Tok::MagicCommand { kind: __tok0, value: __tok1 } if true => __Symbol::Variant4((__tok0, __tok1)), + token::Tok::IpyEscapeCommand { kind: __tok0, value: __tok1 } if true => __Symbol::Variant4((__tok0, __tok1)), _ => unreachable!(), }, 95 => match __token { @@ -9221,56 +9221,56 @@ mod __parse__Top { } 467 => { __state_machine::SimulatedReduce::Reduce { - states_to_pop: 2, + states_to_pop: 1, nonterminal_produced: 160, } } 468 => { __state_machine::SimulatedReduce::Reduce { - states_to_pop: 1, + states_to_pop: 7, nonterminal_produced: 161, } } 469 => { __state_machine::SimulatedReduce::Reduce { - states_to_pop: 7, - nonterminal_produced: 162, + states_to_pop: 4, + nonterminal_produced: 161, } } 470 => { __state_machine::SimulatedReduce::Reduce { - states_to_pop: 4, - nonterminal_produced: 162, + states_to_pop: 8, + nonterminal_produced: 161, } } 471 => { __state_machine::SimulatedReduce::Reduce { - states_to_pop: 8, - nonterminal_produced: 162, + states_to_pop: 5, + nonterminal_produced: 161, } } 472 => { __state_machine::SimulatedReduce::Reduce { - states_to_pop: 5, + states_to_pop: 3, nonterminal_produced: 162, } } 473 => { __state_machine::SimulatedReduce::Reduce { - states_to_pop: 3, - nonterminal_produced: 163, + states_to_pop: 1, + nonterminal_produced: 162, } } 474 => { __state_machine::SimulatedReduce::Reduce { - states_to_pop: 1, + states_to_pop: 3, nonterminal_produced: 163, } } 475 => { __state_machine::SimulatedReduce::Reduce { - states_to_pop: 3, - nonterminal_produced: 164, + states_to_pop: 1, + nonterminal_produced: 163, } } 476 => { @@ -9281,20 +9281,20 @@ mod __parse__Top { } 477 => { __state_machine::SimulatedReduce::Reduce { - states_to_pop: 1, - nonterminal_produced: 165, + states_to_pop: 4, + nonterminal_produced: 164, } } 478 => { __state_machine::SimulatedReduce::Reduce { - states_to_pop: 4, - nonterminal_produced: 165, + states_to_pop: 3, + nonterminal_produced: 164, } } 479 => { __state_machine::SimulatedReduce::Reduce { - states_to_pop: 3, - nonterminal_produced: 165, + states_to_pop: 1, + nonterminal_produced: 164, } } 480 => { @@ -9306,19 +9306,19 @@ mod __parse__Top { 481 => { __state_machine::SimulatedReduce::Reduce { states_to_pop: 1, - nonterminal_produced: 166, + nonterminal_produced: 165, } } 482 => { __state_machine::SimulatedReduce::Reduce { - states_to_pop: 1, + states_to_pop: 0, nonterminal_produced: 166, } } 483 => { __state_machine::SimulatedReduce::Reduce { - states_to_pop: 0, - nonterminal_produced: 167, + states_to_pop: 1, + nonterminal_produced: 166, } } 484 => { @@ -9329,91 +9329,91 @@ mod __parse__Top { } 485 => { __state_machine::SimulatedReduce::Reduce { - states_to_pop: 1, - nonterminal_produced: 168, + states_to_pop: 2, + nonterminal_produced: 167, } } 486 => { __state_machine::SimulatedReduce::Reduce { - states_to_pop: 2, + states_to_pop: 1, nonterminal_produced: 168, } } 487 => { __state_machine::SimulatedReduce::Reduce { - states_to_pop: 1, - nonterminal_produced: 169, + states_to_pop: 2, + nonterminal_produced: 168, } } 488 => { __state_machine::SimulatedReduce::Reduce { - states_to_pop: 2, - nonterminal_produced: 169, + states_to_pop: 1, + nonterminal_produced: 168, } } 489 => { __state_machine::SimulatedReduce::Reduce { - states_to_pop: 1, + states_to_pop: 2, nonterminal_produced: 169, } } 490 => { __state_machine::SimulatedReduce::Reduce { - states_to_pop: 2, - nonterminal_produced: 170, + states_to_pop: 4, + nonterminal_produced: 169, } } 491 => { __state_machine::SimulatedReduce::Reduce { - states_to_pop: 4, + states_to_pop: 1, nonterminal_produced: 170, } } 492 => { __state_machine::SimulatedReduce::Reduce { - states_to_pop: 2, + states_to_pop: 1, nonterminal_produced: 171, } } 493 => { __state_machine::SimulatedReduce::Reduce { - states_to_pop: 1, - nonterminal_produced: 171, + states_to_pop: 2, + nonterminal_produced: 172, } } 494 => { __state_machine::SimulatedReduce::Reduce { states_to_pop: 2, - nonterminal_produced: 172, + nonterminal_produced: 173, } } 495 => { __state_machine::SimulatedReduce::Reduce { states_to_pop: 1, - nonterminal_produced: 172, + nonterminal_produced: 173, } } 496 => { __state_machine::SimulatedReduce::Reduce { - states_to_pop: 4, - nonterminal_produced: 173, + states_to_pop: 2, + nonterminal_produced: 174, } } 497 => { __state_machine::SimulatedReduce::Reduce { - states_to_pop: 3, - nonterminal_produced: 173, + states_to_pop: 1, + nonterminal_produced: 174, } } 498 => { __state_machine::SimulatedReduce::Reduce { - states_to_pop: 1, - nonterminal_produced: 174, + states_to_pop: 4, + nonterminal_produced: 175, } } 499 => { __state_machine::SimulatedReduce::Reduce { - states_to_pop: 1, + states_to_pop: 3, nonterminal_produced: 175, } } @@ -14602,18 +14602,7 @@ mod __parse__Top { __reduce466(mode, __lookahead_start, __symbols, core::marker::PhantomData::<()>) } 467 => { - // HelpEndLineMagic = Expression<"All">, ("?")+ => ActionFn(1423); - assert!(__symbols.len() >= 2); - let __sym1 = __pop_Variant21(__symbols); - let __sym0 = __pop_Variant14(__symbols); - let __start = __sym0.0; - let __end = __sym1.2; - let __nt = match super::__action1423::<>(mode, __sym0, __sym1) { - Ok(v) => v, - Err(e) => return Some(Err(e)), - }; - __symbols.push((__start, __Symbol::Variant36(__nt), __end)); - (2, 160) + __reduce467(mode, __lookahead_start, __symbols, core::marker::PhantomData::<()>) } 468 => { __reduce468(mode, __lookahead_start, __symbols, core::marker::PhantomData::<()>) @@ -14685,13 +14674,42 @@ mod __parse__Top { __reduce490(mode, __lookahead_start, __symbols, core::marker::PhantomData::<()>) } 491 => { - __reduce491(mode, __lookahead_start, __symbols, core::marker::PhantomData::<()>) + // IpyEscapeCommandExpr = ipy_escape_command => ActionFn(1434); + let __sym0 = __pop_Variant4(__symbols); + let __start = __sym0.0; + let __end = __sym0.2; + let __nt = match super::__action1434::<>(mode, __sym0) { + Ok(v) => v, + Err(e) => return Some(Err(e)), + }; + __symbols.push((__start, __Symbol::Variant14(__nt), __end)); + (1, 170) } 492 => { - __reduce492(mode, __lookahead_start, __symbols, core::marker::PhantomData::<()>) + // IpyEscapeCommandStatement = ipy_escape_command => ActionFn(1435); + let __sym0 = __pop_Variant4(__symbols); + let __start = __sym0.0; + let __end = __sym0.2; + let __nt = match super::__action1435::<>(mode, __sym0) { + Ok(v) => v, + Err(e) => return Some(Err(e)), + }; + __symbols.push((__start, __Symbol::Variant36(__nt), __end)); + (1, 171) } 493 => { - __reduce493(mode, __lookahead_start, __symbols, core::marker::PhantomData::<()>) + // IpyHelpEndEscapeCommandStatement = Expression<"All">, ("?")+ => ActionFn(1436); + assert!(__symbols.len() >= 2); + let __sym1 = __pop_Variant21(__symbols); + let __sym0 = __pop_Variant14(__symbols); + let __start = __sym0.0; + let __end = __sym1.2; + let __nt = match super::__action1436::<>(mode, __sym0, __sym1) { + Ok(v) => v, + Err(e) => return Some(Err(e)), + }; + __symbols.push((__start, __Symbol::Variant36(__nt), __end)); + (2, 172) } 494 => { __reduce494(mode, __lookahead_start, __symbols, core::marker::PhantomData::<()>) @@ -14700,6 +14718,12 @@ mod __parse__Top { __reduce495(mode, __lookahead_start, __symbols, core::marker::PhantomData::<()>) } 496 => { + __reduce496(mode, __lookahead_start, __symbols, core::marker::PhantomData::<()>) + } + 497 => { + __reduce497(mode, __lookahead_start, __symbols, core::marker::PhantomData::<()>) + } + 498 => { // LambdaDef = "lambda", ParameterList, ":", Test<"all"> => ActionFn(1819); assert!(__symbols.len() >= 4); let __sym3 = __pop_Variant14(__symbols); @@ -14713,9 +14737,9 @@ mod __parse__Top { Err(e) => return Some(Err(e)), }; __symbols.push((__start, __Symbol::Variant14(__nt), __end)); - (4, 173) + (4, 175) } - 497 => { + 499 => { // LambdaDef = "lambda", ":", Test<"all"> => ActionFn(1820); assert!(__symbols.len() >= 3); let __sym2 = __pop_Variant14(__symbols); @@ -14728,31 +14752,7 @@ mod __parse__Top { Err(e) => return Some(Err(e)), }; __symbols.push((__start, __Symbol::Variant14(__nt), __end)); - (3, 173) - } - 498 => { - // LineMagicExpr = line_magic => ActionFn(1436); - let __sym0 = __pop_Variant4(__symbols); - let __start = __sym0.0; - let __end = __sym0.2; - let __nt = match super::__action1436::<>(mode, __sym0) { - Ok(v) => v, - Err(e) => return Some(Err(e)), - }; - __symbols.push((__start, __Symbol::Variant14(__nt), __end)); - (1, 174) - } - 499 => { - // LineMagicStatement = line_magic => ActionFn(1437); - let __sym0 = __pop_Variant4(__symbols); - let __start = __sym0.0; - let __end = __sym0.2; - let __nt = match super::__action1437::<>(mode, __sym0) { - Ok(v) => v, - Err(e) => return Some(Err(e)), - }; - __symbols.push((__start, __Symbol::Variant36(__nt), __end)); - (1, 175) + (3, 175) } 500 => { __reduce500(mode, __lookahead_start, __symbols, core::marker::PhantomData::<()>) @@ -18686,7 +18686,7 @@ mod __parse__Top { fn __pop_Variant4< >( __symbols: &mut alloc::vec::Vec<(TextSize,__Symbol<>,TextSize)> - ) -> (TextSize, (MagicKind, String), TextSize) + ) -> (TextSize, (IpyEscapeKind, String), TextSize) { match __symbols.pop() { Some((__l, __Symbol::Variant4(__v), __r)) => (__l, __v, __r), @@ -22077,7 +22077,7 @@ mod __parse__Top { _: core::marker::PhantomData<()>, ) -> (usize, usize) { - // AssignSuffix = "=", LineMagicExpr => ActionFn(30); + // AssignSuffix = "=", IpyEscapeCommandExpr => ActionFn(30); assert!(__symbols.len() >= 2); let __sym1 = __pop_Variant14(__symbols); let __sym0 = __pop_Variant0(__symbols); @@ -26702,7 +26702,7 @@ mod __parse__Top { __symbols.push((__start, __Symbol::Variant14(__nt), __end)); (2, 159) } - pub(crate) fn __reduce468< + pub(crate) fn __reduce467< >( mode: Mode, __lookahead_start: Option<&TextSize>, @@ -26710,15 +26710,15 @@ mod __parse__Top { _: core::marker::PhantomData<()>, ) -> (usize, usize) { - // Identifier = name => ActionFn(1424); + // Identifier = name => ActionFn(1423); let __sym0 = __pop_Variant5(__symbols); let __start = __sym0.0; let __end = __sym0.2; - let __nt = super::__action1424::<>(mode, __sym0); + let __nt = super::__action1423::<>(mode, __sym0); __symbols.push((__start, __Symbol::Variant22(__nt), __end)); - (1, 161) + (1, 160) } - pub(crate) fn __reduce469< + pub(crate) fn __reduce468< >( mode: Mode, __lookahead_start: Option<&TextSize>, @@ -26739,9 +26739,9 @@ mod __parse__Top { let __end = __sym6.2; let __nt = super::__action1216::<>(mode, __sym0, __sym1, __sym2, __sym3, __sym4, __sym5, __sym6); __symbols.push((__start, __Symbol::Variant36(__nt), __end)); - (7, 162) + (7, 161) } - pub(crate) fn __reduce470< + pub(crate) fn __reduce469< >( mode: Mode, __lookahead_start: Option<&TextSize>, @@ -26759,9 +26759,9 @@ mod __parse__Top { let __end = __sym3.2; let __nt = super::__action1217::<>(mode, __sym0, __sym1, __sym2, __sym3); __symbols.push((__start, __Symbol::Variant36(__nt), __end)); - (4, 162) + (4, 161) } - pub(crate) fn __reduce471< + pub(crate) fn __reduce470< >( mode: Mode, __lookahead_start: Option<&TextSize>, @@ -26783,9 +26783,9 @@ mod __parse__Top { let __end = __sym7.2; let __nt = super::__action1218::<>(mode, __sym0, __sym1, __sym2, __sym3, __sym4, __sym5, __sym6, __sym7); __symbols.push((__start, __Symbol::Variant36(__nt), __end)); - (8, 162) + (8, 161) } - pub(crate) fn __reduce472< + pub(crate) fn __reduce471< >( mode: Mode, __lookahead_start: Option<&TextSize>, @@ -26804,9 +26804,9 @@ mod __parse__Top { let __end = __sym4.2; let __nt = super::__action1219::<>(mode, __sym0, __sym1, __sym2, __sym3, __sym4); __symbols.push((__start, __Symbol::Variant36(__nt), __end)); - (5, 162) + (5, 161) } - pub(crate) fn __reduce473< + pub(crate) fn __reduce472< >( mode: Mode, __lookahead_start: Option<&TextSize>, @@ -26814,18 +26814,18 @@ mod __parse__Top { _: core::marker::PhantomData<()>, ) -> (usize, usize) { - // ImportAsAlias = DottedName, "as", Identifier => ActionFn(1425); + // ImportAsAlias = DottedName, "as", Identifier => ActionFn(1424); assert!(__symbols.len() >= 3); let __sym2 = __pop_Variant22(__symbols); let __sym1 = __pop_Variant0(__symbols); let __sym0 = __pop_Variant22(__symbols); let __start = __sym0.0; let __end = __sym2.2; - let __nt = super::__action1425::<>(mode, __sym0, __sym1, __sym2); + let __nt = super::__action1424::<>(mode, __sym0, __sym1, __sym2); __symbols.push((__start, __Symbol::Variant68(__nt), __end)); - (3, 163) + (3, 162) } - pub(crate) fn __reduce474< + pub(crate) fn __reduce473< >( mode: Mode, __lookahead_start: Option<&TextSize>, @@ -26833,15 +26833,15 @@ mod __parse__Top { _: core::marker::PhantomData<()>, ) -> (usize, usize) { - // ImportAsAlias = DottedName => ActionFn(1426); + // ImportAsAlias = DottedName => ActionFn(1425); let __sym0 = __pop_Variant22(__symbols); let __start = __sym0.0; let __end = __sym0.2; - let __nt = super::__action1426::<>(mode, __sym0); + let __nt = super::__action1425::<>(mode, __sym0); __symbols.push((__start, __Symbol::Variant68(__nt), __end)); - (1, 163) + (1, 162) } - pub(crate) fn __reduce475< + pub(crate) fn __reduce474< >( mode: Mode, __lookahead_start: Option<&TextSize>, @@ -26849,18 +26849,18 @@ mod __parse__Top { _: core::marker::PhantomData<()>, ) -> (usize, usize) { - // ImportAsAlias = Identifier, "as", Identifier => ActionFn(1427); + // ImportAsAlias = Identifier, "as", Identifier => ActionFn(1426); assert!(__symbols.len() >= 3); let __sym2 = __pop_Variant22(__symbols); let __sym1 = __pop_Variant0(__symbols); let __sym0 = __pop_Variant22(__symbols); let __start = __sym0.0; let __end = __sym2.2; - let __nt = super::__action1427::<>(mode, __sym0, __sym1, __sym2); + let __nt = super::__action1426::<>(mode, __sym0, __sym1, __sym2); __symbols.push((__start, __Symbol::Variant68(__nt), __end)); - (3, 164) + (3, 163) } - pub(crate) fn __reduce476< + pub(crate) fn __reduce475< >( mode: Mode, __lookahead_start: Option<&TextSize>, @@ -26868,15 +26868,15 @@ mod __parse__Top { _: core::marker::PhantomData<()>, ) -> (usize, usize) { - // ImportAsAlias = Identifier => ActionFn(1428); + // ImportAsAlias = Identifier => ActionFn(1427); let __sym0 = __pop_Variant22(__symbols); let __start = __sym0.0; let __end = __sym0.2; - let __nt = super::__action1428::<>(mode, __sym0); + let __nt = super::__action1427::<>(mode, __sym0); __symbols.push((__start, __Symbol::Variant68(__nt), __end)); - (1, 164) + (1, 163) } - pub(crate) fn __reduce477< + pub(crate) fn __reduce476< >( mode: Mode, __lookahead_start: Option<&TextSize>, @@ -26884,15 +26884,15 @@ mod __parse__Top { _: core::marker::PhantomData<()>, ) -> (usize, usize) { - // ImportAsNames = OneOrMore> => ActionFn(1429); + // ImportAsNames = OneOrMore> => ActionFn(1428); let __sym0 = __pop_Variant69(__symbols); let __start = __sym0.0; let __end = __sym0.2; - let __nt = super::__action1429::<>(mode, __sym0); + let __nt = super::__action1428::<>(mode, __sym0); __symbols.push((__start, __Symbol::Variant69(__nt), __end)); - (1, 165) + (1, 164) } - pub(crate) fn __reduce478< + pub(crate) fn __reduce477< >( mode: Mode, __lookahead_start: Option<&TextSize>, @@ -26900,7 +26900,7 @@ mod __parse__Top { _: core::marker::PhantomData<()>, ) -> (usize, usize) { - // ImportAsNames = "(", OneOrMore>, ",", ")" => ActionFn(1430); + // ImportAsNames = "(", OneOrMore>, ",", ")" => ActionFn(1429); assert!(__symbols.len() >= 4); let __sym3 = __pop_Variant0(__symbols); let __sym2 = __pop_Variant0(__symbols); @@ -26908,11 +26908,11 @@ mod __parse__Top { let __sym0 = __pop_Variant0(__symbols); let __start = __sym0.0; let __end = __sym3.2; - let __nt = super::__action1430::<>(mode, __sym0, __sym1, __sym2, __sym3); + let __nt = super::__action1429::<>(mode, __sym0, __sym1, __sym2, __sym3); __symbols.push((__start, __Symbol::Variant69(__nt), __end)); - (4, 165) + (4, 164) } - pub(crate) fn __reduce479< + pub(crate) fn __reduce478< >( mode: Mode, __lookahead_start: Option<&TextSize>, @@ -26920,18 +26920,18 @@ mod __parse__Top { _: core::marker::PhantomData<()>, ) -> (usize, usize) { - // ImportAsNames = "(", OneOrMore>, ")" => ActionFn(1431); + // ImportAsNames = "(", OneOrMore>, ")" => ActionFn(1430); assert!(__symbols.len() >= 3); let __sym2 = __pop_Variant0(__symbols); let __sym1 = __pop_Variant69(__symbols); let __sym0 = __pop_Variant0(__symbols); let __start = __sym0.0; let __end = __sym2.2; - let __nt = super::__action1431::<>(mode, __sym0, __sym1, __sym2); + let __nt = super::__action1430::<>(mode, __sym0, __sym1, __sym2); __symbols.push((__start, __Symbol::Variant69(__nt), __end)); - (3, 165) + (3, 164) } - pub(crate) fn __reduce480< + pub(crate) fn __reduce479< >( mode: Mode, __lookahead_start: Option<&TextSize>, @@ -26939,15 +26939,15 @@ mod __parse__Top { _: core::marker::PhantomData<()>, ) -> (usize, usize) { - // ImportAsNames = "*" => ActionFn(1432); + // ImportAsNames = "*" => ActionFn(1431); let __sym0 = __pop_Variant0(__symbols); let __start = __sym0.0; let __end = __sym0.2; - let __nt = super::__action1432::<>(mode, __sym0); + let __nt = super::__action1431::<>(mode, __sym0); __symbols.push((__start, __Symbol::Variant69(__nt), __end)); - (1, 165) + (1, 164) } - pub(crate) fn __reduce481< + pub(crate) fn __reduce480< >( mode: Mode, __lookahead_start: Option<&TextSize>, @@ -26961,9 +26961,9 @@ mod __parse__Top { let __end = __sym0.2; let __nt = super::__action64::<>(mode, __sym0); __symbols.push((__start, __Symbol::Variant70(__nt), __end)); - (1, 166) + (1, 165) } - pub(crate) fn __reduce482< + pub(crate) fn __reduce481< >( mode: Mode, __lookahead_start: Option<&TextSize>, @@ -26977,9 +26977,9 @@ mod __parse__Top { let __end = __sym0.2; let __nt = super::__action65::<>(mode, __sym0); __symbols.push((__start, __Symbol::Variant70(__nt), __end)); - (1, 166) + (1, 165) } - pub(crate) fn __reduce483< + pub(crate) fn __reduce482< >( mode: Mode, __lookahead_start: Option<&TextSize>, @@ -26992,9 +26992,9 @@ mod __parse__Top { let __end = __start.clone(); let __nt = super::__action370::<>(mode, &__start, &__end); __symbols.push((__start, __Symbol::Variant71(__nt), __end)); - (0, 167) + (0, 166) } - pub(crate) fn __reduce484< + pub(crate) fn __reduce483< >( mode: Mode, __lookahead_start: Option<&TextSize>, @@ -27008,9 +27008,9 @@ mod __parse__Top { let __end = __sym0.2; let __nt = super::__action371::<>(mode, __sym0); __symbols.push((__start, __Symbol::Variant71(__nt), __end)); - (1, 167) + (1, 166) } - pub(crate) fn __reduce485< + pub(crate) fn __reduce484< >( mode: Mode, __lookahead_start: Option<&TextSize>, @@ -27024,9 +27024,9 @@ mod __parse__Top { let __end = __sym0.2; let __nt = super::__action368::<>(mode, __sym0); __symbols.push((__start, __Symbol::Variant71(__nt), __end)); - (1, 168) + (1, 167) } - pub(crate) fn __reduce486< + pub(crate) fn __reduce485< >( mode: Mode, __lookahead_start: Option<&TextSize>, @@ -27042,9 +27042,9 @@ mod __parse__Top { let __end = __sym1.2; let __nt = super::__action369::<>(mode, __sym0, __sym1); __symbols.push((__start, __Symbol::Variant71(__nt), __end)); - (2, 168) + (2, 167) } - pub(crate) fn __reduce487< + pub(crate) fn __reduce486< >( mode: Mode, __lookahead_start: Option<&TextSize>, @@ -27058,9 +27058,9 @@ mod __parse__Top { let __end = __sym0.2; let __nt = super::__action1691::<>(mode, __sym0); __symbols.push((__start, __Symbol::Variant72(__nt), __end)); - (1, 169) + (1, 168) } - pub(crate) fn __reduce488< + pub(crate) fn __reduce487< >( mode: Mode, __lookahead_start: Option<&TextSize>, @@ -27076,9 +27076,9 @@ mod __parse__Top { let __end = __sym1.2; let __nt = super::__action1692::<>(mode, __sym0, __sym1); __symbols.push((__start, __Symbol::Variant72(__nt), __end)); - (2, 169) + (2, 168) } - pub(crate) fn __reduce489< + pub(crate) fn __reduce488< >( mode: Mode, __lookahead_start: Option<&TextSize>, @@ -27092,9 +27092,9 @@ mod __parse__Top { let __end = __sym0.2; let __nt = super::__action63::<>(mode, __sym0); __symbols.push((__start, __Symbol::Variant72(__nt), __end)); - (1, 169) + (1, 168) } - pub(crate) fn __reduce490< + pub(crate) fn __reduce489< >( mode: Mode, __lookahead_start: Option<&TextSize>, @@ -27102,17 +27102,17 @@ mod __parse__Top { _: core::marker::PhantomData<()>, ) -> (usize, usize) { - // ImportStatement = "import", OneOrMore> => ActionFn(1433); + // ImportStatement = "import", OneOrMore> => ActionFn(1432); assert!(__symbols.len() >= 2); let __sym1 = __pop_Variant69(__symbols); let __sym0 = __pop_Variant0(__symbols); let __start = __sym0.0; let __end = __sym1.2; - let __nt = super::__action1433::<>(mode, __sym0, __sym1); + let __nt = super::__action1432::<>(mode, __sym0, __sym1); __symbols.push((__start, __Symbol::Variant36(__nt), __end)); - (2, 170) + (2, 169) } - pub(crate) fn __reduce491< + pub(crate) fn __reduce490< >( mode: Mode, __lookahead_start: Option<&TextSize>, @@ -27120,7 +27120,7 @@ mod __parse__Top { _: core::marker::PhantomData<()>, ) -> (usize, usize) { - // ImportStatement = "from", ImportFromLocation, "import", ImportAsNames => ActionFn(1434); + // ImportStatement = "from", ImportFromLocation, "import", ImportAsNames => ActionFn(1433); assert!(__symbols.len() >= 4); let __sym3 = __pop_Variant69(__symbols); let __sym2 = __pop_Variant0(__symbols); @@ -27128,11 +27128,11 @@ mod __parse__Top { let __sym0 = __pop_Variant0(__symbols); let __start = __sym0.0; let __end = __sym3.2; - let __nt = super::__action1434::<>(mode, __sym0, __sym1, __sym2, __sym3); + let __nt = super::__action1433::<>(mode, __sym0, __sym1, __sym2, __sym3); __symbols.push((__start, __Symbol::Variant36(__nt), __end)); - (4, 170) + (4, 169) } - pub(crate) fn __reduce492< + pub(crate) fn __reduce494< >( mode: Mode, __lookahead_start: Option<&TextSize>, @@ -27148,9 +27148,9 @@ mod __parse__Top { let __end = __sym1.2; let __nt = super::__action1681::<>(mode, __sym0, __sym1); __symbols.push((__start, __Symbol::Variant8(__nt), __end)); - (2, 171) + (2, 173) } - pub(crate) fn __reduce493< + pub(crate) fn __reduce495< >( mode: Mode, __lookahead_start: Option<&TextSize>, @@ -27164,9 +27164,9 @@ mod __parse__Top { let __end = __sym0.2; let __nt = super::__action1682::<>(mode, __sym0); __symbols.push((__start, __Symbol::Variant8(__nt), __end)); - (1, 171) + (1, 173) } - pub(crate) fn __reduce494< + pub(crate) fn __reduce496< >( mode: Mode, __lookahead_start: Option<&TextSize>, @@ -27182,9 +27182,9 @@ mod __parse__Top { let __end = __sym1.2; let __nt = super::__action1076::<>(mode, __sym0, __sym1); __symbols.push((__start, __Symbol::Variant8(__nt), __end)); - (2, 172) + (2, 174) } - pub(crate) fn __reduce495< + pub(crate) fn __reduce497< >( mode: Mode, __lookahead_start: Option<&TextSize>, @@ -27198,7 +27198,7 @@ mod __parse__Top { let __end = __sym0.2; let __nt = super::__action1077::<>(mode, __sym0); __symbols.push((__start, __Symbol::Variant8(__nt), __end)); - (1, 172) + (1, 174) } pub(crate) fn __reduce500< >( @@ -30160,7 +30160,7 @@ mod __parse__Top { _: core::marker::PhantomData<()>, ) -> (usize, usize) { - // SmallStatement = LineMagicStatement => ActionFn(22); + // SmallStatement = IpyEscapeCommandStatement => ActionFn(22); let __sym0 = __pop_Variant36(__symbols); let __start = __sym0.0; let __end = __sym0.2; @@ -30176,7 +30176,7 @@ mod __parse__Top { _: core::marker::PhantomData<()>, ) -> (usize, usize) { - // SmallStatement = HelpEndLineMagic => ActionFn(23); + // SmallStatement = IpyHelpEndEscapeCommandStatement => ActionFn(23); let __sym0 = __pop_Variant36(__symbols); let __start = __sym0.0; let __end = __sym0.2; @@ -33614,22 +33614,22 @@ fn __action74< >( mode: Mode, (_, location, _): (TextSize, TextSize, TextSize), - (_, m, _): (TextSize, (MagicKind, String), TextSize), + (_, c, _): (TextSize, (IpyEscapeKind, String), TextSize), (_, end_location, _): (TextSize, TextSize, TextSize), ) -> Result> { { if mode == Mode::Jupyter { - Ok(ast::Stmt::LineMagic( - ast::StmtLineMagic { - kind: m.0, - value: m.1, + Ok(ast::Stmt::IpyEscapeCommand( + ast::StmtIpyEscapeCommand { + kind: c.0, + value: c.1, range: (location..end_location).into() } )) } else { Err(LexicalError { - error: LexicalErrorType::OtherError("line magics are only allowed in Jupyter mode".to_string()), + error: LexicalErrorType::OtherError("IPython escape commands are only allowed in Jupyter mode".to_string()), location, })? } @@ -33642,29 +33642,29 @@ fn __action75< >( mode: Mode, (_, location, _): (TextSize, TextSize, TextSize), - (_, m, _): (TextSize, (MagicKind, String), TextSize), + (_, c, _): (TextSize, (IpyEscapeKind, String), TextSize), (_, end_location, _): (TextSize, TextSize, TextSize), ) -> Result> { { if mode == Mode::Jupyter { // This should never occur as the lexer won't allow it. - if !matches!(m.0, MagicKind::Magic | MagicKind::Shell) { + if !matches!(c.0, IpyEscapeKind::Magic | IpyEscapeKind::Shell) { return Err(LexicalError { - error: LexicalErrorType::OtherError("expr line magics are only allowed for % and !".to_string()), + error: LexicalErrorType::OtherError("IPython escape command expr is only allowed for % and !".to_string()), location, })?; } - Ok(ast::Expr::LineMagic( - ast::ExprLineMagic { - kind: m.0, - value: m.1, + Ok(ast::Expr::IpyEscapeCommand( + ast::ExprIpyEscapeCommand { + kind: c.0, + value: c.1, range: (location..end_location).into() } )) } else { Err(LexicalError { - error: LexicalErrorType::OtherError("line magics are only allowed in Jupyter mode".to_string()), + error: LexicalErrorType::OtherError("IPython escape commands are only allowed in Jupyter mode".to_string()), location, })? } @@ -33714,7 +33714,7 @@ fn __action76< } Ok(()) } - + if mode != Mode::Jupyter { return Err(ParseError::User { error: LexicalError { @@ -33725,8 +33725,8 @@ fn __action76< } let kind = match suffix.len() { - 1 => MagicKind::Help, - 2 => MagicKind::Help2, + 1 => IpyEscapeKind::Help, + 2 => IpyEscapeKind::Help2, _ => { return Err(ParseError::User { error: LexicalError { @@ -33739,9 +33739,9 @@ fn __action76< let mut value = String::new(); unparse_expr(&e, &mut value)?; - - Ok(ast::Stmt::LineMagic( - ast::StmtLineMagic { + + Ok(ast::Stmt::IpyEscapeCommand( + ast::StmtIpyEscapeCommand { kind, value, range: (location..end_location).into() @@ -49600,33 +49600,6 @@ fn __action886< #[allow(unused_variables)] #[allow(clippy::too_many_arguments)] fn __action887< ->( - mode: Mode, - __0: (TextSize, ast::Expr, TextSize), - __1: (TextSize, alloc::vec::Vec, TextSize), - __2: (TextSize, TextSize, TextSize), -) -> Result> -{ - let __start0 = __0.0; - let __end0 = __0.0; - let __temp0 = __action396( - mode, - &__start0, - &__end0, - ); - let __temp0 = (__start0, __temp0, __end0); - __action76( - mode, - __temp0, - __0, - __1, - __2, - ) -} - -#[allow(unused_variables)] -#[allow(clippy::too_many_arguments)] -fn __action888< >( mode: Mode, __0: (TextSize, String, TextSize), @@ -49651,7 +49624,7 @@ fn __action888< #[allow(unused_variables)] #[allow(clippy::too_many_arguments)] -fn __action889< +fn __action888< >( mode: Mode, __0: (TextSize, token::Tok, TextSize), @@ -49684,7 +49657,7 @@ fn __action889< #[allow(unused_variables)] #[allow(clippy::too_many_arguments)] -fn __action890< +fn __action889< >( mode: Mode, __0: (TextSize, ast::Identifier, TextSize), @@ -49711,7 +49684,7 @@ fn __action890< #[allow(unused_variables)] #[allow(clippy::too_many_arguments)] -fn __action891< +fn __action890< >( mode: Mode, __0: (TextSize, ast::Identifier, TextSize), @@ -49738,7 +49711,7 @@ fn __action891< #[allow(unused_variables)] #[allow(clippy::too_many_arguments)] -fn __action892< +fn __action891< >( mode: Mode, __0: (TextSize, Vec, TextSize), @@ -49763,7 +49736,7 @@ fn __action892< #[allow(unused_variables)] #[allow(clippy::too_many_arguments)] -fn __action893< +fn __action892< >( mode: Mode, __0: (TextSize, token::Tok, TextSize), @@ -49794,7 +49767,7 @@ fn __action893< #[allow(unused_variables)] #[allow(clippy::too_many_arguments)] -fn __action894< +fn __action893< >( mode: Mode, __0: (TextSize, token::Tok, TextSize), @@ -49823,7 +49796,7 @@ fn __action894< #[allow(unused_variables)] #[allow(clippy::too_many_arguments)] -fn __action895< +fn __action894< >( mode: Mode, __0: (TextSize, token::Tok, TextSize), @@ -49848,7 +49821,7 @@ fn __action895< #[allow(unused_variables)] #[allow(clippy::too_many_arguments)] -fn __action896< +fn __action895< >( mode: Mode, __0: (TextSize, token::Tok, TextSize), @@ -49875,7 +49848,7 @@ fn __action896< #[allow(unused_variables)] #[allow(clippy::too_many_arguments)] -fn __action897< +fn __action896< >( mode: Mode, __0: (TextSize, token::Tok, TextSize), @@ -49906,43 +49879,51 @@ fn __action897< #[allow(unused_variables)] #[allow(clippy::too_many_arguments)] -fn __action898< +fn __action897< >( mode: Mode, - __0: (TextSize, token::Tok, TextSize), - __1: (TextSize, core::option::Option, TextSize), - __2: (TextSize, TextSize, TextSize), - __3: (TextSize, token::Tok, TextSize), - __4: (TextSize, ast::Expr, TextSize), - __5: (TextSize, TextSize, TextSize), + __0: (TextSize, (IpyEscapeKind, String), TextSize), + __1: (TextSize, TextSize, TextSize), ) -> Result> { let __start0 = __0.0; let __end0 = __0.0; - let __start1 = __0.2; - let __end1 = __1.0; let __temp0 = __action396( mode, &__start0, &__end0, ); let __temp0 = (__start0, __temp0, __end0); - let __temp1 = __action396( + __action75( mode, - &__start1, - &__end1, + __temp0, + __0, + __1, + ) +} + +#[allow(unused_variables)] +#[allow(clippy::too_many_arguments)] +fn __action898< +>( + mode: Mode, + __0: (TextSize, (IpyEscapeKind, String), TextSize), + __1: (TextSize, TextSize, TextSize), +) -> Result> +{ + let __start0 = __0.0; + let __end0 = __0.0; + let __temp0 = __action396( + mode, + &__start0, + &__end0, ); - let __temp1 = (__start1, __temp1, __end1); - __action183( + let __temp0 = (__start0, __temp0, __end0); + __action74( mode, __temp0, __0, - __temp1, __1, - __2, - __3, - __4, - __5, ) } @@ -49951,9 +49932,10 @@ fn __action898< fn __action899< >( mode: Mode, - __0: (TextSize, (MagicKind, String), TextSize), - __1: (TextSize, TextSize, TextSize), -) -> Result> + __0: (TextSize, ast::Expr, TextSize), + __1: (TextSize, alloc::vec::Vec, TextSize), + __2: (TextSize, TextSize, TextSize), +) -> Result> { let __start0 = __0.0; let __end0 = __0.0; @@ -49963,11 +49945,12 @@ fn __action899< &__end0, ); let __temp0 = (__start0, __temp0, __end0); - __action75( + __action76( mode, __temp0, __0, __1, + __2, ) } @@ -49976,23 +49959,40 @@ fn __action899< fn __action900< >( mode: Mode, - __0: (TextSize, (MagicKind, String), TextSize), - __1: (TextSize, TextSize, TextSize), -) -> Result> + __0: (TextSize, token::Tok, TextSize), + __1: (TextSize, core::option::Option, TextSize), + __2: (TextSize, TextSize, TextSize), + __3: (TextSize, token::Tok, TextSize), + __4: (TextSize, ast::Expr, TextSize), + __5: (TextSize, TextSize, TextSize), +) -> Result> { let __start0 = __0.0; let __end0 = __0.0; + let __start1 = __0.2; + let __end1 = __1.0; let __temp0 = __action396( mode, &__start0, &__end0, ); let __temp0 = (__start0, __temp0, __end0); - __action74( + let __temp1 = __action396( + mode, + &__start1, + &__end1, + ); + let __temp1 = (__start1, __temp1, __end1); + __action183( mode, __temp0, __0, + __temp1, __1, + __2, + __3, + __4, + __5, ) } @@ -58015,7 +58015,7 @@ fn __action1183< __2, ); let __temp0 = (__start0, __temp0, __end0); - __action890( + __action889( mode, __0, __temp0, @@ -58040,7 +58040,7 @@ fn __action1184< &__end0, ); let __temp0 = (__start0, __temp0, __end0); - __action890( + __action889( mode, __0, __temp0, @@ -58067,7 +58067,7 @@ fn __action1185< __2, ); let __temp0 = (__start0, __temp0, __end0); - __action891( + __action890( mode, __0, __temp0, @@ -58092,7 +58092,7 @@ fn __action1186< &__end0, ); let __temp0 = (__start0, __temp0, __end0); - __action891( + __action890( mode, __0, __temp0, @@ -58970,7 +58970,7 @@ fn __action1213< &__end0, ); let __temp0 = (__start0, __temp0, __end0); - __action889( + __action888( mode, __0, __1, @@ -59001,7 +59001,7 @@ fn __action1214< __4, ); let __temp0 = (__start0, __temp0, __end0); - __action889( + __action888( mode, __0, __1, @@ -64753,31 +64753,6 @@ fn __action1422< #[allow(unused_variables)] #[allow(clippy::too_many_arguments)] fn __action1423< ->( - mode: Mode, - __0: (TextSize, ast::Expr, TextSize), - __1: (TextSize, alloc::vec::Vec, TextSize), -) -> Result> -{ - let __start0 = __1.2; - let __end0 = __1.2; - let __temp0 = __action395( - mode, - &__start0, - &__end0, - ); - let __temp0 = (__start0, __temp0, __end0); - __action887( - mode, - __0, - __1, - __temp0, - ) -} - -#[allow(unused_variables)] -#[allow(clippy::too_many_arguments)] -fn __action1424< >( mode: Mode, __0: (TextSize, String, TextSize), @@ -64791,7 +64766,7 @@ fn __action1424< &__end0, ); let __temp0 = (__start0, __temp0, __end0); - __action888( + __action887( mode, __0, __temp0, @@ -64800,7 +64775,7 @@ fn __action1424< #[allow(unused_variables)] #[allow(clippy::too_many_arguments)] -fn __action1425< +fn __action1424< >( mode: Mode, __0: (TextSize, ast::Identifier, TextSize), @@ -64827,7 +64802,7 @@ fn __action1425< #[allow(unused_variables)] #[allow(clippy::too_many_arguments)] -fn __action1426< +fn __action1425< >( mode: Mode, __0: (TextSize, ast::Identifier, TextSize), @@ -64850,7 +64825,7 @@ fn __action1426< #[allow(unused_variables)] #[allow(clippy::too_many_arguments)] -fn __action1427< +fn __action1426< >( mode: Mode, __0: (TextSize, ast::Identifier, TextSize), @@ -64877,7 +64852,7 @@ fn __action1427< #[allow(unused_variables)] #[allow(clippy::too_many_arguments)] -fn __action1428< +fn __action1427< >( mode: Mode, __0: (TextSize, ast::Identifier, TextSize), @@ -64900,7 +64875,7 @@ fn __action1428< #[allow(unused_variables)] #[allow(clippy::too_many_arguments)] -fn __action1429< +fn __action1428< >( mode: Mode, __0: (TextSize, Vec, TextSize), @@ -64914,7 +64889,7 @@ fn __action1429< &__end0, ); let __temp0 = (__start0, __temp0, __end0); - __action892( + __action891( mode, __0, __temp0, @@ -64923,7 +64898,7 @@ fn __action1429< #[allow(unused_variables)] #[allow(clippy::too_many_arguments)] -fn __action1430< +fn __action1429< >( mode: Mode, __0: (TextSize, token::Tok, TextSize), @@ -64940,7 +64915,7 @@ fn __action1430< &__end0, ); let __temp0 = (__start0, __temp0, __end0); - __action893( + __action892( mode, __0, __1, @@ -64952,7 +64927,7 @@ fn __action1430< #[allow(unused_variables)] #[allow(clippy::too_many_arguments)] -fn __action1431< +fn __action1430< >( mode: Mode, __0: (TextSize, token::Tok, TextSize), @@ -64968,7 +64943,7 @@ fn __action1431< &__end0, ); let __temp0 = (__start0, __temp0, __end0); - __action894( + __action893( mode, __0, __1, @@ -64979,7 +64954,7 @@ fn __action1431< #[allow(unused_variables)] #[allow(clippy::too_many_arguments)] -fn __action1432< +fn __action1431< >( mode: Mode, __0: (TextSize, token::Tok, TextSize), @@ -64993,7 +64968,7 @@ fn __action1432< &__end0, ); let __temp0 = (__start0, __temp0, __end0); - __action895( + __action894( mode, __0, __temp0, @@ -65002,7 +64977,7 @@ fn __action1432< #[allow(unused_variables)] #[allow(clippy::too_many_arguments)] -fn __action1433< +fn __action1432< >( mode: Mode, __0: (TextSize, token::Tok, TextSize), @@ -65017,7 +64992,7 @@ fn __action1433< &__end0, ); let __temp0 = (__start0, __temp0, __end0); - __action896( + __action895( mode, __0, __1, @@ -65027,7 +65002,7 @@ fn __action1433< #[allow(unused_variables)] #[allow(clippy::too_many_arguments)] -fn __action1434< +fn __action1433< >( mode: Mode, __0: (TextSize, token::Tok, TextSize), @@ -65044,7 +65019,7 @@ fn __action1434< &__end0, ); let __temp0 = (__start0, __temp0, __end0); - __action897( + __action896( mode, __0, __1, @@ -65056,39 +65031,47 @@ fn __action1434< #[allow(unused_variables)] #[allow(clippy::too_many_arguments)] -fn __action1435< +fn __action1434< >( mode: Mode, - __0: (TextSize, token::Tok, TextSize), - __1: (TextSize, core::option::Option, TextSize), - __2: (TextSize, token::Tok, TextSize), - __3: (TextSize, ast::Expr, TextSize), + __0: (TextSize, (IpyEscapeKind, String), TextSize), ) -> Result> { - let __start0 = __1.2; - let __end0 = __2.0; - let __start1 = __3.2; - let __end1 = __3.2; + let __start0 = __0.2; + let __end0 = __0.2; let __temp0 = __action395( mode, &__start0, &__end0, ); let __temp0 = (__start0, __temp0, __end0); - let __temp1 = __action395( + __action897( mode, - &__start1, - &__end1, + __0, + __temp0, + ) +} + +#[allow(unused_variables)] +#[allow(clippy::too_many_arguments)] +fn __action1435< +>( + mode: Mode, + __0: (TextSize, (IpyEscapeKind, String), TextSize), +) -> Result> +{ + let __start0 = __0.2; + let __end0 = __0.2; + let __temp0 = __action395( + mode, + &__start0, + &__end0, ); - let __temp1 = (__start1, __temp1, __end1); + let __temp0 = (__start0, __temp0, __end0); __action898( mode, __0, - __1, __temp0, - __2, - __3, - __temp1, ) } @@ -65097,11 +65080,12 @@ fn __action1435< fn __action1436< >( mode: Mode, - __0: (TextSize, (MagicKind, String), TextSize), -) -> Result> + __0: (TextSize, ast::Expr, TextSize), + __1: (TextSize, alloc::vec::Vec, TextSize), +) -> Result> { - let __start0 = __0.2; - let __end0 = __0.2; + let __start0 = __1.2; + let __end0 = __1.2; let __temp0 = __action395( mode, &__start0, @@ -65111,6 +65095,7 @@ fn __action1436< __action899( mode, __0, + __1, __temp0, ) } @@ -65120,21 +65105,36 @@ fn __action1436< fn __action1437< >( mode: Mode, - __0: (TextSize, (MagicKind, String), TextSize), -) -> Result> + __0: (TextSize, token::Tok, TextSize), + __1: (TextSize, core::option::Option, TextSize), + __2: (TextSize, token::Tok, TextSize), + __3: (TextSize, ast::Expr, TextSize), +) -> Result> { - let __start0 = __0.2; - let __end0 = __0.2; + let __start0 = __1.2; + let __end0 = __2.0; + let __start1 = __3.2; + let __end1 = __3.2; let __temp0 = __action395( mode, &__start0, &__end0, ); let __temp0 = (__start0, __temp0, __end0); + let __temp1 = __action395( + mode, + &__start1, + &__end1, + ); + let __temp1 = (__start1, __temp1, __end1); __action900( mode, __0, + __1, __temp0, + __2, + __3, + __temp1, ) } @@ -71935,7 +71935,7 @@ fn __action1683< { let __start0 = __0.0; let __end0 = __2.2; - let __temp0 = __action1425( + let __temp0 = __action1424( mode, __0, __1, @@ -71958,7 +71958,7 @@ fn __action1684< { let __start0 = __0.0; let __end0 = __0.2; - let __temp0 = __action1426( + let __temp0 = __action1425( mode, __0, ); @@ -71983,7 +71983,7 @@ fn __action1685< { let __start0 = __2.0; let __end0 = __4.2; - let __temp0 = __action1425( + let __temp0 = __action1424( mode, __2, __3, @@ -72010,7 +72010,7 @@ fn __action1686< { let __start0 = __2.0; let __end0 = __2.2; - let __temp0 = __action1426( + let __temp0 = __action1425( mode, __2, ); @@ -72035,7 +72035,7 @@ fn __action1687< { let __start0 = __0.0; let __end0 = __2.2; - let __temp0 = __action1427( + let __temp0 = __action1426( mode, __0, __1, @@ -72058,7 +72058,7 @@ fn __action1688< { let __start0 = __0.0; let __end0 = __0.2; - let __temp0 = __action1428( + let __temp0 = __action1427( mode, __0, ); @@ -72083,7 +72083,7 @@ fn __action1689< { let __start0 = __2.0; let __end0 = __4.2; - let __temp0 = __action1427( + let __temp0 = __action1426( mode, __2, __3, @@ -72110,7 +72110,7 @@ fn __action1690< { let __start0 = __2.0; let __end0 = __2.2; - let __temp0 = __action1428( + let __temp0 = __action1427( mode, __2, ); @@ -76193,7 +76193,7 @@ fn __action1819< __1, ); let __temp0 = (__start0, __temp0, __end0); - __action1435( + __action1437( mode, __0, __temp0, @@ -76220,7 +76220,7 @@ fn __action1820< &__end0, ); let __temp0 = (__start0, __temp0, __end0); - __action1435( + __action1437( mode, __0, __temp0, diff --git a/crates/ruff_python_parser/src/snapshots/ruff_python_parser__parser__tests__jupyter_magic.snap b/crates/ruff_python_parser/src/snapshots/ruff_python_parser__parser__tests__ipython_escape_commands.snap similarity index 75% rename from crates/ruff_python_parser/src/snapshots/ruff_python_parser__parser__tests__jupyter_magic.snap rename to crates/ruff_python_parser/src/snapshots/ruff_python_parser__parser__tests__ipython_escape_commands.snap index 4149f47aca04c..3d06cd7aeb1ac 100644 --- a/crates/ruff_python_parser/src/snapshots/ruff_python_parser__parser__tests__jupyter_magic.snap +++ b/crates/ruff_python_parser/src/snapshots/ruff_python_parser__parser__tests__ipython_escape_commands.snap @@ -4,7 +4,7 @@ expression: parse_ast --- Module( ModModule { - range: 0..919, + range: 0..929, body: [ Expr( StmtExpr { @@ -31,92 +31,92 @@ Module( ), }, ), - LineMagic( - StmtLineMagic { + IpyEscapeCommand( + StmtIpyEscapeCommand { range: 66..73, kind: Help2, value: "a.foo", }, ), - LineMagic( - StmtLineMagic { + IpyEscapeCommand( + StmtIpyEscapeCommand { range: 74..80, kind: Help, value: "a.foo", }, ), - LineMagic( - StmtLineMagic { + IpyEscapeCommand( + StmtIpyEscapeCommand { range: 81..88, kind: Help, value: "a.foo", }, ), - LineMagic( - StmtLineMagic { + IpyEscapeCommand( + StmtIpyEscapeCommand { range: 89..100, kind: Help2, value: "a.foo()", }, ), - LineMagic( - StmtLineMagic { + IpyEscapeCommand( + StmtIpyEscapeCommand { range: 115..128, kind: Magic, value: "timeit a = b", }, ), - LineMagic( - StmtLineMagic { + IpyEscapeCommand( + StmtIpyEscapeCommand { range: 129..147, kind: Magic, value: "timeit foo(b) % 3", }, ), - LineMagic( - StmtLineMagic { + IpyEscapeCommand( + StmtIpyEscapeCommand { range: 148..176, kind: Magic, value: "alias showPath pwd && ls -a", }, ), - LineMagic( - StmtLineMagic { + IpyEscapeCommand( + StmtIpyEscapeCommand { range: 177..205, kind: Magic, value: "timeit a = foo(b); b = 2", }, ), - LineMagic( - StmtLineMagic { + IpyEscapeCommand( + StmtIpyEscapeCommand { range: 206..226, kind: Magic, value: "matplotlib --inline", }, ), - LineMagic( - StmtLineMagic { + IpyEscapeCommand( + StmtIpyEscapeCommand { range: 227..253, kind: Magic, value: "matplotlib --inline", }, ), - LineMagic( - StmtLineMagic { + IpyEscapeCommand( + StmtIpyEscapeCommand { range: 277..309, kind: Shell, value: "pwd && ls -a | sed 's/^/\\ /'", }, ), - LineMagic( - StmtLineMagic { + IpyEscapeCommand( + StmtIpyEscapeCommand { range: 310..347, kind: Shell, value: "pwd && ls -a | sed 's/^/\\\\ /'", }, ), - LineMagic( - StmtLineMagic { + IpyEscapeCommand( + StmtIpyEscapeCommand { range: 348..393, kind: ShCap, value: "cd /Users/foo/Library/Application\\ Support/", @@ -176,22 +176,22 @@ Module( ], }, ), - LineMagic( - StmtLineMagic { + IpyEscapeCommand( + StmtIpyEscapeCommand { range: 656..664, kind: Paren, value: "foo 1 2", }, ), - LineMagic( - StmtLineMagic { + IpyEscapeCommand( + StmtIpyEscapeCommand { range: 665..673, kind: Quote2, value: "foo 1 2", }, ), - LineMagic( - StmtLineMagic { + IpyEscapeCommand( + StmtIpyEscapeCommand { range: 674..682, kind: Quote, value: "foo 1 2", @@ -199,31 +199,31 @@ Module( ), For( StmtFor { - range: 701..727, + range: 711..737, is_async: false, target: Name( ExprName { - range: 705..706, + range: 715..716, id: "a", ctx: Store, }, ), iter: Call( ExprCall { - range: 710..718, + range: 720..728, func: Name( ExprName { - range: 710..715, + range: 720..725, id: "range", ctx: Load, }, ), arguments: Arguments { - range: 715..718, + range: 725..728, args: [ Constant( ExprConstant { - range: 716..717, + range: 726..727, value: Int( 5, ), @@ -236,9 +236,9 @@ Module( }, ), body: [ - LineMagic( - StmtLineMagic { - range: 724..727, + IpyEscapeCommand( + StmtIpyEscapeCommand { + range: 734..737, kind: Shell, value: "ls", }, @@ -249,19 +249,19 @@ Module( ), Assign( StmtAssign { - range: 729..738, + range: 739..748, targets: [ Name( ExprName { - range: 729..731, + range: 739..741, id: "p1", ctx: Store, }, ), ], - value: LineMagic( - ExprLineMagic { - range: 734..738, + value: IpyEscapeCommand( + ExprIpyEscapeCommand { + range: 744..748, kind: Shell, value: "pwd", }, @@ -270,25 +270,25 @@ Module( ), AnnAssign( StmtAnnAssign { - range: 739..753, + range: 749..763, target: Name( ExprName { - range: 739..741, + range: 749..751, id: "p2", ctx: Store, }, ), annotation: Name( ExprName { - range: 743..746, + range: 753..756, id: "str", ctx: Load, }, ), value: Some( - LineMagic( - ExprLineMagic { - range: 749..753, + IpyEscapeCommand( + ExprIpyEscapeCommand { + range: 759..763, kind: Shell, value: "pwd", }, @@ -299,98 +299,98 @@ Module( ), Assign( StmtAssign { - range: 754..774, + range: 764..784, targets: [ Name( ExprName { - range: 754..757, + range: 764..767, id: "foo", ctx: Store, }, ), ], - value: LineMagic( - ExprLineMagic { - range: 760..774, + value: IpyEscapeCommand( + ExprIpyEscapeCommand { + range: 770..784, kind: Magic, value: "foo bar", }, ), }, ), - LineMagic( - StmtLineMagic { - range: 776..781, + IpyEscapeCommand( + StmtIpyEscapeCommand { + range: 786..791, kind: Magic, value: " foo", }, ), Assign( StmtAssign { - range: 782..803, + range: 792..813, targets: [ Name( ExprName { - range: 782..785, + range: 792..795, id: "foo", ctx: Store, }, ), ], - value: LineMagic( - ExprLineMagic { - range: 788..803, + value: IpyEscapeCommand( + ExprIpyEscapeCommand { + range: 798..813, kind: Magic, value: "foo # comment", }, ), }, ), - LineMagic( - StmtLineMagic { - range: 828..832, + IpyEscapeCommand( + StmtIpyEscapeCommand { + range: 838..842, kind: Help, value: "foo", }, ), - LineMagic( - StmtLineMagic { - range: 833..842, + IpyEscapeCommand( + StmtIpyEscapeCommand { + range: 843..852, kind: Help2, value: "foo.bar", }, ), - LineMagic( - StmtLineMagic { - range: 843..855, + IpyEscapeCommand( + StmtIpyEscapeCommand { + range: 853..865, kind: Help, value: "foo.bar.baz", }, ), - LineMagic( - StmtLineMagic { - range: 856..864, + IpyEscapeCommand( + StmtIpyEscapeCommand { + range: 866..874, kind: Help2, value: "foo[0]", }, ), - LineMagic( - StmtLineMagic { - range: 865..875, + IpyEscapeCommand( + StmtIpyEscapeCommand { + range: 875..885, kind: Help, value: "foo[0][1]", }, ), - LineMagic( - StmtLineMagic { - range: 876..895, + IpyEscapeCommand( + StmtIpyEscapeCommand { + range: 886..905, kind: Help2, value: "foo.bar[0].baz[1]", }, ), - LineMagic( - StmtLineMagic { - range: 896..919, + IpyEscapeCommand( + StmtIpyEscapeCommand { + range: 906..929, kind: Help2, value: "foo.bar[0].baz[2].egg", }, diff --git a/crates/ruff_python_parser/src/token.rs b/crates/ruff_python_parser/src/token.rs index 6a19cf1f37b24..db159a0340e03 100644 --- a/crates/ruff_python_parser/src/token.rs +++ b/crates/ruff_python_parser/src/token.rs @@ -6,7 +6,7 @@ //! [CPython source]: https://github.com/python/cpython/blob/dfc2e065a2e71011017077e549cd2f9bf4944c54/Include/internal/pycore_token.h; use crate::Mode; use num_bigint::BigInt; -use ruff_python_ast::MagicKind; +use ruff_python_ast::IpyEscapeKind; use ruff_text_size::TextSize; use std::fmt; @@ -44,13 +44,13 @@ pub enum Tok { /// Whether the string is triple quoted. triple_quoted: bool, }, - /// Token value for a Jupyter magic commands. These are filtered out of the token stream - /// prior to parsing when the mode is [`Mode::Jupyter`]. - MagicCommand { + /// Token value for IPython escape commands. These are recognized by the lexer + /// only when the mode is [`Mode::Jupyter`]. + IpyEscapeCommand { /// The magic command value. value: String, /// The kind of magic command. - kind: MagicKind, + kind: IpyEscapeKind, }, /// Token value for a comment. These are filtered out of the token stream prior to parsing. Comment(String), @@ -234,7 +234,7 @@ impl fmt::Display for Tok { let quotes = "\"".repeat(if *triple_quoted { 3 } else { 1 }); write!(f, "{kind}{quotes}{value}{quotes}") } - MagicCommand { kind, value } => write!(f, "{kind}{value}"), + IpyEscapeCommand { kind, value } => write!(f, "{kind}{value}"), Newline => f.write_str("Newline"), NonLogicalNewline => f.write_str("NonLogicalNewline"), Indent => f.write_str("Indent"), @@ -450,8 +450,8 @@ pub enum TokenKind { Complex, /// Token value for a string. String, - /// Token value for a Jupyter magic command. - MagicCommand, + /// Token value for a IPython escape command. + EscapeCommand, /// Token value for a comment. These are filtered out of the token stream prior to parsing. Comment, /// Token value for a newline. @@ -781,7 +781,7 @@ impl TokenKind { Tok::Float { .. } => TokenKind::Float, Tok::Complex { .. } => TokenKind::Complex, Tok::String { .. } => TokenKind::String, - Tok::MagicCommand { .. } => TokenKind::MagicCommand, + Tok::IpyEscapeCommand { .. } => TokenKind::EscapeCommand, Tok::Comment(_) => TokenKind::Comment, Tok::Newline => TokenKind::Newline, Tok::NonLogicalNewline => TokenKind::NonLogicalNewline,