summaryrefslogtreecommitdiff
path: root/base/src/bjc/dicelang/Token.java
diff options
context:
space:
mode:
authorstudent <student@localhost>2018-02-12 13:56:22 -0500
committerstudent <student@localhost>2018-02-12 13:56:22 -0500
commit5115f1d2a7eab41436debc696870953e18a1b236 (patch)
treedbb2453580038b9f8102bb5bc53c60d2410f0f00 /base/src/bjc/dicelang/Token.java
parent4c8639f361983d97a7b46282b12528b550fff946 (diff)
General update
Diffstat (limited to 'base/src/bjc/dicelang/Token.java')
-rw-r--r--base/src/bjc/dicelang/Token.java99
1 files changed, 68 insertions, 31 deletions
diff --git a/base/src/bjc/dicelang/Token.java b/base/src/bjc/dicelang/Token.java
index f1bca6c..50e5b31 100644
--- a/base/src/bjc/dicelang/Token.java
+++ b/base/src/bjc/dicelang/Token.java
@@ -1,10 +1,11 @@
package bjc.dicelang;
-import bjc.dicelang.dice.DieExpression;
+import bjc.dicelang.dice.DiceExpression;
import bjc.utils.funcdata.IList;
/*
* @TODO 10/09/17 Ben Culkin :TokenReorg
+ *
* Split the class into subclasses based off of type.
*/
/**
@@ -18,35 +19,81 @@ public class Token {
* Possible token types
*/
public static enum Type {
- // Natural tokens
- // These are produced from lexemes
- ADD, SUBTRACT, MULTIPLY, DIVIDE, IDIVIDE, INT_LIT, FLOAT_LIT, STRING_LIT, VREF, DICE_LIT, DICESCALAR, DICEFUDGE, DICEGROUP, DICECONCAT, DICELIST, LET, BIND, COERCE, STRCAT, STRREP, OPAREN, CPAREN, OBRACKET, CBRACKET, OBRACE, CBRACE,
-
- // Synthetic tokens
- // These are produced when needed
+ /*
+ * Natural tokens
+ *
+ * These are produced from lexemes.
+ */
+ /*
+ * Math tokens.
+ */
+ ADD, SUBTRACT, MULTIPLY, DIVIDE, IDIVIDE,
+
+ /*
+ * Literal tokens.
+ */
+ INT_LIT, FLOAT_LIT, STRING_LIT, VREF, DICE_LIT,
+
+ /*
+ * Dice operators.
+ */
+ DICESCALAR, DICEFUDGE, DICEGROUP, DICECONCAT, DICELIST,
+
+ /*
+ * Expression operators.
+ */
+ LET, BIND, COERCE,
+
+ /*
+ * String operators.
+ */
+ STRCAT, STRREP,
+
+ /*
+ * Grouping operators.
+ */
+ OPAREN, CPAREN, OBRACKET, CBRACKET, OBRACE, CBRACE,
+
+ /*
+ * Synthetic tokens
+ *
+ * These are produced when needed.
+ */
NIL, GROUPSEP, TOKGROUP, TAGOP, TAGOPR
}
public final Type type;
- // This is used for the following token types
- // INT_LIT (int value)
- // STRING_LIT (index into string table)
- // VREF (index into sym table)
- // O* and C* (sym-count of current token)
+ /*
+ * This is used for the following token types
+ *
+ * - INT_LIT (int value)
+ *
+ * - STRING_LIT (index into string table)
+ *
+ * - VREF (index into sym table)
+ *
+ * - O* and C* (sym-count of current token)
+ *
+ */
public long intValue;
- // This is used for the following token types
- // FLOAT_LIT (float value)
+ /*
+ * This is used for the following token types
+ *
+ * - FLOAT_LIT (float value)
+ *
+ */
public double floatValue;
- // This is used for the following token types
- // DICE_LIT (dice value)
- public DieExpression diceValue;
-
- // This is used for the following token types
- // TOKGROUP (the tokens in the group)
- // TAG* (the tagged construct)
+ /*
+ * This is used for the following token types
+ *
+ * - TOKGROUP (the tokens in the group)
+ *
+ * - TAG* (the tagged construct)
+ *
+ */
public IList<Token> tokenValues;
public Token(final Type typ) {
@@ -65,12 +112,6 @@ public class Token {
floatValue = val;
}
- public Token(final Type typ, final DieExpression val) {
- this(typ);
-
- diceValue = val;
- }
-
public Token(final Type typ, final IList<Token> tkVals) {
this(typ);
@@ -94,9 +135,6 @@ public class Token {
case FLOAT_LIT:
return type.toString() + "(" + floatValue + ")";
- case DICE_LIT:
- return type.toString() + "(" + diceValue + ")";
-
case TAGOP:
case TAGOPR:
case TOKGROUP:
@@ -123,7 +161,6 @@ public class Token {
case OBRACE:
case OBRACKET:
return intValue == otk.intValue;
-
default:
return true;
}