diff options
| author | bculkin2442 <bjculkin@mix.wvu.edu> | 2016-03-22 12:28:35 -0400 |
|---|---|---|
| committer | bculkin2442 <bjculkin@mix.wvu.edu> | 2016-03-22 12:28:35 -0400 |
| commit | 01cb9f504c860bc1c037a44f3a76bf342a293d46 (patch) | |
| tree | 02d1d34de0828159bbda93e881c93a6b45720f32 /BJC-Utils2/src/main/java/bjc/utils/parserutils/AST.java | |
| parent | 4685955a62c430007c5c8ed2b915ffc618d30aca (diff) | |
General formatting cleanup and documentation update
Diffstat (limited to 'BJC-Utils2/src/main/java/bjc/utils/parserutils/AST.java')
| -rw-r--r-- | BJC-Utils2/src/main/java/bjc/utils/parserutils/AST.java | 20 |
1 files changed, 15 insertions, 5 deletions
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 f390155..943d177 100644 --- a/BJC-Utils2/src/main/java/bjc/utils/parserutils/AST.java +++ b/BJC-Utils2/src/main/java/bjc/utils/parserutils/AST.java @@ -1,6 +1,5 @@ package bjc.utils.parserutils; -import java.util.Map; import java.util.function.BinaryOperator; import java.util.function.Consumer; import java.util.function.Function; @@ -41,9 +40,9 @@ public class AST<T> { * * @param tokn * The token in this node - * @param left + * @param lft * The left child of this AST - * @param right + * @param rght * The right child of this AST */ public AST(T tokn, AST<T> lft, AST<T> rght) { @@ -53,6 +52,14 @@ public class AST<T> { right = rght; } + /** + * Traverse an AST + * + * @param tlm + * The way to traverse the tree + * @param con + * The function to call on each traversed element + */ public void traverse(TreeLinearizationMethod tlm, Consumer<T> con) { if (left != null && right != null) { switch (tlm) { @@ -83,6 +90,8 @@ public class AST<T> { /** * Collapse this tree into a single node + * @param <E> The final value of the collapsed tree + * @param <T2> * * @param tokenTransform * The function to transform nodes into data @@ -159,7 +168,7 @@ public class AST<T> { * @param n * The number of levels to indent */ - private void indentNLevels(StringBuilder sb, int n) { + private static void indentNLevels(StringBuilder sb, int n) { for (int i = 0; i <= n; i++) { sb.append("\t"); } @@ -190,6 +199,7 @@ public class AST<T> { /** * Transmute the tokens in an AST into a different sort of token + * @param <E> The type of the transformed tokens * * @param tokenTransformer * The transform to run on the tokens @@ -207,6 +217,6 @@ public class AST<T> { r = right.transmuteAST(tokenTransformer); } - return new AST<E>(tokenTransformer.apply(token), l, r); + return new AST<>(tokenTransformer.apply(token), l, r); } } |
