From 8efa5df286e3ea447981a3b0b8b3f2ef70d790dd Mon Sep 17 00:00:00 2001 From: Stefan Behnel Date: Thu, 6 May 2010 22:47:57 +0200 Subject: [PATCH] fix tuple parsing after last commit, some cleanup --- Cython/Compiler/Parsing.py | 25 ++++++++++++++----------- 1 file changed, 14 insertions(+), 11 deletions(-) diff --git a/Cython/Compiler/Parsing.py b/Cython/Compiler/Parsing.py index 4fc861f3..fb25b2c8 100644 --- a/Cython/Compiler/Parsing.py +++ b/Cython/Compiler/Parsing.py @@ -918,11 +918,8 @@ def p_testlist(s): pos = s.position() expr = p_test(s) if s.sy == ',': - exprs = [expr] - while s.sy == ',': - s.next() - exprs.append(p_test(s)) - return ExprNodes.TupleNode(pos, args = exprs) + s.next() + return p_testlist_tuple(s, pos, expr) else: return expr @@ -930,18 +927,24 @@ def p_testlist(s): def p_testlist_comp(s): pos = s.position() - expr = p_simple_expr(s) + expr = p_test(s) if s.sy == ',': - exprs = [expr] - while s.sy == ',': - s.next() - exprs.append(p_test(s)) - return ExprNodes.TupleNode(pos, args = exprs) + s.next() + return p_testlist_tuple(s, pos, expr) elif s.sy == 'for': return p_genexp(s, expr) else: 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): # s.sy == 'for' loop = p_comp_for(s, ExprNodes.YieldExprNode(expr.pos, arg=expr)) -- 2.26.2