|
|
|
@ -34,6 +34,8 @@ public class Compiler { |
|
|
|
|
/** The filename for the object program, normally obj.tam. */ |
|
|
|
|
static String objectName = "obj.tam"; |
|
|
|
|
|
|
|
|
|
static boolean showTree = false; |
|
|
|
|
|
|
|
|
|
private static Scanner scanner; |
|
|
|
|
private static Parser parser; |
|
|
|
|
private static Checker checker; |
|
|
|
@ -114,16 +116,29 @@ public class Compiler { |
|
|
|
|
public static void main(String[] args) { |
|
|
|
|
|
|
|
|
|
if (args.length < 1) { |
|
|
|
|
System.out.println("Usage: tc filename [tree]"); |
|
|
|
|
System.out.println("Usage: tc filename [-o=outputfilename] [tree]"); |
|
|
|
|
System.exit(1); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
parseArgs(args); |
|
|
|
|
|
|
|
|
|
String sourceName = args[0]; |
|
|
|
|
boolean tree = (args.length > 1 && args[1].equalsIgnoreCase("tree")); |
|
|
|
|
var compiledOK = compileProgram(sourceName, objectName, tree, false); |
|
|
|
|
|
|
|
|
|
if (!tree) { |
|
|
|
|
var compiledOK = compileProgram(sourceName, objectName, showTree, false); |
|
|
|
|
|
|
|
|
|
if (!showTree) { |
|
|
|
|
System.exit(compiledOK ? 0 : 1); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
private static void parseArgs(String[] args) { |
|
|
|
|
for (String s : args) { |
|
|
|
|
var sl = s.toLowerCase(); |
|
|
|
|
if (sl.equals("tree")) { |
|
|
|
|
showTree = true; |
|
|
|
|
} else if (sl.startsWith("-o=")) { |
|
|
|
|
objectName = s.substring(3); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|