You've already forked python-uncompyle6
mirror of
https://github.com/rocky/python-uncompyle6.git
synced 2025-08-04 01:09:52 +08:00
Start to fold in 3.7 reduction-rule goodness into 3.6
This commit is contained in:
BIN
test/bytecode_3.6_run/01_conditional.pyc
Normal file
BIN
test/bytecode_3.6_run/01_conditional.pyc
Normal file
Binary file not shown.
@@ -1490,7 +1490,7 @@ class Python3Parser(PythonParser):
|
|||||||
# print("XXX", first, last)
|
# print("XXX", first, last)
|
||||||
# for t in range(first, last): print(tokens[t])
|
# for t in range(first, last): print(tokens[t])
|
||||||
# from trepan.api import debug; debug()
|
# from trepan.api import debug; debug()
|
||||||
# return condition_jump.attr < condition_jump2.off2int()
|
return condition_jump.attr < condition_jump2.off2int()
|
||||||
return False
|
return False
|
||||||
elif lhs == "ifelsestmt" and rule[1][2] == "jump_forward_else":
|
elif lhs == "ifelsestmt" and rule[1][2] == "jump_forward_else":
|
||||||
last = min(last, len(tokens)-1)
|
last = min(last, len(tokens)-1)
|
||||||
|
@@ -153,6 +153,16 @@ class Python36Parser(Python35Parser):
|
|||||||
|
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
# Some of this is duplicated from parse37. Eventually we'll probably rebase from
|
||||||
|
# that and then we can remove this.
|
||||||
|
def p_37conditionals(self, args):
|
||||||
|
"""
|
||||||
|
expr ::= conditional37
|
||||||
|
conditional37 ::= expr expr jf_cfs expr COME_FROM
|
||||||
|
jf_cfs ::= JUMP_FORWARD _come_froms
|
||||||
|
ifelsestmt ::= testexpr c_stmts_opt jf_cfs else_suite opt_come_from_except
|
||||||
|
"""
|
||||||
|
|
||||||
def customize_grammar_rules(self, tokens, customize):
|
def customize_grammar_rules(self, tokens, customize):
|
||||||
# self.remove_rules("""
|
# self.remove_rules("""
|
||||||
# """)
|
# """)
|
||||||
|
@@ -620,6 +620,8 @@ class Python37Parser(Python37BaseParser):
|
|||||||
|
|
||||||
def p_37conditionals(self, args):
|
def p_37conditionals(self, args):
|
||||||
"""
|
"""
|
||||||
|
expr ::= conditional37
|
||||||
|
conditional37 ::= expr expr jf_cfs expr COME_FROM
|
||||||
jf_cfs ::= JUMP_FORWARD _come_froms
|
jf_cfs ::= JUMP_FORWARD _come_froms
|
||||||
ifelsestmt ::= testexpr c_stmts_opt jf_cfs else_suite opt_come_from_except
|
ifelsestmt ::= testexpr c_stmts_opt jf_cfs else_suite opt_come_from_except
|
||||||
|
|
||||||
|
@@ -60,6 +60,12 @@ def customize_for_version36(self, version):
|
|||||||
'call_ex' : (
|
'call_ex' : (
|
||||||
'%c(%p)',
|
'%c(%p)',
|
||||||
(0, 'expr'), (1, 100)),
|
(0, 'expr'), (1, 100)),
|
||||||
|
|
||||||
|
# This comes from 3.7. Eventually we will rebase from 3.7
|
||||||
|
# and then this can go away
|
||||||
|
"conditional37": ( "%p if %c else %c",
|
||||||
|
(1, 'expr', 27), 0, 3 ),
|
||||||
|
|
||||||
'store_annotation': (
|
'store_annotation': (
|
||||||
'%[1]{pattr}: %c',
|
'%[1]{pattr}: %c',
|
||||||
0
|
0
|
||||||
|
@@ -120,6 +120,9 @@ def customize_for_version37(self, version):
|
|||||||
(0, 19),
|
(0, 19),
|
||||||
(6, 19),
|
(6, 19),
|
||||||
),
|
),
|
||||||
|
'conditional37': ( '%p if %c else %c',
|
||||||
|
(1, 'expr', 27), 0, 3 ),
|
||||||
|
|
||||||
"except_return": ("%|except:\n%+%c%-", 3),
|
"except_return": ("%|except:\n%+%c%-", 3),
|
||||||
"if_exp_37a": (
|
"if_exp_37a": (
|
||||||
"%p if %p else %p",
|
"%p if %p else %p",
|
||||||
|
Reference in New Issue
Block a user