Add "comp_if_not" for 2.6-

This commit is contained in:
rocky 2020-06-27 11:16:47 -04:00
parent 5cc572147a
commit 357f28dd89
3 changed files with 8 additions and 3 deletions

View File

@ -232,7 +232,10 @@ class Python26Parser(Python2Parser):
comp_for ::= SETUP_LOOP expr for_iter store comp_iter jb_pb_come_from
comp_body ::= gen_comp_body
comp_iter ::= comp_if_not
comp_if_not ::= expr jmp_true comp_iter
comp_body ::= gen_comp_body
for_block ::= l_stmts_opt _come_froms POP_TOP JUMP_BACK

View File

@ -8,7 +8,6 @@ from uncompyle6.parser import PythonParserSingle, nop_func
from uncompyle6.parsers.parse2 import Python2Parser
from uncompyle6.parsers.reducecheck import (
or_check,
ifelsestmt,
tryelsestmt,
)

View File

@ -33,7 +33,8 @@ def or_check(self, lhs, n, rule, ast, tokens, first, last):
else:
jump_true = expr_jt[1][0]
jmp_true_target = jump_true.attr
jump_inst = self.insts[self.offset2inst_index[jump_true.offset]]
jmp_true_target = jump_inst.argval
last_token = tokens[last]
last_token_offset = last_token.off2int()
@ -43,6 +44,8 @@ def or_check(self, lhs, n, rule, ast, tokens, first, last):
return False
elif jmp_true_target < last_token_offset:
return True
elif expr_jt.kind == "expr_jt" and jmp_true_target > last_token_offset:
return True
# If the jmp is backwards
if last_token == "POP_JUMP_IF_FALSE" and not self.version in (2.7, 3.5, 3.6):