diff options
| author | student <student@localhost> | 2018-03-05 16:48:38 -0500 |
|---|---|---|
| committer | student <student@localhost> | 2018-03-05 16:48:38 -0500 |
| commit | 806cba069576e48477d4660a019a49c405cb0195 (patch) | |
| tree | c1e718b18e660c02a12b5a466a222daf8a435bf4 /base/src/bjc/dicelang/expr/Ezpr.java | |
| parent | f9d9bd4bbf7dd6a297e1daf5ee7b4263d706d9cd (diff) | |
Update
Diffstat (limited to 'base/src/bjc/dicelang/expr/Ezpr.java')
| -rw-r--r-- | base/src/bjc/dicelang/expr/Ezpr.java | 41 |
1 files changed, 24 insertions, 17 deletions
diff --git a/base/src/bjc/dicelang/expr/Ezpr.java b/base/src/bjc/dicelang/expr/Ezpr.java index 2a54b6e..12a3413 100644 --- a/base/src/bjc/dicelang/expr/Ezpr.java +++ b/base/src/bjc/dicelang/expr/Ezpr.java @@ -11,6 +11,13 @@ import com.google.common.collect.Multiset; import static bjc.dicelang.expr.Ezpr.EzprNode.EzprNodeType.*; +/* + * @TODO 3/5/18 Ben Culkin :EzprFinished + * + * Finish the documentation and make sure this class works. + */ + +@SuppressWarnings("javadoc") public class Ezpr { public static enum EzprType { SUM, MUL @@ -42,7 +49,7 @@ public class Ezpr { @Override public String toString() { - if(typ == TOKEN) { + if (typ == TOKEN) { return tok.toString(); } return ezp.toString(); @@ -65,28 +72,28 @@ public class Ezpr { HashMultiset<EzprNode> newPositive = HashMultiset.create(); HashMultiset<EzprNode> newNegative = HashMultiset.create(); - for(EzprNode nd : positive) { + for (EzprNode nd : positive) { /* Flatten enclosed ezprs of the same type. */ - if(nd.typ == EZPR && (nd.ezp.typ == typ)) { + if (nd.typ == EZPR && (nd.ezp.typ == typ)) { /* Recursively flatten kids. */ Ezpr kid = nd.ezp.flatten(); - if(typ == SUM) { + if (typ == SUM) { /* * Add sum parts to corresponding bags. */ - for(EzprNode knd : kid.positive) { + for (EzprNode knd : kid.positive) { newPositive.add(knd); } - for(EzprNode knd : kid.negative) { + for (EzprNode knd : kid.negative) { newNegative.add(knd); } } else { /* @TODO ensure that this is correct. */ - for(EzprNode knd : kid.positive) { + for (EzprNode knd : kid.positive) { newPositive.add(knd); } - for(EzprNode knd : kid.negative) { + for (EzprNode knd : kid.negative) { newNegative.add(knd); } } @@ -95,25 +102,25 @@ public class Ezpr { } } - for(EzprNode nd : negative) { + for (EzprNode nd : negative) { /* Flatten enclosed ezprs of the same type. */ - if(nd.typ == EZPR && (nd.ezp.typ == typ)) { + if (nd.typ == EZPR && (nd.ezp.typ == typ)) { /* Recursively flatten kids. */ Ezpr kid = nd.ezp.flatten(); /* @TODO ensure that this is correct. */ - if(typ == SUM) { - for(EzprNode knd : kid.positive) { + if (typ == SUM) { + for (EzprNode knd : kid.positive) { newNegative.add(knd); } - for(EzprNode knd : kid.negative) { + for (EzprNode knd : kid.negative) { newPositive.add(knd); } } else { - for(EzprNode knd : kid.positive) { + for (EzprNode knd : kid.positive) { newNegative.add(knd); } - for(EzprNode knd : kid.negative) { + for (EzprNode knd : kid.negative) { newPositive.add(knd); } } @@ -130,13 +137,13 @@ public class Ezpr { StringBuilder sb = new StringBuilder(typ.toString()); sb.append(" [ "); - for(EzprNode nd : positive) { + for (EzprNode nd : positive) { sb.append(nd.toString()); sb.append(" "); } sb.append("# "); - for(EzprNode nd : negative) { + for (EzprNode nd : negative) { sb.append(nd.toString()); sb.append(" "); } |
