summaryrefslogtreecommitdiff
path: root/BJC-Utils2/src/main/java/bjc/utils/parserutils/TokenUtils.java
diff options
context:
space:
mode:
authorBenjamin J. Culkin <bjculkin@mix.wvu.edu>2017-09-09 21:46:16 -0300
committerBenjamin J. Culkin <bjculkin@mix.wvu.edu>2017-09-09 21:47:34 -0300
commitd766896972c9e9be4a9e0021ec5f4f0665901865 (patch)
tree1f6473300ef86e0697d682360bea0d28fc144baa /BJC-Utils2/src/main/java/bjc/utils/parserutils/TokenUtils.java
parent40f3a28569366c4357fbda11d2fff3b77686d84f (diff)
Update
Most of it is documentation changes. The rest is more work on BlockReaders, as well as a simple command language for configuring them.
Diffstat (limited to 'BJC-Utils2/src/main/java/bjc/utils/parserutils/TokenUtils.java')
-rw-r--r--BJC-Utils2/src/main/java/bjc/utils/parserutils/TokenUtils.java17
1 files changed, 16 insertions, 1 deletions
diff --git a/BJC-Utils2/src/main/java/bjc/utils/parserutils/TokenUtils.java b/BJC-Utils2/src/main/java/bjc/utils/parserutils/TokenUtils.java
index a8f3db2..33dd1a2 100644
--- a/BJC-Utils2/src/main/java/bjc/utils/parserutils/TokenUtils.java
+++ b/BJC-Utils2/src/main/java/bjc/utils/parserutils/TokenUtils.java
@@ -155,13 +155,19 @@ public class TokenUtils {
public static String descapeString(final String inp) {
if (inp == null) throw new NullPointerException("inp must not be null");
+ /*
+ * Prepare the buffer and escape finder.
+ */
final StringBuffer work = new StringBuffer();
-
final Matcher possibleEscapeFinder = possibleEscapePatt.matcher(inp);
final Matcher escapeFinder = escapePatt.matcher(inp);
while (possibleEscapeFinder.find()) {
if (!escapeFinder.find()) {
+ /*
+ * Found a possible escape that isn't actually an
+ * escape.
+ */
final String msg = String.format("Illegal escape sequence '%s' at position %d",
possibleEscapeFinder.group(), possibleEscapeFinder.start());
@@ -170,6 +176,9 @@ public class TokenUtils {
final String escapeSeq = escapeFinder.group();
+ /*
+ * Convert the escape to a string.
+ */
String escapeRep = "";
switch (escapeSeq) {
case "\\b":
@@ -216,6 +225,9 @@ public class TokenUtils {
return work.toString();
}
+ /*
+ * Handle a unicode codepoint.
+ */
private static String handleUnicodeEscape(final String seq) {
try {
final int codepoint = Integer.parseInt(seq, 16);
@@ -232,6 +244,9 @@ public class TokenUtils {
}
}
+ /*
+ * Handle a octal codepoint.
+ */
private static String handleOctalEscape(final String seq) {
try {
final int codepoint = Integer.parseInt(seq, 8);