summaryrefslogtreecommitdiff
path: root/sources
diff options
context:
space:
mode:
authormichelou <michelou@epfl.ch>2005-09-27 14:59:20 +0000
committermichelou <michelou@epfl.ch>2005-09-27 14:59:20 +0000
commita23a5c8b04883f150ff6c356adf42a1b0891a2a5 (patch)
treea15ec4535e37fd8c9ab876f1f524a26b6e9ad58b /sources
parent288e0c04acc07d40f2e360e5b53fb43ea328a922 (diff)
downloadscala-a23a5c8b04883f150ff6c356adf42a1b0891a2a5.tar.gz
scala-a23a5c8b04883f150ff6c356adf42a1b0891a2a5.tar.bz2
scala-a23a5c8b04883f150ff6c356adf42a1b0891a2a5.zip
- added Moez's changes for Scala interpreter.
Diffstat (limited to 'sources')
-rwxr-xr-xsources/scala/tools/nsc/Main.scala34
-rw-r--r--sources/scala/tools/nsc/ast/parser/SyntaxAnalyzer.scala5
2 files changed, 22 insertions, 17 deletions
diff --git a/sources/scala/tools/nsc/Main.scala b/sources/scala/tools/nsc/Main.scala
index 8403dc954d..686b077372 100755
--- a/sources/scala/tools/nsc/Main.scala
+++ b/sources/scala/tools/nsc/Main.scala
@@ -24,18 +24,19 @@ 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();
- def interactive(compiler: Global): unit = {
+ def interactive(gCompiler: Global): unit = {
val in = new BufferedReader(new InputStreamReader(System.in));
+ val interpreter = new Interpreter {
+ val compiler: gCompiler.type = gCompiler
+ };
System.out.print(prompt);
var line = in.readLine();
while (line != null && line.length() > 0) {
- val args = List.fromString(line, ' ');
- val command = new CompilerCommand(args, error, true);
- compiler.compile(command.files);
+ interpreter.interpret(line.trim(), reporter);
System.out.print(prompt);
line = in.readLine();
}
@@ -51,18 +52,18 @@ object Main {
reporter.info(null, command.usageMsg, true)
else {
try {
- val compiler = new Global(command.settings, reporter);
- if (command.settings.interactive.value)
- interactive(compiler);
- else if (command.files.isEmpty)
- reporter.info(null, command.usageMsg, true)
- else
- compiler.compile(command.files);
+ val compiler = new Global(command.settings, reporter);
+ 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)
- ex.printStackTrace();
- reporter.error(null, "fatal error: " + msg);
+ case ex @ FatalError(msg) =>
+ if (command.settings.debug.value)
+ ex.printStackTrace();
+ reporter.error(null, "fatal error: " + msg);
}
reporter.printSummary()
}
@@ -72,5 +73,4 @@ object Main {
process(args);
System.exit(if (reporter.errors() > 0) 1 else 0);
}
-
}
diff --git a/sources/scala/tools/nsc/ast/parser/SyntaxAnalyzer.scala b/sources/scala/tools/nsc/ast/parser/SyntaxAnalyzer.scala
index 5609cee6bd..641a14abf6 100644
--- a/sources/scala/tools/nsc/ast/parser/SyntaxAnalyzer.scala
+++ b/sources/scala/tools/nsc/ast/parser/SyntaxAnalyzer.scala
@@ -16,5 +16,10 @@ abstract class SyntaxAnalyzer extends SubComponent with Parsers with Scanners {
unit.body = new Parser(unit).parse();
}
}
+ //Moez addition. I wished not to add/modify here, but the fact that Parsers
+ // are NOT accessible (because of Parsers' self type) except in SyntaxAnalyzer
+ // had bitten me, and thus I had to add the following code here.
+ def interpreterParse(unit: global.CompilationUnit): List[global.Tree] =
+ new Parser(unit).templateStatSeq()
}