diff --git a/test/bytecode_2.7_run/07_for_if_else-continue.pyc b/test/bytecode_2.7_run/07_for_if_else-continue.pyc-notyet similarity index 100% rename from test/bytecode_2.7_run/07_for_if_else-continue.pyc rename to test/bytecode_2.7_run/07_for_if_else-continue.pyc-notyet diff --git a/uncompyle6/parser.py b/uncompyle6/parser.py index 8b91f040..7873cd08 100644 --- a/uncompyle6/parser.py +++ b/uncompyle6/parser.py @@ -304,6 +304,9 @@ class PythonParser(GenericASTBuilder): c_stmts ::= lastc_stmt c_stmts ::= continues + ending_return ::= RETURN_VALUE RETURN_LAST + ending_return ::= RETURN_VALUE_LAMBDA LAMBDA_MARKER + lastc_stmt ::= iflaststmt lastc_stmt ::= forelselaststmt lastc_stmt ::= ifelsestmtc diff --git a/uncompyle6/parsers/parse27.py b/uncompyle6/parsers/parse27.py index 06498caa..eee5ef06 100644 --- a/uncompyle6/parsers/parse27.py +++ b/uncompyle6/parsers/parse27.py @@ -39,14 +39,10 @@ class Python27Parser(Python2Parser): stmt ::= dict_comp_func dict_comp_func ::= BUILD_MAP_0 LOAD_FAST FOR_ITER store - comp_iter JUMP_BACK RETURN_VALUE RETURN_LAST - dict_comp_func ::= BUILD_MAP_0 LOAD_FAST FOR_ITER store - comp_iter JUMP_BACK RETURN_VALUE_LAMBDA LAMBDA_MARKER + comp_iter JUMP_BACK ending_return set_comp_func ::= BUILD_SET_0 LOAD_FAST FOR_ITER store comp_iter - JUMP_BACK RETURN_VALUE RETURN_LAST - set_comp_func ::= BUILD_SET_0 LOAD_FAST FOR_ITER store comp_iter - JUMP_BACK RETURN_VALUE_LAMBDA LAMBDA_MARKER + JUMP_BACK ending_return comp_iter ::= comp_if_not comp_if_not ::= expr jmp_true comp_iter diff --git a/uncompyle6/parsers/parse3.py b/uncompyle6/parsers/parse3.py index 2d68da9c..290632f8 100644 --- a/uncompyle6/parsers/parse3.py +++ b/uncompyle6/parsers/parse3.py @@ -79,19 +79,13 @@ class Python3Parser(PythonParser): stmt ::= set_comp_func + # TODO this can be simplified set_comp_func ::= BUILD_SET_0 LOAD_ARG FOR_ITER store comp_iter - JUMP_BACK RETURN_VALUE RETURN_LAST - set_comp_func ::= BUILD_SET_0 LOAD_ARG FOR_ITER store comp_iter - JUMP_BACK RETURN_VALUE_LAMBDA LAMBDA_MARKER + JUMP_BACK ending_return set_comp_func ::= BUILD_SET_0 LOAD_FAST FOR_ITER store comp_iter - JUMP_BACK RETURN_VALUE RETURN_LAST - set_comp_func ::= BUILD_SET_0 LOAD_FAST FOR_ITER store comp_iter - JUMP_BACK RETURN_VALUE_LAMBDA LAMBDA_MARKER - + JUMP_BACK ending_return set_comp_func ::= BUILD_SET_0 LOAD_ARG FOR_ITER store comp_iter - COME_FROM JUMP_BACK RETURN_VALUE RETURN_LAST - set_comp_func ::= BUILD_SET_0 LOAD_ARG FOR_ITER store comp_iter - COME_FROM JUMP_BACK RETURN_VALUE_LAMBDA LAMBDA_MARKER + COME_FROM JUMP_BACK ending_return comp_body ::= dict_comp_body comp_body ::= set_comp_body diff --git a/uncompyle6/parsers/parse30.py b/uncompyle6/parsers/parse30.py index 03dc7e6d..b36f8d41 100644 --- a/uncompyle6/parsers/parse30.py +++ b/uncompyle6/parsers/parse30.py @@ -77,12 +77,8 @@ class Python30Parser(Python31Parser): set_comp_func ::= set_comp_header LOAD_ARG FOR_ITER store comp_iter - JUMP_BACK + JUMP_BACK ending_return RETURN_VALUE RETURN_LAST - set_comp_func ::= set_comp_header - LOAD_ARG FOR_ITER store comp_iter - JUMP_BACK - RETURN_VALUE_LAMBDA LAMBDA_MARKER list_comp_header ::= BUILD_LIST_0 DUP_TOP STORE_FAST list_comp ::= list_comp_header @@ -112,11 +108,7 @@ class Python30Parser(Python31Parser): dict_comp_func ::= BUILD_MAP_0 DUP_TOP STORE_FAST LOAD_ARG FOR_ITER store - dict_comp_iter JUMP_BACK RETURN_VALUE RETURN_LAST - dict_comp_func ::= BUILD_MAP_0 - DUP_TOP STORE_FAST - LOAD_ARG FOR_ITER store - dict_comp_iter JUMP_BACK RETURN_VALUE_LAMBDA LAMBDA_MARKER + dict_comp_iter JUMP_BACK ending_return stmt ::= try_except30 try_except30 ::= SETUP_EXCEPT suite_stmts_opt diff --git a/uncompyle6/parsers/parse37.py b/uncompyle6/parsers/parse37.py index ad2e6248..a1994543 100644 --- a/uncompyle6/parsers/parse37.py +++ b/uncompyle6/parsers/parse37.py @@ -62,6 +62,9 @@ class Python37Parser(Python37BaseParser): c_stmts ::= lastc_stmt c_stmts ::= continues + ending_return ::= RETURN_VALUE RETURN_LAST + ending_return ::= RETURN_VALUE_LAMBDA LAMBDA_MARKER + lastc_stmt ::= iflaststmt lastc_stmt ::= forelselaststmt lastc_stmt ::= ifelsestmtc @@ -739,15 +742,11 @@ class Python37Parser(Python37BaseParser): stmt ::= set_comp_func + # TODO: simplify this set_comp_func ::= BUILD_SET_0 LOAD_ARG for_iter store comp_iter - JUMP_BACK RETURN_VALUE RETURN_LAST + JUMP_BACK ending_return set_comp_func ::= BUILD_SET_0 LOAD_ARG for_iter store comp_iter - JUMP_BACK RETURN_VALUE_LAMBDA LAMBDA_MARKER - - set_comp_func ::= BUILD_SET_0 LOAD_ARG for_iter store comp_iter - COME_FROM JUMP_BACK RETURN_VALUE RETURN_LAST - set_comp_func ::= BUILD_SET_0 LOAD_ARG for_iter store comp_iter - COME_FROM JUMP_BACK RETURN_VALUE_LAMBDA LAMBDA_MARKER + COME_FROM JUMP_BACK ending_return comp_body ::= dict_comp_body comp_body ::= set_comp_body @@ -763,9 +762,7 @@ class Python37Parser(Python37BaseParser): stmt ::= dict_comp_func dict_comp_func ::= BUILD_MAP_0 LOAD_ARG for_iter store - comp_iter JUMP_BACK RETURN_VALUE RETURN_LAST - dict_comp_func ::= BUILD_MAP_0 LOAD_ARG for_iter store - comp_iter JUMP_BACK RETURN_VALUE_LAMBDA LAMBDA_MARKER + comp_iter JUMP_BACK ending_return comp_iter ::= comp_if comp_iter ::= comp_if_not diff --git a/uncompyle6/parsers/parse38.py b/uncompyle6/parsers/parse38.py index e36e65d8..1d62ce0d 100644 --- a/uncompyle6/parsers/parse38.py +++ b/uncompyle6/parsers/parse38.py @@ -121,7 +121,8 @@ class Python38Parser(Python37Parser): for38 ::= expr get_for_iter store for_block forelsestmt38 ::= expr get_for_iter store for_block POP_BLOCK else_suite - forelsestmt38 ::= expr get_for_iter store for_block JUMP_BACK _come_froms else_suite + forelsestmt38 ::= expr get_for_iter store for_block JUMP_BACK _come_froms + else_suite forelselaststmt38 ::= expr get_for_iter store for_block POP_BLOCK else_suitec forelselaststmtl38 ::= expr get_for_iter store for_block POP_BLOCK else_suitel @@ -130,7 +131,8 @@ class Python38Parser(Python37Parser): except_return_value ::= POP_BLOCK return except_return_value ::= expr POP_BLOCK RETURN_VALUE - whilestmt38 ::= _come_froms testexpr l_stmts_opt COME_FROM JUMP_BACK POP_BLOCK + whilestmt38 ::= _come_froms testexpr l_stmts_opt COME_FROM JUMP_BACK + POP_BLOCK whilestmt38 ::= _come_froms testexpr l_stmts_opt JUMP_BACK POP_BLOCK whilestmt38 ::= _come_froms testexpr l_stmts_opt JUMP_BACK come_froms whilestmt38 ::= _come_froms testexpr returns POP_BLOCK