From 4355418164c44170cfb329fcbb7e6f1358c0e314 Mon Sep 17 00:00:00 2001 From: bculkin2442 Date: Mon, 4 Apr 2016 14:16:48 -0400 Subject: Minor changes --- .../java/bjc/utils/configuration/ConfigFile.java | 2 + .../utils/funcdata/bst/BinarySearchTreeLeaf.java | 4 ++ .../src/main/java/bjc/utils/parserutils/AST.java | 51 ++++++++++++++++++++++ 3 files changed, 57 insertions(+) (limited to 'BJC-Utils2/src') diff --git a/BJC-Utils2/src/main/java/bjc/utils/configuration/ConfigFile.java b/BJC-Utils2/src/main/java/bjc/utils/configuration/ConfigFile.java index 458aece..9358419 100644 --- a/BJC-Utils2/src/main/java/bjc/utils/configuration/ConfigFile.java +++ b/BJC-Utils2/src/main/java/bjc/utils/configuration/ConfigFile.java @@ -78,6 +78,8 @@ public class ConfigFile { } } + scn.close(); + return returnedFile; } diff --git a/BJC-Utils2/src/main/java/bjc/utils/funcdata/bst/BinarySearchTreeLeaf.java b/BJC-Utils2/src/main/java/bjc/utils/funcdata/bst/BinarySearchTreeLeaf.java index d2f9013..8ceb554 100644 --- a/BJC-Utils2/src/main/java/bjc/utils/funcdata/bst/BinarySearchTreeLeaf.java +++ b/BJC-Utils2/src/main/java/bjc/utils/funcdata/bst/BinarySearchTreeLeaf.java @@ -112,6 +112,10 @@ public class BinarySearchTreeLeaf implements ITreePart { switch (treeWalker.walk(data)) { case SUCCESS: return true; + // We don't have any children to care about + case FAILURE: + case LEFT: + case RIGHT: default: return false; } diff --git a/BJC-Utils2/src/main/java/bjc/utils/parserutils/AST.java b/BJC-Utils2/src/main/java/bjc/utils/parserutils/AST.java index c4450f8..4b00b63 100644 --- a/BJC-Utils2/src/main/java/bjc/utils/parserutils/AST.java +++ b/BJC-Utils2/src/main/java/bjc/utils/parserutils/AST.java @@ -302,4 +302,55 @@ public class AST { action.accept(token); } } + + /** + * Apply an action to the head node of this AST + * + * @param + * The type of the returned value + * @param headAction + * The action to apply to the head node + * @return The result of applying the action + */ + public E applyToHead(Function headAction) { + if (headAction == null) { + throw new NullPointerException("Action must not be null"); + } + + return headAction.apply(token); + } + + /** + * Apply an action to the left side of this AST + * + * @param + * The type of the returned value + * @param leftAction + * The action to apply to the left side + * @return The result of applying the action + */ + public E applyToLeft(Function, E> leftAction) { + if (leftAction == null) { + throw new NullPointerException("Action must not be null"); + } + + return leftAction.apply(left); + } + + /** + * Apply an action to the right side of this AST + * + * @param + * The type of the returned value + * @param rightAction + * The action to apply to the right side + * @return The result of applying the action + */ + public E applyToRight(Function, E> rightAction) { + if (rightAction == null) { + throw new NullPointerException("Action must not be null"); + } + + return rightAction.apply(right); + } } -- cgit v1.2.3