-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathExprNode.java
99 lines (79 loc) · 2.21 KB
/
ExprNode.java
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
package nodes;
import Visitor.*;
import leafs.LeafID;
import org.w3c.dom.Element;
import support.SymbolTable;
import support.ValueType;
import java.util.ArrayList;
public class ExprNode implements ISyntaxVisitable, ISemanticVisitable, ICVisitable {
public String name = null;
public ModeParNode mod;
public LeafID leaf= null;
public Object value1 = null;
public Object value2 = null;
public ExprNode(String name, Object n) {
this.name = name;
this.value1 = n;
this.mod = null;
this.value2 = null;
this.leaf=null;
}
public ExprNode(String name, Object n1, Object n2) {
this.name = name;
this.value1 = n1;
this.value2 = n2;
this.mod = null;
this.leaf=null;
}
public ExprNode(String name,ModeParNode mod,LeafID leaf) {
this.name =name;
this.mod =mod;
this.leaf=leaf;
value1 = null;
value2 = null;
}
//Semantic part
public ValueType type = null;
//Mi server per gestire l'expr di CallFunNode
/*public void setTypes(ArrayList t) {
try {
for (int i = 0; i < t.size(); i++) {
if (t.get(i) instanceof String)
this.types.add(SymbolTable.StringToType((String) t.get(i)));
else this.types.add((ValueType) t.get(i));
}
} catch (Exception e) {
System.exit(0);
e.printStackTrace();
}
}
*/
public void setType(String t) {
try {
this.type = SymbolTable.StringToType(t);
} catch (Exception e) {
System.exit(0);
e.printStackTrace();
}
}
public void setType(ValueType t) {
try {
this.type = t;
} catch (Exception e) {
System.exit(0);
e.printStackTrace();
}
}
public void setMode(String mod) {
ModeParNode in = new ModeParNode(mod);
this.mod = in;
}
@Override
public Element accept(ISyntaxVisitor v) {
return v.visit(this);
}
@Override
public void accept(ISemanticVisitor v) { v.visit(this); }
@Override
public void accept(ICVisitor v) { v.visit(this); }
}