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

Class Python34Parser

uncompyle6/parsers/parse34.py:23–71  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

21
22
23class Python34Parser(Python33Parser):
24 def p_misc34(self, args):
25 """
26 expr ::= LOAD_ASSERT
27
28
29 # passtmt is needed for semantic actions to add "pass"
30 suite_stmts_opt ::= pass
31
32 whilestmt ::= SETUP_LOOP testexpr returns come_froms POP_BLOCK COME_FROM_LOOP
33
34 # Seems to be needed starting 3.4.4 or so
35 while1stmt ::= SETUP_LOOP l_stmts
36 COME_FROM JUMP_BACK POP_BLOCK COME_FROM_LOOP
37 while1stmt ::= SETUP_LOOP l_stmts
38 POP_BLOCK COME_FROM_LOOP
39
40 # FIXME the below masks a bug in not detecting COME_FROM_LOOP
41 # grammar rules with COME_FROM -> COME_FROM_LOOP already exist
42 whileelsestmt ::= SETUP_LOOP testexpr l_stmts_opt JUMP_BACK POP_BLOCK
43 else_suitel COME_FROM
44
45 while1elsestmt ::= SETUP_LOOP l_stmts JUMP_BACK _come_froms POP_BLOCK else_suitel
46 COME_FROM_LOOP
47
48 # Python 3.4+ optimizes the trailing two JUMPS away
49
50 # This is 3.4 only
51 yield_from ::= expr GET_ITER LOAD_CONST YIELD_FROM
52
53 _ifstmts_jump ::= c_stmts_opt JUMP_ABSOLUTE JUMP_FORWARD COME_FROM
54
55 genexpr_func ::= LOAD_ARG _come_froms FOR_ITER store comp_iter JUMP_BACK
56
57 if_exp_lambda ::= expr jmp_false expr return_if_lambda return_stmt_lambda LAMBDA_MARKER
58 return_if_lambda ::= RETURN_END_IF_LAMBDA come_froms
59 return_if_stmt ::= return_expr RETURN_END_IF POP_BLOCK
60 """
61
62 def customize_grammar_rules(self, tokens, customize):
63 self.remove_rules(
64 """
65 yield_from ::= expr expr YIELD_FROM
66 # 3.4.2 has this. 3.4.4 may now
67 # while1stmt ::= SETUP_LOOP l_stmts COME_FROM JUMP_BACK COME_FROM_LOOP
68 """
69 )
70 super(Python34Parser, self).customize_grammar_rules(tokens, customize)
71 return
72
73
74class Python34ParserSingle(Python34Parser, PythonParserSingle):

Callers 1

parse34.pyFile · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected