From f028ea6dc555fc5192a96b00b8e96e90dbf6de55 Mon Sep 17 00:00:00 2001 From: "Benjamin J. Culkin" Date: Mon, 9 Oct 2017 16:02:10 -0300 Subject: TODO tagging --- dice-lang/src/bjc/dicelang/dice/DiceBox.java | 30 +++++++++++++++++----------- 1 file changed, 18 insertions(+), 12 deletions(-) (limited to 'dice-lang/src/bjc/dicelang/dice/DiceBox.java') diff --git a/dice-lang/src/bjc/dicelang/dice/DiceBox.java b/dice-lang/src/bjc/dicelang/dice/DiceBox.java index f7bf719..8d00d96 100644 --- a/dice-lang/src/bjc/dicelang/dice/DiceBox.java +++ b/dice-lang/src/bjc/dicelang/dice/DiceBox.java @@ -27,8 +27,11 @@ public class DiceBox { /* * @TODO 10/08/17 Ben Culkin :DieErrors :ErrorRefactor * Use different types of exceptions to provide - * better error messages. */ - System.out.println("ERROR: Could not parse die expression (Cause: %s)\n", ex.getMessage); + * better error messages. + */ + String exMessage = ex.getMessage(); + + System.out.printf("ERROR: Could not parse die expression (Cause: %s)\n", exMessage); ex.printStackTrace(); return null; @@ -260,6 +263,10 @@ public class DiceBox { * @return Whether or not the string is a valid command. */ public static boolean isValidExpression(final String exp) { + /* @NOTE + * Should this matcher/matches expression be abstracted in + * some way? + */ if (scalarDiePattern.matcher(exp).matches()) { return true; } else if (simpleDiePattern.matcher(exp).matches()) { @@ -281,24 +288,23 @@ public class DiceBox { } } - /* - * Derive a predicate from a compare point - */ + /* Derive a predicate from a compare point */ private static Predicate deriveCond(final String patt) { final long num = Long.parseLong(patt.substring(1)); + /* @NOTE + * Should this be extended in some way, to provide other + * operators? + */ switch (patt.charAt(0)) { case '<': - return (roll) -> roll < num; - + return (roll) -> (roll < num); case '=': - return (roll) -> roll == num; - + return (roll) -> (roll == num); case '>': - return (roll) -> roll > num; - + return (roll) -> (roll > num); default: - return (roll) -> false; + return (roll) -> (false); } } } -- cgit v1.2.3