| 25 | |
| 26 | |
| 27 | class Python36Parser(Python35Parser): |
| 28 | def __init__(self, debug_parser=PARSER_DEFAULT_DEBUG): |
| 29 | super(Python36Parser, self).__init__(debug_parser) |
| 30 | self.customized = {} |
| 31 | |
| 32 | def p_36_jump(self, args): |
| 33 | """ |
| 34 | # Zero or one COME_FROM |
| 35 | # And/or expressions have this |
| 36 | come_from_opt ::= COME_FROM? |
| 37 | """ |
| 38 | |
| 39 | def p_36_misc(self, args): |
| 40 | """sstmt ::= sstmt RETURN_LAST |
| 41 | |
| 42 | # long except clauses in a loop can sometimes cause a JUMP_BACK to turn into a |
| 43 | # JUMP_FORWARD to a JUMP_BACK. And when this happens there is an additional |
| 44 | # ELSE added to the except_suite. With better flow control perhaps we can |
| 45 | # sort this out better. |
| 46 | except_suite ::= c_stmts_opt POP_EXCEPT jump_except ELSE |
| 47 | except_suite_finalize ::= SETUP_FINALLY c_stmts_opt except_var_finalize END_FINALLY |
| 48 | _jump ELSE |
| 49 | |
| 50 | # 3.6 redoes how return_closure works. FIXME: Isolate to LOAD_CLOSURE |
| 51 | return_closure ::= LOAD_CLOSURE DUP_TOP STORE_NAME RETURN_VALUE RETURN_LAST |
| 52 | |
| 53 | for_block ::= l_stmts_opt come_from_loops JUMP_BACK |
| 54 | come_from_loops ::= COME_FROM_LOOP* |
| 55 | |
| 56 | whilestmt ::= SETUP_LOOP testexpr l_stmts_opt |
| 57 | JUMP_BACK come_froms POP_BLOCK |
| 58 | whilestmt ::= SETUP_LOOP testexpr l_stmts_opt |
| 59 | JUMP_BACK come_froms POP_BLOCK COME_FROM_LOOP |
| 60 | whilestmt ::= SETUP_LOOP testexpr l_stmts_opt |
| 61 | come_froms JUMP_BACK come_froms POP_BLOCK COME_FROM_LOOP |
| 62 | |
| 63 | # 3.6 due to jump optimization, we sometimes add RETURN_END_IF where |
| 64 | # RETURN_VALUE is meant. Specifically, this can happen in |
| 65 | # ifelsestmt -> ...else_suite _. suite_stmts... (last) stmt |
| 66 | return ::= return_expr RETURN_END_IF |
| 67 | return ::= return_expr RETURN_VALUE COME_FROM |
| 68 | return_stmt_lambda ::= return_expr RETURN_VALUE_LAMBDA COME_FROM |
| 69 | |
| 70 | # A COME_FROM is dropped off because of JUMP-to-JUMP optimization |
| 71 | and ::= expr jmp_false expr |
| 72 | and ::= expr jmp_false expr jmp_false |
| 73 | |
| 74 | jf_cf ::= JUMP_FORWARD COME_FROM |
| 75 | cf_jf_else ::= come_froms JUMP_FORWARD ELSE |
| 76 | |
| 77 | if_exp ::= expr jmp_false expr jf_cf expr COME_FROM |
| 78 | |
| 79 | async_for_stmt36 ::= SETUP_LOOP expr |
| 80 | GET_AITER |
| 81 | LOAD_CONST YIELD_FROM |
| 82 | SETUP_EXCEPT GET_ANEXT LOAD_CONST |
| 83 | YIELD_FROM |
| 84 | store |