aboutsummaryrefslogtreecommitdiffstats
path: root/main/core/runtime/Interpreter.java
blob: f84e7e79d75c54ee7a17412985dfa276fe89c372 (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
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) {
        String output = "";
        for (ASTNode node : sequence) {
            DataContainer data = node.evaluate();

            if (data != null) {
                output = data.toString();
            } else {
                break;
            }
        }
        return output;
    }
}