Weird 2.6.9 list comprehension

This commit is contained in:
rocky
2016-06-28 17:07:18 -04:00
parent 36432c7488
commit 0af3dd28bc
2 changed files with 6 additions and 1 deletions

View File

@@ -70,6 +70,7 @@ class Python26Parser(Python2Parser):
come_from_pop ::= COME_FROM POP_TOP come_from_pop ::= COME_FROM POP_TOP
_ifstmts_jump ::= c_stmts_opt jf_pop COME_FROM _ifstmts_jump ::= c_stmts_opt jf_pop COME_FROM
_ifstmts_jump ::= c_stmts_opt JUMP_FORWARD COME_FROM come_from_pop
""" """
def p_stmt26(self, args): def p_stmt26(self, args):
@@ -92,7 +93,6 @@ class Python26Parser(Python2Parser):
POP_BLOCK _come_from POP_BLOCK _come_from
return_if_stmt ::= ret_expr RETURN_END_IF come_from_pop return_if_stmt ::= ret_expr RETURN_END_IF come_from_pop
""" """
def p_comp26(self, args): def p_comp26(self, args):
@@ -106,6 +106,10 @@ class Python26Parser(Python2Parser):
designator list_iter JUMP_BACK del_stmt designator list_iter JUMP_BACK del_stmt
lc_body ::= LOAD_NAME expr LIST_APPEND lc_body ::= LOAD_NAME expr LIST_APPEND
lc_body ::= LOAD_FAST expr LIST_APPEND lc_body ::= LOAD_FAST expr LIST_APPEND
# Make sure we keep indices the same as 2.7
setup_loop_lf ::= SETUP_LOOP LOAD_FAST
genexpr_func ::= setup_loop_lf FOR_ITER designator comp_iter JUMP_BACK POP_BLOCK COME_FROM
''' '''
def p_ret26(self, args): def p_ret26(self, args):

View File

@@ -1067,6 +1067,7 @@ class SourceWalker(GenericASTTraversal, object):
n = ast[iter_index] n = ast[iter_index]
assert n == 'comp_iter' assert n == 'comp_iter'
# find innermost node # find innermost node
while n == 'comp_iter': # list_iter while n == 'comp_iter': # list_iter
n = n[0] # recurse one step n = n[0] # recurse one step