Compare commits

..

No commits in common. "7e8c297d9a74266fd714fdcab8557f940a241ac7" and "4dfea0d69d86cb0b6d9a0e075e671e3d97b8b758" have entirely different histories.

View File

@ -9,7 +9,6 @@ import org.antlr.v4.runtime.CommonTokenStream;
import org.antlr.v4.runtime.Token;
import org.antlr.v4.runtime.tree.ParseTree;
import java.io.Console;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
@ -19,15 +18,16 @@ public class Compiler {
public static void main(String[] args) throws Exception{
// todo code für jar
// if (args.length < 1) {
// System.out.println("Usage: java -jar Compiler.jar <file_path> [--suppress-details]");
// return;
// }
if (args.length < 1) {
System.out.println("Usage: java -jar Compiler.jar <file_path> [--suppress-details]");
return;
}
String filePath = args[0];
boolean suppressDetails = false;
//String filePath = args[0];
String filePath = "src/main/java/TestClass.java";
// TODO false setzen für jar-Build
boolean suppressDetails = true;
if (args.length > 1 && args[1].equals("--suppress-details")) {
suppressDetails = true;
@ -64,7 +64,7 @@ public class Compiler {
}
String readableTokens = stringBuilder.toString().trim();
System.out.println("The tokens of your input are: \n" + readableTokens + "\n");
System.out.println("The tokens of your input are: \n" + readableTokens);
}
@ -80,31 +80,26 @@ public class Compiler {
if(!suppressDetails) {
System.out.println("Parsed " + abstractSyntaxTree.classes.size() + " classes: ");
abstractSyntaxTree.classes.forEach(refType -> {
System.out.println("\t" + refType.name);
System.out.print(refType.name);
if (abstractSyntaxTree.classes.indexOf(refType) < abstractSyntaxTree.classes.size() - 1) {
System.out.print(", ");
} else {
System.out.println();
}
});
System.out.println();
}
try {
abstractSyntaxTree.typeCheck();
}catch(TypeCheckException e){
System.out.println("A TypeCheck error was found in you input. Your input was not compiled.");
System.out.println(e);
return;
}catch (Exception e){
System.out.println("A unexpected error occurred in TypeCheck.");
System.out.println(e);
}
// try {
// abstractSyntaxTree.typeCheck();
// }catch(TypeCheckException e){
// System.out.println("A TypeCheck error occurred. The compilation was stopped.");
// System.out.println(e);
// return;
// }
abstractSyntaxTree.typeCheck();
if(!suppressDetails)
System.out.println("No TypeCheck errors found.");
try {
abstractSyntaxTree.codeGen();
}catch (Exception e){
System.out.println("A error occurred during code generation. Your input was not compiled.");
System.out.println(e);
}
System.out.println("Your input was compiled. You can find the output in your current working directory.");
abstractSyntaxTree.codeGen();
System.out.println("Your input was compiled. You can find the output at ???");// todo wo output? überhaupt hinschreiben?
}
}