summaryrefslogtreecommitdiff
path: root/dice-lang/src/bjc/dicelang/expr/Token.java
diff options
context:
space:
mode:
authorBenjamin J. Culkin <bjculkin@mix.wvu.edu>2017-10-09 16:02:10 -0300
committerBenjamin J. Culkin <bjculkin@mix.wvu.edu>2017-10-09 16:02:10 -0300
commitf028ea6dc555fc5192a96b00b8e96e90dbf6de55 (patch)
tree4b2a28ecbeb30095b50e6e9e8ac8b98fa8ddc79e /dice-lang/src/bjc/dicelang/expr/Token.java
parentbe4675f9512060aa85b1e0a4f223208b51b55812 (diff)
TODO tagging
Diffstat (limited to 'dice-lang/src/bjc/dicelang/expr/Token.java')
-rw-r--r--dice-lang/src/bjc/dicelang/expr/Token.java32
1 files changed, 12 insertions, 20 deletions
diff --git a/dice-lang/src/bjc/dicelang/expr/Token.java b/dice-lang/src/bjc/dicelang/expr/Token.java
index 1a506bf..bf92f97 100644
--- a/dice-lang/src/bjc/dicelang/expr/Token.java
+++ b/dice-lang/src/bjc/dicelang/expr/Token.java
@@ -1,14 +1,18 @@
package bjc.dicelang.expr;
+/*
+ * @TODO 10/08/17 :TokenReorg
+ * I am not a fan of this 'having a bunch of subclasses' in one thing I
+ * seem to have been doing around this project. This should be multiple
+ * subclasses, one for each value for TokenType.
+ */
/**
* Represents a lexical token.
*
* @author Ben Culkin
*/
public class Token {
- /*
- * The state for this token.
- */
+ /* The state for this token. */
private final Tokens tks;
/**
@@ -18,14 +22,10 @@ public class Token {
*/
public final TokenType typ;
- /**
- * The integer value attached to this token.
- */
+ /** The integer value attached to this token. */
public int intValue;
- /**
- * The original string this token was part of.
- */
+ /** The original string this token was part of. */
public String rawValue;
/**
@@ -44,21 +44,20 @@ public class Token {
this.typ = type;
rawValue = raw;
-
tks = toks;
}
@Override
public String toString() {
String typeStr = typ.toString();
- typeStr += " (" + typ.name() + ")";
+ typeStr = String.format("%s (%s)", typeStr, typ.name());
if (typ == TokenType.VREF) {
typeStr += " (ind. " + intValue;
typeStr += ", sym. \"" + tks.symbolTable.get(intValue) + "\")";
}
- return typeStr + " (originally from: " + rawValue + ")";
+ return String.format("%s (originally from: %s)", typeStr, rawValue);
}
/**
@@ -70,27 +69,20 @@ public class Token {
switch (typ) {
case ADD:
return "+";
-
case SUBTRACT:
return "-";
-
case MULTIPLY:
return "*";
-
case DIVIDE:
return "/";
-
case VREF:
return tks.symbolTable.get(intValue);
-
case OPAREN:
return "(";
-
case CPAREN:
return ")";
-
default:
return "???";
}
}
-} \ No newline at end of file
+}