aboutsummaryrefslogtreecommitdiffstats
path: root/main/core/parser/ast/SymbolNode.java
blob: 14578516f6a00cffef84de9b413a436c48568374 (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.parser.ast;

import com.jantuomi.interpreter.main.core.parser.datatype.DataContainer;
import com.jantuomi.interpreter.main.core.runtime.State;
import com.jantuomi.interpreter.main.core.tokenizer.token.Token;

import java.util.Arrays;
import java.util.List;

/**
 * Created by jan on 11.6.2016.
 */
public class SymbolNode extends ExpressionNode {
    private String symbol;

    public SymbolNode(Token token) {
        super(token);

        this.symbol = token.getText();
    }

    @Override
    List<ASTNode> getChildren() {
        return Arrays.asList();
    }

    public String getSymbol() {
        return symbol;
    }

    @Override
    public DataContainer evaluate() {
        return State.getInstance().getSymbolValue(symbol);
    }
}