From 8879708da76f8b8414b3418aa8ef54227ae2ebdd Mon Sep 17 00:00:00 2001 From: rocky Date: Wed, 2 Sep 2020 07:14:56 -0400 Subject: [PATCH] del_stmt -> delete to match Python AST better --- test/simple_source/stmts/10_del.py | 2 +- uncompyle6/parser.py | 8 ++++---- uncompyle6/parsers/parse2.py | 16 ++++++++-------- uncompyle6/parsers/parse23.py | 2 +- uncompyle6/parsers/parse26.py | 4 ++-- uncompyle6/parsers/parse3.py | 6 +++--- uncompyle6/parsers/parse31.py | 6 +++--- uncompyle6/parsers/parse37.py | 10 +++++----- uncompyle6/parsers/parse37base.py | 4 ++-- uncompyle6/semantics/consts.py | 2 +- uncompyle6/semantics/fragments.py | 2 +- uncompyle6/semantics/pysource.py | 2 +- 12 files changed, 32 insertions(+), 32 deletions(-) diff --git a/test/simple_source/stmts/10_del.py b/test/simple_source/stmts/10_del.py index f7d23524..95f35c0b 100644 --- a/test/simple_source/stmts/10_del.py +++ b/test/simple_source/stmts/10_del.py @@ -8,7 +8,7 @@ b = [4, 5, 6] del b[1] del b[:] -# del_stmt ::= expr expr DELETE_SLICE+1 +# delete ::= expr expr DELETE_SLICE+1 l = [None] * 10 del l[-2:] diff --git a/uncompyle6/parser.py b/uncompyle6/parser.py index 56ae1697..fd711fda 100644 --- a/uncompyle6/parser.py +++ b/uncompyle6/parser.py @@ -354,10 +354,10 @@ class PythonParser(GenericASTBuilder): stmt ::= with stmt ::= withasstmt - stmt ::= del_stmt - del_stmt ::= DELETE_FAST - del_stmt ::= DELETE_NAME - del_stmt ::= DELETE_GLOBAL + stmt ::= delete + delete ::= DELETE_FAST + delete ::= DELETE_NAME + delete ::= DELETE_GLOBAL stmt ::= return diff --git a/uncompyle6/parsers/parse2.py b/uncompyle6/parsers/parse2.py index 590ea37a..5683dde3 100644 --- a/uncompyle6/parsers/parse2.py +++ b/uncompyle6/parsers/parse2.py @@ -99,9 +99,9 @@ class Python2Parser(PythonParser): for ::= SETUP_LOOP expr for_iter store for_block POP_BLOCK _come_froms - del_stmt ::= delete_subscript + delete ::= delete_subscript delete_subscript ::= expr expr DELETE_SUBSCR - del_stmt ::= expr DELETE_ATTR + delete ::= expr DELETE_ATTR _mklambda ::= load_closure mklambda kwarg ::= LOAD_CONST expr @@ -423,17 +423,17 @@ class Python2Parser(PythonParser): custom_seen_ops.add(opname) continue elif opname == "DELETE_ATTR": - self.addRule("del_stmt ::= expr DELETE_ATTR", nop_func) + self.addRule("delete ::= expr DELETE_ATTR", nop_func) custom_seen_ops.add(opname) continue elif opname.startswith("DELETE_SLICE"): self.addRule( """ del_expr ::= expr - del_stmt ::= del_expr DELETE_SLICE+0 - del_stmt ::= del_expr del_expr DELETE_SLICE+1 - del_stmt ::= del_expr del_expr DELETE_SLICE+2 - del_stmt ::= del_expr del_expr del_expr DELETE_SLICE+3 + delete ::= del_expr DELETE_SLICE+0 + delete ::= del_expr del_expr DELETE_SLICE+1 + delete ::= del_expr del_expr DELETE_SLICE+2 + delete ::= del_expr del_expr del_expr DELETE_SLICE+3 """, nop_func, ) @@ -453,7 +453,7 @@ class Python2Parser(PythonParser): elif opname == "DELETE_SUBSCR": self.addRule( """ - del_stmt ::= delete_subscript + delete ::= delete_subscript delete_subscript ::= expr expr DELETE_SUBSCR """, nop_func, diff --git a/uncompyle6/parsers/parse23.py b/uncompyle6/parsers/parse23.py index 0e41ad64..3b241e63 100644 --- a/uncompyle6/parsers/parse23.py +++ b/uncompyle6/parsers/parse23.py @@ -48,7 +48,7 @@ class Python23Parser(Python24Parser): while1stmt ::= _while1test l_stmts JUMP_BACK POP_TOP POP_BLOCK - list_comp ::= BUILD_LIST_0 DUP_TOP LOAD_ATTR store list_iter del_stmt + list_comp ::= BUILD_LIST_0 DUP_TOP LOAD_ATTR store list_iter delete list_for ::= expr for_iter store list_iter JUMP_BACK come_froms POP_TOP JUMP_BACK lc_body ::= LOAD_NAME expr CALL_FUNCTION_1 POP_TOP diff --git a/uncompyle6/parsers/parse26.py b/uncompyle6/parsers/parse26.py index ac2a08e8..ef123c01 100644 --- a/uncompyle6/parsers/parse26.py +++ b/uncompyle6/parsers/parse26.py @@ -230,9 +230,9 @@ class Python26Parser(Python2Parser): list_iter ::= list_if JUMP_BACK list_iter ::= list_if JUMP_BACK COME_FROM POP_TOP list_comp ::= BUILD_LIST_0 DUP_TOP - store list_iter del_stmt + store list_iter delete list_comp ::= BUILD_LIST_0 DUP_TOP - store list_iter JUMP_BACK del_stmt + store list_iter JUMP_BACK delete lc_body ::= LOAD_NAME expr LIST_APPEND lc_body ::= LOAD_FAST expr LIST_APPEND diff --git a/uncompyle6/parsers/parse3.py b/uncompyle6/parsers/parse3.py index 82971708..c39689b9 100644 --- a/uncompyle6/parsers/parse3.py +++ b/uncompyle6/parsers/parse3.py @@ -254,7 +254,7 @@ class Python3Parser(PythonParser): END_FINALLY _jump except_var_finalize ::= POP_BLOCK POP_EXCEPT LOAD_CONST COME_FROM_FINALLY - LOAD_CONST store del_stmt + LOAD_CONST store delete except_suite ::= returns @@ -933,7 +933,7 @@ class Python3Parser(PythonParser): self.addRule("continue ::= CONTINUE_LOOP", nop_func) custom_ops_processed.add(opname) elif opname == "DELETE_ATTR": - self.addRule("del_stmt ::= expr DELETE_ATTR", nop_func) + self.addRule("delete ::= expr DELETE_ATTR", nop_func) custom_ops_processed.add(opname) elif opname == "DELETE_DEREF": self.addRule( @@ -947,7 +947,7 @@ class Python3Parser(PythonParser): elif opname == "DELETE_SUBSCR": self.addRule( """ - del_stmt ::= delete_subscript + delete ::= delete_subscript delete_subscript ::= expr expr DELETE_SUBSCR """, nop_func, diff --git a/uncompyle6/parsers/parse31.py b/uncompyle6/parsers/parse31.py index a5d8a74a..8e04fae6 100644 --- a/uncompyle6/parsers/parse31.py +++ b/uncompyle6/parsers/parse31.py @@ -18,15 +18,15 @@ class Python31Parser(Python32Parser): with ::= expr setupwith SETUP_FINALLY suite_stmts_opt POP_BLOCK LOAD_CONST COME_FROM_FINALLY - load del_stmt WITH_CLEANUP END_FINALLY + load delete WITH_CLEANUP END_FINALLY # Keeps Python 3.1 withas desigator in the same position as it is in other version - setupwithas31 ::= setupwithas SETUP_FINALLY load del_stmt + setupwithas31 ::= setupwithas SETUP_FINALLY load delete withasstmt ::= expr setupwithas31 store suite_stmts_opt POP_BLOCK LOAD_CONST COME_FROM_FINALLY - load del_stmt WITH_CLEANUP END_FINALLY + load delete WITH_CLEANUP END_FINALLY store ::= STORE_NAME load ::= LOAD_FAST diff --git a/uncompyle6/parsers/parse37.py b/uncompyle6/parsers/parse37.py index a4d0bc29..d1ea51cf 100644 --- a/uncompyle6/parsers/parse37.py +++ b/uncompyle6/parsers/parse37.py @@ -113,10 +113,10 @@ class Python37Parser(Python37BaseParser): stmt ::= tryelsestmt stmt ::= tryfinallystmt - stmt ::= del_stmt - del_stmt ::= DELETE_FAST - del_stmt ::= DELETE_NAME - del_stmt ::= DELETE_GLOBAL + stmt ::= delete + delete ::= DELETE_FAST + delete ::= DELETE_NAME + delete ::= DELETE_GLOBAL stmt ::= return return ::= ret_expr RETURN_VALUE @@ -889,7 +889,7 @@ class Python37Parser(Python37BaseParser): END_FINALLY _jump except_var_finalize ::= POP_BLOCK POP_EXCEPT LOAD_CONST COME_FROM_FINALLY - LOAD_CONST store del_stmt + LOAD_CONST store delete except_suite ::= returns diff --git a/uncompyle6/parsers/parse37base.py b/uncompyle6/parsers/parse37base.py index 9a5bcf36..23a23c9f 100644 --- a/uncompyle6/parsers/parse37base.py +++ b/uncompyle6/parsers/parse37base.py @@ -541,7 +541,7 @@ class Python37BaseParser(PythonParser): self.addRule("continue ::= CONTINUE_LOOP", nop_func) custom_ops_processed.add(opname) elif opname == "DELETE_ATTR": - self.addRule("del_stmt ::= expr DELETE_ATTR", nop_func) + self.addRule("delete ::= expr DELETE_ATTR", nop_func) custom_ops_processed.add(opname) elif opname == "DELETE_DEREF": self.addRule( @@ -555,7 +555,7 @@ class Python37BaseParser(PythonParser): elif opname == "DELETE_SUBSCR": self.addRule( """ - del_stmt ::= delete_subscript + delete ::= delete_subscript delete_subscript ::= expr expr DELETE_SUBSCR """, nop_func, diff --git a/uncompyle6/semantics/consts.py b/uncompyle6/semantics/consts.py index 8e80b2ea..d1609b62 100644 --- a/uncompyle6/semantics/consts.py +++ b/uncompyle6/semantics/consts.py @@ -433,7 +433,7 @@ MAP_R = (TABLE_R, -1) MAP = { "stmt": MAP_R, "call": MAP_R, - "del_stmt": MAP_R, + "delete": MAP_R, "store": MAP_R, "exprlist": MAP_R0, } diff --git a/uncompyle6/semantics/fragments.py b/uncompyle6/semantics/fragments.py index 194fa80a..9489c001 100644 --- a/uncompyle6/semantics/fragments.py +++ b/uncompyle6/semantics/fragments.py @@ -258,7 +258,7 @@ class FragmentsWalker(pysource.SourceWalker, object): raise GenericASTTraversalPruningException n_slice0 = n_slice1 = n_slice2 = n_slice3 = n_subscript = table_r_node - n_aug_assign_1 = n_print_item = exec_stmt = print_to_item = del_stmt = table_r_node + n_aug_assign_1 = n_print_item = exec_stmt = print_to_item = delete = table_r_node n_classdefco1 = n_classdefco2 = except_cond1 = except_cond2 = table_r_node def n_pass(self, node): diff --git a/uncompyle6/semantics/pysource.py b/uncompyle6/semantics/pysource.py index c8b2a981..e398a990 100644 --- a/uncompyle6/semantics/pysource.py +++ b/uncompyle6/semantics/pysource.py @@ -980,7 +980,7 @@ class SourceWalker(GenericASTTraversal, object): self.n_list_comp_pypy27(node) return n = node[-1] - elif node[-1] == "del_stmt": + elif node[-1] == "delete": if node[-2] == "JUMP_BACK": n = node[-3] else: