blob: e51ea4e91d0db66b66d9e02513013a61f43bd615 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
|
/* NSC -- new scala compiler
* Copyright 2005 LAMP/EPFL
* @author Martin Odersky
*/
// $Id$
package scala.tools.nsc;
import scala.tools.util.{Position, Reporter, ConsoleReporter}
/** The main class for NSC, a compiler for the programming
* language Scala.
*/
object Main {
val PRODUCT: String =
System.getProperty("scala.product", "scalac");
val VERSION: String =
System.getProperty("scala.version", "unknown version");
val versionMsg = PRODUCT + " " + VERSION + " -- (c) 2002-04 LAMP/EPFL";
private var reporter: ConsoleReporter = _;
def error(msg: String): unit =
reporter.error(new Position(PRODUCT),
msg + "\n " + PRODUCT + " -help gives more information");
def process(args: Array[String]): unit = {
reporter = new ConsoleReporter();
val command = new CompilerCommand(args, error);
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)
reporter.info(null, command.usageMsg, true)
else {
try {
val compiler = new Global(command.settings, reporter);
compiler.compile(command.files);
} catch {
case ex @ FatalError(msg) =>
if (command.settings.debug.value)
ex.printStackTrace();
reporter.error(null, "fatal error: " + msg);
}
reporter.printSummary()
}
}
def main(args: Array[String]): unit = {
process(args);
System.exit(if (reporter.errors() > 0) 1 else 0);
}
}
|