diff options
| author | Benjamin J. Culkin <bjculkin@mix.wvu.edu> | 2017-10-09 16:02:10 -0300 |
|---|---|---|
| committer | Benjamin J. Culkin <bjculkin@mix.wvu.edu> | 2017-10-09 16:02:10 -0300 |
| commit | f028ea6dc555fc5192a96b00b8e96e90dbf6de55 (patch) | |
| tree | 4b2a28ecbeb30095b50e6e9e8ac8b98fa8ddc79e /dice-lang/src/bjc/dicelang/dice/DiceBox.java | |
| parent | be4675f9512060aa85b1e0a4f223208b51b55812 (diff) | |
TODO tagging
Diffstat (limited to 'dice-lang/src/bjc/dicelang/dice/DiceBox.java')
| -rw-r--r-- | dice-lang/src/bjc/dicelang/dice/DiceBox.java | 30 |
1 files changed, 18 insertions, 12 deletions
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<Long> 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); } } } |
