summaryrefslogtreecommitdiff
path: root/scl/src/main/java/bjc
diff options
context:
space:
mode:
Diffstat (limited to 'scl/src/main/java/bjc')
-rw-r--r--scl/src/main/java/bjc/dicelang/scl/StreamControlEngine.java4
-rw-r--r--scl/src/main/java/bjc/dicelang/scl/tokens/BooleanSCLToken.java2
-rw-r--r--scl/src/main/java/bjc/dicelang/scl/tokens/FloatSCLToken.java2
-rw-r--r--scl/src/main/java/bjc/dicelang/scl/tokens/IntSCLToken.java2
-rw-r--r--scl/src/main/java/bjc/dicelang/scl/tokens/SCLToken.java68
-rw-r--r--scl/src/main/java/bjc/dicelang/scl/tokens/StringSCLToken.java4
-rw-r--r--scl/src/main/java/bjc/dicelang/scl/tokens/TokenType.java61
-rw-r--r--scl/src/main/java/bjc/dicelang/scl/tokens/WordListSCLToken.java4
-rw-r--r--scl/src/main/java/bjc/dicelang/scl/tokens/WordSCLToken.java80
-rw-r--r--scl/src/main/java/bjc/dicelang/scl/tokens/WordType.java71
10 files changed, 150 insertions, 148 deletions
diff --git a/scl/src/main/java/bjc/dicelang/scl/StreamControlEngine.java b/scl/src/main/java/bjc/dicelang/scl/StreamControlEngine.java
index a590bb3..c79a715 100644
--- a/scl/src/main/java/bjc/dicelang/scl/StreamControlEngine.java
+++ b/scl/src/main/java/bjc/dicelang/scl/StreamControlEngine.java
@@ -18,8 +18,8 @@ import bjc.utils.funcdata.IList;
import bjc.utils.parserutils.TokenUtils;
import static bjc.dicelang.scl.Errors.ErrorKey.*;
-import static bjc.dicelang.scl.tokens.SCLToken.Type.*;
-import static bjc.dicelang.scl.tokens.WordSCLToken.Word.*;
+import static bjc.dicelang.scl.tokens.TokenType.*;
+import static bjc.dicelang.scl.tokens.WordType.*;
/*
* @TODO 10/08/17 Ben Culkin :SCLReorg
diff --git a/scl/src/main/java/bjc/dicelang/scl/tokens/BooleanSCLToken.java b/scl/src/main/java/bjc/dicelang/scl/tokens/BooleanSCLToken.java
index 25fb1ac..bccffe0 100644
--- a/scl/src/main/java/bjc/dicelang/scl/tokens/BooleanSCLToken.java
+++ b/scl/src/main/java/bjc/dicelang/scl/tokens/BooleanSCLToken.java
@@ -19,7 +19,7 @@ public class BooleanSCLToken extends SCLToken {
* The value of the token.
*/
public BooleanSCLToken(boolean val) {
- super(Type.BLIT);
+ super(TokenType.BLIT);
boolVal = val;
}
diff --git a/scl/src/main/java/bjc/dicelang/scl/tokens/FloatSCLToken.java b/scl/src/main/java/bjc/dicelang/scl/tokens/FloatSCLToken.java
index ee924c9..82e44e2 100644
--- a/scl/src/main/java/bjc/dicelang/scl/tokens/FloatSCLToken.java
+++ b/scl/src/main/java/bjc/dicelang/scl/tokens/FloatSCLToken.java
@@ -19,7 +19,7 @@ public class FloatSCLToken extends SCLToken {
* The value of the token.
*/
public FloatSCLToken(double val) {
- super(Type.FLIT);
+ super(TokenType.FLIT);
floatVal = val;
}
diff --git a/scl/src/main/java/bjc/dicelang/scl/tokens/IntSCLToken.java b/scl/src/main/java/bjc/dicelang/scl/tokens/IntSCLToken.java
index 03be900..3c77eee 100644
--- a/scl/src/main/java/bjc/dicelang/scl/tokens/IntSCLToken.java
+++ b/scl/src/main/java/bjc/dicelang/scl/tokens/IntSCLToken.java
@@ -19,7 +19,7 @@ public class IntSCLToken extends SCLToken {
* The value of the token.
*/
public IntSCLToken(final long iVal) {
- super(Type.ILIT);
+ super(TokenType.ILIT);
intVal = iVal;
}
diff --git a/scl/src/main/java/bjc/dicelang/scl/tokens/SCLToken.java b/scl/src/main/java/bjc/dicelang/scl/tokens/SCLToken.java
index 659f545..5fe9053 100644
--- a/scl/src/main/java/bjc/dicelang/scl/tokens/SCLToken.java
+++ b/scl/src/main/java/bjc/dicelang/scl/tokens/SCLToken.java
@@ -7,7 +7,7 @@ import bjc.dicelang.scl.Errors;
import bjc.utils.parserutils.TokenUtils;
import static bjc.dicelang.scl.Errors.ErrorKey.*;
-import static bjc.dicelang.scl.tokens.SCLToken.Type.*;
+import static bjc.dicelang.scl.tokens.TokenType.*;
/**
* Base class for SCL tokens.
@@ -18,69 +18,9 @@ import static bjc.dicelang.scl.tokens.SCLToken.Type.*;
public class SCLToken {
/**
- * Represent all the types of a token.
- *
- * @author student
- *
- */
- public static enum Type {
- /* Natural tokens. These come directly from strings */
- /**
- * Integer literal.
- */
- ILIT,
- /**
- * Floating-point literal.
- */
- FLIT,
- /**
- * Boolean literal.
- */
- BLIT,
- /**
- * Single-quote.
- */
- SQUOTE,
- /**
- * Double-quote.
- */
- DQUOTE,
- /**
- * Open-bracket.
- */
- OBRACKET,
- /**
- * Open-brace.
- */
- OBRACE,
- /**
- * Symbol.
- */
- SYMBOL,
- /**
- * Word.
- */
- WORD,
-
- /* Synthetic tokens. These are produced from special tokens. */
- /**
- * String literal.
- */
- SLIT,
- /**
- * List of words.
- */
- WORDS,
- /**
- * List of data.
- */
- ARRAY,
- }
-
- /**
* The type of the token.
*/
- public SCLToken.Type type;
+ public TokenType type;
/**
* Convert a string into a token.
@@ -110,13 +50,13 @@ public class SCLToken {
}
}
- protected static final Map<String, Type> litTokens;
+ protected static final Map<String, TokenType> litTokens;
protected SCLToken() {
}
- protected SCLToken(Type typ) {
+ protected SCLToken(TokenType typ) {
type = typ;
}
diff --git a/scl/src/main/java/bjc/dicelang/scl/tokens/StringSCLToken.java b/scl/src/main/java/bjc/dicelang/scl/tokens/StringSCLToken.java
index d026bdb..40e5c27 100644
--- a/scl/src/main/java/bjc/dicelang/scl/tokens/StringSCLToken.java
+++ b/scl/src/main/java/bjc/dicelang/scl/tokens/StringSCLToken.java
@@ -14,9 +14,9 @@ public abstract class StringSCLToken extends SCLToken {
protected StringSCLToken(boolean isSymbol, String val) {
if (isSymbol) {
- type = Type.SYMBOL;
+ type = TokenType.SYMBOL;
} else {
- type = Type.SLIT;
+ type = TokenType.SLIT;
}
stringVal = val;
diff --git a/scl/src/main/java/bjc/dicelang/scl/tokens/TokenType.java b/scl/src/main/java/bjc/dicelang/scl/tokens/TokenType.java
new file mode 100644
index 0000000..519331c
--- /dev/null
+++ b/scl/src/main/java/bjc/dicelang/scl/tokens/TokenType.java
@@ -0,0 +1,61 @@
+package bjc.dicelang.scl.tokens;
+
+/**
+ * Represent all the types of a token.
+ *
+ * @author student
+ *
+ */
+public enum TokenType {
+ /* Natural tokens. These come directly from strings */
+ /**
+ * Integer literal.
+ */
+ ILIT,
+ /**
+ * Floating-point literal.
+ */
+ FLIT,
+ /**
+ * Boolean literal.
+ */
+ BLIT,
+ /**
+ * Single-quote.
+ */
+ SQUOTE,
+ /**
+ * Double-quote.
+ */
+ DQUOTE,
+ /**
+ * Open-bracket.
+ */
+ OBRACKET,
+ /**
+ * Open-brace.
+ */
+ OBRACE,
+ /**
+ * Symbol.
+ */
+ SYMBOL,
+ /**
+ * Word.
+ */
+ WORD,
+
+ /* Synthetic tokens. These are produced from special tokens. */
+ /**
+ * String literal.
+ */
+ SLIT,
+ /**
+ * List of words.
+ */
+ WORDS,
+ /**
+ * List of data.
+ */
+ ARRAY,
+} \ No newline at end of file
diff --git a/scl/src/main/java/bjc/dicelang/scl/tokens/WordListSCLToken.java b/scl/src/main/java/bjc/dicelang/scl/tokens/WordListSCLToken.java
index d5bf537..1d870db 100644
--- a/scl/src/main/java/bjc/dicelang/scl/tokens/WordListSCLToken.java
+++ b/scl/src/main/java/bjc/dicelang/scl/tokens/WordListSCLToken.java
@@ -16,9 +16,9 @@ public abstract class WordListSCLToken extends SCLToken {
protected WordListSCLToken(boolean isArray, IList<SCLToken> tokens) {
if (isArray) {
- type = Type.ARRAY;
+ type = TokenType.ARRAY;
} else {
- type = Type.WORDS;
+ type = TokenType.WORDS;
}
tokenVals = tokens;
diff --git a/scl/src/main/java/bjc/dicelang/scl/tokens/WordSCLToken.java b/scl/src/main/java/bjc/dicelang/scl/tokens/WordSCLToken.java
index ae185de..9d99569 100644
--- a/scl/src/main/java/bjc/dicelang/scl/tokens/WordSCLToken.java
+++ b/scl/src/main/java/bjc/dicelang/scl/tokens/WordSCLToken.java
@@ -1,6 +1,6 @@
package bjc.dicelang.scl.tokens;
-import static bjc.dicelang.scl.tokens.WordSCLToken.Word.*;
+import static bjc.dicelang.scl.tokens.WordType.*;
import java.util.HashMap;
import java.util.Map;
@@ -13,79 +13,9 @@ import java.util.Map;
*/
public class WordSCLToken extends SCLToken {
/**
- * Represents the word type.
- *
- * @author student
- *
- */
- public static enum Word {
- /* Array manipulation */
- /**
- * Create an array
- */
- MAKEARRAY,
- /**
- * Make a token executable.
- */
- MAKEEXEC,
- /**
- * Make a token unexecutable.
- */
- MAKEUNEXEC,
-
- /* Stream manipulation */
- /**
- * Create a new stream.
- */
- NEWSTREAM,
- /**
- * Swap to the left stream.
- */
- LEFTSTREAM,
- /**
- * Swap to the right stream.
- */
- RIGHTSTREAM,
- /**
- * Delete the current stream.
- */
- DELETESTREAM,
- /**
- * Merge the streams.
- */
- MERGESTREAM,
-
- /* Stack manipulation */
- /**
- * Get the count of items on the stack.
- */
- STACKCOUNT,
- /**
- * Check if the stack is empty.
- */
- STACKEMPTY,
- /**
- * Drop an item from the top of the stack.
- */
- DROP,
- /**
- * Drop a number of items from the top of the stack.
- */
- NDROP,
- /**
- * Drop an item, leaving the top of the stack alone.
- */
- NIP,
- /**
- * Drop a number of items, leaving the top of the stack alone.
- */
- NNIP,
- }
-
- /**
* The value of the word.
*/
- public Word wordVal;
+ public WordType wordVal;
/**
* Create a new word token.
@@ -103,8 +33,8 @@ public class WordSCLToken extends SCLToken {
* @param wrd
* The value of the word.
*/
- public WordSCLToken(Word wrd) {
- super(Type.WORD);
+ public WordSCLToken(WordType wrd) {
+ super(TokenType.WORD);
wordVal = wrd;
}
@@ -148,7 +78,7 @@ public class WordSCLToken extends SCLToken {
return builtinWords.containsKey(wrd);
}
- private static final Map<String, WordSCLToken.Word> builtinWords;
+ private static final Map<String, WordType> builtinWords;
static {
/* Init builtin words. */
diff --git a/scl/src/main/java/bjc/dicelang/scl/tokens/WordType.java b/scl/src/main/java/bjc/dicelang/scl/tokens/WordType.java
new file mode 100644
index 0000000..b64e825
--- /dev/null
+++ b/scl/src/main/java/bjc/dicelang/scl/tokens/WordType.java
@@ -0,0 +1,71 @@
+package bjc.dicelang.scl.tokens;
+
+/**
+ * Represents the word type.
+ *
+ * @author student
+ *
+ */
+public enum WordType {
+ /* Array manipulation */
+ /**
+ * Create an array
+ */
+ MAKEARRAY,
+ /**
+ * Make a token executable.
+ */
+ MAKEEXEC,
+ /**
+ * Make a token unexecutable.
+ */
+ MAKEUNEXEC,
+
+ /* Stream manipulation */
+ /**
+ * Create a new stream.
+ */
+ NEWSTREAM,
+ /**
+ * Swap to the left stream.
+ */
+ LEFTSTREAM,
+ /**
+ * Swap to the right stream.
+ */
+ RIGHTSTREAM,
+ /**
+ * Delete the current stream.
+ */
+ DELETESTREAM,
+ /**
+ * Merge the streams.
+ */
+ MERGESTREAM,
+
+ /* Stack manipulation */
+ /**
+ * Get the count of items on the stack.
+ */
+ STACKCOUNT,
+ /**
+ * Check if the stack is empty.
+ */
+ STACKEMPTY,
+ /**
+ * Drop an item from the top of the stack.
+ */
+ DROP,
+ /**
+ * Drop a number of items from the top of the stack.
+ */
+ NDROP,
+ /**
+ * Drop an item, leaving the top of the stack alone.
+ */
+ NIP,
+ /**
+ * Drop a number of items, leaving the top of the stack alone.
+ */
+ NNIP,
+} \ No newline at end of file