You've already forked python-uncompyle6
mirror of
https://github.com/rocky/python-uncompyle6.git
synced 2025-08-02 16:44:46 +08:00
NT "_for" -> "for_iter" reduces confusion w/ "for"
This commit is contained in:
@@ -376,20 +376,20 @@ class PythonParser(GenericASTBuilder):
|
||||
|
||||
def p_forstmt(self, args):
|
||||
"""
|
||||
_for ::= GET_ITER FOR_ITER
|
||||
for_iter ::= GET_ITER FOR_ITER
|
||||
|
||||
for_block ::= l_stmts_opt _come_froms JUMP_BACK
|
||||
|
||||
for ::= SETUP_LOOP expr _for store
|
||||
for ::= SETUP_LOOP expr for_iter store
|
||||
for_block POP_BLOCK _come_froms
|
||||
|
||||
forelsestmt ::= SETUP_LOOP expr _for store
|
||||
forelsestmt ::= SETUP_LOOP expr for_iter store
|
||||
for_block POP_BLOCK else_suite _come_froms
|
||||
|
||||
forelselaststmt ::= SETUP_LOOP expr _for store
|
||||
forelselaststmt ::= SETUP_LOOP expr for_iter store
|
||||
for_block POP_BLOCK else_suitec _come_froms
|
||||
|
||||
forelselaststmtl ::= SETUP_LOOP expr _for store
|
||||
forelselaststmtl ::= SETUP_LOOP expr for_iter store
|
||||
for_block POP_BLOCK else_suitel _come_froms
|
||||
"""
|
||||
|
||||
|
@@ -246,7 +246,7 @@ class Python2Parser(PythonParser):
|
||||
stmt ::= assign2_pypy
|
||||
assign3_pypy ::= expr expr expr store store store
|
||||
assign2_pypy ::= expr expr store store
|
||||
list_comp ::= expr BUILD_LIST_FROM_ARG _for store list_iter
|
||||
list_comp ::= expr BUILD_LIST_FROM_ARG for_iter store list_iter
|
||||
JUMP_BACK
|
||||
""", nop_func)
|
||||
|
||||
|
@@ -13,11 +13,11 @@ class Python21Parser(Python22Parser):
|
||||
|
||||
def p_forstmt21(self, args):
|
||||
"""
|
||||
_for ::= LOAD_CONST FOR_LOOP
|
||||
for ::= SETUP_LOOP expr _for store
|
||||
for_iter ::= LOAD_CONST FOR_LOOP
|
||||
for ::= SETUP_LOOP expr for_iter store
|
||||
return_stmts
|
||||
POP_BLOCK COME_FROM
|
||||
for ::= SETUP_LOOP expr _for store
|
||||
for ::= SETUP_LOOP expr for_iter store
|
||||
l_stmts_opt _jump_back
|
||||
POP_BLOCK COME_FROM
|
||||
|
||||
|
@@ -13,10 +13,10 @@ class Python22Parser(Python23Parser):
|
||||
|
||||
def p_misc22(self, args):
|
||||
'''
|
||||
_for ::= LOAD_CONST FOR_LOOP
|
||||
for_iter ::= LOAD_CONST FOR_LOOP
|
||||
list_iter ::= list_if JUMP_FORWARD
|
||||
COME_FROM POP_TOP COME_FROM
|
||||
list_for ::= expr _for store list_iter CONTINUE JUMP_FORWARD
|
||||
list_for ::= expr for_iter store list_iter CONTINUE JUMP_FORWARD
|
||||
COME_FROM POP_TOP COME_FROM
|
||||
'''
|
||||
|
||||
|
@@ -36,7 +36,7 @@ class Python23Parser(Python24Parser):
|
||||
COME_FROM POP_TOP POP_BLOCK COME_FROM
|
||||
|
||||
list_comp ::= BUILD_LIST_0 DUP_TOP LOAD_ATTR store list_iter del_stmt
|
||||
list_for ::= expr _for 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_FAST expr CALL_FUNCTION_1 POP_TOP
|
||||
|
@@ -180,23 +180,23 @@ class Python26Parser(Python2Parser):
|
||||
|
||||
def p_comp26(self, args):
|
||||
'''
|
||||
list_for ::= expr _for store list_iter JUMP_BACK come_froms POP_TOP
|
||||
list_for ::= expr for_iter store list_iter JUMP_BACK come_froms POP_TOP
|
||||
|
||||
# The JUMP FORWARD below jumps to the JUMP BACK. It seems to happen
|
||||
# in rare cases that may have to with length of code
|
||||
# FIXME: we can add a reduction check for this
|
||||
|
||||
list_for ::= expr _for store list_iter JUMP_FORWARD come_froms POP_TOP
|
||||
list_for ::= expr for_iter store list_iter JUMP_FORWARD come_froms POP_TOP
|
||||
COME_FROM JUMP_BACK
|
||||
|
||||
list_for ::= expr _for store list_iter jb_cont
|
||||
list_for ::= expr for_iter store list_iter jb_cont
|
||||
|
||||
# This is for a really funky:
|
||||
# [ x for x in range(10) if x % 2 if x % 3 ]
|
||||
# the JUMP_ABSOLUTE is to the instruction after the last POP_TOP
|
||||
# we have a reduction check for this
|
||||
|
||||
list_for ::= expr _for store list_iter JUMP_ABSOLUTE come_froms
|
||||
list_for ::= expr for_iter store list_iter JUMP_ABSOLUTE come_froms
|
||||
POP_TOP jb_pop
|
||||
|
||||
list_iter ::= list_if JUMP_BACK
|
||||
@@ -208,7 +208,7 @@ class Python26Parser(Python2Parser):
|
||||
lc_body ::= LOAD_NAME expr LIST_APPEND
|
||||
lc_body ::= LOAD_FAST expr LIST_APPEND
|
||||
|
||||
comp_for ::= SETUP_LOOP expr _for store comp_iter jb_pb_come_from
|
||||
comp_for ::= SETUP_LOOP expr for_iter store comp_iter jb_pb_come_from
|
||||
|
||||
comp_body ::= gen_comp_body
|
||||
|
||||
@@ -314,7 +314,7 @@ class Python26Parser(Python2Parser):
|
||||
tokens[last].pattr == jmp_false.pattr)
|
||||
elif rule == (
|
||||
'list_for',
|
||||
('expr', '_for', 'store', 'list_iter',
|
||||
('expr', 'for_iter', 'store', 'list_iter',
|
||||
'JUMP_ABSOLUTE', 'come_froms', 'POP_TOP', 'jb_pop')):
|
||||
# The JUMP_ABSOLUTE has to be to the last POP_TOP or this is invalid
|
||||
ja_attr = ast[4].attr
|
||||
|
@@ -14,7 +14,7 @@ class Python27Parser(Python2Parser):
|
||||
|
||||
def p_comprehension27(self, args):
|
||||
"""
|
||||
list_for ::= expr _for store list_iter JUMP_BACK
|
||||
list_for ::= expr for_iter store list_iter JUMP_BACK
|
||||
list_comp ::= BUILD_LIST_0 list_iter
|
||||
lc_body ::= expr LIST_APPEND
|
||||
|
||||
@@ -33,7 +33,7 @@ class Python27Parser(Python2Parser):
|
||||
|
||||
comp_body ::= dict_comp_body
|
||||
comp_body ::= set_comp_body
|
||||
comp_for ::= expr _for store comp_iter JUMP_BACK
|
||||
comp_for ::= expr for_iter store comp_iter JUMP_BACK
|
||||
|
||||
dict_comp_body ::= expr expr MAP_ADD
|
||||
set_comp_body ::= expr SET_ADD
|
||||
|
@@ -38,8 +38,8 @@ class Python3Parser(PythonParser):
|
||||
# one may be a continue - sometimes classifies a JUMP_BACK
|
||||
# as a CONTINUE. The two are kind of the same in a comprehension.
|
||||
|
||||
comp_for ::= expr _for store comp_iter CONTINUE
|
||||
comp_for ::= expr _for store comp_iter JUMP_BACK
|
||||
comp_for ::= expr for_iter store comp_iter CONTINUE
|
||||
comp_for ::= expr for_iter store comp_iter JUMP_BACK
|
||||
|
||||
list_comp ::= BUILD_LIST_0 list_iter
|
||||
lc_body ::= expr LIST_APPEND
|
||||
@@ -328,16 +328,16 @@ class Python3Parser(PythonParser):
|
||||
|
||||
def p_loop_stmt3(self, args):
|
||||
"""
|
||||
for ::= SETUP_LOOP expr _for store for_block POP_BLOCK
|
||||
for ::= SETUP_LOOP expr for_iter store for_block POP_BLOCK
|
||||
COME_FROM_LOOP
|
||||
|
||||
forelsestmt ::= SETUP_LOOP expr _for store for_block POP_BLOCK else_suite
|
||||
forelsestmt ::= SETUP_LOOP expr for_iter store for_block POP_BLOCK else_suite
|
||||
COME_FROM_LOOP
|
||||
|
||||
forelselaststmt ::= SETUP_LOOP expr _for store for_block POP_BLOCK else_suitec
|
||||
forelselaststmt ::= SETUP_LOOP expr for_iter store for_block POP_BLOCK else_suitec
|
||||
COME_FROM_LOOP
|
||||
|
||||
forelselaststmtl ::= SETUP_LOOP expr _for store for_block POP_BLOCK else_suitel
|
||||
forelselaststmtl ::= SETUP_LOOP expr for_iter store for_block POP_BLOCK else_suitel
|
||||
COME_FROM_LOOP
|
||||
|
||||
whilestmt ::= SETUP_LOOP testexpr l_stmts_opt COME_FROM JUMP_BACK POP_BLOCK
|
||||
@@ -372,7 +372,7 @@ class Python3Parser(PythonParser):
|
||||
COME_FROM_LOOP
|
||||
whileTruestmt ::= SETUP_LOOP l_stmts_opt JUMP_BACK POP_BLOCK NOP
|
||||
COME_FROM_LOOP
|
||||
for ::= SETUP_LOOP expr _for store for_block POP_BLOCK NOP
|
||||
for ::= SETUP_LOOP expr for_iter store for_block POP_BLOCK NOP
|
||||
COME_FROM_LOOP
|
||||
"""
|
||||
|
||||
|
Reference in New Issue
Block a user