summaryrefslogtreecommitdiff
path: root/src/ast/nodes/Node.java
blob: 0e58093e8703e0b61f1f606ebf7999ee85e9bbdb (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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
package ast.nodes;

import ast.types.*;
import java.util.ArrayList;
import semanticanalysis.SemanticError;
import semanticanalysis.SymbolTable;

/**
 * Base interface for a Node.
 */
public interface Node {

    static final String[] bif = {
        "abs",
        "aiter",
        "all",
        "anext",
        "any",
        "ascii",
        "bin",
        "bool",
        "breakpoint",
        "bytearray",
        "bytes",
        "callable",
        "chr",
        "classmethod",
        "compile",
        "complex",
        "delattr",
        "dict",
        "dir",
        "divmod",
        "enumerate",
        "eval",
        "exec",
        "exit",
        "filter",
        "float",
        "format",
        "frozenset",
        "getattr",
        "globals",
        "hasattr",
        "hash",
        "help",
        "hex",
        "id",
        "input",
        "int",
        "isinstance",
        "issubclass",
        "iter",
        "len",
        "list",
        "locals",
        "map",
        "max",
        "memoryview",
        "min",
        "next",
        "object",
        "oct",
        "open",
        "ord",
        "pow",
        "print",
        "property",
        "range",
        "repr",
        "reversed",
        "round",
        "set",
        "setattr",
        "slice",
        "sorted",
        "staticmethod",
        "str",
        "sum",
        "super",
        "tuple",
        "type",
        "vars",
        "zip",
        "__import__"};

    /**
     * Checks semantics for a given node for a SymbolTable ST and a level of
     * nesting. Returns a list of `SemanticError`.
     */
    ArrayList<SemanticError> checkSemantics(SymbolTable ST, int _nesting, FunctionType ft);

    /**
     * Checks the type for a given node. If there's any error, returns an
     * `ErrorType`.
     */
    Type typeCheck();

    /**
     * Returns a string for the Python Virtual Machine.
     */
    String codeGeneration();

    /**
     * Returns a string for a given node with a prefix. It used when an AST
     * wants to be visualized on screen.
     */
    String toPrint(String prefix);
}