Add 2.x if vs if/else reduction rule check

This commit is contained in:
rocky
2020-01-05 21:07:24 -05:00
parent 962c503133
commit 3c5ad58e25
2 changed files with 10 additions and 1 deletions

View File

@@ -32,11 +32,11 @@ typeset -A SKIP_TESTS
case $PYVERSION in
2.4)
SKIP_TESTS=(
[test_decimal.py]=1 #
[test_dis.py]=1 # We change line numbers - duh!
[test_grp.py]=1 # Long test - might work Control flow?
[test_pep247.py]=1 # Long test - might work? Control flow?
[test_pwd.py]=1 # Long test - might work? Control flow?
[test_pyclbr.py]=1 # Investigate
[test_socketserver.py]=1 # -- test takes too long to run: 40 seconds
[test_threading.py]=1 # test takes too long to run: 11 seconds
[test_thread.py]=1 # test takes too long to run: 36 seconds

View File

@@ -643,6 +643,7 @@ class Python2Parser(PythonParser):
self.check_reduce["tryelsestmtl"] = "AST"
self.check_reduce["aug_assign2"] = "AST"
self.check_reduce["or"] = "AST"
self.check_reduce["ifstmt"] = "tokens"
# self.check_reduce['_stmts'] = 'AST'
# Dead code testing...
@@ -667,6 +668,14 @@ class Python2Parser(PythonParser):
jmp_false = ast[1]
jump_target = jmp_false[0].attr
return jump_target > tokens[last].off2int()
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
pass
elif lhs in ("raise_stmt1",):
# We will assume 'LOAD_ASSERT' will be handled by an assert grammar rule
return tokens[first] == "LOAD_ASSERT" and (last >= len(tokens))