diff options
| author | bculkin2442 <bjculkin@mix.wvu.edu> | 2016-04-25 22:11:28 -0400 |
|---|---|---|
| committer | bculkin2442 <bjculkin@mix.wvu.edu> | 2016-04-25 22:11:28 -0400 |
| commit | fb7d03388e298258563c22abda1bd46cdaf991b7 (patch) | |
| tree | ff2caeda751acd733ea00c089800ff380211f0b3 /BJC-Utils2/src/main/java/bjc/utils/parserutils/TreeConstructor.java | |
| parent | 42f7d379a430aaf2fad169f0170de04072b08b10 (diff) | |
General code cleanup, and some more GUI controls
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 | 21 |
1 files changed, 12 insertions, 9 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 2d2a69e..283d16e 100644 --- a/BJC-Utils2/src/main/java/bjc/utils/parserutils/TreeConstructor.java +++ b/BJC-Utils2/src/main/java/bjc/utils/parserutils/TreeConstructor.java @@ -24,7 +24,7 @@ public class TreeConstructor { * * Only binary operators are accepted. * - * @param <T> + * @param <TokenType> * The elements of the parse tree * @param tokens * The list of tokens to build a tree from @@ -33,8 +33,9 @@ public class TreeConstructor { * operator * @return A AST from the expression */ - public static <T> ITree<T> constructTree(IFunctionalList<T> tokens, - Predicate<T> operatorPredicate) { + public static <TokenType> ITree<TokenType> constructTree( + IFunctionalList<TokenType> tokens, + Predicate<TokenType> operatorPredicate) { return constructTree(tokens, operatorPredicate, (op) -> false, null); } @@ -45,7 +46,7 @@ public class TreeConstructor { * Only binary operators are accepted by default. Use the last two * parameters to handle non-binary operators * - * @param <T> + * @param <TokenType> * The elements of the parse tree * @param tokens * The list of tokens to build a tree from @@ -63,9 +64,11 @@ public class TreeConstructor { * interface. Maybe there's a better way to express how that * works */ - public static <T> ITree<T> constructTree(IFunctionalList<T> tokens, - Predicate<T> operatorPredicate, Predicate<T> isSpecialOperator, - Function<T, Function<Deque<ITree<T>>, ITree<T>>> handleSpecialOperator) { + public static <TokenType> ITree<TokenType> constructTree( + IFunctionalList<TokenType> tokens, + Predicate<TokenType> operatorPredicate, + Predicate<TokenType> isSpecialOperator, + Function<TokenType, Function<Deque<ITree<TokenType>>, ITree<TokenType>>> handleSpecialOperator) { if (tokens == null) { throw new NullPointerException("Tokens must not be null"); } else if (operatorPredicate == null) { @@ -76,8 +79,8 @@ public class TreeConstructor { "Special operator determiner must not be null"); } - IHolder<IPair<Deque<ITree<T>>, ITree<T>>> initialState = new Identity<>( - new Pair<>(new LinkedList<>(), null)); + IHolder<IPair<Deque<ITree<TokenType>>, ITree<TokenType>>> initialState = + new Identity<>(new Pair<>(new LinkedList<>(), null)); tokens.forEach( new TokenTransformer<>(initialState, operatorPredicate, |
