setcomp_func -> set_comp ...

to match AST name more closely
This commit is contained in:
rocky
2018-03-05 10:20:14 -05:00
parent 01f2f6578b
commit 2bdfd76635
4 changed files with 15 additions and 15 deletions

View File

@@ -19,7 +19,7 @@ class Python27Parser(Python2Parser):
lc_body ::= expr LIST_APPEND
for_iter ::= GET_ITER COME_FROM FOR_ITER
stmt ::= setcomp_func
stmt ::= set_comp
# Dictionary and set comprehensions were added in Python 2.7
@@ -30,7 +30,7 @@ class Python27Parser(Python2Parser):
dictcomp_func ::= BUILD_MAP_0 LOAD_FAST FOR_ITER store
comp_iter JUMP_BACK RETURN_VALUE RETURN_LAST
setcomp_func ::= BUILD_SET_0 LOAD_FAST FOR_ITER store comp_iter
set_comp ::= BUILD_SET_0 LOAD_FAST FOR_ITER store comp_iter
JUMP_BACK RETURN_VALUE RETURN_LAST
comp_body ::= dict_comp_body

View File

@@ -50,13 +50,13 @@ class Python3Parser(PythonParser):
jb_or_c ::= JUMP_BACK
jb_or_c ::= CONTINUE
stmt ::= setcomp_func
stmt ::= set_comp
setcomp_func ::= BUILD_SET_0 LOAD_FAST FOR_ITER store comp_iter
JUMP_BACK RETURN_VALUE RETURN_LAST
set_comp ::= BUILD_SET_0 LOAD_FAST FOR_ITER store comp_iter
JUMP_BACK RETURN_VALUE RETURN_LAST
setcomp_func ::= BUILD_SET_0 LOAD_FAST FOR_ITER store comp_iter
COME_FROM JUMP_BACK RETURN_VALUE RETURN_LAST
set_comp ::= BUILD_SET_0 LOAD_FAST FOR_ITER store comp_iter
COME_FROM JUMP_BACK RETURN_VALUE RETURN_LAST
comp_body ::= dict_comp_body
comp_body ::= set_comp_body

View File

@@ -676,7 +676,7 @@ class FragmentsWalker(pysource.SourceWalker, object):
# skip over stmt return ret_expr
ast = ast[0][0][0]
store = None
if ast in ['setcomp_func', 'dictcomp_func']:
if ast in ['set_comp', 'dictcomp_func']:
# Offset 0: BUILD_SET should have the span
# of '{'
self.gen_source(ast, code_name, {})
@@ -721,8 +721,8 @@ class FragmentsWalker(pysource.SourceWalker, object):
pass
# Python 2.7+ starts including set_comp_body
# Python 3.5+ starts including setcomp_func
assert n.kind in ('lc_body', 'comp_body', 'setcomp_func', 'set_comp_body'), ast
# Python 3.5+ starts including set_comp
assert n.kind in ('lc_body', 'comp_body', 'set_comp', 'set_comp_body'), ast
assert store, "Couldn't find store in list/set comprehension"
old_name = self.name
@@ -865,8 +865,8 @@ class FragmentsWalker(pysource.SourceWalker, object):
self.prune()
# FIXME: Not sure if below is general. Also, add dict_comp_func.
# 'setcomp_func': ("%|lambda %c: {%c for %c in %c%c}\n", 1, 3, 3, 1, 4)
def n_setcomp_func(self, node):
# 'set_comp': ("%|lambda %c: {%c for %c in %c%c}\n", 1, 3, 3, 1, 4)
def n_set_comp(self, node):
setcomp_start = len(self.f.getvalue())
self.write(self.indent, "lambda ")
param_node = node[1]

View File

@@ -1296,7 +1296,7 @@ class SourceWalker(GenericASTTraversal, object):
ast = ast[0]
store = None
if ast in ['setcomp_func', 'dictcomp_func']:
if ast in ['set_comp', 'dictcomp_func']:
for k in ast:
if k == 'comp_iter':
n = k
@@ -1337,8 +1337,8 @@ class SourceWalker(GenericASTTraversal, object):
pass
# Python 2.7+ starts including set_comp_body
# Python 3.5+ starts including setcomp_func
assert n.kind in ('lc_body', 'comp_body', 'setcomp_func', 'set_comp_body'), ast
# Python 3.5+ starts including set_comp
assert n.kind in ('lc_body', 'comp_body', 'set_comp', 'set_comp_body'), ast
assert store, "Couldn't find store in list/set comprehension"
# A problem created with later Python code generation is that there