Python 2.6 while1 if/and handling

This commit is contained in:
rocky
2018-03-06 09:39:13 -05:00
parent 3b0a5aab16
commit 8278c72a6f
3 changed files with 11 additions and 6 deletions

Binary file not shown.

View File

@@ -0,0 +1,8 @@
# From 2.6.9 ftplib.py
# Bug was handling if with "and' inside while1
def getmultiline(line):
if line[3]:
while 1:
if line[2] and line[5]:
break
return

View File

@@ -134,12 +134,11 @@ class Python26Parser(Python2Parser):
setup_finally ::= STORE_FAST SETUP_FINALLY LOAD_FAST DELETE_FAST
setup_finally ::= STORE_NAME SETUP_FINALLY LOAD_NAME DELETE_NAME
while1stmt ::= SETUP_LOOP l_stmts JUMP_BACK COME_FROM
while1stmt ::= SETUP_LOOP l_stmts_opt JUMP_BACK
while1stmt ::= SETUP_LOOP l_stmts_opt JUMP_BACK _come_froms
# Sometimes JUMP_BACK is misclassified as CONTINUE.
# workaround until we have better control flow in place
while1stmt ::= SETUP_LOOP l_stmts_opt CONTINUE
while1stmt ::= SETUP_LOOP l_stmts_opt CONTINUE _come_froms
whilestmt ::= SETUP_LOOP testexpr l_stmts_opt jb_pop POP_BLOCK _come_froms
whilestmt ::= SETUP_LOOP testexpr l_stmts_opt jb_cf_pop bp_come_from
@@ -154,13 +153,11 @@ class Python26Parser(Python2Parser):
return ::= ret_expr RETURN_VALUE POP_TOP
return_if_stmt ::= ret_expr RETURN_END_IF POP_TOP
iflaststmtl ::= testexpr c_stmts_opt JUMP_BACK come_from_pop
iflaststmtl ::= testexpr c_stmts_opt jb_cf_pop
iflaststmt ::= testexpr c_stmts_opt JUMP_ABSOLUTE come_from_pop
lastc_stmt ::= iflaststmt COME_FROM
while1stmt ::= SETUP_LOOP l_stmts_opt JUMP_BACK COME_FROM
ifstmt ::= testexpr_then _ifstmts_jump
# Semantic actions want the else to be at position 3