Go over 2.5 for reduction rules and tests

This commit is contained in:
rocky
2020-01-06 23:34:18 -05:00
parent 19cac525ee
commit 14468fe8c9
2 changed files with 25 additions and 11 deletions

View File

@@ -707,12 +707,14 @@ class Python2Parser(PythonParser):
pass
pass
elif rule == ("ifstmt", ("testexpr", "_ifstmts_jump")):
for i in range(last-1, last-4, -1):
t = tokens[i]
if t == "JUMP_FORWARD":
return t.attr > tokens[min(last, len(tokens)-1)].off2int()
elif t not in ("POP_TOP", "COME_FROM"):
break
# FIXME: move this into 2.7-specific code?
if self.version == 2.7:
for i in range(last-1, last-4, -1):
t = tokens[i]
if t == "JUMP_FORWARD":
return t.attr > tokens[min(last, len(tokens)-1)].off2int()
elif t not in ("POP_TOP", "COME_FROM"):
break
pass
elif lhs in ("raise_stmt1",):
# We will assume 'LOAD_ASSERT' will be handled by an assert grammar rule
@@ -736,9 +738,12 @@ class Python2Parser(PythonParser):
# ti will be invalid here.
if come_from == "COME_FROM":
first_come_from = except_handler[-1]
elif come_from == "END_FINALLY":
return False
else:
assert come_from == "come_froms"
first_come_from = come_from[0]
leading_jump = except_handler[0]
# We really don't care that this is a jump per-se. But