diff options
Diffstat (limited to 'src/Compiler/Language.java')
-rw-r--r-- | src/Compiler/Language.java | 10 |
1 files changed, 4 insertions, 6 deletions
diff --git a/src/Compiler/Language.java b/src/Compiler/Language.java index 44168db..bb7e235 100644 --- a/src/Compiler/Language.java +++ b/src/Compiler/Language.java @@ -10,7 +10,6 @@ import java.util.Scanner; public class Language { static boolean hadError = false; public static void main(String[] args){ - //Allow users to input a single line of code //Still needs some work to re-ask for input after each line if (args.length < 1){ @@ -19,7 +18,7 @@ public class Language { while (sourceCode!=""){ System.out.print("Code: "); sourceCode = input.nextLine(); - runInterpreter(sourceCode); + runInterpreter(sourceCode, "out"); hadError=false; } input.close(); @@ -28,7 +27,7 @@ public class Language { } else if (args.length==1){ try { String sourcecode = Files.readString(Paths.get(args[0])); //Maybe should set charset here - runInterpreter(sourcecode); + runInterpreter(sourcecode, args[0].split("\\.(?=[^\\.]+$)")[0]); } catch (IOException exception){ System.out.println("File not found"); } @@ -40,8 +39,7 @@ public class Language { } //Function to take source code and output the result - private static void runInterpreter(String sourceCode){ - + private static void runInterpreter(String sourceCode, String outName){ //Extract tokens from the source code TokenScanner scanner = new TokenScanner(); List<Token> tokens = scanner.extractTokens(sourceCode); @@ -62,7 +60,7 @@ public class Language { //Execute created C code ExecuteC cExecutor = new ExecuteC(); - cExecutor.compileAndExecuteC(code); + cExecutor.compileAndExecuteC(code, outName); } |