diff --git a/test/bytecode_2.6/02_while1else.pyc b/test/bytecode_2.6/02_while1else.pyc new file mode 100644 index 00000000..b31113bc Binary files /dev/null and b/test/bytecode_2.6/02_while1else.pyc differ diff --git a/uncompyle6/parsers/parse2.py b/uncompyle6/parsers/parse2.py index f05dd518..20b69f28 100644 --- a/uncompyle6/parsers/parse2.py +++ b/uncompyle6/parsers/parse2.py @@ -40,12 +40,10 @@ class Python2Parser(PythonParser): def p_stmt2(self, args): """ - while1stmt ::= SETUP_LOOP l_stmts_opt JUMP_BACK POP_BLOCK COME_FROM - while1stmt ::= SETUP_LOOP l_stmts JUMP_BACK COME_FROM - while1stmt ::= SETUP_LOOP l_stmts JUMP_BACK POP_BLOCK COME_FROM + 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 POP_BLOCK else_suite COME_FROM - while1elsestmt ::= SETUP_LOOP l_stmts JUMP_BACK else_suite COME_FROM + while1elsestmt ::= SETUP_LOOP l_stmts JUMP_BACK else_suite COME_FROM exec_stmt ::= expr exprlist DUP_TOP EXEC_STMT exec_stmt ::= expr exprlist EXEC_STMT @@ -396,10 +394,18 @@ class Python2Parser(PythonParser): self.check_reduce['augassign1'] = 'AST' self.check_reduce['augassign2'] = 'AST' self.check_reduce['_stmts'] = 'AST' + + # Dead code testing... + # self.check_reduce['while1elsestmt'] = 'tokens' return def reduce_is_invalid(self, rule, ast, tokens, first, last): lhs = rule[0] + + # Dead code testing... + # if lhs == 'while1elsestmt': + # from trepan.api import debug; debug() + if lhs in ('augassign1', 'augassign2') and ast[0] and ast[0][0] == 'and': return True elif lhs == '_stmts': diff --git a/uncompyle6/parsers/parse27.py b/uncompyle6/parsers/parse27.py index 85819711..6a30a953 100644 --- a/uncompyle6/parsers/parse27.py +++ b/uncompyle6/parsers/parse27.py @@ -108,6 +108,9 @@ class Python27Parser(Python2Parser): 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):