NT continue_stmt -> continue to match AST

This commit is contained in:
rocky
2017-12-06 01:45:08 -05:00
parent 7b39002476
commit f8d6998b22
5 changed files with 15 additions and 15 deletions

View File

@@ -65,11 +65,11 @@ class Python2Parser(PythonParser):
stmt ::= break_stmt stmt ::= break_stmt
break_stmt ::= BREAK_LOOP break_stmt ::= BREAK_LOOP
stmt ::= continue_stmt stmt ::= continue
continue_stmt ::= CONTINUE continue ::= CONTINUE
continue_stmts ::= _stmts lastl_stmt continue_stmt continues ::= _stmts lastl_stmt continue
continue_stmts ::= lastl_stmt continue_stmt continues ::= lastl_stmt continue
continue_stmts ::= continue_stmt continues ::= continue
stmt ::= assert2 stmt ::= assert2
stmt ::= raise_stmt0 stmt ::= raise_stmt0
@@ -339,7 +339,7 @@ class Python2Parser(PythonParser):
rule = 'call ::= expr ' + 'expr '*args_pos + 'kwarg '*args_kw \ rule = 'call ::= expr ' + 'expr '*args_pos + 'kwarg '*args_kw \
+ 'expr ' * nak + opname + 'expr ' * nak + opname
elif opname == 'CONTINUE_LOOP': elif opname == 'CONTINUE_LOOP':
self.add_unique_rule('continue_stmt ::= CONTINUE_LOOP', self.add_unique_rule('continue ::= CONTINUE_LOOP',
opname, v, customize) opname, v, customize)
continue continue
elif opname_base in ('DUP_TOPX', 'RAISE_VARARGS'): elif opname_base in ('DUP_TOPX', 'RAISE_VARARGS'):

View File

@@ -91,12 +91,12 @@ class Python3Parser(PythonParser):
stmt ::= break_stmt stmt ::= break_stmt
break_stmt ::= BREAK_LOOP break_stmt ::= BREAK_LOOP
stmt ::= continue_stmt stmt ::= continue
continue_stmt ::= CONTINUE continue ::= CONTINUE
continue_stmt ::= CONTINUE_LOOP continue ::= CONTINUE_LOOP
continue_stmts ::= _stmts lastl_stmt continue_stmt continues ::= _stmts lastl_stmt continue
continue_stmts ::= lastl_stmt continue_stmt continues ::= lastl_stmt continue
continue_stmts ::= continue_stmt continues ::= continue
del_stmt ::= delete_subscr del_stmt ::= delete_subscr
delete_subscr ::= expr expr DELETE_SUBSCR delete_subscr ::= expr expr DELETE_SUBSCR

View File

@@ -20,7 +20,7 @@ def checker(ast, in_loop, errors):
errors.append(error_text) errors.append(error_text)
for node in ast: for node in ast:
if not in_loop and node.kind in ('continue_stmt', 'break_stmt'): if not in_loop and node.kind in ('continue', 'break_stmt'):
text = str(node) text = str(node)
error_text = '\n# not in loop:\n#\t' + '\n# '.join(text.split("\n")) error_text = '\n# not in loop:\n#\t' + '\n# '.join(text.split("\n"))
errors.append(error_text) errors.append(error_text)

View File

@@ -225,7 +225,7 @@ TABLE_DIRECT = {
'call_stmt': ( '%|%p\n', (0, 200)), 'call_stmt': ( '%|%p\n', (0, 200)),
'break_stmt': ( '%|break\n', ), 'break_stmt': ( '%|break\n', ),
'continue_stmt': ( '%|continue\n', ), 'continue': ( '%|continue\n', ),
'raise_stmt0': ( '%|raise\n', ), 'raise_stmt0': ( '%|raise\n', ),
'raise_stmt1': ( '%|raise %c\n', 0), 'raise_stmt1': ( '%|raise %c\n', 0),

View File

@@ -85,7 +85,7 @@ ExtractInfo = namedtuple("ExtractInfo",
TABLE_DIRECT_FRAGMENT = { TABLE_DIRECT_FRAGMENT = {
'break_stmt': ( '%|%rbreak\n', ), 'break_stmt': ( '%|%rbreak\n', ),
'continue_stmt': ( '%|%rcontinue\n', ), 'continue ': ( '%|%rcontinue\n', ),
'passstmt': ( '%|%rpass\n', ), 'passstmt': ( '%|%rpass\n', ),
'raise_stmt0': ( '%|%rraise\n', ), 'raise_stmt0': ( '%|%rraise\n', ),
'import': ( '%|import %c%x\n', 2, (2, (0, 1)), ), 'import': ( '%|import %c%x\n', 2, (2, (0, 1)), ),