You've already forked python-uncompyle6
mirror of
https://github.com/rocky/python-uncompyle6.git
synced 2025-08-04 01:09:52 +08:00
2.6 "if" vs "if/else" disambiguation via reduction rule.
This commit is contained in:
@@ -71,13 +71,10 @@ case $PYVERSION in
|
|||||||
2.6)
|
2.6)
|
||||||
SKIP_TESTS=(
|
SKIP_TESTS=(
|
||||||
[test_aepack.py]=1 # Fails on its own
|
[test_aepack.py]=1 # Fails on its own
|
||||||
[test_compile.py]=1 # Intermittent - sometimes works and sometimes doesn't
|
|
||||||
[test_dis.py]=1 # We change line numbers - duh!
|
[test_dis.py]=1 # We change line numbers - duh!
|
||||||
[test_generators.py]=1 # Investigate
|
[test_generators.py]=1 # Investigate
|
||||||
[test_grp.py]=1 # Long test - might work Control flow?
|
[test_grp.py]=1 # Long test - might work Control flow?
|
||||||
[test_pep352.py]=1 # Investigate
|
[test_pep352.py]=1 # Investigate
|
||||||
[test_pprint.py]=1
|
|
||||||
[test_pty.py]=1
|
|
||||||
[test_pyclbr.py]=1 # Investigate
|
[test_pyclbr.py]=1 # Investigate
|
||||||
[test_pwd.py]=1 # Long test - might work? Control flow?
|
[test_pwd.py]=1 # Long test - might work? Control flow?
|
||||||
[test_trace.py]=1 # Line numbers are expected to be different
|
[test_trace.py]=1 # Line numbers are expected to be different
|
||||||
|
@@ -343,6 +343,7 @@ class Python26Parser(Python2Parser):
|
|||||||
super(Python26Parser, self).customize_grammar_rules(tokens, customize)
|
super(Python26Parser, self).customize_grammar_rules(tokens, customize)
|
||||||
self.check_reduce['and'] = 'AST'
|
self.check_reduce['and'] = 'AST'
|
||||||
self.check_reduce['assert_expr_and'] = 'AST'
|
self.check_reduce['assert_expr_and'] = 'AST'
|
||||||
|
self.check_reduce["ifstmt"] = "tokens"
|
||||||
self.check_reduce['list_for'] = 'AST'
|
self.check_reduce['list_for'] = 'AST'
|
||||||
self.check_reduce['try_except'] = 'tokens'
|
self.check_reduce['try_except'] = 'tokens'
|
||||||
self.check_reduce['tryelsestmt'] = 'AST'
|
self.check_reduce['tryelsestmt'] = 'AST'
|
||||||
@@ -382,6 +383,16 @@ class Python26Parser(Python2Parser):
|
|||||||
|
|
||||||
return not (jmp_target == tokens[test_index].offset or
|
return not (jmp_target == tokens[test_index].offset or
|
||||||
tokens[last].pattr == jmp_false.pattr)
|
tokens[last].pattr == jmp_false.pattr)
|
||||||
|
|
||||||
|
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
|
||||||
|
pass
|
||||||
elif rule == (
|
elif rule == (
|
||||||
'list_for',
|
'list_for',
|
||||||
('expr', 'for_iter', 'store', 'list_iter',
|
('expr', 'for_iter', 'store', 'list_iter',
|
||||||
|
Reference in New Issue
Block a user