diff options
| author | bculkin2442 <bjculkin@mix.wvu.edu> | 2016-04-17 15:57:20 -0400 |
|---|---|---|
| committer | bculkin2442 <bjculkin@mix.wvu.edu> | 2016-04-17 15:57:20 -0400 |
| commit | d9437c1d328ccc2b26bd0aae19c2aff7140e466b (patch) | |
| tree | a2292224ba16766fe3dc99140e90089e24aea9c7 /dice-lang/src/main/java/bjc/dicelang/IDiceExpression.java | |
| parent | 4fcefd106eb23295592e9cc23a0c5d63a28f9e76 (diff) | |
Minor cleanups
Diffstat (limited to 'dice-lang/src/main/java/bjc/dicelang/IDiceExpression.java')
| -rw-r--r-- | dice-lang/src/main/java/bjc/dicelang/IDiceExpression.java | 27 |
1 files changed, 15 insertions, 12 deletions
diff --git a/dice-lang/src/main/java/bjc/dicelang/IDiceExpression.java b/dice-lang/src/main/java/bjc/dicelang/IDiceExpression.java index 16e1761..013d69d 100644 --- a/dice-lang/src/main/java/bjc/dicelang/IDiceExpression.java +++ b/dice-lang/src/main/java/bjc/dicelang/IDiceExpression.java @@ -42,19 +42,20 @@ public interface IDiceExpression { /** * Parse this node into an expression - * @param exp The string to convert to an expression * - * @return The node in expression form + * @param expression + * The string to convert to an expression + * + * @return The string in expression form */ - static IDiceExpression toExpression(String exp) { - String literalData = exp; - + static IDiceExpression toExpression(String expression) { + String literalData = expression; + if (StringUtils.containsInfixOperator(literalData, "c")) { String[] strangs = literalData.split("c"); - + return new CompoundDice(strangs); - } else if (StringUtils.containsInfixOperator(literalData, - "d")) { + } else if (StringUtils.containsInfixOperator(literalData, "d")) { /* * Handle dice groups */ @@ -63,11 +64,13 @@ public interface IDiceExpression { try { return new ScalarDie(Integer.parseInt(literalData)); } catch (NumberFormatException nfex) { - UnsupportedOperationException usex = new UnsupportedOperationException( - "Found malformed leaf token " + exp); - + UnsupportedOperationException usex = + new UnsupportedOperationException( + "Found malformed leaf token " + + expression); + usex.initCause(nfex); - + throw usex; } } |
