blob: 00294e27f6e1b78545a1a68bbd948246ff8096a5 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
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();
}
}
|