Commit 8efa5df2 authored by Stefan Behnel's avatar Stefan Behnel

fix tuple parsing after last commit, some cleanup

parent 5b60eb8b
...@@ -918,11 +918,8 @@ def p_testlist(s): ...@@ -918,11 +918,8 @@ def p_testlist(s):
pos = s.position() pos = s.position()
expr = p_test(s) expr = p_test(s)
if s.sy == ',': if s.sy == ',':
exprs = [expr] s.next()
while s.sy == ',': return p_testlist_tuple(s, pos, expr)
s.next()
exprs.append(p_test(s))
return ExprNodes.TupleNode(pos, args = exprs)
else: else:
return expr return expr
...@@ -930,18 +927,24 @@ def p_testlist(s): ...@@ -930,18 +927,24 @@ def p_testlist(s):
def p_testlist_comp(s): def p_testlist_comp(s):
pos = s.position() pos = s.position()
expr = p_simple_expr(s) expr = p_test(s)
if s.sy == ',': if s.sy == ',':
exprs = [expr] s.next()
while s.sy == ',': return p_testlist_tuple(s, pos, expr)
s.next()
exprs.append(p_test(s))
return ExprNodes.TupleNode(pos, args = exprs)
elif s.sy == 'for': elif s.sy == 'for':
return p_genexp(s, expr) return p_genexp(s, expr)
else: else:
return expr return expr
def p_testlist_tuple(s, pos, expr):
exprs = [expr]
while s.sy not in expr_terminators:
exprs.append(p_test(s))
if s.sy != ',':
break
s.next()
return ExprNodes.TupleNode(pos, args = exprs)
def p_genexp(s, expr): def p_genexp(s, expr):
# s.sy == 'for' # s.sy == 'for'
loop = p_comp_for(s, ExprNodes.YieldExprNode(expr.pos, arg=expr)) loop = p_comp_for(s, ExprNodes.YieldExprNode(expr.pos, arg=expr))
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment