summaryrefslogtreecommitdiff
path: root/src/compiler/scala/tools/nsc/ast/parser/Parsers.scala
diff options
context:
space:
mode:
authorMartin Odersky <odersky@gmail.com>2006-06-20 16:34:51 +0000
committerMartin Odersky <odersky@gmail.com>2006-06-20 16:34:51 +0000
commit4d929158efa9a6e95df14c399091a0f213aebf2d (patch)
tree488270edb1eed025a96c1655e8cc139951d84839 /src/compiler/scala/tools/nsc/ast/parser/Parsers.scala
parent640ea6fc45b860e85b588d3217df61d087d674ba (diff)
downloadscala-4d929158efa9a6e95df14c399091a0f213aebf2d.tar.gz
scala-4d929158efa9a6e95df14c399091a0f213aebf2d.tar.bz2
scala-4d929158efa9a6e95df14c399091a0f213aebf2d.zip
Fixed parsing problem for closures
Diffstat (limited to 'src/compiler/scala/tools/nsc/ast/parser/Parsers.scala')
-rw-r--r--src/compiler/scala/tools/nsc/ast/parser/Parsers.scala21
1 files changed, 16 insertions, 5 deletions
diff --git a/src/compiler/scala/tools/nsc/ast/parser/Parsers.scala b/src/compiler/scala/tools/nsc/ast/parser/Parsers.scala
index 5107db14ee..ce885459a9 100644
--- a/src/compiler/scala/tools/nsc/ast/parser/Parsers.scala
+++ b/src/compiler/scala/tools/nsc/ast/parser/Parsers.scala
@@ -608,9 +608,9 @@ trait Parsers requires SyntaxAnalyzer {
ts.toList
}
- /** Expr ::= Bindings `=>' Expr
+ /** Expr ::= (Bindings | Id) `=>' Expr
* | Expr1
- * ResultExpr ::= Bindings `=>' Block
+ * ResultExpr ::= (Bindings | Id `:' Type1) `=>' Block
* | Expr1
* Expr1 ::= if (' Expr `)' [NewLine] Expr [[`;'] else Expr]
* | try `{' block `}' [catch `{' caseClauses `}'] [finally Expr]
@@ -625,8 +625,7 @@ trait Parsers requires SyntaxAnalyzer {
* | PostfixExpr [`:' Type1]
* | PostfixExpr match `{' CaseClauses `}'
* | MethodClosure
- * Bindings ::= Id [`:' Type1]
- * | `(' [Binding {`,' Binding}] `)'
+ * Bindings ::= `(' [Binding {`,' Binding}] `)'
* Binding ::= Id [`:' Type]
*/
def expr(): Tree =
@@ -726,7 +725,19 @@ trait Parsers requires SyntaxAnalyzer {
syntaxError(in.currentPos, "`*' expected", true);
}
} else {
- t = atPos(pos) { Typed(t, type1()) }
+ t = atPos(pos) { Typed(t, if (isInBlock) type1() else typ()) }
+ if (isInBlock && in.token == COMMA) {
+ val vdefs = new ListBuffer[ValDef];
+ while (in.token == COMMA) {
+ in.nextToken();
+ vdefs += ValDef(Modifiers(Flags.PARAM), ident(), typedOpt(), EmptyTree)
+ }
+ if (in.token == ARROW) {
+ t = atPos(in.skipToken()) {
+ Function(convertToParams(t) ::: vdefs.toList, block())
+ }
+ } else syntaxError(in.currentPos, "`=>' expected", true)
+ }
}
} else if (in.token == MATCH) {
t = atPos(in.skipToken()) {