From d9437c1d328ccc2b26bd0aae19c2aff7140e466b Mon Sep 17 00:00:00 2001 From: bculkin2442 Date: Sun, 17 Apr 2016 15:57:20 -0400 Subject: Minor cleanups --- .../main/java/bjc/dicelang/IDiceExpression.java | 27 ++++++++++++---------- 1 file changed, 15 insertions(+), 12 deletions(-) (limited to 'dice-lang/src/main/java/bjc/dicelang/IDiceExpression.java') 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; } } -- cgit v1.2.3