2.6 genexpr. Some not quite right.

This commit is contained in:
rocky 2016-06-29 23:30:45 -04:00
parent d7f7748000
commit 4b0b7f76dc
4 changed files with 20 additions and 1 deletions

Binary file not shown.

View File

@ -0,0 +1,7 @@
# from 2.6.9 ast
# Should see genexpr
rv = '%s(%s' % (node.__class__.__name__, ', '.join(
('%s=%s' % field for field in fields)
if annotate_fields else
(b for a, b in fields)
))

View File

@ -74,6 +74,7 @@ class Python26Parser(Python2Parser):
jb_cf_pop ::= JUMP_BACK come_froms POP_TOP
ja_cf_pop ::= JUMP_ABSOLUTE come_from_pop
jf_cf_pop ::= JUMP_FORWARD come_from_pop
_ifstmts_jump ::= c_stmts_opt jf_pop COME_FROM
_ifstmts_jump ::= c_stmts_opt JUMP_FORWARD COME_FROM come_from_pop
@ -133,6 +134,8 @@ class Python26Parser(Python2Parser):
setup_loop_lf ::= SETUP_LOOP LOAD_FAST
genexpr_func ::= setup_loop_lf FOR_ITER designator comp_iter JUMP_BACK POP_BLOCK COME_FROM
genexpr_func ::= setup_loop_lf FOR_ITER designator comp_iter JUMP_BACK come_from_pop JUMP_BACK POP_BLOCK COME_FROM
genexpr ::= LOAD_GENEXPR MAKE_FUNCTION_0 expr GET_ITER CALL_FUNCTION_1 COME_FROM
'''
def p_ret26(self, args):
@ -153,7 +156,10 @@ class Python26Parser(Python2Parser):
except_suite ::= c_stmts_opt jmp_abs new_block
'''
def p_misc(self, args):
'''
conditional ::= expr jmp_false expr jf_cf_pop expr
'''
class Python26ParserSingle(Python2Parser, PythonParserSingle):
pass

View File

@ -1045,6 +1045,12 @@ class SourceWalker(GenericASTTraversal, object):
# FIXME: clean this up
if self.version > 3.0 and node == 'dictcomp':
cn = node[1]
elif self.version < 2.7 and node == 'genexpr':
if node[0] == 'LOAD_GENEXPR':
cn = node[0]
elif node[0] == 'load_closure':
cn = node[1]
elif self.version > 3.0 and node == 'genexpr':
if node[0] == 'load_genexpr':
load_genexpr = node[0]