From eba31c969bb289bb79f844a23acc1604825d05ff Mon Sep 17 00:00:00 2001 From: jwansek Date: Mon, 8 Nov 2021 14:21:59 +0000 Subject: changed output name to same as source file, added build folder, linux compatability --- src/Compiler/Language.java | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) (limited to 'src/Compiler/Language.java') 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 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); } -- cgit v1.2.3