diff options
| author | EVE <EVE@EVE-PC> | 2017-03-14 12:07:14 -0400 |
|---|---|---|
| committer | EVE <EVE@EVE-PC> | 2017-03-14 12:07:14 -0400 |
| commit | 504ca816530efdff06bc202e0432ebd354aec304 (patch) | |
| tree | 4836932fb81d1d625470502c78c94d202c9a7420 /BJC-Utils2/src/main/java/bjc/utils/parserutils/TreeConstructor.java | |
| parent | 5c1163df17c46f7d3e15b6c7949c38843ec56146 (diff) | |
Cleanup
Diffstat (limited to 'BJC-Utils2/src/main/java/bjc/utils/parserutils/TreeConstructor.java')
| -rw-r--r-- | BJC-Utils2/src/main/java/bjc/utils/parserutils/TreeConstructor.java | 29 |
1 files changed, 14 insertions, 15 deletions
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 <TokenType> * 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 <TokenType> * 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<TokenType> isOperator, Predicate<TokenType> isSpecialOperator, Function<TokenType, Function<Deque<ITree<TokenType>>, ITree<TokenType>>> 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<IPair<Deque<ITree<TokenType>>, ITree<TokenType>>> initialState = new Identity<>( |
