From c19726b180758dc3b9d4dd070dff626fce5836d7 Mon Sep 17 00:00:00 2001 From: Martin Odersky Date: Fri, 10 Feb 2006 14:49:29 +0000 Subject: --- src/compiler/scala/tools/nsc/ast/parser/Parsers.scala | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) (limited to 'src/compiler/scala/tools/nsc/ast/parser/Parsers.scala') diff --git a/src/compiler/scala/tools/nsc/ast/parser/Parsers.scala b/src/compiler/scala/tools/nsc/ast/parser/Parsers.scala index 5f74667dc4..329b2604c7 100644 --- a/src/compiler/scala/tools/nsc/ast/parser/Parsers.scala +++ b/src/compiler/scala/tools/nsc/ast/parser/Parsers.scala @@ -931,21 +931,25 @@ mixin class Parsers requires SyntaxAnalyzer { * Enumerator ::= Generator * | Expr */ - def enumerators(): List[Tree] = { - val enums = new ListBuffer[Tree] + generator(); + def enumerators(): List[Enumerator] = { + val enums = new ListBuffer[Enumerator] + generator(false); while (in.token == SEMI || in.token == NEWLINE) { in.nextToken(); - enums += (if (in.token == VAL) generator() else expr()) + enums += (if (in.token == VAL) generator(true) else Filter(expr())) } enums.toList } /** Generator ::= val Pattern1 `<-' Expr */ - def generator(): Tree = - atPos(accept(VAL)) { - makeGenerator(pattern1(false), { accept(LARROW); expr() }) - } + def generator(eqOK: boolean): Enumerator = { + val pos = accept(VAL); + val pat = pattern1(false); + val tok = in.token; + if (tok == EQUALS && eqOK) in.nextToken() + else accept(LARROW); + makeGenerator(pos, pat, tok == EQUALS, expr) + } //////// PATTERNS //////////////////////////////////////////////////////////// -- cgit v1.2.3