diff --git a/uncompyle6/parsers/parse2.py b/uncompyle6/parsers/parse2.py index 20b69f28..874ebe30 100644 --- a/uncompyle6/parsers/parse2.py +++ b/uncompyle6/parsers/parse2.py @@ -40,9 +40,8 @@ class Python2Parser(PythonParser): def p_stmt2(self, args): """ + # Note: these are removed in 2.7 while1stmt ::= SETUP_LOOP l_stmts JUMP_BACK COME_FROM - while1stmt ::= SETUP_LOOP l_stmts JUMP_BACK POP_BLOCK COME_FROM - while1elsestmt ::= SETUP_LOOP l_stmts JUMP_BACK else_suite COME_FROM exec_stmt ::= expr exprlist DUP_TOP EXEC_STMT diff --git a/uncompyle6/parsers/parse27.py b/uncompyle6/parsers/parse27.py index 6a30a953..2473b894 100644 --- a/uncompyle6/parsers/parse27.py +++ b/uncompyle6/parsers/parse27.py @@ -101,19 +101,22 @@ class Python27Parser(Python2Parser): POP_BLOCK LOAD_CONST COME_FROM_WITH WITH_CLEANUP END_FINALLY + while1stmt ::= SETUP_LOOP return_stmts bp_come_from + while1stmt ::= SETUP_LOOP return_stmts COME_FROM + while1elsestmt ::= SETUP_LOOP l_stmts JUMP_BACK POP_BLOCK else_suite COME_FROM + while1stmt ::= SETUP_LOOP l_stmts_opt JUMP_BACK POP_BLOCK COME_FROM + # Common with 2.6 return_if_lambda ::= RETURN_END_IF_LAMBDA COME_FROM conditional_lambda ::= expr jmp_false expr return_if_lambda return_stmt_lambda LAMBDA_MARKER - - while1stmt ::= SETUP_LOOP return_stmts bp_come_from - while1stmt ::= SETUP_LOOP return_stmts COME_FROM - while1elsestmt ::= SETUP_LOOP l_stmts JUMP_BACK POP_BLOCK else_suite COME_FROM - while1stmt ::= SETUP_LOOP l_stmts_opt JUMP_BACK POP_BLOCK COME_FROM - """ def add_custom_rules(self, tokens, customize): + self.remove_rules(""" + while1stmt ::= SETUP_LOOP l_stmts JUMP_BACK COME_FROM + while1elsestmt ::= SETUP_LOOP l_stmts JUMP_BACK else_suite COME_FROM + """) super(Python27Parser, self).add_custom_rules(tokens, customize) self.check_reduce['and'] = 'AST' return