Handle Python 3.1 "with ... as" statement

This commit is contained in:
rocky
2016-10-25 02:03:50 -04:00
parent 334f6935b6
commit 7a10917857
2 changed files with 16 additions and 4 deletions

Binary file not shown.

View File

@@ -698,10 +698,22 @@ class Python31Parser(Python32Parser):
def p_31(self, args):
"""
binary_subscr2 ::= expr expr DUP_TOPX BINARY_SUBSCR
setupwith ::= DUP_TOP LOAD_ATTR store LOAD_ATTR CALL_FUNCTION_0 POP_TOP
withstmt ::= expr setupwith SETUP_FINALLY suite_stmts_opt
POP_BLOCK LOAD_CONST COME_FROM_FINALLY
load del_stmt WITH_CLEANUP END_FINALLY
setupwith ::= DUP_TOP LOAD_ATTR store LOAD_ATTR CALL_FUNCTION_0 POP_TOP
setupwithas ::= DUP_TOP LOAD_ATTR store LOAD_ATTR CALL_FUNCTION_0 store
withstmt ::= expr setupwith SETUP_FINALLY
suite_stmts_opt
POP_BLOCK LOAD_CONST COME_FROM_FINALLY
load del_stmt WITH_CLEANUP END_FINALLY
# Keeps Python 3.1 withas desigator in the same position as it is in other version
setupwithas31 ::= setupwithas SETUP_FINALLY load del_stmt
withasstmt ::= expr setupwithas31 designator
suite_stmts_opt
POP_BLOCK LOAD_CONST COME_FROM_FINALLY
load del_stmt WITH_CLEANUP END_FINALLY
store ::= STORE_FAST
store ::= STORE_NAME
load ::= LOAD_FAST