MCPcopy
hub / github.com/rocky/python-uncompyle6 / Python27Parser

Class Python27Parser

uncompyle6/parsers/parse27.py:20–385  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

18
19
20class Python27Parser(Python2Parser):
21 def __init__(self, debug_parser=PARSER_DEFAULT_DEBUG):
22 super(Python27Parser, self).__init__(debug_parser)
23 self.customized = {}
24
25 def p_comprehension27(self, args):
26 """
27 list_for ::= expr for_iter store list_iter JUMP_BACK
28 list_comp ::= BUILD_LIST_0 list_iter
29 lc_body ::= expr LIST_APPEND
30 for_iter ::= GET_ITER COME_FROM FOR_ITER
31
32 stmt ::= set_comp_func
33
34
35 # Dictionary and set comprehensions were added in Python 2.7
36 expr ::= dict_comp
37 dict_comp ::= LOAD_DICTCOMP MAKE_FUNCTION_0 expr GET_ITER CALL_FUNCTION_1
38
39 stmt ::= dict_comp_func
40
41 dict_comp_func ::= BUILD_MAP_0 LOAD_FAST FOR_ITER store
42 comp_iter JUMP_BACK ending_return
43
44 set_comp_func ::= BUILD_SET_0 LOAD_FAST FOR_ITER store comp_iter
45 JUMP_BACK ending_return
46
47 comp_iter ::= comp_if_not
48 comp_if_not ::= expr jmp_true comp_iter
49
50 comp_body ::= dict_comp_body
51 comp_body ::= set_comp_body
52 comp_for ::= expr for_iter store comp_iter JUMP_BACK
53
54 dict_comp_body ::= expr expr MAP_ADD
55 set_comp_body ::= expr SET_ADD
56
57 # See also common Python p_list_comprehension
58 """
59
60 def p_try27(self, args):
61 """
62 # If the last except is a "raise" we might not have a final COME_FROM
63 # FIXME: need a check on this rule since this accepts try_except when
64 # we shouldn't
65 try_except ::= SETUP_EXCEPT suite_stmts_opt POP_BLOCK
66 except_handler
67
68 tryfinallystmt ::= SETUP_FINALLY suite_stmts_opt
69 POP_BLOCK LOAD_CONST
70 COME_FROM_FINALLY suite_stmts_opt END_FINALLY
71
72 tryelsestmt ::= SETUP_EXCEPT suite_stmts_opt POP_BLOCK
73 except_handler_else else_suite COME_FROM
74
75 tryelsestmtl ::= SETUP_EXCEPT suite_stmts_opt POP_BLOCK
76 except_handler_else else_suitel JUMP_BACK COME_FROM
77

Callers 1

parse27.pyFile · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected