diff options
author | Martin Odersky <odersky@gmail.com> | 2005-05-25 16:29:18 +0000 |
---|---|---|
committer | Martin Odersky <odersky@gmail.com> | 2005-05-25 16:29:18 +0000 |
commit | b5c59169585faf8c352ed105db969e8deb590cf7 (patch) | |
tree | 0672dc159471047b9d55e38af31a976845a674fa /sources/scala/tools/nsc/Main.scala | |
parent | 6e45b64b7c55dd92da686418f65e1a415c346bf7 (diff) | |
download | scala-b5c59169585faf8c352ed105db969e8deb590cf7.tar.gz scala-b5c59169585faf8c352ed105db969e8deb590cf7.tar.bz2 scala-b5c59169585faf8c352ed105db969e8deb590cf7.zip |
a
Diffstat (limited to 'sources/scala/tools/nsc/Main.scala')
-rwxr-xr-x | sources/scala/tools/nsc/Main.scala | 26 |
1 files changed, 23 insertions, 3 deletions
diff --git a/sources/scala/tools/nsc/Main.scala b/sources/scala/tools/nsc/Main.scala index e51ea4e91d..b761e609cc 100755 --- a/sources/scala/tools/nsc/Main.scala +++ b/sources/scala/tools/nsc/Main.scala @@ -5,6 +5,7 @@ // $Id$ package scala.tools.nsc; +import java.io._; import scala.tools.util.{Position, Reporter, ConsoleReporter} /** The main class for NSC, a compiler for the programming @@ -17,6 +18,7 @@ object Main { val VERSION: String = System.getProperty("scala.version", "unknown version"); val versionMsg = PRODUCT + " " + VERSION + " -- (c) 2002-04 LAMP/EPFL"; + val prompt = "\nnsc> "; private var reporter: ConsoleReporter = _; @@ -24,18 +26,36 @@ object Main { reporter.error(new Position(PRODUCT), msg + "\n " + PRODUCT + " -help gives more information"); + def interactive(compiler: Global): unit = { + val in = new BufferedReader(new InputStreamReader(System.in)); + System.out.print(prompt); + var line = in.readLine(); + while (line.length() > 0) { + val args = List.fromString(line, ' '); + val command = new CompilerCommand(args, error, true); + compiler.compile(command.files); + System.out.print(prompt); + line = in.readLine(); + } + } + def process(args: Array[String]): unit = { reporter = new ConsoleReporter(); - val command = new CompilerCommand(args, error); + val command = new CompilerCommand(List.fromArray(args), error, false); reporter.prompt(command.settings.prompt.value); if (command.settings.version.value) reporter.info(null, versionMsg, true) - else if (command.settings.help.value || command.files.isEmpty) + else if (command.settings.help.value) reporter.info(null, command.usageMsg, true) else { try { val compiler = new Global(command.settings, reporter); - compiler.compile(command.files); + if (command.settings.interactive.value) + interactive(compiler); + else if (command.files.isEmpty) + reporter.info(null, command.usageMsg, true) + else + compiler.compile(command.files); } catch { case ex @ FatalError(msg) => if (command.settings.debug.value) |