summaryrefslogtreecommitdiff
path: root/src/ast/nodes/CompOpNode.java
blob: 79970525776d5a4ea76c3d5037ccae3bb27c45b0 (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
36
37
38
39
40
41
42
43
44
45
46
47
48
package ast.nodes;

import java.util.ArrayList;

import semanticanalysis.SemanticError;
import semanticanalysis.SymbolTable;
import ast.types.*;
import org.antlr.v4.runtime.tree.TerminalNode;

/**
 * Node for the `comp_op` statement of the grammar.
 */
public class CompOpNode implements Node {

    private final TerminalNode op;

    public CompOpNode(TerminalNode op) {
        this.op = op;
    }

    public String getOp() {
        return op.toString();
    }

    @Override
    public ArrayList<SemanticError> checkSemantics(SymbolTable ST, int _nesting, FunctionType ft) {
        return new ArrayList<>();
    }

    // TODO: it should be boolean, right?
    @Override
    public Type typeCheck() {
        return new VoidType();
    }

    /**
     * The code generation for this operation is in `ExprNode`.
     */
    @Override
    public String codeGeneration() {
        return "";
    }

    @Override
    public String toPrint(String prefix) {
        return prefix + "CompOpNode(" + op + ")\n";
    }
}