summaryrefslogtreecommitdiff
path: root/src/main/java/bjc/everge/ReplPair.java
diff options
context:
space:
mode:
authorbculkin2442 <bjculkin@mix.wvu.edu>2019-06-24 20:43:15 -0400
committerbculkin2442 <bjculkin@mix.wvu.edu>2019-06-24 20:49:05 -0400
commite760e590104a177a26badb616ac400fef815c679 (patch)
tree2e29aacbc2cdd2ddda33106abb0c4f5575596b26 /src/main/java/bjc/everge/ReplPair.java
parent39dad5c09e73a464c26086741d12dd62e5ebcc08 (diff)
Part I of factoring out controls
This is part one of factoring out controls and control parsing so that we aren't doing it in three different places. Two main things before this is done: 1. Finish up the parsing in ControlledString 2. Actually replace the old implementations in ReplPair
Diffstat (limited to 'src/main/java/bjc/everge/ReplPair.java')
-rw-r--r--src/main/java/bjc/everge/ReplPair.java50
1 files changed, 50 insertions, 0 deletions
diff --git a/src/main/java/bjc/everge/ReplPair.java b/src/main/java/bjc/everge/ReplPair.java
index 2d2e115..904b1fa 100644
--- a/src/main/java/bjc/everge/ReplPair.java
+++ b/src/main/java/bjc/everge/ReplPair.java
@@ -761,4 +761,54 @@ public class ReplPair implements Comparable<ReplPair>, UnaryOperator<String> {
return;
}
+
+ private static ControlledString getControls(String lne, List<ReplError> errs,
+ ReplOpts ropts, IntHolder lno, IntHolder pno, String type) {
+ if (!lne.startsWith("//")) {
+ return new ControlledString(lne);
+ }
+
+ String tmp = lne.substring(2);
+
+ String[] bits = StringUtils.escapeSplit("|", "//", lne);
+
+ if (bits.length < 2) {
+ String msg = "Did not find control terminator (//) in %s where it should be";
+ msg = String.format(msg, type);
+
+ ReplError re = new ReplError(lno, pno, msg, lne);
+ errs.add(re);
+
+ return null;
+ }
+
+ ControlledString cs = new ControlledString(bits[0]);
+
+ bits = StringUtils.escapeSplit("|", ";", bits[1]);
+
+ cs.controls = new Control[bits.length];
+
+ for (int i = 0; i < bits.length; i++) {
+ String bit = bits[i];
+
+ String[] bots = StringUtils.escapeSplit("|", "/", bit);
+
+ Control cont = new Control(bots[0]);
+
+ if (cont.name.length() > 1) {
+ cont.name = cont.name.toUpperCase();
+ }
+
+ if (bots.length > 1) {
+ cont.args = new String[bots.length - 1];
+ for (int j = 1; j < bots.length; j++) {
+ cont.args[j - 1] = bots[j];
+ }
+ }
+
+ cs.controls[i] = cont;
+ }
+
+ return cs;
+ }
}