uncompyle6.parsers package¶
Submodules¶
uncompyle6.parsers.astnode module¶
uncompyle6.parsers.parse2 module¶
A spark grammar for Python 2.x.
However instead of terminal symbols being the usual ASCII text, e.g. 5, myvariable, “for”, etc. they are CPython Bytecode tokens, e.g. “LOAD_CONST 5”, “STORE NAME myvariable”, “SETUP_LOOP”, etc.
If we succeed in creating a parse tree, then we have a Python program that a later phase can tern into a sequence of ASCII text.
-
class
uncompyle6.parsers.parse2.Python2Parser(debug_parser={'rules': False, 'errorstack': None, 'transition': False, 'reduce': False, 'context': True})¶ Bases:
uncompyle6.parser.PythonParser-
add_custom_rules(tokens, customize)¶ Special handling for opcodes such as those that take a variable number of arguments – we add a new rule for each:
build_list ::= {expr}^n BUILD_LIST_n build_list ::= {expr}^n BUILD_TUPLE_n unpack_list ::= UNPACK_LIST {expr}^n unpack ::= UNPACK_TUPLE {expr}^n unpack ::= UNPACK_SEQEUENCE {expr}^n
mkfunc ::= {expr}^n LOAD_CONST MAKE_FUNCTION_n mklambda ::= {expr}^n LOAD_LAMBDA MAKE_FUNCTION_n mkfunc ::= {expr}^n load_closure LOAD_CONST MAKE_FUNCTION_n expr ::= expr {expr}^n CALL_FUNCTION_n expr ::= expr {expr}^n CALL_FUNCTION_VAR_n POP_TOP expr ::= expr {expr}^n CALL_FUNCTION_VAR_KW_n POP_TOP expr ::= expr {expr}^n CALL_FUNCTION_KW_n POP_TOP
PyPy adds custom rules here as well
-
p_dictcomp2(args)¶ ” dictcomp ::= LOAD_DICTCOMP MAKE_FUNCTION_0 expr GET_ITER CALL_FUNCTION_1
-
p_expr2(args)¶ expr ::= LOAD_LOCALS expr ::= slice0 expr ::= slice1 expr ::= slice2 expr ::= slice3 expr ::= unary_convert
and ::= expr jmp_false expr come_from_opt or ::= expr jmp_true expr come_from_opt
slice0 ::= expr SLICE+0 slice0 ::= expr DUP_TOP SLICE+0 slice1 ::= expr expr SLICE+1 slice1 ::= expr expr DUP_TOPX_2 SLICE+1 slice2 ::= expr expr SLICE+2 slice2 ::= expr expr DUP_TOPX_2 SLICE+2 slice3 ::= expr expr expr SLICE+3 slice3 ::= expr expr expr DUP_TOPX_3 SLICE+3 unary_convert ::= expr UNARY_CONVERT
# In Python 3, DUP_TOPX_2 is DUP_TOP_TWO binary_subscr2 ::= expr expr DUP_TOPX_2 BINARY_SUBSCR
-
p_genexpr2(args)¶ genexpr ::= LOAD_GENEXPR MAKE_FUNCTION_0 expr GET_ITER CALL_FUNCTION_1
-
p_grammar(args)¶ sstmt ::= stmt sstmt ::= ifelsestmtr sstmt ::= return_stmt RETURN_LAST
return_if_stmts ::= return_if_stmt return_if_stmts ::= _stmts return_if_stmt return_if_stmt ::= ret_expr RETURN_END_IF
stmt ::= importstmt
stmt ::= break_stmt break_stmt ::= BREAK_LOOP
stmt ::= continue_stmt continue_stmt ::= CONTINUE continue_stmt ::= CONTINUE_LOOP continue_stmts ::= _stmts lastl_stmt continue_stmt continue_stmts ::= lastl_stmt continue_stmt continue_stmts ::= continue_stmt
stmt ::= raise_stmt0 stmt ::= raise_stmt1 stmt ::= raise_stmt2 stmt ::= raise_stmt3
raise_stmt0 ::= RAISE_VARARGS_0 raise_stmt1 ::= expr RAISE_VARARGS_1 raise_stmt2 ::= expr expr RAISE_VARARGS_2 raise_stmt3 ::= expr expr expr RAISE_VARARGS_3
stmt ::= exec_stmt
del_stmt ::= expr DELETE_SLICE+0 del_stmt ::= expr expr DELETE_SLICE+1 del_stmt ::= expr expr DELETE_SLICE+2 del_stmt ::= expr expr expr DELETE_SLICE+3 del_stmt ::= delete_subscr delete_subscr ::= expr expr DELETE_SUBSCR del_stmt ::= expr DELETE_ATTR
kwarg ::= LOAD_CONST expr
classdef ::= buildclass designator
- buildclass ::= LOAD_CONST expr mkfunc
- CALL_FUNCTION_0 BUILD_CLASS
stmt ::= classdefdeco classdefdeco ::= classdefdeco1 designator classdefdeco1 ::= expr classdefdeco1 CALL_FUNCTION_1 classdefdeco1 ::= expr classdefdeco2 CALL_FUNCTION_1 classdefdeco2 ::= LOAD_CONST expr mkfunc CALL_FUNCTION_0 BUILD_CLASS
assert2 ::= assert_expr jmp_true LOAD_ASSERT expr CALL_FUNCTION_1 RAISE_VARARGS_1
assert_expr ::= expr assert_expr ::= assert_expr_or assert_expr ::= assert_expr_and assert_expr_or ::= assert_expr jmp_true expr assert_expr_and ::= assert_expr jmp_false expr
ifstmt ::= testexpr _ifstmts_jump
testexpr ::= testfalse testexpr ::= testtrue testfalse ::= expr jmp_false testtrue ::= expr jmp_true
_ifstmts_jump ::= return_if_stmts
iflaststmt ::= testexpr c_stmts_opt JUMP_ABSOLUTE
iflaststmtl ::= testexpr c_stmts_opt JUMP_BACK
ifelsestmt ::= testexpr c_stmts_opt JUMP_FORWARD else_suite COME_FROM
ifelsestmtc ::= testexpr c_stmts_opt JUMP_ABSOLUTE else_suitec
ifelsestmtr ::= testexpr return_if_stmts return_stmts
ifelsestmtl ::= testexpr c_stmts_opt JUMP_BACK else_suitel
# this is nested inside a trystmt tryfinallystmt ::= SETUP_FINALLY suite_stmts_opt
POP_BLOCK LOAD_CONST COME_FROM suite_stmts_opt END_FINALLY# Move to 2.7? 2.6 may use come_froms tryelsestmtc ::= SETUP_EXCEPT suite_stmts_opt POP_BLOCK
try_middle else_suitec COME_FROM- tryelsestmtl ::= SETUP_EXCEPT suite_stmts_opt POP_BLOCK
- try_middle else_suitel COME_FROM
- trystmt ::= SETUP_EXCEPT suite_stmts_opt POP_BLOCK
- try_middle COME_FROM
- try_middle ::= JUMP_FORWARD COME_FROM except_stmts
- END_FINALLY COME_FROM
- try_middle ::= jmp_abs COME_FROM except_stmts
- END_FINALLY
except_stmts ::= except_stmts except_stmt except_stmts ::= except_stmt
except_stmt ::= except_cond1 except_suite except_stmt ::= except
except_suite ::= c_stmts_opt JUMP_FORWARD except_suite ::= c_stmts_opt jmp_abs except_suite ::= return_stmts
except ::= POP_TOP POP_TOP POP_TOP c_stmts_opt _jump except ::= POP_TOP POP_TOP POP_TOP return_stmts
jmp_abs ::= JUMP_ABSOLUTE jmp_abs ::= JUMP_BACK
-
p_op2(args)¶ inplace_op ::= INPLACE_DIVIDE binary_op ::= BINARY_DIVIDE binary_subscr2 ::= expr expr DUP_TOPX_2 BINARY_SUBSCR
-
p_print2(args)¶ stmt ::= print_items_stmt stmt ::= print_nl stmt ::= print_items_nl_stmt
print_items_stmt ::= expr PRINT_ITEM print_items_opt print_items_nl_stmt ::= expr PRINT_ITEM print_items_opt PRINT_NEWLINE_CONT print_items_opt ::= print_items print_items_opt ::= print_items ::= print_items print_item print_items ::= print_item print_item ::= expr PRINT_ITEM_CONT print_nl ::= PRINT_NEWLINE
-
p_print_to(args)¶ stmt ::= print_to stmt ::= print_to_nl stmt ::= print_nl_to print_to ::= expr print_to_items POP_TOP print_to_nl ::= expr print_to_items PRINT_NEWLINE_TO print_nl_to ::= expr PRINT_NEWLINE_TO print_to_items ::= print_to_items print_to_item print_to_items ::= print_to_item print_to_item ::= DUP_TOP expr ROT_TWO PRINT_ITEM_TO
-
p_slice2(args)¶ designator ::= expr STORE_SLICE+0 designator ::= expr expr STORE_SLICE+1 designator ::= expr expr STORE_SLICE+2 designator ::= expr expr expr STORE_SLICE+3 augassign1 ::= expr expr inplace_op ROT_TWO STORE_SLICE+0 augassign1 ::= expr expr inplace_op ROT_THREE STORE_SLICE+1 augassign1 ::= expr expr inplace_op ROT_THREE STORE_SLICE+2 augassign1 ::= expr expr inplace_op ROT_FOUR STORE_SLICE+3 slice0 ::= expr SLICE+0 slice0 ::= expr DUP_TOP SLICE+0 slice1 ::= expr expr SLICE+1 slice1 ::= expr expr DUP_TOPX_2 SLICE+1 slice2 ::= expr expr SLICE+2 slice2 ::= expr expr DUP_TOPX_2 SLICE+2 slice3 ::= expr expr expr SLICE+3 slice3 ::= expr expr expr DUP_TOPX_3 SLICE+3
-
p_stmt2(args)¶ while1stmt ::= SETUP_LOOP l_stmts_opt JUMP_BACK POP_BLOCK COME_FROM while1stmt ::= SETUP_LOOP l_stmts JUMP_BACK COME_FROM while1stmt ::= SETUP_LOOP l_stmts JUMP_BACK POP_BLOCK 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 EXEC_STMT
-
-
class
uncompyle6.parsers.parse2.Python2ParserSingle(debug_parser={'rules': False, 'errorstack': None, 'transition': False, 'reduce': False, 'context': True})¶ Bases:
uncompyle6.parsers.parse2.Python2Parser,uncompyle6.parser.PythonParserSingle
uncompyle6.parsers.parse22 module¶
-
class
uncompyle6.parsers.parse22.Python22Parser(debug_parser={'rules': False, 'errorstack': None, 'transition': False, 'reduce': False, 'context': True})¶ Bases:
uncompyle6.parsers.parse23.Python23Parser-
p_misc22(args)¶ _for ::= LOAD_CONST FOR_LOOP list_iter ::= list_if JUMP_FORWARD
COME_FROM POP_TOP COME_FROM- list_for ::= expr _for designator list_iter CONTINUE JUMP_FORWARD
- COME_FROM POP_TOP COME_FROM
-
-
class
uncompyle6.parsers.parse22.Python22ParserSingle(debug_parser={'rules': False, 'errorstack': None, 'transition': False, 'reduce': False, 'context': True})¶ Bases:
uncompyle6.parsers.parse23.Python23Parser,uncompyle6.parser.PythonParserSingle
uncompyle6.parsers.parse23 module¶
-
class
uncompyle6.parsers.parse23.Python23Parser(debug_parser={'rules': False, 'errorstack': None, 'transition': False, 'reduce': False, 'context': True})¶ Bases:
uncompyle6.parsers.parse24.Python24Parser-
p_misc23(args)¶ # Used to keep semantic positions the same across later versions # of Python _while1test ::= SETUP_LOOP JUMP_FORWARD JUMP_IF_FALSE POP_TOP COME_FROM
- while1stmt ::= _while1test l_stmts_opt JUMP_BACK
- COME_FROM POP_TOP POP_BLOCK COME_FROM
list_compr ::= BUILD_LIST_0 DUP_TOP LOAD_ATTR designator list_iter del_stmt list_for ::= expr _for designator list_iter JUMP_BACK come_froms POP_TOP JUMP_BACK
lc_body ::= LOAD_NAME expr CALL_FUNCTION_1 POP_TOP lc_body ::= LOAD_FAST expr CALL_FUNCTION_1 POP_TOP lc_body ::= LOAD_NAME expr LIST_APPEND lc_body ::= LOAD_FAST expr LIST_APPEND
-
-
class
uncompyle6.parsers.parse23.Python23ParserSingle(debug_parser={'rules': False, 'errorstack': None, 'transition': False, 'reduce': False, 'context': True})¶ Bases:
uncompyle6.parsers.parse23.Python23Parser,uncompyle6.parser.PythonParserSingle
uncompyle6.parsers.parse24 module¶
spark grammar differences over Python2.5 for Python 2.4.
-
class
uncompyle6.parsers.parse24.Python24Parser(debug_parser={'rules': False, 'errorstack': None, 'transition': False, 'reduce': False, 'context': True})¶ Bases:
uncompyle6.parsers.parse25.Python25Parser-
p_misc24(args)¶ # 2.5+ has two LOAD_CONSTs, one for the number ‘.’s in a relative import # keep positions similar to simplify semantic actions
importstmt ::= filler LOAD_CONST import_as importfrom ::= filler LOAD_CONST IMPORT_NAME importlist2 POP_TOP importstar ::= filler LOAD_CONST IMPORT_NAME IMPORT_STAR
importmultiple ::= filler LOAD_CONST import_as imports_cont import_cont ::= filler LOAD_CONST import_as_cont
# Python 2.5+ omits POP_TOP POP_BLOCK while1stmt ::= SETUP_LOOP l_stmts JUMP_BACK POP_TOP POP_BLOCK COME_FROM while1stmt ::= SETUP_LOOP l_stmts_opt JUMP_BACK POP_TOP POP_BLOCK COME_FROM
# Python 2.5+: # call_stmt ::= expr POP_TOP # expr ::= yield call_stmt ::= yield
# Python 2.5+ adds POP_TOP at the end gen_comp_body ::= expr YIELD_VALUE
-
-
class
uncompyle6.parsers.parse24.Python24ParserSingle(debug_parser={'rules': False, 'errorstack': None, 'transition': False, 'reduce': False, 'context': True})¶ Bases:
uncompyle6.parsers.parse24.Python24Parser,uncompyle6.parser.PythonParserSingle
uncompyle6.parsers.parse25 module¶
spark grammar differences over Python2.6 for Python 2.5.
-
class
uncompyle6.parsers.parse25.Python25Parser(debug_parser={'rules': False, 'errorstack': None, 'transition': False, 'reduce': False, 'context': True})¶ Bases:
uncompyle6.parsers.parse26.Python26Parser-
p_misc25(args)¶ # If “return_if_stmt” is in a loop, a JUMP_BACK can be emitted. In 2.6 the # JUMP_BACK doesn’t appear
return_if_stmt ::= ret_expr RETURN_END_IF JUMP_BACK
# Python 2.6 uses ROT_TWO instead of the STORE_xxx setupwithas ::= DUP_TOP LOAD_ATTR store LOAD_ATTR CALL_FUNCTION_0
setup_finallystore ::= STORE_FAST store ::= STORE_NAME
# Python 2.6 omits ths LOAD_FAST DELETE_FAST below withasstmt ::= expr setupwithas designator suite_stmts_opt
POP_BLOCK LOAD_CONST COME_FROM with_cleanupwith_cleanup ::= LOAD_FAST DELETE_FAST WITH_CLEANUP END_FINALLY with_cleanup ::= LOAD_NAME DELETE_NAME WITH_CLEANUP END_FINALLY
-
-
class
uncompyle6.parsers.parse25.Python25ParserSingle(debug_parser={'rules': False, 'errorstack': None, 'transition': False, 'reduce': False, 'context': True})¶ Bases:
uncompyle6.parsers.parse26.Python26Parser,uncompyle6.parser.PythonParserSingle
uncompyle6.parsers.parse26 module¶
spark grammar differences over Python2 for Python 2.6.
-
class
uncompyle6.parsers.parse26.Python26Parser(debug_parser={'rules': False, 'errorstack': None, 'transition': False, 'reduce': False, 'context': True})¶ Bases:
uncompyle6.parsers.parse2.Python2Parser-
p_comp26(args)¶ list_for ::= expr _for designator list_iter JUMP_BACK come_froms POP_TOP
# The JUMP FORWARD below jumps to the JUMP BACK. It seems to happen # in rare cases that may have to with length of code list_for ::= expr _for designator list_iter JUMP_FORWARD come_froms POP_TOP
COME_FROM JUMP_BACKlist_for ::= expr _for designator list_iter jb_cont
list_iter ::= list_if JUMP_BACK list_iter ::= list_if JUMP_BACK COME_FROM POP_TOP list_compr ::= BUILD_LIST_0 DUP_TOP
designator list_iter del_stmt- list_compr ::= BUILD_LIST_0 DUP_TOP
- designator list_iter JUMP_BACK del_stmt
lc_body ::= LOAD_NAME expr LIST_APPEND lc_body ::= LOAD_FAST expr LIST_APPEND
comp_for ::= SETUP_LOOP expr _for designator comp_iter jb_bp_come_from
comp_body ::= gen_comp_body
# Make sure we keep indices the same as 2.7 setup_loop_lf ::= SETUP_LOOP LOAD_FAST genexpr_func ::= setup_loop_lf FOR_ITER designator comp_iter jb_bp_come_from genexpr_func ::= setup_loop_lf FOR_ITER designator comp_iter JUMP_BACK come_from_pop jb_bp_come_from genexpr ::= LOAD_GENEXPR MAKE_FUNCTION_0 expr GET_ITER CALL_FUNCTION_1 COME_FROM
-
p_except26(args)¶ except_suite ::= c_stmts_opt jmp_abs come_from_pop
-
p_jumps26(args)¶ # The are the equivalents of Python 2.7+’s # POP_JUMP_IF_TRUE and POP_JUMP_IF_FALSE jmp_true ::= JUMP_IF_TRUE POP_TOP jmp_false ::= JUMP_IF_FALSE POP_TOP
jf_pop ::= JUMP_FORWARD come_from_pop jf_pop ::= JUMP_ABSOLUTE come_from_pop jb_pop ::= JUMP_BACK come_from_pop
jb_cont ::= JUMP_BACK jb_cont ::= CONTINUE
jb_cf_pop ::= JUMP_BACK come_froms POP_TOP ja_cf_pop ::= JUMP_ABSOLUTE come_froms POP_TOP jf_cf_pop ::= JUMP_FORWARD come_froms POP_TOP
bp_come_from ::= POP_BLOCK COME_FROM jb_bp_come_from ::= JUMP_BACK bp_come_from
_ifstmts_jump ::= c_stmts_opt jf_pop COME_FROM _ifstmts_jump ::= c_stmts_opt JUMP_FORWARD COME_FROM come_from_pop _ifstmts_jump ::= c_stmts_opt JUMP_FORWARD come_froms POP_TOP 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
-
p_misc26(args)¶ conditional ::= expr jmp_false expr jf_cf_pop expr come_from_opt and ::= expr JUMP_IF_FALSE POP_TOP expr JUMP_IF_FALSE POP_TOP cmp_list ::= expr cmp_list1 ROT_TWO COME_FROM POP_TOP _come_from
-
p_ret26(args)¶ ret_and ::= expr jmp_false ret_expr_or_cond COME_FROM ret_or ::= expr jmp_true ret_expr_or_cond COME_FROM ret_cond ::= expr jmp_false expr RETURN_END_IF POP_TOP ret_expr_or_cond ret_cond ::= expr jmp_false expr ret_expr_or_cond ret_cond_not ::= expr jmp_true expr RETURN_END_IF POP_TOP ret_expr_or_cond
return_if_stmt ::= ret_expr RETURN_END_IF POP_TOP return_stmt ::= ret_expr RETURN_VALUE POP_TOP
# FIXME: split into Python 2.5 ret_or ::= expr jmp_true ret_expr_or_cond come_froms
-
p_stmt26(args)¶ # We use filler as a placeholder to keep nonterminal positions # the same across different grammars so that the same semantic actions # can be used filler ::=
assert ::= assert_expr jmp_true LOAD_ASSERT RAISE_VARARGS_1 come_froms_pop assert2 ::= assert_expr jmp_true LOAD_ASSERT expr RAISE_VARARGS_2 come_froms_pop
break_stmt ::= BREAK_LOOP JUMP_BACK
# Semantic actions want the else to be at position 3 ifelsestmt ::= testexpr c_stmts_opt jf_cf_pop else_suite come_froms ifelsestmt ::= testexpr c_stmts_opt filler else_suitel come_froms POP_TOP
# Semantic actions want else_suitel to be at index 3 ifelsestmtl ::= testexpr c_stmts_opt jb_cf_pop else_suitel ifelsestmtc ::= testexpr c_stmts_opt ja_cf_pop else_suitec
iflaststmt ::= testexpr c_stmts_opt JUMP_ABSOLUTE come_froms POP_TOP
# Semantic actions want suite_stmts_opt to be at index 3 withstmt ::= expr setupwith SETUP_FINALLY suite_stmts_opt
POP_BLOCK LOAD_CONST COME_FROM WITH_CLEANUP END_FINALLY# Semantic actions want designator to be at index 2 # Rule is possibly 2.6 only withasstmt ::= expr setupwithas designator suite_stmts_opt
POP_BLOCK LOAD_CONST COME_FROM WITH_CLEANUP END_FINALLY# This is truly weird. 2.7 does this (not including POP_TOP) with # opcode SETUP_WITH setupwith ::= DUP_TOP LOAD_ATTR ROT_TWO LOAD_ATTR CALL_FUNCTION_0 POP_TOP
# Possibly 2.6 only 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_NAME SETUP_FINALLY LOAD_NAME DELETE_NAME
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 return_stmts come_froms POP_TOP bp_come_from
- whileelsestmt ::= SETUP_LOOP testexpr l_stmts_opt jb_pop POP_BLOCK
- else_suite COME_FROM
return_stmt ::= ret_expr RETURN_END_IF come_from_pop return_stmt ::= ret_expr RETURN_VALUE come_from_pop return_if_stmt ::= ret_expr RETURN_END_IF come_from_pop
iflaststmtl ::= testexpr c_stmts_opt JUMP_BACK come_from_pop iflaststmt ::= testexpr c_stmts_opt JUMP_ABSOLUTE come_from_pop
while1stmt ::= SETUP_LOOP l_stmts_opt JUMP_BACK COME_FROM
# Common with 2.7 while1stmt ::= SETUP_LOOP return_stmts bp_come_from while1stmt ::= SETUP_LOOP return_stmts COME_FROM
-
p_try_except26(args)¶ except_stmt ::= except_cond3 except_suite except_cond1 ::= DUP_TOP expr COMPARE_OP
JUMP_IF_FALSE POP_TOP POP_TOP POP_TOP POP_TOP- except_cond3 ::= DUP_TOP expr COMPARE_OP
- JUMP_IF_FALSE POP_TOP POP_TOP designator POP_TOP
- try_middle ::= JUMP_FORWARD COME_FROM except_stmts
- come_from_pop END_FINALLY COME_FROM
- try_middle ::= jmp_abs COME_FROM except_stmts
- POP_TOP END_FINALLY
- try_middle ::= jmp_abs COME_FROM except_stmts
- come_from_pop END_FINALLY
- trystmt ::= SETUP_EXCEPT suite_stmts_opt come_from_pop
- try_middle
# Sometimes we don’t put in COME_FROM to the next statement # like we do in 2.7. Perhaps we should? trystmt ::= SETUP_EXCEPT suite_stmts_opt POP_BLOCK
try_middle- trystmt ::= SETUP_EXCEPT suite_stmts_opt POP_BLOCK
- try_middle come_froms
- tryelsestmt ::= SETUP_EXCEPT suite_stmts_opt POP_BLOCK
- try_middle else_suite come_froms
_ifstmts_jump ::= c_stmts_opt JUMP_FORWARD COME_FROM POP_TOP
except_suite ::= c_stmts_opt JUMP_FORWARD come_from_pop
# Python 3 also has this. come_froms ::= come_froms COME_FROM come_froms ::= COME_FROM
come_froms_pop ::= come_froms POP_TOP
-
-
class
uncompyle6.parsers.parse26.Python26ParserSingle(debug_parser={'rules': False, 'errorstack': None, 'transition': False, 'reduce': False, 'context': True})¶ Bases:
uncompyle6.parsers.parse2.Python2Parser,uncompyle6.parser.PythonParserSingle
uncompyle6.parsers.parse27 module¶
-
class
uncompyle6.parsers.parse27.Python27Parser(debug_parser={'rules': False, 'errorstack': None, 'transition': False, 'reduce': False, 'context': True})¶ Bases:
uncompyle6.parsers.parse2.Python2Parser-
p_comprehension27(args)¶ list_for ::= expr _for designator list_iter JUMP_BACK
stmt ::= setcomp_func
- setcomp_func ::= BUILD_SET_0 LOAD_FAST FOR_ITER designator comp_iter
- JUMP_BACK RETURN_VALUE RETURN_LAST
comp_body ::= dict_comp_body comp_body ::= set_comp_body dict_comp_body ::= expr expr MAP_ADD set_comp_body ::= expr SET_ADD
# See also common Python p_list_comprehension
-
p_jump27(args)¶ _ifstmts_jump ::= c_stmts_opt JUMP_FORWARD COME_FROM bp_come_from ::= POP_BLOCK COME_FROM
# FIXME: Common with 3.0+ jmp_false ::= POP_JUMP_IF_FALSE jmp_true ::= POP_JUMP_IF_TRUE
ret_and ::= expr JUMP_IF_FALSE_OR_POP ret_expr_or_cond COME_FROM ret_or ::= expr JUMP_IF_TRUE_OR_POP ret_expr_or_cond COME_FROM ret_cond ::= expr POP_JUMP_IF_FALSE expr RETURN_END_IF ret_expr_or_cond ret_cond_not ::= expr POP_JUMP_IF_TRUE expr RETURN_END_IF ret_expr_or_cond
or ::= expr JUMP_IF_TRUE_OR_POP expr COME_FROM and ::= expr JUMP_IF_FALSE_OR_POP expr COME_FROM
- cmp_list1 ::= expr DUP_TOP ROT_THREE
- COMPARE_OP JUMP_IF_FALSE_OR_POP cmp_list1 COME_FROM
- cmp_list1 ::= expr DUP_TOP ROT_THREE
- COMPARE_OP JUMP_IF_FALSE_OR_POP cmp_list2 COME_FROM
-
p_stmt27(args)¶ # assert condition assert ::= assert_expr jmp_true LOAD_ASSERT RAISE_VARARGS_1
# assert condition, expr assert2 ::= assert_expr jmp_true LOAD_ASSERT expr RAISE_VARARGS_2
- withstmt ::= expr SETUP_WITH POP_TOP suite_stmts_opt
- POP_BLOCK LOAD_CONST COME_FROM WITH_CLEANUP END_FINALLY
- withasstmt ::= expr SETUP_WITH designator suite_stmts_opt
- POP_BLOCK LOAD_CONST COME_FROM WITH_CLEANUP END_FINALLY
while1stmt ::= SETUP_LOOP l_stmts_opt JUMP_BACK POP_BLOCK COME_FROM
# Common with 2.6 while1stmt ::= SETUP_LOOP return_stmts bp_come_from while1stmt ::= SETUP_LOOP return_stmts COME_FROM
-
p_try27(args)¶ - tryelsestmt ::= SETUP_EXCEPT suite_stmts_opt POP_BLOCK
- try_middle else_suite COME_FROM
except_stmt ::= except_cond2 except_suite
- except_cond1 ::= DUP_TOP expr COMPARE_OP
- jmp_false POP_TOP POP_TOP POP_TOP
- except_cond2 ::= DUP_TOP expr COMPARE_OP
- jmp_false POP_TOP designator POP_TOP
-
-
class
uncompyle6.parsers.parse27.Python27ParserSingle(debug_parser={'rules': False, 'errorstack': None, 'transition': False, 'reduce': False, 'context': True})¶ Bases:
uncompyle6.parsers.parse27.Python27Parser,uncompyle6.parser.PythonParserSingle
uncompyle6.parsers.parse3 module¶
A spark grammar for Python 3.x.
However instead of terminal symbols being the usual ASCII text, e.g. 5, myvariable, “for”, etc. they are CPython Bytecode tokens, e.g. “LOAD_CONST 5”, “STORE NAME myvariable”, “SETUP_LOOP”, etc.
If we succeed in creating a parse tree, then we have a Python program that a later phase can turn into a sequence of ASCII text.
-
class
uncompyle6.parsers.parse3.Python31Parser(debug_parser={'rules': False, 'errorstack': None, 'transition': False, 'reduce': False, 'context': True})¶ Bases:
uncompyle6.parsers.parse3.Python3Parser-
p_31(args)¶ # Store locals is only in Python 3.0 to 3.3 stmt ::= store_locals store_locals ::= LOAD_FAST STORE_LOCALS
-
-
class
uncompyle6.parsers.parse3.Python31ParserSingle(debug_parser={'rules': False, 'errorstack': None, 'transition': False, 'reduce': False, 'context': True})¶ Bases:
uncompyle6.parsers.parse3.Python31Parser,uncompyle6.parser.PythonParserSingle
-
class
uncompyle6.parsers.parse3.Python32Parser(debug_parser={'rules': False, 'errorstack': None, 'transition': False, 'reduce': False, 'context': True})¶ Bases:
uncompyle6.parsers.parse3.Python3Parser-
p_32(args)¶ # Store locals is only in Python 3.0 to 3.3 stmt ::= store_locals store_locals ::= LOAD_FAST STORE_LOCALS
-
-
class
uncompyle6.parsers.parse3.Python32ParserSingle(debug_parser={'rules': False, 'errorstack': None, 'transition': False, 'reduce': False, 'context': True})¶ Bases:
uncompyle6.parsers.parse3.Python32Parser,uncompyle6.parser.PythonParserSingle
-
class
uncompyle6.parsers.parse3.Python33Parser(debug_parser={'rules': False, 'errorstack': None, 'transition': False, 'reduce': False, 'context': True})¶ Bases:
uncompyle6.parsers.parse3.Python3Parser-
p_33(args)¶ # Store locals is only in Python 3.0 to 3.3 stmt ::= store_locals store_locals ::= LOAD_FAST STORE_LOCALS
# Python 3.3 adds yield from. expr ::= yield_from yield_from ::= expr expr YIELD_FROM
-
-
class
uncompyle6.parsers.parse3.Python33ParserSingle(debug_parser={'rules': False, 'errorstack': None, 'transition': False, 'reduce': False, 'context': True})¶ Bases:
uncompyle6.parsers.parse3.Python33Parser,uncompyle6.parser.PythonParserSingle
-
class
uncompyle6.parsers.parse3.Python3Parser(debug_parser={'rules': False, 'errorstack': None, 'transition': False, 'reduce': False, 'context': True})¶ Bases:
uncompyle6.parser.PythonParser-
add_custom_rules(tokens, customize)¶ Special handling for opcodes such as those that take a variable number of arguments – we add a new rule for each:
unpack_list ::= UNPACK_LIST_n {expr}^n unpack ::= UNPACK_TUPLE_n {expr}^n unpack ::= UNPACK_SEQEUENCE_n {expr}^n unpack_ex ::= UNPACK_EX_b_a {expr}^(a+b)
# build_class (see load_build_class)
build_list ::= {expr}^n BUILD_LIST_n build_list ::= {expr}^n BUILD_TUPLE_n
load_closure ::= {LOAD_CLOSURE}^n BUILD_TUPLE_n # call_function (see custom_classfunc_rule)
# ———— # Python <= 3.2 omits LOAD_CONST before MAKE_ # Note: are the below specific instances of a more general case? # ————
# Is there something more general than this? adding pos_arg? # Is there something corresponding using MAKE_CLOSURE? dictcomp ::= LOAD_DICTCOMP [LOAD_CONST] MAKE_FUNCTION_0 expr
GET_ITER CALL_FUNCTION_1- genexpr ::= {pos_arg}^n load_genexpr [LOAD_CONST] MAKE_FUNCTION_n expr
- GET_ITER CALL_FUNCTION_1
- genexpr ::= {expr}^n load_closure LOAD_GENEXPR [LOAD_CONST]
- MAKE_CLOSURE_n expr GET_ITER CALL_FUNCTION_1
- listcomp ::= {pos_arg}^n LOAD_LISTCOMP [LOAD_CONST] MAKE_CLOSURE_n expr
- GET_ITER CALL_FUNCTION_1
- listcomp ::= {pos_arg}^n load_closure LOAD_LISTCOMP [LOAD_CONST]
- MAKE_CLOSURE_n expr GET_ITER CALL_FUNCTION_1
# Is there something more general than this? adding pos_arg? # Is there something corresponding using MAKE_CLOSURE? For example: # setcomp ::= {pos_arg}^n LOAD_SETCOMP [LOAD_CONST] MAKE_CLOSURE_n
GET_ITER CALL_FUNCTION_1- setcomp ::= LOAD_SETCOMP [LOAD_CONST] MAKE_FUNCTION_0 expr
- GET_ITER CALL_FUNCTION_1
- setcomp ::= {pos_arg}^n load_closure LOAD_SETCOMP [LOAD_CONST]
- MAKE_CLOSURE_n expr GET_ITER CALL_FUNCTION_1
mkfunc ::= {pos_arg}^n load_closure [LOAD_CONST] MAKE_FUNCTION_n mkfunc ::= {pos_arg}^n load_closure [LOAD_CONST] MAKE_CLOSURE_n mkfunc ::= {pos_arg}^n [LOAD_CONST] MAKE_FUNCTION_n mklambda ::= {pos_arg}^n LOAD_LAMBDA [LOAD_CONST] MAKE_FUNCTION_n
- For PYPY:
- load_attr ::= expr LOOKUP_METHOD call_function ::= expr CALL_METHOD
-
add_make_function_rule(rule, opname, attr, customize)¶ Python 3.3 added a an addtional LOAD_CONST before MAKE_FUNCTION and this has an effect on many rules.
-
static
call_fn_name(token)¶ Customize CALL_FUNCTION to add the number of positional arguments
-
custom_build_class_rule(opname, i, token, tokens, customize)¶ # Should the first rule be somehow folded into the 2nd one? build_class ::= LOAD_BUILD_CLASS mkfunc
LOAD_CLASSNAME {expr}^n-1 CALL_FUNCTION_n LOAD_CONST CALL_FUNCTION_n- build_class ::= LOAD_BUILD_CLASS mkfunc
- expr call_function CALL_FUNCTION_3
-
custom_classfunc_rule(opname, token, customize)¶ call_function ::= expr {expr}^n CALL_FUNCTION_n call_function ::= expr {expr}^n CALL_FUNCTION_VAR_n POP_TOP call_function ::= expr {expr}^n CALL_FUNCTION_VAR_KW_n POP_TOP call_function ::= expr {expr}^n CALL_FUNCTION_KW_n POP_TOP
classdefdeco2 ::= LOAD_BUILD_CLASS mkfunc {expr}^n-1 CALL_FUNCTION_n
-
p_come_from3(args)¶ opt_come_from_except ::= COME_FROM_EXCEPT opt_come_from_except ::= come_froms
come_froms ::= come_froms COME_FROM come_froms ::=
opt_come_from_loop ::= opt_come_from_loop COME_FROM_LOOP opt_come_from_loop ::=
come_from_or_finally ::= COME_FROM_FINALLY come_from_or_finally ::= COME_FROM
-
p_comprehension3(args)¶ # Python3 scanner adds LOAD_LISTCOMP. Python3 does list comprehension like # other comprehensions (set, dictionary).
# listcomp is a custom Python3 rule expr ::= listcomp
# Our “continue” heuristic - in two successive JUMP_BACKS, the first # one may be a continue - sometimes classifies a JUMP_BACK # as a CONTINUE. The two are kind of the same in a comprehension.
comp_for ::= expr _for designator comp_iter CONTINUE
list_for ::= expr FOR_ITER designator list_iter jb_or_c
jb_or_c ::= JUMP_BACK jb_or_c ::= CONTINUE
stmt ::= setcomp_func
- setcomp_func ::= BUILD_SET_0 LOAD_FAST FOR_ITER designator comp_iter
- JUMP_BACK RETURN_VALUE RETURN_LAST
comp_body ::= dict_comp_body comp_body ::= set_comp_body dict_comp_body ::= expr expr MAP_ADD set_comp_body ::= expr SET_ADD
# See also common Python p_list_comprehension
-
p_dictcomp3(args)¶ ” dictcomp ::= LOAD_DICTCOMP LOAD_CONST MAKE_FUNCTION_0 expr GET_ITER CALL_FUNCTION_1
-
p_expr3(args)¶ expr ::= LOAD_CLASSNAME
# Python 3.4+ expr ::= LOAD_CLASSDEREF
# Python3 drops slice0..slice3
# In Python 2, DUP_TOP_TWO is DUP_TOPX_2 binary_subscr2 ::= expr expr DUP_TOP_TWO BINARY_SUBSCR
-
p_genexpr3(args)¶ load_genexpr ::= LOAD_GENEXPR load_genexpr ::= BUILD_TUPLE_1 LOAD_GENEXPR LOAD_CONST
# Is there something general going on here? dictcomp ::= load_closure LOAD_DICTCOMP LOAD_CONST MAKE_CLOSURE_0 expr GET_ITER CALL_FUNCTION_1
-
p_grammar(args)¶ sstmt ::= stmt sstmt ::= ifelsestmtr sstmt ::= return_stmt RETURN_LAST
return_if_stmts ::= return_if_stmt come_from_opt return_if_stmts ::= _stmts return_if_stmt return_if_stmt ::= ret_expr RETURN_END_IF
stmt ::= break_stmt break_stmt ::= BREAK_LOOP
stmt ::= continue_stmt continue_stmt ::= CONTINUE continue_stmt ::= CONTINUE_LOOP continue_stmts ::= _stmts lastl_stmt continue_stmt continue_stmts ::= lastl_stmt continue_stmt continue_stmts ::= continue_stmt
stmt ::= raise_stmt0 stmt ::= raise_stmt1 stmt ::= raise_stmt2 stmt ::= raise_stmt3
raise_stmt0 ::= RAISE_VARARGS_0 raise_stmt1 ::= expr RAISE_VARARGS_1 raise_stmt2 ::= expr expr RAISE_VARARGS_2 raise_stmt3 ::= expr expr expr RAISE_VARARGS_3
del_stmt ::= delete_subscr delete_subscr ::= expr expr DELETE_SUBSCR del_stmt ::= expr DELETE_ATTR
kwarg ::= LOAD_CONST expr kwargs ::= kwargs kwarg kwargs ::=
classdef ::= build_class designator
# Python3 introduced LOAD_BUILD_CLASS # Other definitions are in a custom rule build_class ::= LOAD_BUILD_CLASS mkfunc expr call_function CALL_FUNCTION_3
stmt ::= classdefdeco classdefdeco ::= classdefdeco1 designator classdefdeco1 ::= expr classdefdeco1 CALL_FUNCTION_1 classdefdeco1 ::= expr classdefdeco2 CALL_FUNCTION_1
assert ::= assert_expr jmp_true LOAD_ASSERT RAISE_VARARGS_1 assert2 ::= assert_expr jmp_true LOAD_ASSERT expr CALL_FUNCTION_1 RAISE_VARARGS_1 assert2 ::= assert_expr jmp_true LOAD_ASSERT expr RAISE_VARARGS_2
assert_expr ::= expr assert_expr ::= assert_expr_or assert_expr ::= assert_expr_and assert_expr_or ::= assert_expr jmp_true expr assert_expr_and ::= assert_expr jmp_false expr
ifstmt ::= testexpr _ifstmts_jump
testexpr ::= testfalse testexpr ::= testtrue testfalse ::= expr jmp_false testtrue ::= expr jmp_true
_ifstmts_jump ::= return_if_stmts _ifstmts_jump ::= c_stmts_opt JUMP_FORWARD COME_FROM
iflaststmt ::= testexpr c_stmts_opt JUMP_ABSOLUTE
iflaststmtl ::= testexpr c_stmts_opt JUMP_BACK iflaststmtl ::= testexpr c_stmts_opt JUMP_BACK COME_FROM_LOOP
ifelsestmt ::= testexpr c_stmts_opt JUMP_FORWARD else_suite COME_FROM
ifelsestmtc ::= testexpr c_stmts_opt JUMP_ABSOLUTE else_suitec
ifelsestmtr ::= testexpr return_if_stmts return_stmts
ifelsestmtl ::= testexpr c_stmts_opt JUMP_BACK else_suitel ifelsestmtl ::= testexpr c_stmts_opt JUMP_BACK else_suitel JUMP_BACK COME_FROM_LOOP ifelsestmtl ::= testexpr c_stmts_opt JUMP_BACK else_suitel COME_FROM_LOOP
# FIXME: this feels like a hack. Is it just 1 or two # COME_FROMs? the parsed tree for this and even with just the # one COME_FROM for Python 2.7 seems to associate the # COME_FROM targets from the wrong places
- trystmt ::= SETUP_EXCEPT suite_stmts_opt POP_BLOCK
- try_middle opt_come_from_except
# this is nested inside a trystmt tryfinallystmt ::= SETUP_FINALLY suite_stmts_opt
POP_BLOCK LOAD_CONST come_from_or_finally suite_stmts_opt END_FINALLY- tryelsestmt ::= SETUP_EXCEPT suite_stmts_opt POP_BLOCK
- try_middle else_suite come_froms
- tryelsestmtc ::= SETUP_EXCEPT suite_stmts_opt POP_BLOCK
- try_middle else_suitec COME_FROM
- tryelsestmtl ::= SETUP_EXCEPT suite_stmts_opt POP_BLOCK
- try_middle else_suitel COME_FROM
- try_middle ::= jmp_abs COME_FROM except_stmts
- END_FINALLY
- try_middle ::= jmp_abs COME_FROM_EXCEPT except_stmts
- END_FINALLY
# FIXME: remove this try_middle ::= JUMP_FORWARD COME_FROM except_stmts
END_FINALLY COME_FROM- try_middle ::= JUMP_FORWARD COME_FROM except_stmts
- END_FINALLY COME_FROM_EXCEPT
except_stmts ::= except_stmts except_stmt except_stmts ::= except_stmt
except_stmt ::= except_cond1 except_suite except_stmt ::= except_cond2 except_suite except_stmt ::= except_cond2 except_suite_finalize except_stmt ::= except
## FIXME: what’s except_pop_except? except_stmt ::= except_pop_except
# Python3 introduced POP_EXCEPT except_suite ::= c_stmts_opt POP_EXCEPT jump_except jump_except ::= JUMP_ABSOLUTE jump_except ::= JUMP_BACK jump_except ::= JUMP_FORWARD jump_except ::= CONTINUE
# This is used in Python 3 in # “except ... as e” to remove ‘e’ after the c_stmts_opt finishes except_suite_finalize ::= SETUP_FINALLY c_stmts_opt except_var_finalize
END_FINALLY _jump- except_var_finalize ::= POP_BLOCK POP_EXCEPT LOAD_CONST come_from_or_finally
- LOAD_CONST designator del_stmt
except_suite ::= return_stmts
- except_cond1 ::= DUP_TOP expr COMPARE_OP
- jmp_false POP_TOP POP_TOP POP_TOP
- except_cond2 ::= DUP_TOP expr COMPARE_OP
- jmp_false POP_TOP designator POP_TOP
except ::= POP_TOP POP_TOP POP_TOP c_stmts_opt POP_EXCEPT _jump except ::= POP_TOP POP_TOP POP_TOP return_stmts
jmp_abs ::= JUMP_ABSOLUTE jmp_abs ::= JUMP_BACK
- withstmt ::= expr SETUP_WITH POP_TOP suite_stmts_opt
- POP_BLOCK LOAD_CONST COME_FROM_WITH WITH_CLEANUP END_FINALLY
- withasstmt ::= expr SETUP_WITH designator suite_stmts_opt
- POP_BLOCK LOAD_CONST COME_FROM_WITH WITH_CLEANUP END_FINALLY
and ::= expr jmp_false expr COME_FROM or ::= expr jmp_true expr COME_FROM
-
p_jump3(args)¶ jmp_false ::= POP_JUMP_IF_FALSE jmp_true ::= POP_JUMP_IF_TRUE
# FIXME: Common with 2.7 ret_and ::= expr JUMP_IF_FALSE_OR_POP ret_expr_or_cond COME_FROM ret_or ::= expr JUMP_IF_TRUE_OR_POP ret_expr_or_cond COME_FROM ret_cond ::= expr POP_JUMP_IF_FALSE expr RETURN_END_IF ret_expr_or_cond ret_cond_not ::= expr POP_JUMP_IF_TRUE expr RETURN_END_IF ret_expr_or_cond
or ::= expr JUMP_IF_TRUE_OR_POP expr COME_FROM and ::= expr JUMP_IF_FALSE_OR_POP expr COME_FROM
- cmp_list1 ::= expr DUP_TOP ROT_THREE
- COMPARE_OP JUMP_IF_FALSE_OR_POP cmp_list1 COME_FROM
- cmp_list1 ::= expr DUP_TOP ROT_THREE
- COMPARE_OP JUMP_IF_FALSE_OR_POP cmp_list2 COME_FROM
-
p_loop_stmt3(args)¶ - forstmt ::= SETUP_LOOP expr _for designator for_block POP_BLOCK
- opt_come_from_loop
- forelsestmt ::= SETUP_LOOP expr _for designator for_block POP_BLOCK else_suite
- COME_FROM_LOOP
- forelselaststmt ::= SETUP_LOOP expr _for designator for_block POP_BLOCK else_suitec
- COME_FROM_LOOP
- forelselaststmtl ::= SETUP_LOOP expr _for designator for_block POP_BLOCK else_suitel
- COME_FROM_LOOP
- whilestmt ::= SETUP_LOOP testexpr l_stmts_opt JUMP_BACK POP_BLOCK
- COME_FROM_LOOP
# The JUMP_ABSOLUTE below comes from escaping an “if” block which surrounds # the while. This is messy whilestmt ::= SETUP_LOOP testexpr l_stmts_opt JUMP_BACK POP_BLOCK
JUMP_ABSOLUTE 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
- else_suite COME_FROM_LOOP
- while1elsestmt ::= SETUP_LOOP l_stmts JUMP_BACK
- else_suite COME_FROM_LOOP
- whileelselaststmt ::= SETUP_LOOP testexpr l_stmts_opt JUMP_BACK POP_BLOCK
- else_suitec COME_FROM_LOOP
- whileTruestmt ::= SETUP_LOOP l_stmts_opt JUMP_BACK POP_BLOCK
- COME_FROM_LOOP
while1stmt ::= SETUP_LOOP l_stmts
# Python < 3.5 no POP BLOCK whileTruestmt ::= SETUP_LOOP l_stmts_opt JUMP_BACK
COME_FROM_LOOP- whileTruestmt ::= SETUP_LOOP return_stmts
- COME_FROM_LOOP
# FIXME: investigate - can code really produce a NOP? whileTruestmt ::= SETUP_LOOP l_stmts_opt JUMP_BACK NOP
COME_FROM_LOOP- whileTruestmt ::= SETUP_LOOP l_stmts_opt JUMP_BACK POP_BLOCK NOP
- COME_FROM_LOOP
- whileTruestmt ::= SETUP_LOOP l_stmts_opt JUMP_BACK POP_BLOCK NOP
- COME_FROM_LOOP
- forstmt ::= SETUP_LOOP expr _for designator for_block POP_BLOCK NOP
- COME_FROM_LOOP
-
p_misc3(args)¶ try_middle ::= JUMP_FORWARD COME_FROM_EXCEPT except_stmts END_FINALLY COME_FROM
for_block ::= l_stmts_opt opt_come_from_loop JUMP_BACK for_block ::= l_stmts iflaststmtl ::= testexpr c_stmts_opt iflaststmt ::= testexpr c_stmts_opt34 c_stmts_opt34 ::= JUMP_BACK JUMP_ABSOLUTE c_stmts_opt
-
p_stmt3(args)¶ stmt ::= LOAD_CLOSURE RETURN_VALUE RETURN_LAST stmt ::= whileTruestmt ifelsestmt ::= testexpr c_stmts_opt JUMP_FORWARD else_suite _come_from
-
-
class
uncompyle6.parsers.parse3.Python3ParserSingle(debug_parser={'rules': False, 'errorstack': None, 'transition': False, 'reduce': False, 'context': True})¶ Bases:
uncompyle6.parsers.parse3.Python3Parser,uncompyle6.parser.PythonParserSingle
-
uncompyle6.parsers.parse3.info(args)¶
uncompyle6.parsers.parse34 module¶
spark grammar differences over Python3 for Python 3.4.2.
-
class
uncompyle6.parsers.parse34.Python34Parser(debug_parser={'rules': False, 'errorstack': None, 'transition': False, 'reduce': False, 'context': True})¶ Bases:
uncompyle6.parsers.parse3.Python3Parser-
p_misc34(args)¶ # Python 3.5+ optimizes the trailing two JUMPS away
for_block ::= l_stmts
iflaststmtl ::= testexpr c_stmts_opt
_ifstmts_jump ::= c_stmts_opt JUMP_FORWARD _come_from
# We do the grammar hackery below for semantics # actions that want c_stmts_opt at index 1 iflaststmt ::= testexpr c_stmts_opt34 c_stmts_opt34 ::= JUMP_BACK JUMP_ABSOLUTE c_stmts_opt
# Python 3.3 added “yield from.” Do it the same way as in # 3.3
expr ::= yield_from yield_from ::= expr expr YIELD_FROM
# Is this 3.4 only? yield_from ::= expr GET_ITER LOAD_CONST YIELD_FROM
# Python 3.4+ has more loop optimization that removes # JUMP_FORWARD in some cases, and hence we also don’t # see COME_FROM _ifstmts_jump ::= c_stmts_opt
-
-
class
uncompyle6.parsers.parse34.Python34ParserSingle(debug_parser={'rules': False, 'errorstack': None, 'transition': False, 'reduce': False, 'context': True})¶ Bases:
uncompyle6.parsers.parse34.Python34Parser,uncompyle6.parser.PythonParserSingle
uncompyle6.parsers.parse35 module¶
spark grammar differences over Python3 for Python 3.5.
-
class
uncompyle6.parsers.parse35.Python35Parser(debug_parser={'rules': False, 'errorstack': None, 'transition': False, 'reduce': False, 'context': True})¶ Bases:
uncompyle6.parsers.parse3.Python3Parser-
p_35on(args)¶ # Python 3.5+ has WITH_CLEANUP_START/FINISH
- withstmt ::= expr SETUP_WITH exprlist suite_stmts_opt
- POP_BLOCK LOAD_CONST COME_FROM_WITH WITH_CLEANUP_START WITH_CLEANUP_FINISH END_FINALLY
- withstmt ::= expr SETUP_WITH POP_TOP suite_stmts_opt
- POP_BLOCK LOAD_CONST COME_FROM_WITH WITH_CLEANUP_START WITH_CLEANUP_FINISH END_FINALLY
- withasstmt ::= expr SETUP_WITH designator suite_stmts_opt
- POP_BLOCK LOAD_CONST COME_FROM_WITH WITH_CLEANUP_START WITH_CLEANUP_FINISH END_FINALLY
inplace_op ::= INPLACE_MATRIX_MULTIPLY binary_op ::= BINARY_MATRIX_MULTIPLY
# Python 3.5+ does jump optimization # In <.3.5 the below is a JUMP_FORWARD to a JUMP_ABSOLUTE. # in return_stmt, we will need the semantic actions in pysource.py # to work out whether to dedent or not based on the presence of # RETURN_END_IF vs RETURN_VALUE
ifelsestmtc ::= testexpr c_stmts_opt JUMP_FORWARD else_suitec # ifstmt ::= testexpr c_stmts_opt
# Python 3.3+ also has yield from. 3.5 does it # differently than 3.3, 3.4
expr ::= yield_from yield_from ::= expr GET_YIELD_FROM_ITER LOAD_CONST YIELD_FROM
# Python 3.4+ has more loop optimization that removes # JUMP_FORWARD in some cases, and hence we also don’t # see COME_FROM _ifstmts_jump ::= c_stmts_opt
-
-
class
uncompyle6.parsers.parse35.Python35ParserSingle(debug_parser={'rules': False, 'errorstack': None, 'transition': False, 'reduce': False, 'context': True})¶ Bases:
uncompyle6.parsers.parse35.Python35Parser,uncompyle6.parser.PythonParserSingle
uncompyle6.parsers.parse36 module¶
spark grammar differences over Python 3.5 for Python 3.6.
-
class
uncompyle6.parsers.parse36.Python36Parser(debug_parser={'rules': False, 'errorstack': None, 'transition': False, 'reduce': False, 'context': True})¶ Bases:
uncompyle6.parsers.parse35.Python35Parser-
p_36misc(args)¶ formatted_value ::= LOAD_FAST FORMAT_VALUE str ::= LOAD_CONST joined_str ::= LOAD_CONST LOAD_ATTR format_value_or_strs
BUILD_LIST CALL_FUNCTIONformat_value_or_strs ::= format_value_or_strs format_value_or_str format_value_or_strs ::= format_value_or_str format_value_or_str ::= format_value format_value_or_str ::= str
-
-
class
uncompyle6.parsers.parse36.Python36ParserSingle(debug_parser={'rules': False, 'errorstack': None, 'transition': False, 'reduce': False, 'context': True})¶ Bases:
uncompyle6.parsers.parse36.Python36Parser,uncompyle6.parser.PythonParserSingle