More 2.6.9 bugs fixed

* break loop parsing bug
* ifelsestmt semantic-action bug in handling else
This commit is contained in:
rocky
2016-06-30 21:41:04 -04:00
parent d87b5fe34c
commit 261c60efd9
4 changed files with 24 additions and 7 deletions

Binary file not shown.

View File

@@ -0,0 +1,11 @@
# 2.6.9 _strptime.py
# In 2.6 bug in handling BREAK_LOOP followed by JUMP_BACK
# So added rule:
# break_stmt ::= BREAK_LOOP JUMP_BACK
for value in __file__:
if value:
if (value and __name__):
pass
else:
tz = 'a'
break

View File

@@ -91,13 +91,21 @@ class Python26Parser(Python2Parser):
def p_stmt26(self, args):
"""
# We use filler as a placeholder to keep nonterminal positions
# the same across different grammars so that the same semantic actions
# can be used
filler ::=
assert ::= assert_expr jmp_true LOAD_ASSERT RAISE_VARARGS_1 come_from_pop
assert2 ::= assert_expr jmp_true LOAD_ASSERT expr RAISE_VARARGS_2 come_from_pop
ifelsestmt ::= testexpr c_stmts_opt jf_pop else_suite COME_FROM
ifelsestmt ::= testexpr c_stmts_opt else_suitel come_froms POP_TOP
break_stmt ::= BREAK_LOOP JUMP_BACK
# Semantic actions want else_suitel to be at index 2 or 3
# Semantic actions want the else to be at position 3
ifelsestmt ::= testexpr c_stmts_opt jf_pop else_suite COME_FROM
ifelsestmt ::= testexpr c_stmts_opt filler else_suitel come_froms POP_TOP
# Semantic actions want else_suitel to be at index 3
ifelsestmtl ::= testexpr c_stmts_opt jb_cf_pop else_suitel
ifelsestmtc ::= testexpr c_stmts_opt ja_cf_pop else_suitec
@@ -119,6 +127,7 @@ class Python26Parser(Python2Parser):
iflaststmtl ::= testexpr c_stmts_opt JUMP_BACK come_from_pop
iflaststmt ::= testexpr c_stmts_opt JUMP_ABSOLUTE come_from_pop
"""
def p_comp26(self, args):

View File

@@ -850,10 +850,7 @@ class SourceWalker(GenericASTTraversal, object):
self.prune() # stop recursing
def n_ifelsestmt(self, node, preprocess=False):
if node[2].type.startswith('else_suite'):
else_suite = node[2]
elif node[3].type.startswith('else_suite'):
else_suite = node[3]
else_suite = node[3]
n = else_suite[0]