| 9 | |
| 10 | |
| 11 | class Python32Parser(Python3Parser): |
| 12 | def p_30to33(self, args): |
| 13 | """ |
| 14 | # Store locals is only in Python 3.0 to 3.3 |
| 15 | stmt ::= store_locals |
| 16 | store_locals ::= LOAD_FAST STORE_LOCALS |
| 17 | """ |
| 18 | |
| 19 | def p_gen_comp32(self, args): |
| 20 | """ |
| 21 | genexpr_func ::= LOAD_ARG FOR_ITER store comp_iter JUMP_BACK |
| 22 | """ |
| 23 | |
| 24 | def p_32to35(self, args): |
| 25 | """ |
| 26 | if_exp ::= expr jmp_false expr jump_forward_else expr COME_FROM |
| 27 | |
| 28 | # compare_chained_right is used in a "chained_compare": x <= y <= z |
| 29 | compare_chained_right ::= expr COMPARE_OP RETURN_VALUE |
| 30 | compare_chained_right ::= expr COMPARE_OP RETURN_VALUE_LAMBDA |
| 31 | |
| 32 | # Python < 3.5 no POP BLOCK |
| 33 | whileTruestmt ::= SETUP_LOOP l_stmts_opt JUMP_BACK COME_FROM_LOOP |
| 34 | |
| 35 | # Python 3.5+ has jump optimization to remove the redundant |
| 36 | # jump_excepts. But in 3.3 we need them added |
| 37 | |
| 38 | try_except ::= SETUP_EXCEPT suite_stmts_opt POP_BLOCK |
| 39 | except_handler |
| 40 | jump_excepts come_from_except_clauses |
| 41 | |
| 42 | except_handler ::= JUMP_FORWARD COME_FROM_EXCEPT except_stmts |
| 43 | END_FINALLY |
| 44 | |
| 45 | tryelsestmt ::= SETUP_EXCEPT suite_stmts_opt POP_BLOCK |
| 46 | except_handler else_suite |
| 47 | jump_excepts come_from_except_clauses |
| 48 | |
| 49 | jump_excepts ::= jump_except+ |
| 50 | |
| 51 | # Python 3.2+ has more loop optimization that removes |
| 52 | # JUMP_FORWARD in some cases, and hence we also don't |
| 53 | # see COME_FROM |
| 54 | _ifstmts_jump ::= stmts_opt |
| 55 | _ifstmts_jump ::= stmts_opt JUMP_FORWARD _come_froms |
| 56 | _ifstmts_jumpl ::= c_stmts_opt |
| 57 | _ifstmts_jumpl ::= c_stmts_opt JUMP_FORWARD _come_froms |
| 58 | |
| 59 | kv3 ::= expr expr STORE_MAP |
| 60 | """ |
| 61 | |
| 62 | pass |
| 63 | |
| 64 | def p_32on(self, args): |
| 65 | """ |
| 66 | # In Python 3.2+, DUP_TOPX is DUP_TOP_TWO |
| 67 | subscript2 ::= expr expr DUP_TOP_TWO BINARY_SUBSCR |
| 68 | """ |