diff options
author | michelou <michelou@epfl.ch> | 2006-03-06 12:45:14 +0000 |
---|---|---|
committer | michelou <michelou@epfl.ch> | 2006-03-06 12:45:14 +0000 |
commit | 750b48f0916b6847834cc4bfc7e6a748fa49bc26 (patch) | |
tree | 347a00c3297deb74264a064218bed62c902f3b90 | |
parent | 31b6aecca77ca376f28cb139e87635032356cd3a (diff) | |
download | scala-750b48f0916b6847834cc4bfc7e6a748fa49bc26.tar.gz scala-750b48f0916b6847834cc4bfc7e6a748fa49bc26.tar.bz2 scala-750b48f0916b6847834cc4bfc7e6a748fa49bc26.zip |
removed implicit import of java.io.Console (Jav...
removed implicit import of java.io.Console (Java 6), cleaned up code
(copyright, tabs, ..)
-rw-r--r-- | src/compiler/scala/tools/nsc/MainInterpreter.scala | 48 |
1 files changed, 22 insertions, 26 deletions
diff --git a/src/compiler/scala/tools/nsc/MainInterpreter.scala b/src/compiler/scala/tools/nsc/MainInterpreter.scala index 4727cd8cc9..13518b51c1 100644 --- a/src/compiler/scala/tools/nsc/MainInterpreter.scala +++ b/src/compiler/scala/tools/nsc/MainInterpreter.scala @@ -1,11 +1,11 @@ -/* NSC -- new scala compiler - * Copyright 2005 LAMP/EPFL +/* NSC -- new Scala compiler + * Copyright 2005-2006 LAMP/EPFL * @author emir */ // $Id$ package scala.tools.nsc -import java.io._ +import java.io.{BufferedReader, FileReader, IOException, InputStreamReader} import scala.tools.nsc.util.{Position} import scala.tools.nsc.reporters.{Reporter, ConsoleReporter} @@ -35,11 +35,10 @@ object MainInterpreter { while(true) { Console.print("\nscala> ") var line = in.readLine() - if(line == null) + if(line == null) return () // assumes null means EOF val keepGoing = evpr(line) - if(!keepGoing) return () // the evpr function said to stop } @@ -49,12 +48,11 @@ object MainInterpreter { def interpretOne(line: String): Unit = { try { interpreter.interpret(line) - } catch { - case e: Exception => { - reporter.info(null,"Exception occurred: " + e.getMessage(),true) - //e.printStackTrace() - } - } + } catch { + case e: Exception => + reporter.info(null, "Exception occurred: " + e.getMessage(), true) + //e.printStackTrace() + } } /** interpret all lines from a specified file */ @@ -63,14 +61,14 @@ object MainInterpreter { new FileReader(filename) } catch { case _:IOException => - Console.println("Error opening file: " + filename) - null + Console.println("Error opening file: " + filename) + null } - if(fileIn == null) return () + if (fileIn == null) return () val in = new BufferedReader(fileIn) while(true) { val line = in.readLine - if(line == null) { + if (line == null) { fileIn.close return () } @@ -80,9 +78,9 @@ object MainInterpreter { /** run one command submitted by the user */ def command(line: String): Boolean = { - def withFile(command: String)(action: String=>Unit): Unit = { + def withFile(command: String)(action: String => Unit): Unit = { val spaceIdx = command.indexOf(' ') - if(spaceIdx <= 0) { + if (spaceIdx <= 0) { Console.println("That command requires a filename to be specified.") return () } @@ -90,7 +88,7 @@ object MainInterpreter { action(filename) } - if(line.startsWith(":")) + if (line.startsWith(":")) line match { case ":help" => printHelp case ":quit" => return false @@ -103,30 +101,28 @@ object MainInterpreter { true } - - /** the main interpreter loop */ def interpretLoop(compiler: Global): unit = { - interpreter = new Interpreter(compiler, str=>Console.print(str)) + interpreter = new Interpreter(compiler, str => Console.print(str)) repl(command) interpreter.close } - - /** process the command-line arguments and do as they request */ - def process(args: Array[String]): unit = { + def process(args: Array[String]): Unit = { val command = new CompilerCommand(List.fromArray(args), error, false) reporter.prompt = command.settings.prompt.value if (command.settings.help.value) { reporter.info(null, command.usageMsg, true) - } else { + } + else { printHelp interpretLoop(new Global(command.settings, reporter)) } } - def main(args: Array[String]): unit = { + def main(args: Array[String]): Unit = { process(args) } + } |