You've already forked python-uncompyle6
mirror of
https://github.com/rocky/python-uncompyle6.git
synced 2025-08-04 01:09:52 +08:00
PY3: COME_FROM -> COME_FROM_FINALLY as appropriate
We now have all WITH_ op jumps associated in the grammar Also, some COME_FROM_LOOP grammar fixes
This commit is contained in:
@@ -34,6 +34,7 @@ def test_grammar():
|
|||||||
"""
|
"""
|
||||||
JUMP_BACK CONTINUE RETURN_END_IF
|
JUMP_BACK CONTINUE RETURN_END_IF
|
||||||
COME_FROM COME_FROM_EXCEPT COME_FROM_LOOP COME_FROM_WITH
|
COME_FROM COME_FROM_EXCEPT COME_FROM_LOOP COME_FROM_WITH
|
||||||
|
COME_FROM_FINALLY
|
||||||
LOAD_GENEXPR LOAD_ASSERT LOAD_SETCOMP LOAD_DICTCOMP
|
LOAD_GENEXPR LOAD_ASSERT LOAD_SETCOMP LOAD_DICTCOMP
|
||||||
LAMBDA_MARKER RETURN_LAST
|
LAMBDA_MARKER RETURN_LAST
|
||||||
""".split())
|
""".split())
|
||||||
|
@@ -158,7 +158,7 @@ class Python3Parser(PythonParser):
|
|||||||
# this is nested inside a trystmt
|
# this is nested inside a trystmt
|
||||||
tryfinallystmt ::= SETUP_FINALLY suite_stmts_opt
|
tryfinallystmt ::= SETUP_FINALLY suite_stmts_opt
|
||||||
POP_BLOCK LOAD_CONST
|
POP_BLOCK LOAD_CONST
|
||||||
COME_FROM suite_stmts_opt END_FINALLY
|
come_from_or_finally suite_stmts_opt END_FINALLY
|
||||||
|
|
||||||
tryelsestmt ::= SETUP_EXCEPT suite_stmts_opt POP_BLOCK
|
tryelsestmt ::= SETUP_EXCEPT suite_stmts_opt POP_BLOCK
|
||||||
try_middle else_suite come_froms
|
try_middle else_suite come_froms
|
||||||
@@ -203,8 +203,8 @@ class Python3Parser(PythonParser):
|
|||||||
except_suite_finalize ::= SETUP_FINALLY c_stmts_opt except_var_finalize
|
except_suite_finalize ::= SETUP_FINALLY c_stmts_opt except_var_finalize
|
||||||
END_FINALLY _jump
|
END_FINALLY _jump
|
||||||
|
|
||||||
except_var_finalize ::= POP_BLOCK POP_EXCEPT LOAD_CONST COME_FROM LOAD_CONST
|
except_var_finalize ::= POP_BLOCK POP_EXCEPT LOAD_CONST come_from_or_finally
|
||||||
designator del_stmt
|
LOAD_CONST designator del_stmt
|
||||||
|
|
||||||
except_suite ::= return_stmts
|
except_suite ::= return_stmts
|
||||||
|
|
||||||
@@ -249,8 +249,12 @@ class Python3Parser(PythonParser):
|
|||||||
come_froms ::= come_froms COME_FROM
|
come_froms ::= come_froms COME_FROM
|
||||||
come_froms ::=
|
come_froms ::=
|
||||||
|
|
||||||
opt_come_from_loop ::= _come_from COME_FROM_LOOP
|
opt_come_from_loop ::= opt_come_from_loop COME_FROM_LOOP
|
||||||
opt_come_from_loop ::=
|
opt_come_from_loop ::=
|
||||||
|
|
||||||
|
come_from_or_finally ::= COME_FROM_FINALLY
|
||||||
|
come_from_or_finally ::= COME_FROM
|
||||||
|
|
||||||
"""
|
"""
|
||||||
|
|
||||||
def p_jump3(self, args):
|
def p_jump3(self, args):
|
||||||
@@ -294,8 +298,12 @@ class Python3Parser(PythonParser):
|
|||||||
|
|
||||||
forelselaststmtl ::= SETUP_LOOP expr _for designator for_block POP_BLOCK else_suitel
|
forelselaststmtl ::= SETUP_LOOP expr _for designator for_block POP_BLOCK else_suitel
|
||||||
COME_FROM_LOOP
|
COME_FROM_LOOP
|
||||||
|
|
||||||
whilestmt ::= SETUP_LOOP testexpr l_stmts_opt JUMP_BACK POP_BLOCK
|
whilestmt ::= SETUP_LOOP testexpr l_stmts_opt JUMP_BACK POP_BLOCK
|
||||||
COME_FROM_LOOP
|
COME_FROM_LOOP
|
||||||
|
whilestmt ::= SETUP_LOOP testexpr return_stmts POP_BLOCK
|
||||||
|
COME_FROM_LOOP
|
||||||
|
|
||||||
whileelsestmt ::= SETUP_LOOP testexpr l_stmts_opt JUMP_BACK POP_BLOCK
|
whileelsestmt ::= SETUP_LOOP testexpr l_stmts_opt JUMP_BACK POP_BLOCK
|
||||||
else_suite COME_FROM_LOOP
|
else_suite COME_FROM_LOOP
|
||||||
whileelselaststmt ::= SETUP_LOOP testexpr l_stmts_opt JUMP_BACK POP_BLOCK
|
whileelselaststmt ::= SETUP_LOOP testexpr l_stmts_opt JUMP_BACK POP_BLOCK
|
||||||
|
@@ -208,12 +208,9 @@ class Scanner3(Scanner):
|
|||||||
come_from_name = 'COME_FROM'
|
come_from_name = 'COME_FROM'
|
||||||
if (inst.offset in offset_action):
|
if (inst.offset in offset_action):
|
||||||
action = offset_action[inst.offset]
|
action = offset_action[inst.offset]
|
||||||
if (action.type == 'end'
|
if (action.type == 'end'
|
||||||
and (self.opName(jump_offset)[len('SETUP_'):]
|
and (self.opName(jump_offset)[len('SETUP_'):]
|
||||||
== action.name)
|
== action.name)):
|
||||||
# After the grammar is fully adjusted, remove the below
|
|
||||||
# test
|
|
||||||
and action.name in ['EXCEPT', 'LOOP', 'WITH']):
|
|
||||||
come_from_name = '%s_%s' % (
|
come_from_name = '%s_%s' % (
|
||||||
(come_from_name, action.name))
|
(come_from_name, action.name))
|
||||||
pass
|
pass
|
||||||
|
Reference in New Issue
Block a user