Correct ifelsestmtc rules for 3.x

This commit is contained in:
rocky
2020-02-09 08:14:44 -05:00
parent 339b4c56ee
commit 8836444be2
2 changed files with 12 additions and 2 deletions

View File

@@ -1534,7 +1534,7 @@ class Python3Parser(PythonParser):
"except_handler_else": except_handler_else,
# "ifstmt": ifstmt,
"ifstmtl": ifstmt,
"ifelsestmtc": ifstmt,
"ifelsestmtc": ifelsestmt,
"ifelsestmt": ifelsestmt,
"or": or_check,
"testtrue": testtrue,

View File

@@ -33,6 +33,15 @@ IFELSE_STMT_RULES = frozenset(
"else_suitec",
),
),
(
"ifelsestmtc",
(
"testexpr",
"c_stmts_opt",
"jump_absolute_else",
"else_suitec"
),
),
(
"ifelsestmt",
(
@@ -79,7 +88,8 @@ IFELSE_STMT_RULES = frozenset(
])
def ifelsestmt(self, lhs, n, rule, ast, tokens, first, last):
if (last + 1) < n and tokens[last + 1] == "COME_FROM_LOOP":
if (last + 1) < n and tokens[last + 1] == "COME_FROM_LOOP" and lhs != "ifelsestmtc":
# ifelsestmt jumped outside of loop. No good.
return True