Compare commits
No commits in common. "7e8c297d9a74266fd714fdcab8557f940a241ac7" and "4dfea0d69d86cb0b6d9a0e075e671e3d97b8b758" have entirely different histories.
7e8c297d9a
...
4dfea0d69d
@ -9,7 +9,6 @@ import org.antlr.v4.runtime.CommonTokenStream;
|
|||||||
import org.antlr.v4.runtime.Token;
|
import org.antlr.v4.runtime.Token;
|
||||||
import org.antlr.v4.runtime.tree.ParseTree;
|
import org.antlr.v4.runtime.tree.ParseTree;
|
||||||
|
|
||||||
import java.io.Console;
|
|
||||||
import java.nio.file.Files;
|
import java.nio.file.Files;
|
||||||
import java.nio.file.Path;
|
import java.nio.file.Path;
|
||||||
import java.nio.file.Paths;
|
import java.nio.file.Paths;
|
||||||
@ -19,15 +18,16 @@ public class Compiler {
|
|||||||
|
|
||||||
public static void main(String[] args) throws Exception{
|
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) {
|
//String filePath = args[0];
|
||||||
System.out.println("Usage: java -jar Compiler.jar <file_path> [--suppress-details]");
|
String filePath = "src/main/java/TestClass.java";
|
||||||
return;
|
// TODO false setzen für jar-Build
|
||||||
}
|
boolean suppressDetails = true;
|
||||||
|
|
||||||
String filePath = args[0];
|
|
||||||
|
|
||||||
boolean suppressDetails = false;
|
|
||||||
|
|
||||||
if (args.length > 1 && args[1].equals("--suppress-details")) {
|
if (args.length > 1 && args[1].equals("--suppress-details")) {
|
||||||
suppressDetails = true;
|
suppressDetails = true;
|
||||||
@ -64,7 +64,7 @@ public class Compiler {
|
|||||||
}
|
}
|
||||||
String readableTokens = stringBuilder.toString().trim();
|
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) {
|
if(!suppressDetails) {
|
||||||
System.out.println("Parsed " + abstractSyntaxTree.classes.size() + " classes: ");
|
System.out.println("Parsed " + abstractSyntaxTree.classes.size() + " classes: ");
|
||||||
abstractSyntaxTree.classes.forEach(refType -> {
|
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 {
|
||||||
try {
|
// abstractSyntaxTree.typeCheck();
|
||||||
abstractSyntaxTree.typeCheck();
|
// }catch(TypeCheckException e){
|
||||||
}catch(TypeCheckException e){
|
// System.out.println("A TypeCheck error occurred. The compilation was stopped.");
|
||||||
System.out.println("A TypeCheck error was found in you input. Your input was not compiled.");
|
// System.out.println(e);
|
||||||
System.out.println(e);
|
// return;
|
||||||
return;
|
// }
|
||||||
}catch (Exception e){
|
abstractSyntaxTree.typeCheck();
|
||||||
System.out.println("A unexpected error occurred in TypeCheck.");
|
|
||||||
System.out.println(e);
|
|
||||||
}
|
|
||||||
|
|
||||||
if(!suppressDetails)
|
if(!suppressDetails)
|
||||||
System.out.println("No TypeCheck errors found.");
|
System.out.println("No TypeCheck errors found.");
|
||||||
|
|
||||||
try {
|
abstractSyntaxTree.codeGen();
|
||||||
abstractSyntaxTree.codeGen();
|
System.out.println("Your input was compiled. You can find the output at ???");// todo wo output? überhaupt hinschreiben?
|
||||||
}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.");
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user