You've already forked python-uncompyle6
mirror of
https://github.com/rocky/python-uncompyle6.git
synced 2025-08-03 00:45:53 +08:00
del_stmt -> delete to match Python AST better
This commit is contained in:
@@ -8,7 +8,7 @@ b = [4, 5, 6]
|
|||||||
del b[1]
|
del b[1]
|
||||||
del b[:]
|
del b[:]
|
||||||
|
|
||||||
# del_stmt ::= expr expr DELETE_SLICE+1
|
# delete ::= expr expr DELETE_SLICE+1
|
||||||
l = [None] * 10
|
l = [None] * 10
|
||||||
del l[-2:]
|
del l[-2:]
|
||||||
|
|
||||||
|
@@ -354,10 +354,10 @@ class PythonParser(GenericASTBuilder):
|
|||||||
stmt ::= with
|
stmt ::= with
|
||||||
stmt ::= withasstmt
|
stmt ::= withasstmt
|
||||||
|
|
||||||
stmt ::= del_stmt
|
stmt ::= delete
|
||||||
del_stmt ::= DELETE_FAST
|
delete ::= DELETE_FAST
|
||||||
del_stmt ::= DELETE_NAME
|
delete ::= DELETE_NAME
|
||||||
del_stmt ::= DELETE_GLOBAL
|
delete ::= DELETE_GLOBAL
|
||||||
|
|
||||||
|
|
||||||
stmt ::= return
|
stmt ::= return
|
||||||
|
@@ -99,9 +99,9 @@ class Python2Parser(PythonParser):
|
|||||||
for ::= SETUP_LOOP expr for_iter store
|
for ::= SETUP_LOOP expr for_iter store
|
||||||
for_block POP_BLOCK _come_froms
|
for_block POP_BLOCK _come_froms
|
||||||
|
|
||||||
del_stmt ::= delete_subscript
|
delete ::= delete_subscript
|
||||||
delete_subscript ::= expr expr DELETE_SUBSCR
|
delete_subscript ::= expr expr DELETE_SUBSCR
|
||||||
del_stmt ::= expr DELETE_ATTR
|
delete ::= expr DELETE_ATTR
|
||||||
|
|
||||||
_mklambda ::= load_closure mklambda
|
_mklambda ::= load_closure mklambda
|
||||||
kwarg ::= LOAD_CONST expr
|
kwarg ::= LOAD_CONST expr
|
||||||
@@ -423,17 +423,17 @@ class Python2Parser(PythonParser):
|
|||||||
custom_seen_ops.add(opname)
|
custom_seen_ops.add(opname)
|
||||||
continue
|
continue
|
||||||
elif opname == "DELETE_ATTR":
|
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)
|
custom_seen_ops.add(opname)
|
||||||
continue
|
continue
|
||||||
elif opname.startswith("DELETE_SLICE"):
|
elif opname.startswith("DELETE_SLICE"):
|
||||||
self.addRule(
|
self.addRule(
|
||||||
"""
|
"""
|
||||||
del_expr ::= expr
|
del_expr ::= expr
|
||||||
del_stmt ::= del_expr DELETE_SLICE+0
|
delete ::= del_expr DELETE_SLICE+0
|
||||||
del_stmt ::= del_expr del_expr DELETE_SLICE+1
|
delete ::= del_expr del_expr DELETE_SLICE+1
|
||||||
del_stmt ::= del_expr del_expr DELETE_SLICE+2
|
delete ::= del_expr del_expr DELETE_SLICE+2
|
||||||
del_stmt ::= del_expr del_expr del_expr DELETE_SLICE+3
|
delete ::= del_expr del_expr del_expr DELETE_SLICE+3
|
||||||
""",
|
""",
|
||||||
nop_func,
|
nop_func,
|
||||||
)
|
)
|
||||||
@@ -453,7 +453,7 @@ class Python2Parser(PythonParser):
|
|||||||
elif opname == "DELETE_SUBSCR":
|
elif opname == "DELETE_SUBSCR":
|
||||||
self.addRule(
|
self.addRule(
|
||||||
"""
|
"""
|
||||||
del_stmt ::= delete_subscript
|
delete ::= delete_subscript
|
||||||
delete_subscript ::= expr expr DELETE_SUBSCR
|
delete_subscript ::= expr expr DELETE_SUBSCR
|
||||||
""",
|
""",
|
||||||
nop_func,
|
nop_func,
|
||||||
|
@@ -48,7 +48,7 @@ class Python23Parser(Python24Parser):
|
|||||||
while1stmt ::= _while1test l_stmts JUMP_BACK
|
while1stmt ::= _while1test l_stmts JUMP_BACK
|
||||||
POP_TOP POP_BLOCK
|
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
|
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
|
lc_body ::= LOAD_NAME expr CALL_FUNCTION_1 POP_TOP
|
||||||
|
@@ -230,9 +230,9 @@ class Python26Parser(Python2Parser):
|
|||||||
list_iter ::= list_if JUMP_BACK
|
list_iter ::= list_if JUMP_BACK
|
||||||
list_iter ::= list_if JUMP_BACK COME_FROM POP_TOP
|
list_iter ::= list_if JUMP_BACK COME_FROM POP_TOP
|
||||||
list_comp ::= BUILD_LIST_0 DUP_TOP
|
list_comp ::= BUILD_LIST_0 DUP_TOP
|
||||||
store list_iter del_stmt
|
store list_iter delete
|
||||||
list_comp ::= BUILD_LIST_0 DUP_TOP
|
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_NAME expr LIST_APPEND
|
||||||
lc_body ::= LOAD_FAST expr LIST_APPEND
|
lc_body ::= LOAD_FAST expr LIST_APPEND
|
||||||
|
|
||||||
|
@@ -254,7 +254,7 @@ class Python3Parser(PythonParser):
|
|||||||
END_FINALLY _jump
|
END_FINALLY _jump
|
||||||
|
|
||||||
except_var_finalize ::= POP_BLOCK POP_EXCEPT LOAD_CONST COME_FROM_FINALLY
|
except_var_finalize ::= POP_BLOCK POP_EXCEPT LOAD_CONST COME_FROM_FINALLY
|
||||||
LOAD_CONST store del_stmt
|
LOAD_CONST store delete
|
||||||
|
|
||||||
except_suite ::= returns
|
except_suite ::= returns
|
||||||
|
|
||||||
@@ -933,7 +933,7 @@ class Python3Parser(PythonParser):
|
|||||||
self.addRule("continue ::= CONTINUE_LOOP", nop_func)
|
self.addRule("continue ::= CONTINUE_LOOP", nop_func)
|
||||||
custom_ops_processed.add(opname)
|
custom_ops_processed.add(opname)
|
||||||
elif opname == "DELETE_ATTR":
|
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)
|
custom_ops_processed.add(opname)
|
||||||
elif opname == "DELETE_DEREF":
|
elif opname == "DELETE_DEREF":
|
||||||
self.addRule(
|
self.addRule(
|
||||||
@@ -947,7 +947,7 @@ class Python3Parser(PythonParser):
|
|||||||
elif opname == "DELETE_SUBSCR":
|
elif opname == "DELETE_SUBSCR":
|
||||||
self.addRule(
|
self.addRule(
|
||||||
"""
|
"""
|
||||||
del_stmt ::= delete_subscript
|
delete ::= delete_subscript
|
||||||
delete_subscript ::= expr expr DELETE_SUBSCR
|
delete_subscript ::= expr expr DELETE_SUBSCR
|
||||||
""",
|
""",
|
||||||
nop_func,
|
nop_func,
|
||||||
|
@@ -18,15 +18,15 @@ class Python31Parser(Python32Parser):
|
|||||||
with ::= expr setupwith SETUP_FINALLY
|
with ::= expr setupwith SETUP_FINALLY
|
||||||
suite_stmts_opt
|
suite_stmts_opt
|
||||||
POP_BLOCK LOAD_CONST COME_FROM_FINALLY
|
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
|
# 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
|
withasstmt ::= expr setupwithas31 store
|
||||||
suite_stmts_opt
|
suite_stmts_opt
|
||||||
POP_BLOCK LOAD_CONST COME_FROM_FINALLY
|
POP_BLOCK LOAD_CONST COME_FROM_FINALLY
|
||||||
load del_stmt WITH_CLEANUP END_FINALLY
|
load delete WITH_CLEANUP END_FINALLY
|
||||||
|
|
||||||
store ::= STORE_NAME
|
store ::= STORE_NAME
|
||||||
load ::= LOAD_FAST
|
load ::= LOAD_FAST
|
||||||
|
@@ -113,10 +113,10 @@ class Python37Parser(Python37BaseParser):
|
|||||||
stmt ::= tryelsestmt
|
stmt ::= tryelsestmt
|
||||||
stmt ::= tryfinallystmt
|
stmt ::= tryfinallystmt
|
||||||
|
|
||||||
stmt ::= del_stmt
|
stmt ::= delete
|
||||||
del_stmt ::= DELETE_FAST
|
delete ::= DELETE_FAST
|
||||||
del_stmt ::= DELETE_NAME
|
delete ::= DELETE_NAME
|
||||||
del_stmt ::= DELETE_GLOBAL
|
delete ::= DELETE_GLOBAL
|
||||||
|
|
||||||
stmt ::= return
|
stmt ::= return
|
||||||
return ::= ret_expr RETURN_VALUE
|
return ::= ret_expr RETURN_VALUE
|
||||||
@@ -889,7 +889,7 @@ class Python37Parser(Python37BaseParser):
|
|||||||
END_FINALLY _jump
|
END_FINALLY _jump
|
||||||
|
|
||||||
except_var_finalize ::= POP_BLOCK POP_EXCEPT LOAD_CONST COME_FROM_FINALLY
|
except_var_finalize ::= POP_BLOCK POP_EXCEPT LOAD_CONST COME_FROM_FINALLY
|
||||||
LOAD_CONST store del_stmt
|
LOAD_CONST store delete
|
||||||
|
|
||||||
except_suite ::= returns
|
except_suite ::= returns
|
||||||
|
|
||||||
|
@@ -541,7 +541,7 @@ class Python37BaseParser(PythonParser):
|
|||||||
self.addRule("continue ::= CONTINUE_LOOP", nop_func)
|
self.addRule("continue ::= CONTINUE_LOOP", nop_func)
|
||||||
custom_ops_processed.add(opname)
|
custom_ops_processed.add(opname)
|
||||||
elif opname == "DELETE_ATTR":
|
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)
|
custom_ops_processed.add(opname)
|
||||||
elif opname == "DELETE_DEREF":
|
elif opname == "DELETE_DEREF":
|
||||||
self.addRule(
|
self.addRule(
|
||||||
@@ -555,7 +555,7 @@ class Python37BaseParser(PythonParser):
|
|||||||
elif opname == "DELETE_SUBSCR":
|
elif opname == "DELETE_SUBSCR":
|
||||||
self.addRule(
|
self.addRule(
|
||||||
"""
|
"""
|
||||||
del_stmt ::= delete_subscript
|
delete ::= delete_subscript
|
||||||
delete_subscript ::= expr expr DELETE_SUBSCR
|
delete_subscript ::= expr expr DELETE_SUBSCR
|
||||||
""",
|
""",
|
||||||
nop_func,
|
nop_func,
|
||||||
|
@@ -433,7 +433,7 @@ MAP_R = (TABLE_R, -1)
|
|||||||
MAP = {
|
MAP = {
|
||||||
"stmt": MAP_R,
|
"stmt": MAP_R,
|
||||||
"call": MAP_R,
|
"call": MAP_R,
|
||||||
"del_stmt": MAP_R,
|
"delete": MAP_R,
|
||||||
"store": MAP_R,
|
"store": MAP_R,
|
||||||
"exprlist": MAP_R0,
|
"exprlist": MAP_R0,
|
||||||
}
|
}
|
||||||
|
@@ -258,7 +258,7 @@ class FragmentsWalker(pysource.SourceWalker, object):
|
|||||||
raise GenericASTTraversalPruningException
|
raise GenericASTTraversalPruningException
|
||||||
|
|
||||||
n_slice0 = n_slice1 = n_slice2 = n_slice3 = n_subscript = table_r_node
|
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
|
n_classdefco1 = n_classdefco2 = except_cond1 = except_cond2 = table_r_node
|
||||||
|
|
||||||
def n_pass(self, node):
|
def n_pass(self, node):
|
||||||
|
@@ -980,7 +980,7 @@ class SourceWalker(GenericASTTraversal, object):
|
|||||||
self.n_list_comp_pypy27(node)
|
self.n_list_comp_pypy27(node)
|
||||||
return
|
return
|
||||||
n = node[-1]
|
n = node[-1]
|
||||||
elif node[-1] == "del_stmt":
|
elif node[-1] == "delete":
|
||||||
if node[-2] == "JUMP_BACK":
|
if node[-2] == "JUMP_BACK":
|
||||||
n = node[-3]
|
n = node[-3]
|
||||||
else:
|
else:
|
||||||
|
Reference in New Issue
Block a user