summaryrefslogtreecommitdiffstats
path: root/src/Compiler/Language.java
diff options
context:
space:
mode:
authorAidenRushbrooke <72034940+AidenRushbrooke@users.noreply.github.com>2021-11-07 01:23:19 +0000
committerAidenRushbrooke <72034940+AidenRushbrooke@users.noreply.github.com>2021-11-07 01:23:19 +0000
commitf8b888716211b78900db62ede497fa4ac2100c00 (patch)
tree3ea66c732de6abb95b10e708d0ab33651cb6b327 /src/Compiler/Language.java
parentd3046e3b1481cf6d190b8fcb814985e29852b5eb (diff)
downloadesotericFORTRAN-f8b888716211b78900db62ede497fa4ac2100c00.tar.gz
esotericFORTRAN-f8b888716211b78900db62ede497fa4ac2100c00.zip
Basic floating point support and small improvements to error handing
Diffstat (limited to 'src/Compiler/Language.java')
-rw-r--r--src/Compiler/Language.java11
1 files changed, 10 insertions, 1 deletions
diff --git a/src/Compiler/Language.java b/src/Compiler/Language.java
index 9151bd5..44168db 100644
--- a/src/Compiler/Language.java
+++ b/src/Compiler/Language.java
@@ -39,25 +39,34 @@ public class Language {
}
}
- //Extract and print each token
+ //Function to take source code and output the result
private static void runInterpreter(String sourceCode){
+
+ //Extract tokens from the source code
TokenScanner scanner = new TokenScanner();
List<Token> tokens = scanner.extractTokens(sourceCode);
//for (Token token : tokens) {
// System.out.println(token);
//}
if (hadError) return;
+
//Parse into AST
Parser parser = new Parser(tokens);
List<Statement> ast = parser.parse();
if (hadError) return;
+
+ //Translate AST into equivalent C code
Translator translator = new Translator();
List<String> code = translator.compileToC(ast);
if (hadError) return;
+
+ //Execute created C code
ExecuteC cExecutor = new ExecuteC();
cExecutor.compileAndExecuteC(code);
}
+
+ //Basic error reporting
static void displayError(String message){
hadError=true;
System.out.println("An error was encountered");