This commit is contained in:
ChUrl
2020-12-11 13:34:47 +01:00
parent e8d88dda40
commit 5f88a56d53
2 changed files with 17 additions and 5 deletions

View File

@ -1,5 +1,7 @@
package util.ast;
import java.util.Objects;
public class AST {
private final Node root;
@ -25,4 +27,9 @@ public class AST {
public String toString() {
return this.root.toString();
}
@Override
public int hashCode() {
return Objects.hash(this.root);
}
}

View File

@ -3,6 +3,7 @@ package util.ast;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import java.util.Objects;
public class Node {
@ -15,11 +16,6 @@ public class Node {
this.value = "";
}
public Node(String name, String value) {
this.name = name;
this.value = value;
}
public void addChild(Node node) {
this.children.add(node);
}
@ -28,6 +24,10 @@ public class Node {
return !this.children.isEmpty();
}
public List<Node> getChildren() {
return this.children;
}
public String getName() {
return this.name;
}
@ -77,4 +77,9 @@ public class Node {
}
}
}
@Override
public int hashCode() {
return Objects.hash(this.name, this.value, this.children); // TODO: children?
}
}