From 504ca816530efdff06bc202e0432ebd354aec304 Mon Sep 17 00:00:00 2001 From: EVE Date: Tue, 14 Mar 2017 12:07:14 -0400 Subject: Cleanup --- .../bjc/utils/parserutils/TreeConstructor.java | 29 +++++++++++----------- 1 file changed, 14 insertions(+), 15 deletions(-) (limited to 'BJC-Utils2/src/main/java/bjc/utils/parserutils/TreeConstructor.java') diff --git a/BJC-Utils2/src/main/java/bjc/utils/parserutils/TreeConstructor.java b/BJC-Utils2/src/main/java/bjc/utils/parserutils/TreeConstructor.java index 6f4e384..82ded42 100644 --- a/BJC-Utils2/src/main/java/bjc/utils/parserutils/TreeConstructor.java +++ b/BJC-Utils2/src/main/java/bjc/utils/parserutils/TreeConstructor.java @@ -1,10 +1,5 @@ package bjc.utils.parserutils; -import java.util.Deque; -import java.util.LinkedList; -import java.util.function.Function; -import java.util.function.Predicate; - import bjc.utils.data.IHolder; import bjc.utils.data.IPair; import bjc.utils.data.ITree; @@ -12,18 +7,23 @@ import bjc.utils.data.Identity; import bjc.utils.data.Pair; import bjc.utils.funcdata.IList; +import java.util.Deque; +import java.util.LinkedList; +import java.util.function.Function; +import java.util.function.Predicate; + /** * Creates a parse tree from a postfix expression - * + * * @author ben * */ public class TreeConstructor { /** * Construct a tree from a list of tokens in postfix notation - * + * * Only binary operators are accepted. - * + * * @param * The elements of the parse tree * @param tokens @@ -41,10 +41,10 @@ public class TreeConstructor { /** * Construct a tree from a list of tokens in postfix notation - * + * * Only binary operators are accepted by default. Use the last two * parameters to handle non-binary operators - * + * * @param * The elements of the parse tree * @param tokens @@ -58,7 +58,7 @@ public class TreeConstructor { * @param handleSpecialOperator * The function to use to handle special case operators * @return A AST from the expression - * + * * FIXME The handleSpecialOp function seems like an ugly * interface. Maybe there's a better way to express how that * works. @@ -67,13 +67,12 @@ public class TreeConstructor { Predicate isOperator, Predicate isSpecialOperator, Function>, ITree>> handleSpecialOperator) { // Make sure our parameters are valid - if (tokens == null) { + if(tokens == null) throw new NullPointerException("Tokens must not be null"); - } else if (isOperator == null) { + else if(isOperator == null) throw new NullPointerException("Operator predicate must not be null"); - } else if (isSpecialOperator == null) { + else if(isSpecialOperator == null) throw new NullPointerException("Special operator determiner must not be null"); - } // Here is the state for the tree construction IHolder>, ITree>> initialState = new Identity<>( -- cgit v1.2.3