From ba9cf27de7e9f31dfa97a7266979f300101d67f9 Mon Sep 17 00:00:00 2001 From: bculkin2442 Date: Thu, 10 Nov 2016 19:44:22 -0500 Subject: Doc updates --- BJC-Utils2/src/main/java/bjc/utils/parserutils/TreeConstructor.java | 5 +++++ 1 file changed, 5 insertions(+) (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 2ddde9d..0b61363 100644 --- a/BJC-Utils2/src/main/java/bjc/utils/parserutils/TreeConstructor.java +++ b/BJC-Utils2/src/main/java/bjc/utils/parserutils/TreeConstructor.java @@ -36,6 +36,7 @@ public class TreeConstructor { public static ITree constructTree( IList tokens, Predicate operatorPredicate) { + // Construct a tree with no special operators return constructTree(tokens, operatorPredicate, (op) -> false, null); } @@ -70,6 +71,7 @@ public class TreeConstructor { Predicate isSpecialOperator, Function>, ITree>> handleSpecialOperator) { + // Make sure our parameters are valid if (tokens == null) { throw new NullPointerException("Tokens must not be null"); } else if (operatorPredicate == null) { @@ -80,14 +82,17 @@ public class TreeConstructor { "Special operator determiner must not be null"); } + // Here is the state for the tree construction IHolder>, ITree>> initialState = new Identity<>( new Pair<>(new LinkedList<>(), null)); + // Transform each of the tokens tokens.forEach( new TokenTransformer<>(initialState, operatorPredicate, isSpecialOperator, handleSpecialOperator)); + // Grab the tree from the state return initialState.unwrap((pair) -> { return pair.getRight(); }); -- cgit v1.2.3