diff options
author | Martin Odersky <odersky@gmail.com> | 2006-02-10 14:49:29 +0000 |
---|---|---|
committer | Martin Odersky <odersky@gmail.com> | 2006-02-10 14:49:29 +0000 |
commit | c19726b180758dc3b9d4dd070dff626fce5836d7 (patch) | |
tree | a714012c48e571f209f135ce99d910d3fe0bc7b3 /src/compiler/scala/tools/nsc/ast/parser/Parsers.scala | |
parent | 5ea297c2becd1d277e8fbe16a6046b4967ce870c (diff) | |
download | scala-c19726b180758dc3b9d4dd070dff626fce5836d7.tar.gz scala-c19726b180758dc3b9d4dd070dff626fce5836d7.tar.bz2 scala-c19726b180758dc3b9d4dd070dff626fce5836d7.zip |
Diffstat (limited to 'src/compiler/scala/tools/nsc/ast/parser/Parsers.scala')
-rw-r--r-- | src/compiler/scala/tools/nsc/ast/parser/Parsers.scala | 18 |
1 files changed, 11 insertions, 7 deletions
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 //////////////////////////////////////////////////////////// |