Hack around grammar weakness in 3.5..3.6 for now

This commit is contained in:
rocky 2020-01-25 09:46:34 -05:00
parent f6f2d8dd05
commit 58f2e19539
3 changed files with 10 additions and 1 deletions

View File

@ -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")

View File

@ -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:

View File

@ -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.