You've already forked python-uncompyle6
mirror of
https://github.com/rocky/python-uncompyle6.git
synced 2025-08-04 01:09:52 +08:00
Grammar "COME_FROM"_from cleanups ...
tryelse constructs in 2.x fixed up _come_from -> _come_froms (COME_FROM*) consolidate come_froms rule into sincle parser.py
This commit is contained in:
@@ -47,16 +47,11 @@ class Python26Parser(Python2Parser):
|
||||
except_suite ::= c_stmts_opt JUMP_FORWARD POP_TOP
|
||||
except_suite ::= c_stmts_opt jmp_abs come_from_pop
|
||||
|
||||
# Python 3 also has this.
|
||||
come_froms ::= come_froms COME_FROM
|
||||
come_froms ::= COME_FROM
|
||||
|
||||
# This is what happens after a jump where
|
||||
# we start a new block. For reasons I don't fully
|
||||
# understand, there is also a value on the top of the stack
|
||||
come_from_pop ::= COME_FROM POP_TOP
|
||||
come_froms_pop ::= come_froms POP_TOP
|
||||
|
||||
"""
|
||||
|
||||
# In contrast to Python 2.7, Python 2.6 has a lot of
|
||||
@@ -86,7 +81,7 @@ class Python26Parser(Python2Parser):
|
||||
# COME_FROM_LOOP, but in <= 2.6 we don't distinguish
|
||||
# this
|
||||
|
||||
cf_jb_cf_pop ::= _come_from JUMP_BACK come_froms POP_TOP
|
||||
cf_jb_cf_pop ::= _come_froms JUMP_BACK come_froms POP_TOP
|
||||
|
||||
bp_come_from ::= POP_BLOCK COME_FROM
|
||||
jb_bp_come_from ::= JUMP_BACK bp_come_from
|
||||
@@ -137,7 +132,7 @@ class Python26Parser(Python2Parser):
|
||||
|
||||
while1stmt ::= SETUP_LOOP l_stmts JUMP_BACK COME_FROM
|
||||
|
||||
whilestmt ::= SETUP_LOOP testexpr l_stmts_opt jb_pop POP_BLOCK _come_from
|
||||
whilestmt ::= SETUP_LOOP testexpr l_stmts_opt jb_pop POP_BLOCK _come_froms
|
||||
whilestmt ::= SETUP_LOOP testexpr l_stmts_opt jb_cf_pop bp_come_from
|
||||
whilestmt ::= SETUP_LOOP testexpr return_stmts POP_BLOCK COME_FROM
|
||||
|
||||
@@ -179,7 +174,7 @@ class Python26Parser(Python2Parser):
|
||||
jmp_true_then ::= JUMP_IF_TRUE THEN POP_TOP
|
||||
|
||||
while1stmt ::= SETUP_LOOP return_stmts COME_FROM
|
||||
for_block ::= return_stmts _come_from
|
||||
for_block ::= return_stmts _come_froms
|
||||
"""
|
||||
|
||||
def p_comp26(self, args):
|
||||
@@ -206,7 +201,7 @@ class Python26Parser(Python2Parser):
|
||||
|
||||
comp_body ::= gen_comp_body
|
||||
|
||||
for_block ::= l_stmts_opt _come_from POP_TOP JUMP_BACK
|
||||
for_block ::= l_stmts_opt _come_froms POP_TOP JUMP_BACK
|
||||
|
||||
# Make sure we keep indices the same as 2.7
|
||||
setup_loop_lf ::= SETUP_LOOP LOAD_FAST
|
||||
@@ -242,11 +237,11 @@ class Python26Parser(Python2Parser):
|
||||
and ::= expr JUMP_IF_FALSE POP_TOP expr JUMP_IF_FALSE POP_TOP
|
||||
|
||||
# compare_chained is like x <= y <= z
|
||||
compare_chained ::= expr compare_chained1 ROT_TWO COME_FROM POP_TOP _come_from
|
||||
compare_chained ::= expr compare_chained1 ROT_TWO COME_FROM POP_TOP _come_froms
|
||||
compare_chained1 ::= expr DUP_TOP ROT_THREE COMPARE_OP
|
||||
jmp_false compare_chained1 _come_from
|
||||
jmp_false compare_chained1 _come_froms
|
||||
compare_chained1 ::= expr DUP_TOP ROT_THREE COMPARE_OP
|
||||
jmp_false compare_chained2 _come_from
|
||||
jmp_false compare_chained2 _come_froms
|
||||
return_if_lambda ::= RETURN_END_IF_LAMBDA POP_TOP
|
||||
stmt ::= conditional_lambda
|
||||
conditional_lambda ::= expr jmp_false_then expr return_if_lambda
|
||||
|
Reference in New Issue
Block a user