diff options
| author | Jan Tuomi <jans.tuomi@gmail.com> | 2016-06-15 21:56:03 +0300 |
|---|---|---|
| committer | Jan Tuomi <jans.tuomi@gmail.com> | 2016-07-26 19:46:51 +0300 |
| commit | f441022881945db08846e09a8f3bfee2f8cfa95d (patch) | |
| tree | 3b565c6902e5b5b6c351df89fe1d58b00d79f091 /main/core/runtime/Interpreter.java | |
| parent | 12eeefcdba1ee392f033f51e6b9826eaae3c4de6 (diff) | |
Add interpreter and AST
Diffstat (limited to 'main/core/runtime/Interpreter.java')
| -rw-r--r-- | main/core/runtime/Interpreter.java | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/main/core/runtime/Interpreter.java b/main/core/runtime/Interpreter.java new file mode 100644 index 0000000..00294e2 --- /dev/null +++ b/main/core/runtime/Interpreter.java @@ -0,0 +1,35 @@ +package com.jantuomi.interpreter.main.core.runtime; + +import com.jantuomi.interpreter.main.core.parser.ast.ASTNode; +import com.jantuomi.interpreter.main.core.parser.datatype.DataContainer; + +import java.util.List; + +/** + * Created by jan on 14.6.2016. + */ +public class Interpreter { + private static final Interpreter instance = new Interpreter(); + + public static Interpreter getInstance() { + return instance; + } + + private Interpreter() { + + } + public static String execute(List<ASTNode> sequence) { + StringBuilder output = new StringBuilder(); + for (ASTNode node : sequence) { + DataContainer data = node.evaluate(); + + if (data != null) { + String out = data.toString(); + output.append(out); + } else { + break; + } + } + return output.toString(); + } +} |
