You've already forked python-uncompyle6
mirror of
https://github.com/rocky/python-uncompyle6.git
synced 2025-08-04 01:09:52 +08:00
Add 2.x if vs if/else reduction rule check
This commit is contained in:
@@ -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))
|
||||
|
Reference in New Issue
Block a user