diff options
author | Martin Odersky <odersky@gmail.com> | 2006-06-20 16:34:51 +0000 |
---|---|---|
committer | Martin Odersky <odersky@gmail.com> | 2006-06-20 16:34:51 +0000 |
commit | 4d929158efa9a6e95df14c399091a0f213aebf2d (patch) | |
tree | 488270edb1eed025a96c1655e8cc139951d84839 /src/compiler | |
parent | 640ea6fc45b860e85b588d3217df61d087d674ba (diff) | |
download | scala-4d929158efa9a6e95df14c399091a0f213aebf2d.tar.gz scala-4d929158efa9a6e95df14c399091a0f213aebf2d.tar.bz2 scala-4d929158efa9a6e95df14c399091a0f213aebf2d.zip |
Fixed parsing problem for closures
Diffstat (limited to 'src/compiler')
-rw-r--r-- | src/compiler/scala/tools/ant/Scalac.scala | 6 | ||||
-rw-r--r-- | src/compiler/scala/tools/ant/Scaladoc.scala | 2 | ||||
-rw-r--r-- | src/compiler/scala/tools/nsc/CompileSocket.scala | 2 | ||||
-rw-r--r-- | src/compiler/scala/tools/nsc/ast/parser/Parsers.scala | 21 | ||||
-rw-r--r-- | src/compiler/scala/tools/nsc/io/PlainFile.scala | 2 |
5 files changed, 22 insertions, 11 deletions
diff --git a/src/compiler/scala/tools/ant/Scalac.scala b/src/compiler/scala/tools/ant/Scalac.scala index 9632094102..0db460b084 100644 --- a/src/compiler/scala/tools/ant/Scalac.scala +++ b/src/compiler/scala/tools/ant/Scalac.scala @@ -255,7 +255,7 @@ package scala.tools.ant { /** Sets the log attribute. Used by Ant. * @param input The value for <code>logPhase</code>. */ def setLogPhase(input: String) = { - logPhase = List.fromArray(input.split(",")).flatMap(s: String => { + logPhase = List.fromArray(input.split(",")).flatMap { s: String => val st = s.trim() if (CompilerPhase.isPermissible(st)) (if (input != "") List(st) else Nil) @@ -263,7 +263,7 @@ package scala.tools.ant { error("Phase " + st + " in log does not exist.") Nil } - }) + } } /** Sets the use predefs attribute. Used by Ant. @@ -479,7 +479,7 @@ package scala.tools.ant { // Compiles the actual code val compiler = new Global(settings, reporter) try { - (new compiler.Run).compile(sourceFiles.map(f:File=>f.toString())) + (new compiler.Run).compile(sourceFiles.map { f:File=>f.toString() }) } catch { case exception: Throwable if (exception.getMessage != null) => exception.printStackTrace() diff --git a/src/compiler/scala/tools/ant/Scaladoc.scala b/src/compiler/scala/tools/ant/Scaladoc.scala index 4e7581c6f4..08ddbfb320 100644 --- a/src/compiler/scala/tools/ant/Scaladoc.scala +++ b/src/compiler/scala/tools/ant/Scaladoc.scala @@ -390,7 +390,7 @@ package scala.tools.ant { object compiler extends Global(settings, reporter) try { val run = new compiler.Run - run.compile(sourceFiles.map(f: File => f.toString())) + run.compile(sourceFiles.map { f: File => f.toString() }) object generator extends DocGenerator { val global = compiler def outdir = settings.outdir.value diff --git a/src/compiler/scala/tools/nsc/CompileSocket.scala b/src/compiler/scala/tools/nsc/CompileSocket.scala index 207df561bf..32683d9029 100644 --- a/src/compiler/scala/tools/nsc/CompileSocket.scala +++ b/src/compiler/scala/tools/nsc/CompileSocket.scala @@ -14,7 +14,7 @@ object CompileSocket { private val dirName = "scalac-compile-server-port" /** The vm-part of the command to start a new scala compile server */ - private val vmCommand = "scala" + private val vmCommand = "java" /** The class name of the scala compile server */ private val serverClass = "scala.tools.nsc.CompileServer" 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()) { diff --git a/src/compiler/scala/tools/nsc/io/PlainFile.scala b/src/compiler/scala/tools/nsc/io/PlainFile.scala index 5ab83c447f..60f8ad4f7f 100644 --- a/src/compiler/scala/tools/nsc/io/PlainFile.scala +++ b/src/compiler/scala/tools/nsc/io/PlainFile.scala @@ -83,7 +83,7 @@ class PlainFile(val file: File) extends AbstractFile { assert(isDirectory, "not a directory '" + this + "'"); val names: Array[String] = file.list(); if (names == null || names.length == 0) Iterator.empty; - else Iterator.fromArray(names).map(name: String => new File(file, name)) + else Iterator.fromArray(names).map { name: String => new File(file, name) } .filter(.exists()).map(file => new PlainFile(file)) } |