You've already forked python-uncompyle6
mirror of
https://github.com/rocky/python-uncompyle6.git
synced 2025-08-03 16:59:52 +08:00
customize "async for" on 3.6. and 3.7
This commit is contained in:
Binary file not shown.
BIN
test/bytecode_3.7/03_async_await.pyc
Normal file
BIN
test/bytecode_3.7/03_async_await.pyc
Normal file
Binary file not shown.
@@ -56,7 +56,18 @@ class Python36Parser(Python35Parser):
|
|||||||
jf_cf ::= JUMP_FORWARD COME_FROM
|
jf_cf ::= JUMP_FORWARD COME_FROM
|
||||||
conditional ::= expr jmp_false expr jf_cf expr COME_FROM
|
conditional ::= expr jmp_false expr jf_cf expr COME_FROM
|
||||||
|
|
||||||
# FIXME: remove corresponding rule for 3.5
|
async_for_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
|
||||||
|
COME_FROM_LOOP
|
||||||
|
|
||||||
async_forelse_stmt ::= SETUP_LOOP expr
|
async_forelse_stmt ::= SETUP_LOOP expr
|
||||||
GET_AITER
|
GET_AITER
|
||||||
LOAD_CONST YIELD_FROM SETUP_EXCEPT GET_ANEXT LOAD_CONST
|
LOAD_CONST YIELD_FROM SETUP_EXCEPT GET_ANEXT LOAD_CONST
|
||||||
@@ -105,9 +116,32 @@ class Python36Parser(Python35Parser):
|
|||||||
"""
|
"""
|
||||||
|
|
||||||
def customize_grammar_rules(self, tokens, customize):
|
def customize_grammar_rules(self, tokens, customize):
|
||||||
|
# self.remove_rules("""
|
||||||
|
# """)
|
||||||
super(Python36Parser, self).customize_grammar_rules(tokens, customize)
|
super(Python36Parser, self).customize_grammar_rules(tokens, customize)
|
||||||
self.remove_rules("""
|
self.remove_rules("""
|
||||||
dict_comp ::= load_closure LOAD_DICTCOMP LOAD_CONST MAKE_CLOSURE_0 expr GET_ITER CALL_FUNCTION_1
|
async_for_stmt ::= SETUP_LOOP expr
|
||||||
|
GET_AITER
|
||||||
|
LOAD_CONST YIELD_FROM SETUP_EXCEPT GET_ANEXT LOAD_CONST
|
||||||
|
YIELD_FROM
|
||||||
|
store
|
||||||
|
POP_BLOCK jump_except 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 JUMP_ABSOLUTE
|
||||||
|
COME_FROM_LOOP
|
||||||
|
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 pb_ja
|
||||||
|
else_suite COME_FROM_LOOP
|
||||||
""")
|
""")
|
||||||
self.check_reduce['call_kw'] = 'AST'
|
self.check_reduce['call_kw'] = 'AST'
|
||||||
|
|
||||||
|
@@ -33,6 +33,32 @@ class Python37Parser(Python36Parser):
|
|||||||
stmt ::= import37
|
stmt ::= import37
|
||||||
import37 ::= import POP_TOP
|
import37 ::= import POP_TOP
|
||||||
|
|
||||||
|
async_for_stmt ::= SETUP_LOOP expr
|
||||||
|
GET_AITER
|
||||||
|
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_TRUE
|
||||||
|
END_FINALLY COME_FROM
|
||||||
|
for_block
|
||||||
|
COME_FROM
|
||||||
|
POP_TOP POP_TOP POP_TOP POP_EXCEPT POP_TOP POP_BLOCK
|
||||||
|
COME_FROM_LOOP
|
||||||
|
|
||||||
|
async_forelse_stmt ::= SETUP_LOOP expr
|
||||||
|
GET_AITER
|
||||||
|
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_TRUE
|
||||||
|
END_FINALLY COME_FROM
|
||||||
|
for_block
|
||||||
|
COME_FROM
|
||||||
|
POP_TOP POP_TOP POP_TOP POP_EXCEPT POP_TOP POP_BLOCK
|
||||||
|
else_suite COME_FROM_LOOP
|
||||||
|
|
||||||
# Is there a pattern here?
|
# Is there a pattern here?
|
||||||
attributes ::= IMPORT_FROM ROT_TWO POP_TOP IMPORT_FROM
|
attributes ::= IMPORT_FROM ROT_TWO POP_TOP IMPORT_FROM
|
||||||
|
|
||||||
@@ -46,6 +72,19 @@ class Python37Parser(Python36Parser):
|
|||||||
"""
|
"""
|
||||||
|
|
||||||
def customize_grammar_rules(self, tokens, customize):
|
def customize_grammar_rules(self, tokens, customize):
|
||||||
|
self.remove_rules("""
|
||||||
|
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
|
||||||
|
""")
|
||||||
super(Python37Parser, self).customize_grammar_rules(tokens, customize)
|
super(Python37Parser, self).customize_grammar_rules(tokens, customize)
|
||||||
|
|
||||||
class Python37ParserSingle(Python37Parser, PythonParserSingle):
|
class Python37ParserSingle(Python37Parser, PythonParserSingle):
|
||||||
|
@@ -885,6 +885,12 @@ def customize_for_version3(self, version):
|
|||||||
PRECEDENCE['attribute37'] = 2
|
PRECEDENCE['attribute37'] = 2
|
||||||
TABLE_DIRECT.update({
|
TABLE_DIRECT.update({
|
||||||
'attribute37': ( '%c.%[1]{pattr}', 0 ),
|
'attribute37': ( '%c.%[1]{pattr}', 0 ),
|
||||||
|
'async_forelse_stmt': (
|
||||||
|
'%|async for %c in %c:\n%+%c%-%|else:\n%+%c%-\n\n',
|
||||||
|
7, 1, 17, (25, 'else_suite') ),
|
||||||
|
'async_for_stmt': (
|
||||||
|
'%|async for %c in %c:\n%+%c%-%-\n\n',
|
||||||
|
7, 1, 17),
|
||||||
})
|
})
|
||||||
pass
|
pass
|
||||||
pass # version >= 3.6
|
pass # version >= 3.6
|
||||||
|
Reference in New Issue
Block a user