diff --git a/pytest/test_grammar.py b/pytest/test_grammar.py index d8c69601..eeb04e8f 100644 --- a/pytest/test_grammar.py +++ b/pytest/test_grammar.py @@ -27,6 +27,9 @@ def test_grammar(): expect_lhs.add("attribute") expect_lhs.add("get_iter") + + if PYTHON_VERSION > 3.7 or PYTHON_VERSION < 3.0: + expect_lhs.add("stmts_opt") else: expect_lhs.add("async_with_as_stmt") expect_lhs.add("async_with_stmt") diff --git a/uncompyle6/parser.py b/uncompyle6/parser.py index 162d375d..fd71f46f 100644 --- a/uncompyle6/parser.py +++ b/uncompyle6/parser.py @@ -89,7 +89,7 @@ class PythonParser(GenericASTBuilder): # singleton reduction that we can simplify. It also happens to be optional # in its other derivation self.optional_nt |= frozenset( - ("come_froms", "suite_stmts", "l_stmts_opt", "c_stmts_opt") + ("come_froms", "suite_stmts", "l_stmts_opt", "c_stmts_opt", "stmts_opt") ) # Reduce singleton reductions in these nonterminals: diff --git a/uncompyle6/parsers/parse35.py b/uncompyle6/parsers/parse35.py index 1c7870c9..447a4fc7 100644 --- a/uncompyle6/parsers/parse35.py +++ b/uncompyle6/parsers/parse35.py @@ -17,6 +17,12 @@ class Python35Parser(Python34Parser): def p_35on(self, args): """ + # FIXME! isolate this to only loops! + _ifstmts_jump ::= c_stmts_opt come_froms + ifelsestmt ::= testexpr c_stmts_opt JUMP_FORWARD + ifelsestmt ::= testexpr c_stmts_opt jump_forward_else else_suite _come_froms + _ifstmts_jump ::= c_stmts_opt JUMP_FORWARD _come_froms + pb_ja ::= POP_BLOCK JUMP_ABSOLUTE # The number of canned instructions in new statements is mind boggling.