diff options
author | paltherr <paltherr@epfl.ch> | 2003-07-18 14:23:52 +0000 |
---|---|---|
committer | paltherr <paltherr@epfl.ch> | 2003-07-18 14:23:52 +0000 |
commit | 5df0cb2c74dccc7983397bde2e2511618fc57f7c (patch) | |
tree | 18def27dada86c51bdd963015bb398a6d5e244bb /sources | |
parent | 323f6c89615f3098b09073e84fb36709beb020a5 (diff) | |
download | scala-5df0cb2c74dccc7983397bde2e2511618fc57f7c.tar.gz scala-5df0cb2c74dccc7983397bde2e2511618fc57f7c.tar.bz2 scala-5df0cb2c74dccc7983397bde2e2511618fc57f7c.zip |
- Added flag -c to siris & surus
Diffstat (limited to 'sources')
-rw-r--r-- | sources/scala/tools/scalai/InterpreterCommand.java | 11 | ||||
-rw-r--r-- | sources/scala/tools/scalai/InterpreterShell.java | 16 | ||||
-rw-r--r-- | sources/scala/tools/scalai/Main.java | 2 |
3 files changed, 18 insertions, 11 deletions
diff --git a/sources/scala/tools/scalai/InterpreterCommand.java b/sources/scala/tools/scalai/InterpreterCommand.java index a95f529879..9b538d5b49 100644 --- a/sources/scala/tools/scalai/InterpreterCommand.java +++ b/sources/scala/tools/scalai/InterpreterCommand.java @@ -12,6 +12,7 @@ package scalai; import scalac.PhaseRepository; import scalac.CompilerCommand; import scalac.util.Reporter; +import scalac.util.StringOptionParser; import scalac.util.BooleanOptionParser; import scalac.util.ScalaProgramArgumentParser; @@ -20,6 +21,7 @@ public class InterpreterCommand extends CompilerCommand { //######################################################################## // Public Fields + public final StringOptionParser script; public final BooleanOptionParser interactive; public final BooleanOptionParser emacs; public final ScalaProgramArgumentParser program; @@ -39,6 +41,10 @@ public class InterpreterCommand extends CompilerCommand { { super(product, version, syntax, reporter, phases); + this.script = new StringOptionParser(this, + "c", "Evaluate <string> and print result", + "string", null); + this.interactive = new BooleanOptionParser(this, "interactive", "Start interpreter in interactive mode", false); @@ -52,8 +58,9 @@ public class InterpreterCommand extends CompilerCommand { remove(outpath); remove(target); - add(0, interactive); - add(1, emacs); + add(0, script); + add(1, interactive); + add(2, emacs); add(parsers().indexOf(unknown_options), program); } diff --git a/sources/scala/tools/scalai/InterpreterShell.java b/sources/scala/tools/scalai/InterpreterShell.java index a762ee11f5..43be36f97a 100644 --- a/sources/scala/tools/scalai/InterpreterShell.java +++ b/sources/scala/tools/scalai/InterpreterShell.java @@ -86,16 +86,16 @@ public class InterpreterShell { //######################################################################## // Public Methods - shell - public void main(String[] program, String main, String[] args) { + public void main(String[] files, String script, String main, String[]args){ if (interactive) showBanner(); - if (program.length > 0) load(lfiles = program); + if (files.length > 0) load(lfiles = files); global.stop("total"); // !!! remove ? - if (global.reporter.errors() == 0) { - if (main != null) call(main, args); - } else { - if (!interactive) global.reporter.printSummary(); - } - if (interactive) loop(); + if (global.reporter.errors() == 0 && script != null) eval(script); + if (global.reporter.errors() == 0 && main != null) call(main, args); + if (interactive) + loop(); + else + global.reporter.printSummary(); } public void loop() { diff --git a/sources/scala/tools/scalai/Main.java b/sources/scala/tools/scalai/Main.java index 9fcfbc5f30..a5c3dfda77 100644 --- a/sources/scala/tools/scalai/Main.java +++ b/sources/scala/tools/scalai/Main.java @@ -31,7 +31,7 @@ public class Main { PRODUCT, VERSION, reporter, new PhaseRepository()); if (command.parse(args)) { InterpreterShell shell = new InterpreterShell(command); - shell.main(command.files.toArray(), + shell.main(command.files.toArray(), command.script.value, command.program.main, command.program.args); } System.exit((reporter.errors() > 0) ? 1 : 0); |