You've already forked python-uncompyle6
mirror of
https://github.com/rocky/python-uncompyle6.git
synced 2025-08-03 00:45:53 +08:00
DRY parse{2,3} code
Add test for last bug.
This commit is contained in:
@@ -182,6 +182,34 @@ class PythonParser(GenericASTBuilder):
|
||||
for_block POP_BLOCK else_suitel _come_from
|
||||
"""
|
||||
|
||||
def p_whilestmt(self, args):
|
||||
"""
|
||||
whilestmt ::= SETUP_LOOP
|
||||
testexpr
|
||||
l_stmts_opt JUMP_BACK
|
||||
POP_BLOCK _come_from
|
||||
|
||||
whilestmt ::= SETUP_LOOP
|
||||
testexpr
|
||||
return_stmts
|
||||
POP_BLOCK COME_FROM
|
||||
|
||||
while1stmt ::= SETUP_LOOP l_stmts JUMP_BACK COME_FROM
|
||||
while1stmt ::= SETUP_LOOP l_stmts JUMP_BACK POP_BLOCK COME_FROM
|
||||
while1stmt ::= SETUP_LOOP return_stmts COME_FROM
|
||||
|
||||
while1elsestmt ::= SETUP_LOOP l_stmts JUMP_BACK else_suite COME_FROM
|
||||
whileelsestmt ::= SETUP_LOOP testexpr
|
||||
l_stmts_opt JUMP_BACK
|
||||
POP_BLOCK
|
||||
else_suite COME_FROM
|
||||
|
||||
whileelselaststmt ::= SETUP_LOOP testexpr
|
||||
l_stmts_opt JUMP_BACK
|
||||
POP_BLOCK
|
||||
else_suitec COME_FROM
|
||||
"""
|
||||
|
||||
def p_import20(self, args):
|
||||
'''
|
||||
stmt ::= importstmt
|
||||
|
@@ -318,30 +318,6 @@ class Python2Parser(PythonParser):
|
||||
POP_BLOCK LOAD_CONST COME_FROM
|
||||
WITH_CLEANUP END_FINALLY
|
||||
|
||||
whilestmt ::= SETUP_LOOP
|
||||
testexpr
|
||||
l_stmts_opt JUMP_BACK
|
||||
POP_BLOCK COME_FROM
|
||||
|
||||
whilestmt ::= SETUP_LOOP
|
||||
testexpr
|
||||
return_stmts
|
||||
POP_BLOCK COME_FROM
|
||||
|
||||
while1stmt ::= SETUP_LOOP l_stmts JUMP_BACK COME_FROM
|
||||
while1stmt ::= SETUP_LOOP return_stmts COME_FROM
|
||||
while1stmt ::= SETUP_LOOP l_stmts JUMP_BACK POP_BLOCK COME_FROM
|
||||
|
||||
while1elsestmt ::= SETUP_LOOP l_stmts JUMP_BACK else_suite COME_FROM
|
||||
whileelsestmt ::= SETUP_LOOP testexpr
|
||||
l_stmts_opt JUMP_BACK
|
||||
POP_BLOCK
|
||||
else_suite COME_FROM
|
||||
|
||||
whileelselaststmt ::= SETUP_LOOP testexpr
|
||||
l_stmts_opt JUMP_BACK
|
||||
POP_BLOCK
|
||||
else_suitec COME_FROM
|
||||
'''
|
||||
|
||||
def p_expr2(self, args):
|
||||
|
@@ -328,29 +328,6 @@ class Python3Parser(PythonParser):
|
||||
POP_BLOCK LOAD_CONST COME_FROM
|
||||
WITH_CLEANUP END_FINALLY
|
||||
|
||||
whilestmt ::= SETUP_LOOP
|
||||
testexpr
|
||||
l_stmts_opt JUMP_BACK
|
||||
POP_BLOCK _come_from
|
||||
|
||||
whilestmt ::= SETUP_LOOP
|
||||
testexpr
|
||||
return_stmts
|
||||
POP_BLOCK COME_FROM
|
||||
|
||||
while1stmt ::= SETUP_LOOP l_stmts JUMP_BACK COME_FROM
|
||||
while1stmt ::= SETUP_LOOP return_stmts COME_FROM
|
||||
|
||||
while1elsestmt ::= SETUP_LOOP l_stmts JUMP_BACK else_suite COME_FROM
|
||||
whileelsestmt ::= SETUP_LOOP testexpr
|
||||
l_stmts_opt JUMP_BACK
|
||||
POP_BLOCK
|
||||
else_suite COME_FROM
|
||||
|
||||
whileelselaststmt ::= SETUP_LOOP testexpr
|
||||
l_stmts_opt JUMP_BACK
|
||||
POP_BLOCK
|
||||
else_suitec COME_FROM
|
||||
'''
|
||||
|
||||
def p_genexpr3(self, args):
|
||||
|
Reference in New Issue
Block a user