diff options
author | Alfie Eagleton <67986414+TheAlfanator@users.noreply.github.com> | 2021-11-08 17:28:30 +0000 |
---|---|---|
committer | Alfie Eagleton <67986414+TheAlfanator@users.noreply.github.com> | 2021-11-08 17:28:30 +0000 |
commit | 03380520e95699ca41c74439f6216685ab8da6b7 (patch) | |
tree | 89a46bc6e1e85b2647d5b0e4bed529e2c0414798 /src/Compiler/Language.java | |
parent | 8157d9bee1c0d6ce0e59ac45bcad0d011cbe10a3 (diff) | |
parent | a12094123dcacee41a7472031db6fe6027b083a7 (diff) | |
download | esotericFORTRAN-03380520e95699ca41c74439f6216685ab8da6b7.tar.gz esotericFORTRAN-03380520e95699ca41c74439f6216685ab8da6b7.zip |
Merge branch 'main' of https://github.com/AlfieEagleton/EsotericProject
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); } |