From 870d769cfc152171d27b2331a7c590d0b307ad48 Mon Sep 17 00:00:00 2001 From: EVE Date: Mon, 13 Mar 2017 16:41:15 -0400 Subject: More tweaker work. --- dice-lang/src/bjc/dicelang/CompilerTweaker.java | 75 ++++++++++++++++++++++++- 1 file changed, 74 insertions(+), 1 deletion(-) (limited to 'dice-lang/src/bjc/dicelang/CompilerTweaker.java') 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(); + } + } -- cgit v1.2.3