-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathParseNode.java
More file actions
45 lines (33 loc) · 923 Bytes
/
ParseNode.java
File metadata and controls
45 lines (33 loc) · 923 Bytes
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
import java.util.ArrayList;
public class ParseNode {
public String name = "";
ArrayList <ParseNode> children = new ArrayList <ParseNode> ();
public boolean isTerminal;
public ParseNode(String name) {
this.name = name;
this.isTerminal = false;
}
public String toString() {
return name;
}
public ParseNode(String name, boolean isTerminal) {
this.name = name;
this.isTerminal = isTerminal;
}
public int numChildren () {
return children.size();
}
public ArrayList <ParseNode> getChildren() {
return children;
}
public ArrayList <ParseNode> addChildren(ArrayList <ParseNode> children) {
for(int i= 0 ; i < children.size(); i++) {
this.children.add(children.get(i));
}
return children;
}
public ArrayList <ParseNode> addChildren(ParseNode child ) {
this.children.add(child);
return children;
}
}