-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathpython_Tree.java
184 lines (143 loc) · 3.58 KB
/
python_Tree.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
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
public class python_Tree {
public static Tree<String> tree = new Tree<String>("Python_program");
}
class PythonNode<String> extends Node{
int line;
public PythonNode(String data,int line){
super(data);
this.line = line;
}
}
class Identifier<String> extends PythonNode{
public Identifier(String data,int line) {
super(data,line);
}
}
class Lista<String> extends PythonNode{
public Lista(String data,int line) {
super(data,line);
}
}
class Import<String> extends PythonNode{
public Import(String data,int line){
super(data,line);
}
public void addChildren(Node<String> op){
this.addChild(op);
}
}
class Assignment<String> extends PythonNode{
public Assignment(String assignment, Node<String> op1, Node<String> op2, int line){
super(assignment,line);
this.addChild(op1);
this.addChild(op2);
}
}
class As<String> extends PythonNode{
public As(Identifier<String> op, int line){
super("As",line);
this.addChild(op);
}
public void addChildren(Node<String> op){
this.addFirstChild(op);
}
}
class Function<String> extends PythonNode{
public Function(Node<String> name,Node<String> paramlist, Node<String> body, int line){
super("Fun_Dec",line);
this.addChild(name);
this.addChild(paramlist);
this.addChild(body);
}
public Function(Node<String> name, Node<String> body,int line){
super("Fun_Dec",line);
this.addChild(name);
this.addChild(body);
}
}
class Classe<String> extends PythonNode{
public Classe(Node<String> name,Node<String> body, int line){
super("Class",line);
this.addChild(name);
this.addChild(body);
}
}
class Stringa<String> extends PythonNode{
public Stringa(String data,int line) {
super(data,line);
}
}
class BoolOp<String> extends PythonNode{
public BoolOp(String op,Node<String> op1,Node<String> op2, int line){
super(op,line);
this.addChild(op1);
this.addChild(op2);
}
public BoolOp(String op,Node<String> op1, int line){
super(op,line);
this.addChild(op1);
}
}
class Numeric<String> extends PythonNode{
public Numeric(String data,int line) {
super(data,line);
}
}
class Boolean<String> extends PythonNode{
public Boolean(String data,int line) {
super(data,line);
}
}
class ArithExp<String> extends PythonNode{
public ArithExp(String op,Node<String> op1,Node<String> op2, int line){
super(op,line);
this.addChild(op1);
this.addChild(op2);
}
}
class Control<String> extends PythonNode{
public Control(String op,Node<String> suite,int line){
super(op,line);
this.addChild(suite);
}
public Control(String op,Node<String> test, Node<String> suite,int line){
super(op,line);
this.addChild(test);
this.addChild(suite);
}
}
class TryFinally<String> extends PythonNode{
public TryFinally(String op,Node<String> suite, int line){
super(op,line);
this.addChild(suite);
}
}
class ArrayEle<String> extends PythonNode{
public ArrayEle(Node<String> name,Node<String> param,int line){
super("Array_Element",line);
this.addChild(name);
this.addChild(param);
}
public ArrayEle(Node<String> name,int line){
super("Array_Element",line);
this.addChild(name);
}
}
class FunctionCall<String> extends PythonNode{
public FunctionCall(Node<String> name,Node<String> paramlist,int line){
super("Function_Call",line);
this.addChild(name);
this.addChild(paramlist);
}
public FunctionCall(Node<String> name,int line){
super("Fun_Call",line);
this.addChild(name);
}
}
class ItemCall<String> extends PythonNode{
public ItemCall(Node<String> op1,Node<String> op2, int line){
super(".",line);
this.addChild(op1);
this.addChild(op2);
}
}