summaryrefslogtreecommitdiff
path: root/dice-lang/src/bjc/dicelang/Errors.java
diff options
context:
space:
mode:
authorbjculkin <bjculkin@mix.wvu.edu>2017-04-11 17:51:13 -0400
committerbjculkin <bjculkin@mix.wvu.edu>2017-04-11 17:51:13 -0400
commit40858cee415643769ee5f6216b0cd4335996ff2f (patch)
tree86b1c334fa2e5b79cddc16984f5ad43c3c72e41f /dice-lang/src/bjc/dicelang/Errors.java
parent767ca1b248da19b754d42a814b71b43ef16090be (diff)
General cleanup and fixes
Diffstat (limited to 'dice-lang/src/bjc/dicelang/Errors.java')
-rw-r--r--dice-lang/src/bjc/dicelang/Errors.java247
1 files changed, 193 insertions, 54 deletions
diff --git a/dice-lang/src/bjc/dicelang/Errors.java b/dice-lang/src/bjc/dicelang/Errors.java
index 6fa8072..7d85242 100644
--- a/dice-lang/src/bjc/dicelang/Errors.java
+++ b/dice-lang/src/bjc/dicelang/Errors.java
@@ -1,138 +1,274 @@
package bjc.dicelang;
+/**
+ * Repository for error messages.
+ *
+ * @author EVE
+ *
+ */
public class Errors {
+ /**
+ * The types of error message.
+ *
+ * @author EVE
+ *
+ */
public static enum ErrorKey {
// Define Errors
- // Incorrect define guard syntax
+ /**
+ * Incorrect define guard syntax
+ */
EK_DFN_PREDSYN,
- // Incorrect define search syntax
+ /**
+ * Incorrect define search syntax
+ */
EK_DFN_SRCSYN,
- // Recursive define recursed too many times
+ /**
+ * Recursive define recursed too many times
+ */
EK_DFN_RECUR,
// Console Errors
- // Unknown console pragma
+ /**
+ * Unknown console pragma
+ */
EK_CONS_INVPRAG,
- // Improperly formatted define
+ /**
+ * Improperly formatted define
+ */
EK_CONS_INVDEFINE,
// Language Engine Errors
- // Found closing doublebrace w/out opening doublebrace
+ /**
+ * Found closing double-brace w/out opening double-brace
+ */
EK_ENG_NOOPENING,
- // Reached end of command w/out balanced doublebraces
+ /**
+ * Reached end of command w/out balanced double-braces
+ */
EK_ENG_NOCLOSING,
// Tokenizer Errors
- // Found an unexpected grouping token
+ /**
+ * Found an unexpected grouping token
+ */
EK_TOK_UNGROUP,
- // Invalid base for a flexadecimal number
+ /**
+ * Invalid base for a flexadecimal number
+ */
EK_TOK_INVBASE,
- // Invalid flexadecimal number in a given base
+ /**
+ * Invalid flexadecimal number in a given base
+ */
EK_TOK_INVFLEX,
// Evaluator Errors
- // Unknown node type
+ /**
+ * Unknown node type
+ */
EK_EVAL_INVNODE,
- // Incorrect # of args to binary operator
+ /**
+ * Incorrect # of args to binary operator
+ */
EK_EVAL_INVBIN,
- // Incorrect # of args to unary operator
+ /**
+ * Incorrect # of args to unary operator
+ */
EK_EVAL_INVUNARY,
- // Unknown binary operator
+ /**
+ * Unknown binary operator
+ */
EK_EVAL_UNBIN,
- // Unknown unary operator
+ /**
+ * Unknown unary operator
+ */
EK_EVAL_UNUNARY,
- // Math on strings doesn't work
+ /**
+ * Math on strings doesn't work
+ */
EK_EVAL_STRINGMATH,
- // Attempted divide by zero
+ /**
+ * Attempted divide by zero
+ */
EK_EVAL_DIVZERO,
- // Attempted to divide dice
+ /**
+ * Attempted to divide dice
+ */
EK_EVAL_DIVDICE,
- // Unknown math operator
+ /**
+ * Unknown math operator
+ */
EK_EVAL_UNMATH,
- // Unknown token reference
+ /**
+ * Unknown token reference
+ */
EK_EVAL_UNTOK,
- // Unknown dice operator
+ /**
+ * Unknown dice operator
+ */
EK_EVAL_UNDICE,
- // Incorrect type to dice group operator
+ /**
+ * Incorrect type to dice group operator
+ */
EK_EVAL_INVDGROUP,
- // Incorrect type to dice creation operator
+ /**
+ * Incorrect type to dice creation operator
+ */
EK_EVAL_INVDCREATE,
- // Incorrect type to other dice operator
+ /**
+ * Incorrect type to other dice operator
+ */
EK_EVAL_INVDICE,
- // Mismatched types to math operator
+ /**
+ * Mismatched types to math operator
+ */
EK_EVAL_MISMATH,
- // Incorrect type to string operator
+ /**
+ * Incorrect type to string operator
+ */
EK_EVAL_INVSTRING,
- // Unknown string operator
+ /**
+ * Unknown string operator
+ */
EK_EVAL_UNSTRING,
// Parser Error
- // Group closing where there couldn't be an opener
+ /**
+ * Group closing where there couldn't be an opener
+ */
EK_PARSE_NOCLOSE,
- // Group closing without group opener
+ /**
+ * Group closing without group opener
+ */
EK_PARSE_UNCLOSE,
- // Incorrect # of arguments to binary operator
+ /**
+ * Incorrect # of arguments to binary operator
+ */
EK_PARSE_BINARY,
- // Not enough operands to binary operator
+ /**
+ * Not enough operands to binary operator
+ */
EK_PARSE_UNOPERAND,
- // Unrecognized token type
+ /**
+ * Unrecognized token type
+ */
EK_PARSE_INVTOKEN,
// Shunter Error
- // Unary operator expected a operand, but got an operator
+ /**
+ * Unary operator expected a operand, but got an operator
+ */
EK_SHUNT_NOTADV,
- // Unary operator expected an operator, but got an operand
+ /**
+ * Unary operator expected an operator, but got an operand
+ */
EK_SHUNT_NOTADJ,
- // Unary operator expected an operator, but didn't find one
+ /**
+ * Unary operator expected an operator, but didn't find one
+ */
EK_SHUNT_NOOP,
- // Asked for opening grouping operator, but couldn't find one
+ /**
+ * Asked for opening grouping operator, but couldn't find one
+ */
EK_SHUNT_NOGROUP,
- // No group for group seperator to attach to
+ /**
+ * No group for group seperator to attach to
+ */
EK_SHUNT_INVSEP,
- // Attempted to chain non-associative operator
+ /**
+ * Attempted to chain non-associative operator
+ */
EK_SHUNT_NOTASSOC,
// Stream Errors
- // Attempted to switch to a non-existant stream
+ /**
+ * Attempted to switch to a non-existant stream
+ */
EK_STRM_NONEX,
- // Can't delete the last stream
+ /**
+ * Can't delete the last stream
+ */
EK_STRM_LAST,
- // Unknown stream command
+ /**
+ * Unknown stream command
+ */
EK_STRM_INVCOM,
// SCL Errors
- // Unknown SCL token
+ /**
+ * Unknown SCL token
+ */
EK_SCL_INVTOKEN,
- // Mismatched quote in SCL command
+ /**
+ * Mismatched quote in SCL command
+ */
EK_SCL_MMQUOTE,
- // Stack underflow in SCL command
+ /**
+ * Stack underflow in SCL command
+ */
EK_SCL_SUNDERFLOW,
- // Unknown word in SCL command
+ /**
+ * Unknown word in SCL command
+ */
EK_SCL_UNWORD,
- // Invalid argument to SCL command
+ /**
+ * Invalid argument to SCL command
+ */
EK_SCL_INVARG,
- // CLI Argument Erros
- // Unknown CLI argument
+ // CLI Argument Errors
+ /**
+ * Unknown CLI argument
+ */
EK_CLI_UNARG,
- // Missing subargument to argument
+ /**
+ * Missing sub-argument to argument
+ */
EK_CLI_MISARG,
- // Invalid define type
+ /**
+ * Invalid define type
+ */
EK_CLI_INVDFNTYPE,
- // Misc. errors
- // Unknown I/O problem
+ // Miscellaneous errors
+ /**
+ * Unknown I/O problem
+ */
EK_MISC_IOEX,
- // File not found
+ /**
+ * File not found
+ */
EK_MISC_NOFILE,
}
+ /**
+ * The mode for the type of error messages to print out.
+ *
+ * @author EVE
+ *
+ */
public static enum ErrorMode {
- WIZARD, DEV
+ /**
+ * Output error messages for wizards.
+ */
+ WIZARD,
+ /**
+ * Output error messages for developers.
+ */
+ DEV
}
private ErrorMode mode;
+ /**
+ * Print an error.
+ *
+ * @param key
+ * The key of the error.
+ *
+ * @param args
+ * The arguments for the error.
+ */
public void printError(ErrorKey key, String... args) {
switch(mode) {
case WIZARD:
@@ -312,6 +448,9 @@ public class Errors {
}
}
+ /**
+ * The instance of the errors.
+ */
public final static Errors inst;
static {