summaryrefslogtreecommitdiff
path: root/dice-lang/src/bjc/dicelang/v2/Token.java
diff options
context:
space:
mode:
authorbjculkin <bjculkin@WIT-136XG42.wvu-ad.wvu.edu>2017-03-01 10:13:41 -0500
committerbjculkin <bjculkin@WIT-136XG42.wvu-ad.wvu.edu>2017-03-01 10:13:41 -0500
commit36e0911c6ec27707a74f0b90b1052a16374243ea (patch)
tree08ca7723b0c0a6a7f3ce1830c59e5211e46168b8 /dice-lang/src/bjc/dicelang/v2/Token.java
parent6ed83507953322c35a456d64d89f8f4f9cb0a6a1 (diff)
Package reorganization
Diffstat (limited to 'dice-lang/src/bjc/dicelang/v2/Token.java')
-rw-r--r--dice-lang/src/bjc/dicelang/v2/Token.java140
1 files changed, 0 insertions, 140 deletions
diff --git a/dice-lang/src/bjc/dicelang/v2/Token.java b/dice-lang/src/bjc/dicelang/v2/Token.java
deleted file mode 100644
index 3d8359f..0000000
--- a/dice-lang/src/bjc/dicelang/v2/Token.java
+++ /dev/null
@@ -1,140 +0,0 @@
-package bjc.dicelang.v2;
-
-import bjc.dicelang.v2.dice.DieExpression;
-import bjc.utils.funcdata.IList;
-
-/**
- * Lexer token
- */
-public class Token {
- public final static Token NIL_TOKEN = new Token(Type.NIL);
-
- /**
- * 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, DICEGROUP, DICECONCAT, DICELIST,
- LET, BIND, COERCE,
- 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)
- public long intValue;
-
- // 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)
- public IList<Token> tokenValues;
-
- public Token(Type typ) {
- type = typ;
- }
-
- public Token(Type typ, long val) {
- this(typ);
-
- intValue = val;
- }
-
- public Token(Type typ, double val) {
- this(typ);
-
- floatValue = val;
- }
-
- public Token(Type typ, DieExpression val) {
- this(typ);
-
- diceValue = val;
- }
-
- public Token(Type typ, IList<Token> tkVals) {
- this(typ);
-
- tokenValues = tkVals;
- }
-
- 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();
- }
- }
-
- public boolean equals(Object other) {
- if(!(other instanceof Token)) return false;
-
- Token otk = (Token)other;
-
- if(otk.type != type) return false;
-
- 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;
- }
- }
-}