summaryrefslogtreecommitdiff
path: root/dice-lang/src/bjc/dicelang/Token.java
diff options
context:
space:
mode:
authorEVE <EVE@EVE-PC>2017-03-13 16:41:45 -0400
committerEVE <EVE@EVE-PC>2017-03-13 16:41:45 -0400
commit01136c6796e21f023713e026674576d8e623462d (patch)
treee77886fe0e0adaf3c0430fba9ce248ef83f74fe4 /dice-lang/src/bjc/dicelang/Token.java
parent870d769cfc152171d27b2331a7c590d0b307ad48 (diff)
Formatting
Diffstat (limited to 'dice-lang/src/bjc/dicelang/Token.java')
-rw-r--r--dice-lang/src/bjc/dicelang/Token.java120
1 files changed, 53 insertions, 67 deletions
diff --git a/dice-lang/src/bjc/dicelang/Token.java b/dice-lang/src/bjc/dicelang/Token.java
index 4cc3f16..e53cba8 100644
--- a/dice-lang/src/bjc/dicelang/Token.java
+++ b/dice-lang/src/bjc/dicelang/Token.java
@@ -15,46 +15,34 @@ public class Token {
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,
+ 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
- NIL, GROUPSEP, TOKGROUP,
- TAGOP, TAGOPR
+ NIL, GROUPSEP, TOKGROUP, TAGOP, TAGOPR
}
- public final Type type;
+ 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)
- public long intValue;
+ // 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)
- public double floatValue;
+ // FLOAT_LIT (float value)
+ public double floatValue;
// This is used for the following token types
- // DICE_LIT (dice value)
+ // 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)
- public IList<Token> tokenValues;
+ // TOKGROUP (the tokens in the group)
+ // TAG* (the tagged construct)
+ public IList<Token> tokenValues;
public Token(Type typ) {
type = typ;
@@ -85,58 +73,56 @@ public class Token {
}
public String toString() {
- switch(type) {
- case INT_LIT:
- case STRING_LIT:
- case VREF:
- case OPAREN:
- case CPAREN:
- case OBRACKET:
- case CBRACKET:
- case OBRACE:
- case CBRACE:
- return type.toString() + "("
- + intValue + ")";
- case FLOAT_LIT:
- return type.toString() + "("
- + floatValue + ")";
- case DICE_LIT:
- return type.toString() + "("
- + diceValue + ")";
- case TAGOP:
- case TAGOPR:
- case TOKGROUP:
- return type.toString() + "("
- + tokenValues + ")";
- default:
- return type.toString();
+ switch (type) {
+ case INT_LIT:
+ case STRING_LIT:
+ case VREF:
+ case OPAREN:
+ case CPAREN:
+ case OBRACKET:
+ case CBRACKET:
+ case OBRACE:
+ case CBRACE:
+ return type.toString() + "(" + intValue + ")";
+ case FLOAT_LIT:
+ return type.toString() + "(" + floatValue + ")";
+ case DICE_LIT:
+ return type.toString() + "(" + diceValue + ")";
+ case TAGOP:
+ case TAGOPR:
+ case TOKGROUP:
+ return type.toString() + "(" + tokenValues + ")";
+ default:
+ return type.toString();
}
}
public boolean equals(Object other) {
- if(!(other instanceof Token)) return false;
+ if (!(other instanceof Token))
+ return false;
- Token otk = (Token)other;
+ Token otk = (Token) other;
- if(otk.type != type) return false;
+ if (otk.type != type)
+ return false;
- switch(type) {
- case OBRACE:
- case OBRACKET:
- return intValue == otk.intValue;
- default:
- return true;
+ switch (type) {
+ case OBRACE:
+ case OBRACKET:
+ return intValue == otk.intValue;
+ default:
+ return true;
}
}
public boolean isGrouper() {
- switch(type) {
- case OPAREN:
- case OBRACE:
- case OBRACKET:
- return true;
- default:
- return false;
+ switch (type) {
+ case OPAREN:
+ case OBRACE:
+ case OBRACKET:
+ return true;
+ default:
+ return false;
}
}
}