summaryrefslogtreecommitdiffstats
path: root/src/Compiler/Language.java
diff options
context:
space:
mode:
authorjwansek <eddie.atten.ea29@gmail.com>2021-11-08 14:21:59 +0000
committerjwansek <eddie.atten.ea29@gmail.com>2021-11-08 14:21:59 +0000
commiteba31c969bb289bb79f844a23acc1604825d05ff (patch)
treee542882ed4ff718ddf02751d23b6ee03715a4140 /src/Compiler/Language.java
parent975fb6f000918085d1f5ba4ac6eb95c60411dae9 (diff)
downloadesotericFORTRAN-eba31c969bb289bb79f844a23acc1604825d05ff.tar.gz
esotericFORTRAN-eba31c969bb289bb79f844a23acc1604825d05ff.zip
changed output name to same as source file, added build folder, linux compatability
Diffstat (limited to 'src/Compiler/Language.java')
-rw-r--r--src/Compiler/Language.java10
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);
}