You've already forked python-uncompyle6
mirror of
https://github.com/rocky/python-uncompyle6.git
synced 2025-08-03 00:45:53 +08:00
Python 3.(4?) while1 bug
Clean up while1 grammar a tad
This commit is contained in:
@@ -294,9 +294,6 @@ class PythonParser(GenericASTBuilder):
|
||||
while1stmt ::= SETUP_LOOP l_stmts JUMP_BACK COME_FROM
|
||||
while1stmt ::= SETUP_LOOP l_stmts JUMP_BACK POP_BLOCK COME_FROM
|
||||
|
||||
# This is Python 2.7+; segregate
|
||||
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
|
||||
|
@@ -150,14 +150,16 @@ class Python26Parser(Python2Parser):
|
||||
whileelsestmt ::= SETUP_LOOP testexpr l_stmts_opt jb_pop POP_BLOCK
|
||||
else_suite COME_FROM
|
||||
|
||||
while1stmt ::= SETUP_LOOP return_stmts bp_come_from
|
||||
|
||||
return_stmt ::= ret_expr RETURN_END_IF come_from_pop
|
||||
return_stmt ::= ret_expr RETURN_VALUE come_from_pop
|
||||
return_if_stmt ::= ret_expr RETURN_END_IF come_from_pop
|
||||
|
||||
iflaststmtl ::= testexpr c_stmts_opt JUMP_BACK come_from_pop
|
||||
iflaststmt ::= testexpr c_stmts_opt JUMP_ABSOLUTE come_from_pop
|
||||
|
||||
# Common with 2.7
|
||||
while1stmt ::= SETUP_LOOP return_stmts bp_come_from
|
||||
while1stmt ::= SETUP_LOOP return_stmts COME_FROM
|
||||
"""
|
||||
|
||||
def p_comp26(self, args):
|
||||
|
@@ -39,6 +39,7 @@ class Python27Parser(Python2Parser):
|
||||
_ifstmts_jump ::= c_stmts_opt JUMP_FORWARD COME_FROM
|
||||
jmp_false ::= POP_JUMP_IF_FALSE
|
||||
jmp_true ::= POP_JUMP_IF_TRUE
|
||||
bp_come_from ::= POP_BLOCK COME_FROM
|
||||
"""
|
||||
|
||||
|
||||
@@ -55,7 +56,9 @@ class Python27Parser(Python2Parser):
|
||||
POP_BLOCK LOAD_CONST COME_FROM
|
||||
WITH_CLEANUP END_FINALLY
|
||||
|
||||
while1stmt ::= SETUP_LOOP l_stmts POP_BLOCK COME_FROM
|
||||
# Common with 2.6
|
||||
while1stmt ::= SETUP_LOOP return_stmts bp_come_from
|
||||
while1stmt ::= SETUP_LOOP return_stmts COME_FROM
|
||||
"""
|
||||
|
||||
|
||||
|
@@ -273,6 +273,7 @@ class Python3Parser(PythonParser):
|
||||
# Python < 3.5 no POP BLOCK
|
||||
whileTruestmt ::= SETUP_LOOP l_stmts_opt JUMP_BACK _come_from
|
||||
whileTruestmt ::= SETUP_LOOP l_stmts_opt JUMP_BACK NOP _come_from
|
||||
while1stmt ::= SETUP_LOOP l_stmts _come_from JUMP_BACK _come_from
|
||||
"""
|
||||
|
||||
def p_genexpr3(self, args):
|
||||
|
@@ -307,7 +307,9 @@ class Scanner3(scan.Scanner):
|
||||
"""
|
||||
code = self.code
|
||||
codelen = len(code)
|
||||
self.prev_op = [0]
|
||||
# 2.x uses prev 3.x uses prev_op. Sigh
|
||||
# Until we get this sorted out.
|
||||
self.prev = self.prev_op = [0]
|
||||
for offset in self.op_range(0, codelen):
|
||||
op = code[offset]
|
||||
for _ in range(self.op_size(op)):
|
||||
|
Reference in New Issue
Block a user