You've already forked python-uncompyle6
mirror of
https://github.com/rocky/python-uncompyle6.git
synced 2025-08-02 16:44:46 +08:00
2.x Grammar reduction/isolation
This commit is contained in:
Binary file not shown.
Binary file not shown.
@@ -1,3 +1,4 @@
|
|||||||
# Tests BINARY_TRUE_DIVIDE
|
# Tests BINARY_TRUE_DIVIDE and INPLACE_TRUE_DIVIDE
|
||||||
from __future__ import division # needed on 2.6 and 2.7
|
from __future__ import division # needed on 2.6 and 2.7
|
||||||
x = len(__file__) / 1
|
x = len(__file__) / 1
|
||||||
|
x /= 1
|
||||||
|
@@ -40,10 +40,6 @@ class Python2Parser(PythonParser):
|
|||||||
|
|
||||||
def p_stmt2(self, args):
|
def p_stmt2(self, args):
|
||||||
"""
|
"""
|
||||||
# Note: these are removed in 2.7
|
|
||||||
while1stmt ::= SETUP_LOOP l_stmts JUMP_BACK COME_FROM
|
|
||||||
while1elsestmt ::= SETUP_LOOP l_stmts JUMP_BACK else_suite COME_FROM
|
|
||||||
|
|
||||||
exec_stmt ::= expr exprlist DUP_TOP EXEC_STMT
|
exec_stmt ::= expr exprlist DUP_TOP EXEC_STMT
|
||||||
exec_stmt ::= expr exprlist EXEC_STMT
|
exec_stmt ::= expr exprlist EXEC_STMT
|
||||||
|
|
||||||
|
@@ -53,7 +53,6 @@ class Python25Parser(Python26Parser):
|
|||||||
POP_BLOCK LOAD_CONST COME_FROM WITH_CLEANUP END_FINALLY
|
POP_BLOCK LOAD_CONST COME_FROM WITH_CLEANUP END_FINALLY
|
||||||
withasstmt ::= expr setupwithas designator suite_stmts_opt
|
withasstmt ::= expr setupwithas designator suite_stmts_opt
|
||||||
POP_BLOCK LOAD_CONST COME_FROM WITH_CLEANUP END_FINALLY
|
POP_BLOCK LOAD_CONST COME_FROM WITH_CLEANUP END_FINALLY
|
||||||
whilestmt ::= SETUP_LOOP testexpr return_stmts come_froms POP_TOP bp_come_from
|
|
||||||
assert2 ::= assert_expr jmp_true LOAD_ASSERT expr CALL_FUNCTION_1 RAISE_VARARGS_1
|
assert2 ::= assert_expr jmp_true LOAD_ASSERT expr CALL_FUNCTION_1 RAISE_VARARGS_1
|
||||||
""")
|
""")
|
||||||
super(Python25Parser, self).add_custom_rules(tokens, customize)
|
super(Python25Parser, self).add_custom_rules(tokens, customize)
|
||||||
|
@@ -126,27 +126,27 @@ class Python26Parser(Python2Parser):
|
|||||||
POP_BLOCK LOAD_CONST COME_FROM WITH_CLEANUP END_FINALLY
|
POP_BLOCK LOAD_CONST COME_FROM WITH_CLEANUP END_FINALLY
|
||||||
|
|
||||||
# Semantic actions want designator to be at index 2
|
# Semantic actions want designator to be at index 2
|
||||||
# Rule is possibly 2.6 only
|
|
||||||
withasstmt ::= expr setupwithas designator suite_stmts_opt
|
withasstmt ::= expr setupwithas designator suite_stmts_opt
|
||||||
POP_BLOCK LOAD_CONST COME_FROM WITH_CLEANUP END_FINALLY
|
POP_BLOCK LOAD_CONST COME_FROM WITH_CLEANUP END_FINALLY
|
||||||
|
|
||||||
# This is truly weird. 2.7 does this (not including POP_TOP) with
|
# This is truly weird. 2.7 does this (not including POP_TOP) with
|
||||||
# opcode SETUP_WITH
|
# opcode SETUP_WITH
|
||||||
setupwith ::= DUP_TOP LOAD_ATTR ROT_TWO LOAD_ATTR CALL_FUNCTION_0 POP_TOP
|
|
||||||
|
|
||||||
# Possibly 2.6 only
|
setupwith ::= DUP_TOP LOAD_ATTR ROT_TWO LOAD_ATTR CALL_FUNCTION_0 POP_TOP
|
||||||
setupwithas ::= DUP_TOP LOAD_ATTR ROT_TWO LOAD_ATTR CALL_FUNCTION_0 setup_finally
|
setupwithas ::= DUP_TOP LOAD_ATTR ROT_TWO LOAD_ATTR CALL_FUNCTION_0 setup_finally
|
||||||
|
|
||||||
setup_finally ::= STORE_FAST SETUP_FINALLY LOAD_FAST DELETE_FAST
|
setup_finally ::= STORE_FAST SETUP_FINALLY LOAD_FAST DELETE_FAST
|
||||||
setup_finally ::= STORE_NAME SETUP_FINALLY LOAD_NAME DELETE_NAME
|
setup_finally ::= STORE_NAME SETUP_FINALLY LOAD_NAME DELETE_NAME
|
||||||
|
|
||||||
|
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_from
|
||||||
whilestmt ::= SETUP_LOOP testexpr l_stmts_opt jb_cf_pop bp_come_from
|
whilestmt ::= SETUP_LOOP testexpr l_stmts_opt jb_cf_pop bp_come_from
|
||||||
whilestmt ::= SETUP_LOOP testexpr return_stmts come_froms POP_TOP bp_come_from
|
whilestmt ::= SETUP_LOOP testexpr return_stmts come_froms POP_TOP bp_come_from
|
||||||
|
|
||||||
whileelsestmt ::= SETUP_LOOP testexpr l_stmts_opt jb_pop POP_BLOCK
|
whileelsestmt ::= SETUP_LOOP testexpr l_stmts_opt jb_pop POP_BLOCK
|
||||||
else_suite COME_FROM
|
else_suite COME_FROM
|
||||||
|
while1elsestmt ::= SETUP_LOOP l_stmts JUMP_BACK else_suite COME_FROM
|
||||||
|
|
||||||
return_stmt ::= ret_expr RETURN_END_IF POP_TOP
|
return_stmt ::= ret_expr RETURN_END_IF POP_TOP
|
||||||
return_stmt ::= ret_expr RETURN_VALUE POP_TOP
|
return_stmt ::= ret_expr RETURN_VALUE POP_TOP
|
||||||
|
@@ -105,6 +105,7 @@ class Python27Parser(Python2Parser):
|
|||||||
while1stmt ::= SETUP_LOOP return_stmts bp_come_from
|
while1stmt ::= SETUP_LOOP return_stmts bp_come_from
|
||||||
while1elsestmt ::= SETUP_LOOP l_stmts JUMP_BACK POP_BLOCK else_suite COME_FROM
|
while1elsestmt ::= SETUP_LOOP l_stmts JUMP_BACK POP_BLOCK else_suite COME_FROM
|
||||||
while1stmt ::= SETUP_LOOP l_stmts_opt JUMP_BACK POP_BLOCK COME_FROM
|
while1stmt ::= SETUP_LOOP l_stmts_opt JUMP_BACK POP_BLOCK COME_FROM
|
||||||
|
whilestmt ::= SETUP_LOOP testexpr l_stmts_opt JUMP_BACK POP_BLOCK _come_from
|
||||||
|
|
||||||
# Common with 2.6
|
# Common with 2.6
|
||||||
return_if_lambda ::= RETURN_END_IF_LAMBDA COME_FROM
|
return_if_lambda ::= RETURN_END_IF_LAMBDA COME_FROM
|
||||||
|
Reference in New Issue
Block a user