You've already forked python-uncompyle6
mirror of
https://github.com/rocky/python-uncompyle6.git
synced 2025-08-02 16:44:46 +08:00
Adjust 3.8 while-stmt rules
This commit is contained in:
BIN
test/bytecode_3.8/02_while_and.pyc
Normal file
BIN
test/bytecode_3.8/02_while_and.pyc
Normal file
Binary file not shown.
@@ -34,6 +34,7 @@ class Python38Parser(Python37Parser):
|
||||
stmt ::= tryfinally38
|
||||
stmt ::= try_except_ret38
|
||||
stmt ::= try_except38
|
||||
stmt ::= whilestmt38
|
||||
|
||||
# FIXME this should be restricted to being inside a try block
|
||||
stmt ::= except_ret38
|
||||
@@ -59,9 +60,12 @@ class Python38Parser(Python37Parser):
|
||||
forelsestmt38 ::= expr for_iter store for_block POP_BLOCK else_suite
|
||||
forelselaststmt38 ::= expr for_iter store for_block POP_BLOCK else_suitec
|
||||
forelselaststmtl38 ::= expr for_iter store for_block POP_BLOCK else_suitel
|
||||
whilestmt ::= testexpr l_stmts_opt COME_FROM JUMP_BACK POP_BLOCK
|
||||
whilestmt ::= testexpr l_stmts_opt JUMP_BACK POP_BLOCK
|
||||
whilestmt ::= testexpr returns POP_BLOCK
|
||||
|
||||
whilestmt38 ::= testexpr l_stmts_opt COME_FROM JUMP_BACK POP_BLOCK
|
||||
whilestmt38 ::= testexpr l_stmts_opt JUMP_BACK POP_BLOCK
|
||||
whilestmt38 ::= testexpr returns POP_BLOCK
|
||||
whilestmt38 ::= testexpr l_stmts JUMP_BACK
|
||||
|
||||
# while1elsestmt ::= l_stmts JUMP_BACK
|
||||
whileelsestmt ::= testexpr l_stmts JUMP_BACK POP_BLOCK
|
||||
whileTruestmt ::= l_stmts JUMP_BACK POP_BLOCK
|
||||
|
@@ -918,13 +918,16 @@ def customize_for_version3(self, version):
|
||||
|
||||
PRECEDENCE['attribute37'] = 2
|
||||
TABLE_DIRECT.update({
|
||||
'attribute37': ( '%c.%[1]{pattr}', 0 ),
|
||||
'async_forelse_stmt': (
|
||||
'%|async for %c in %c:\n%+%c%-%|else:\n%+%c%-\n\n',
|
||||
(7, 'store'), (1, 'expr'), (17, 'for_block'), (25, 'else_suite') ),
|
||||
'async_for_stmt': (
|
||||
'%|async for %c in %c:\n%+%c%-%-\n\n',
|
||||
(7, 'store'), (1, 'expr'), (17, 'for_block')),
|
||||
'async_for_stmt37': (
|
||||
'%|async for %c in %c:\n%+%c%-%-\n\n',
|
||||
(7, 'store'), (1, 'expr'), (16, 'for_block') ),
|
||||
'attribute37': ( '%c.%[1]{pattr}', 0 ),
|
||||
'compare_chained1a_37': ( ' %[3]{pattr.replace("-", " ")} %p %p',
|
||||
(0, 19),
|
||||
(-4, 19)),
|
||||
@@ -935,9 +938,6 @@ def customize_for_version3(self, version):
|
||||
|
||||
'compare_chained2b_37': ( '%[1]{pattr.replace("-", " ")} %p', (0, 19)),
|
||||
|
||||
'async_for_stmt37': (
|
||||
'%|async for %c in %c:\n%+%c%-%-\n\n',
|
||||
(7, 'store'), (1, 'expr'), (16, 'for_block') ),
|
||||
})
|
||||
if version >= 3.8:
|
||||
########################
|
||||
@@ -954,6 +954,11 @@ def customize_for_version3(self, version):
|
||||
'%|async for %c in %c:\n%+%c%-%-\n\n',
|
||||
(0, 'expr'), (7, 'store'), (8, 'for_block') ),
|
||||
|
||||
'except_handler38a': (
|
||||
'%c', (-2, 'stmts') ),
|
||||
'except_ret38a': (
|
||||
'return %c', (4, 'expr') ),
|
||||
'except_ret38': ( '%|return %c\n', (1, 'expr') ),
|
||||
'for38': (
|
||||
'%|for %c in %c:\n%+%c%-\n\n',
|
||||
(2, 'store'),
|
||||
@@ -974,20 +979,18 @@ def customize_for_version3(self, version):
|
||||
(2, 'store'),
|
||||
(0, 'expr'),
|
||||
(3, 'for_block'), -2 ),
|
||||
|
||||
'whilestmt38': ( '%|while %c:\n%+%c%-\n\n',
|
||||
(0, 'testexpr'), (1, 'l_stmts') ),
|
||||
'tryfinally38': (
|
||||
'%|try:\n%+%c%-%|finally:\n%+%c%-\n\n',
|
||||
(3, 'returns'), 6 ),
|
||||
'except_ret38': ( '%|return %c\n', (1, 'expr') ),
|
||||
'try_except38': (
|
||||
'%|try:\n%+%c\n%-%|except:\n%|%-%c\n\n',
|
||||
(-2, 'suite_stmts_opt'), (-1, 'except_handler38a') ),
|
||||
'try_except_ret38': (
|
||||
'%|try:\n%+%|return %c%-\n%|except:\n%+%|%c%-\n\n',
|
||||
(1, 'expr'), (-1, 'except_ret38a') ),
|
||||
'except_ret38a': (
|
||||
'return %c', (4, 'expr') ),
|
||||
'except_handler38a': (
|
||||
'%c', (-2, 'stmts') )
|
||||
})
|
||||
pass # version >= 3.8
|
||||
pass
|
||||
|
Reference in New Issue
Block a user