Fix some 3.6/3.7 bugs

This commit is contained in:
rocky
2018-04-19 10:00:40 -04:00
parent 6fcf49b214
commit 27f67e6fca
6 changed files with 19 additions and 2 deletions

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@@ -16,6 +16,9 @@ class Python35Parser(Python34Parser):
def p_35on(self, args):
"""
pb_ja ::= POP_BLOCK JUMP_ABSOLUTE
# The number of canned instructions in new statements is mind boggling.
# I'm sure by the time Python 4 comes around these will be turned
# into special opcodes
@@ -90,7 +93,7 @@ class Python35Parser(Python34Parser):
LOAD_GLOBAL COMPARE_OP POP_JUMP_IF_FALSE
POP_TOP POP_TOP POP_TOP POP_EXCEPT POP_BLOCK
JUMP_ABSOLUTE END_FINALLY COME_FROM
for_block POP_BLOCK JUMP_ABSOLUTE
for_block pb_ja
else_suite COME_FROM_LOOP

View File

@@ -56,6 +56,19 @@ class Python36Parser(Python35Parser):
jf_cf ::= JUMP_FORWARD COME_FROM
conditional ::= expr jmp_false expr jf_cf expr COME_FROM
# FIXME: remove corresponding rule for 3.5
async_forelse_stmt ::= SETUP_LOOP expr
GET_AITER
LOAD_CONST YIELD_FROM SETUP_EXCEPT GET_ANEXT LOAD_CONST
YIELD_FROM
store
POP_BLOCK JUMP_FORWARD COME_FROM_EXCEPT DUP_TOP
LOAD_GLOBAL COMPARE_OP POP_JUMP_IF_FALSE
POP_TOP POP_TOP POP_TOP POP_EXCEPT POP_BLOCK
JUMP_ABSOLUTE END_FINALLY COME_FROM
for_block POP_BLOCK
else_suite COME_FROM_LOOP
# Adds a COME_FROM_ASYNC_WITH over 3.5
# FIXME: remove corresponding rule for 3.5?

View File

@@ -265,7 +265,8 @@ def customize_for_version3(self, version):
'async_for_stmt': (
'%|async for %c in %c:\n%+%c%-\n\n', 9, 1, 25 ),
'async_forelse_stmt': (
'%|async for %c in %c:\n%+%c%-%|else:\n%+%c%-\n\n', 9, 1, 25, 28 ),
'%|async for %c in %c:\n%+%c%-%|else:\n%+%c%-\n\n',
9, 1, 25, (27, 'else_suite') ),
'async_with_stmt': (
'%|async with %c:\n%+%c%-', 0, 7),
'async_with_as_stmt': (