If statement in loop isolation

This commit is contained in:
rocky
2020-01-17 10:47:38 -05:00
parent 4510aa932c
commit b333d7afc2
3 changed files with 17 additions and 13 deletions

View File

@@ -52,7 +52,7 @@ class PythonParser(GenericASTBuilder):
# stmts -> stmts stmt -> stmts stmt stmt ...
# collect as stmts -> stmt stmt ...
nt_list = [
'stmts', 'except_stmts', '_stmts', 'attributes',
'stmts', 'except_stmts', '_stmts', 'attributes', "l_stmts",
'exprlist', 'kvlist', 'kwargs', 'come_froms', '_come_froms',
'importlist',
# Python < 3

View File

@@ -156,10 +156,10 @@ class Python3Parser(PythonParser):
_ifstmts_jump ::= return_if_stmts
_ifstmts_jump ::= c_stmts_opt come_froms
_ifstmts_jumpl ::= return_if_stmts
_ifstmts_jumpl ::= c_stmts_opt come_froms
iflaststmt ::= testexpr c_stmts_opt JUMP_ABSOLUTE
# ifstmts where we are in a loop
_ifstmts_jumpl ::= _ifstmts_jump
iflaststmtl ::= testexpr c_stmts_opt JUMP_BACK
iflaststmtl ::= testexpr _ifstmts_jumpl
@@ -365,6 +365,10 @@ class Python3Parser(PythonParser):
lastc_stmt ::= iflaststmtl
lastc_stmt ::= forelselaststmt
lastc_stmt ::= ifelsestmtc
# Statements in a loop
lstmt ::= stmt
l_stmts ::= lstmt+
"""
def p_loop_stmt3(self, args):