summaryrefslogtreecommitdiff
path: root/dice-lang/src/bjc/dicelang/CompilerTweaker.java
diff options
context:
space:
mode:
authorEVE <EVE@EVE-PC>2017-03-13 16:41:15 -0400
committerEVE <EVE@EVE-PC>2017-03-13 16:41:15 -0400
commit870d769cfc152171d27b2331a7c590d0b307ad48 (patch)
tree3fee9a6bbbf03792cbe9c0a7927b92e4783e07a0 /dice-lang/src/bjc/dicelang/CompilerTweaker.java
parent620ad3db1cbebe52ebd8df03fcda9d965ecb3282 (diff)
More tweaker work.
Diffstat (limited to 'dice-lang/src/bjc/dicelang/CompilerTweaker.java')
-rw-r--r--dice-lang/src/bjc/dicelang/CompilerTweaker.java75
1 files changed, 74 insertions, 1 deletions
diff --git a/dice-lang/src/bjc/dicelang/CompilerTweaker.java b/dice-lang/src/bjc/dicelang/CompilerTweaker.java
index ffbfb7e..3779f2b 100644
--- a/dice-lang/src/bjc/dicelang/CompilerTweaker.java
+++ b/dice-lang/src/bjc/dicelang/CompilerTweaker.java
@@ -1,5 +1,7 @@
package bjc.dicelang;
+import bjc.utils.funcutils.NeoTokenSplitter;
+
/**
* Contains methods for customizing the DiceLang and SCL compilers.
*
@@ -7,6 +9,77 @@ package bjc.dicelang;
*/
public class CompilerTweaker {
/*
- * @TODO add things
+ * Bits of the compiler necessary
+ */
+ private DiceLangEngine eng;
+ private NeoTokenSplitter opExpander;
+
+ public CompilerTweaker(DiceLangEngine eng) {
+ this.eng = eng;
+
+ this.opExpander = eng.opExpander;
+ }
+
+ /**
+ * Add a string literal to the compiler's internal banks.
+ *
+ * @param val
+ * The string literal to add.
+ *
+ * @return The key into the string literal table for this string.
*/
+ public int addStringLiteral(String val) {
+ eng.addStringLiteral(eng.nextLiteral, val);
+
+ eng.nextLiteral += 1;
+ return eng.nextLiteral;
+ }
+
+ /**
+ * Add a line defn to the compiler.
+ *
+ * @param dfn
+ * The defn to add.
+ */
+ public void addLineDefine(Define dfn) {
+ eng.addLineDefine(dfn);
+ }
+
+ /**
+ * Add a token defn to the compiler.
+ *
+ * @param dfn
+ * The defn to add.
+ */
+ public void addTokenDefine(Define dfn) {
+ eng.addTokenDefine(dfn);
+ }
+
+ /**
+ * Adds a delimiter that is expanded from tokens.
+ *
+ * @param delim
+ * The delimiter to expand on.
+ */
+ public void addDelimiter(String delim) {
+ opExpander.addDelimiter(delim);
+ }
+
+ /**
+ * Adds a multi-character delimiter that is expanded from tokens.
+ *
+ * @param delim
+ * The multi-character delimiter to expand on.
+ */
+ public void addMultiDelimiter(String delim) {
+ opExpander.addMultiDelimiter(delim);
+ }
+
+ /**
+ * Make delimiter changes visible to the compiler.
+ */
+ public void compile() {
+ opExpander.compile();
+ }
+
}