Towards fixing a 3.2 while true: ... break bug

This commit is contained in:
rocky
2016-12-28 18:57:09 -05:00
parent 9b1dd0f26c
commit 723fa5dfed
3 changed files with 12 additions and 5 deletions

View File

@@ -696,12 +696,19 @@ class Python3Parser(PythonParser):
self.check_reduce['augassign1'] = 'AST'
self.check_reduce['augassign2'] = 'AST'
self.check_reduce['while1stmt'] = 'noAST'
# FIXME: remove parser errors caused by the below
# self.check_reduce['while1elsestmt'] = 'noAST'
return
def reduce_is_invalid(self, rule, ast, tokens, first, last):
lhs = rule[0]
if lhs in ('augassign1', 'augassign2') and ast[0][0] == 'and':
return True
elif lhs == 'while1elsestmt':
last += 1
while isinstance(tokens[last], str):
last += 1
return tokens[first].attr != tokens[last].offset
elif lhs == 'while1stmt':
if tokens[last] in ('COME_FROM_LOOP', 'JUMP_BACK'):
# jump_back should be right afer SETUP_LOOP. Test?