diff --git a/Parser/spec/Helpers.jadd b/Parser/spec/Helpers.jadd new file mode 100644 index 0000000000000000000000000000000000000000..a147c4b4caed0bb36b1d108deb12255f2db3698e --- /dev/null +++ b/Parser/spec/Helpers.jadd @@ -0,0 +1,22 @@ +aspect Helpers { + + public void ASTNode.checkTreeStructure() { + for (ASTNode child : astChildren()) { + if (child.getParent() != this) { + throw new RuntimeException(); + } + child.checkTreeStructure(); + } + } + + public void ASTNode.fixTreeStructure() { + for (ASTNode child : astChildren()) { + if (child.getParent() != this) { + // System.err.println("fixed parent of " + child); + child.parent = this; + } + child.fixTreeStructure(); + } + } + +}