From 28895cad07c7aec1b324a2c75e5da5ce728cad91 Mon Sep 17 00:00:00 2001 From: Ben Culkin Date: Thu, 3 Dec 2020 19:22:06 -0500 Subject: Adapt to esodata changes --- base/src/bjc/dicelang/DiceLangEngine.java | 60 +++++++++++++++---------------- 1 file changed, 30 insertions(+), 30 deletions(-) (limited to 'base/src/bjc/dicelang/DiceLangEngine.java') diff --git a/base/src/bjc/dicelang/DiceLangEngine.java b/base/src/bjc/dicelang/DiceLangEngine.java index 549faf6..e0cddb1 100644 --- a/base/src/bjc/dicelang/DiceLangEngine.java +++ b/base/src/bjc/dicelang/DiceLangEngine.java @@ -14,12 +14,12 @@ import bjc.dicelang.eval.EvaluatorResult; import bjc.dicelang.eval.FailureEvaluatorResult; import bjc.dicelang.scl.StreamEngine; import bjc.dicelang.tokens.Token; -import bjc.data.ITree; +import bjc.data.Tree; import bjc.funcdata.FunctionalList; import bjc.funcdata.FunctionalMap; import bjc.funcdata.FunctionalStringTokenizer; -import bjc.funcdata.IList; -import bjc.funcdata.IMap; +import bjc.funcdata.ListEx; +import bjc.funcdata.MapEx; import bjc.utils.funcutils.ListUtils; import bjc.utils.parserutils.TokenUtils; import bjc.utils.parserutils.splitter.ConfigurableTokenSplitter; @@ -71,15 +71,15 @@ public class DiceLangEngine { /** * The symbol table. */ - public final IMap symTable; + public final MapEx symTable; /* String literal tables */ - private final IMap stringLits; - private final IMap stringLiterals; + private final MapEx stringLits; + private final MapEx stringLiterals; /* Lists of defns. */ - private final IList lineDefns; - private final IList tokenDefns; + private final ListEx lineDefns; + private final ListEx tokenDefns; /* Are defns currently sorted by priority? */ private boolean defnsSorted; @@ -237,21 +237,21 @@ public class DiceLangEngine { * * Instead of strings, this should maybe use a RawToken class or something. */ - final IList preprocessedTokens = preprocessCommand(command); + final ListEx preprocessedTokens = preprocessCommand(command); if (preprocessedTokens == null) { return false; } /* Lex the string tokens into token-tokens */ - final IList lexedTokens = lexTokens(preprocessedTokens); + final ListEx lexedTokens = lexTokens(preprocessedTokens); if (lexedTokens == null) { return false; } /* Parse the tokens into an AST forest */ - final IList> astForest = new FunctionalList<>(); + final ListEx> astForest = new FunctionalList<>(); final boolean succ = Parser.parseTokens(lexedTokens, astForest); if (!succ) { @@ -264,8 +264,8 @@ public class DiceLangEngine { } /* Lex string tokens into token-tokens */ - private IList lexTokens(final IList preprocessedTokens) { - final IList lexedTokens = new FunctionalList<>(); + private ListEx lexTokens(final ListEx preprocessedTokens) { + final ListEx lexedTokens = new FunctionalList<>(); for (final String token : preprocessedTokens) { String newTok = token; @@ -308,8 +308,8 @@ public class DiceLangEngine { } /* Preshunt preshunt-marked groups of tokens */ - IList shuntedTokens = lexedTokens; - final IList preparedTokens = new FunctionalList<>(); + ListEx shuntedTokens = lexedTokens; + final ListEx preparedTokens = new FunctionalList<>(); boolean succ = removePreshuntTokens(lexedTokens, preparedTokens); @@ -348,7 +348,7 @@ public class DiceLangEngine { } /* Expand token groups */ - final IList readyTokens = shuntedTokens.flatMap(tk -> { + final ListEx readyTokens = shuntedTokens.flatMap(tk -> { if (tk.type == Token.Type.TOKGROUP || tk.type == Token.Type.TAGOP || tk.type == Token.Type.TAGOPR) { String msg = String.format("Expanding token group to: %s\n", tk.tokenValues.toString()); LOG.finer(msg); @@ -396,14 +396,14 @@ public class DiceLangEngine { } /* Preprocess a command into a list of string tokens. */ - private IList preprocessCommand(final String command) { + private ListEx preprocessCommand(final String command) { /* Sort the defines if they aren't sorted */ if (!defnsSorted) { sortDefns(); } /* Run the tokens through the stream engine */ - final IList streamToks = new FunctionalList<>(); + final ListEx streamToks = new FunctionalList<>(); final boolean succ = streamEng.doStreams(command.split(" "), streamToks); if (!succ) { @@ -486,10 +486,10 @@ public class DiceLangEngine { /* Split the command into tokens */ final String strang = destringedCommand.toString(); - IList tokens = FunctionalStringTokenizer.fromString(strang).toList(); + ListEx tokens = FunctionalStringTokenizer.fromString(strang).toList(); /* Temporarily remove non-expanding tokens */ - final IMap nonExpandedTokens = new FunctionalMap<>(); + final MapEx nonExpandedTokens = new FunctionalMap<>(); tokens = tokens.map(tk -> { final Matcher nonExpandMatcher = nonExpandPattern.matcher(tk); @@ -518,7 +518,7 @@ public class DiceLangEngine { } /* Expand tokens */ - IList fullyExpandedTokens = tokens.flatMap(opExpander::split); + ListEx fullyExpandedTokens = tokens.flatMap(opExpander::split); if (debugMode) { String msg = String.format("\tCommand after token expansion: %s\n", fullyExpandedTokens.toString()); @@ -549,10 +549,10 @@ public class DiceLangEngine { } /* Evaluate a forest of AST nodes. */ - private void evaluateForest(final IList> astForest) { + private void evaluateForest(final ListEx> astForest) { int treeNo = 1; - for (final ITree ast : astForest) { + for (final Tree ast : astForest) { if (debugMode) { System.out.printf("\t\tTree %d in forest:\n%s\n", treeNo, ast.toString()); } @@ -564,8 +564,8 @@ public class DiceLangEngine { int step = 1; /* Evaluate it step by step */ - for (final Iterator> itr = eval.stepDebug(ast); itr.hasNext();) { - final ITree nodeStep = itr.next(); + for (final Iterator> itr = eval.stepDebug(ast); itr.hasNext();) { + final Tree nodeStep = itr.next(); System.out.printf("\t\tStep %d: Node is %s", step, nodeStep); @@ -590,7 +590,7 @@ public class DiceLangEngine { } if (res.type == EvaluatorResult.Type.FAILURE) { - ITree otree = ((FailureEvaluatorResult) res).origVal; + Tree otree = ((FailureEvaluatorResult) res).origVal; System.out.printf(" (original tree is %s)", otree); } @@ -626,13 +626,13 @@ public class DiceLangEngine { } /* Preshunt preshunt-marked groups of tokens. */ - private boolean removePreshuntTokens(final IList lexedTokens, final IList preparedTokens) { + private boolean removePreshuntTokens(final ListEx lexedTokens, final ListEx preparedTokens) { /* Current nesting level of tokens. */ int curBraceCount = 0; /* Data storage. */ - final Deque> bracedTokens = new LinkedList<>(); - IList curBracedTokens = new FunctionalList<>(); + final Deque> bracedTokens = new LinkedList<>(); + ListEx curBracedTokens = new FunctionalList<>(); for (final Token tk : lexedTokens) { if (tk.type == Token.Type.OBRACE && tk.intValue == 2) { @@ -659,7 +659,7 @@ public class DiceLangEngine { curBraceCount -= 1; - final IList preshuntTokens = new FunctionalList<>(); + final ListEx preshuntTokens = new FunctionalList<>(); /* Shunt preshunt group. */ final boolean success = shunt.shuntTokens(curBracedTokens, preshuntTokens); -- cgit v1.2.3