diff options
author | michelou <michelou@epfl.ch> | 2005-09-28 16:07:44 +0000 |
---|---|---|
committer | michelou <michelou@epfl.ch> | 2005-09-28 16:07:44 +0000 |
commit | 7314eaba5ef183cfd9e1ab779b29efc85d10950b (patch) | |
tree | a9089a281caadffd0cecce6b8ce8d013b8eed515 /sources/scala/tools/nsc/Main.scala | |
parent | cc54f727041e4a0a814004ea48d70562d3602fcc (diff) | |
download | scala-7314eaba5ef183cfd9e1ab779b29efc85d10950b.tar.gz scala-7314eaba5ef183cfd9e1ab779b29efc85d10950b.tar.bz2 scala-7314eaba5ef183cfd9e1ab779b29efc85d10950b.zip |
- adapted Moez'code to new option 'interprete'.
- added private method 'loop'.
Diffstat (limited to 'sources/scala/tools/nsc/Main.scala')
-rwxr-xr-x | sources/scala/tools/nsc/Main.scala | 29 |
1 files changed, 28 insertions, 1 deletions
diff --git a/sources/scala/tools/nsc/Main.scala b/sources/scala/tools/nsc/Main.scala index 9c158c85b1..3f96e66799 100755 --- a/sources/scala/tools/nsc/Main.scala +++ b/sources/scala/tools/nsc/Main.scala @@ -24,11 +24,23 @@ object Main { def error(msg: String): unit = reporter.error(new Position(PRODUCT), - msg + "\n " + PRODUCT + " -help gives more information"); + msg + "\n " + PRODUCT + " -help gives more information"); def errors() = reporter.errors(); + private def loop(action: (String) => Unit): unit = { + val in = new BufferedReader(new InputStreamReader(System.in)); + System.out.print(prompt); + var line = in.readLine(); + while (line != null && line.length() > 0) { + action(line); + System.out.print(prompt); + line = in.readLine(); + } + } + def resident(compiler: Global): unit = { +/* val in = new BufferedReader(new InputStreamReader(System.in)); System.out.print(prompt); var line = in.readLine(); @@ -39,6 +51,19 @@ object Main { System.out.print(prompt); line = in.readLine(); } +*/ + loop(line => { + val args = List.fromString(line, ' '); + val command = new CompilerCommand(args, error, true); + (new compiler.Run) compile command.files + }) + } + + def interprete(gCompiler: Global): unit = { + val interpreter = new Interpreter { + val compiler: gCompiler.type = gCompiler + }; + loop(line => interpreter.interpret(line.trim(), reporter)) } def process(args: Array[String]): unit = { @@ -54,6 +79,8 @@ object Main { val compiler = new Global(command.settings, reporter); if (command.settings.resident.value) resident(compiler); + else if (command.settings.interprete.value) + interprete(compiler); else if (command.files.isEmpty) reporter.info(null, command.usageMsg, true) else |