in src/compiler/Compiler.java [184:266]
public static void main(String argv[]) throws Exception {
Compiler comp = new Compiler();
String out = ".";
String amdir = null;
boolean stackTrace = false;
LinkedList<String> plsrc = new LinkedList<>();
int argi = 0;
for (; argi < argv.length; argi++) {
String a = argv[argi];
if (a.equals("--")) {
argi++;
break;
}
if (a.equals("-O")) {
comp.enableDefaultOptions();
} else if (a.equals("-O:none")) {
comp.options.clear();
} else if (a.startsWith("-O:")) {
String optname = a.substring("-O:".length());
Option opt = findOptionByName(optname);
if (opt != null)
comp.enable(opt);
} else if (a.equals("-s")) {
if (++argi == argv.length)
usage();
out = argv[argi];
} else if (a.equals("-am")) {
if (++argi == argv.length)
usage();
amdir = argv[argi];
} else if (a.equals("-h") || a.equals("--help") || a.equals("-help")) {
usage();
} else if (a.equals("--show-stack-trace")) {
stackTrace = true;
} else if (a.startsWith("-")) {
System.err.println("error: Unsupported flag '" + a + "'");
usage();
} else {
plsrc.add(a);
}
}
if (argi < argv.length)
plsrc.addAll(Arrays.asList(argv).subList(argi, argv.length));
if (plsrc.isEmpty())
usage();
banner();
for (String pl : plsrc) {
System.err.println("Translating " + pl);
try {
if (amdir != null) {
String base;
if (pl.endsWith(".pl"))
base = pl.substring(0, pl.length() - 3);
else
base = pl;
File am = new File(new File(amdir), base + ".am");
am.getParentFile().mkdirs();
comp.prologToWAM(pl, am.getPath());
comp.wamToJavaSource(am.getPath(), out);
} else {
comp.prologToJavaSource(pl, out);
}
} catch (CompileException err) {
if (stackTrace)
err.printStackTrace();
else
System.err.println("error: " + err.getMessage());
System.exit(1);
}
}
}