summaryrefslogtreecommitdiff
path: root/BJC-Utils2/src/main/java/bjc/utils/parserutils
diff options
context:
space:
mode:
authorbjculkin <bjculkin@mix.wvu.edu>2017-04-06 16:18:22 -0400
committerbjculkin <bjculkin@mix.wvu.edu>2017-04-06 16:18:22 -0400
commitb912d84b1afe05e5f079bd6edef2f0d74020f9aa (patch)
treea090a3aa65b2f3f93f4b6659a96bfc541d4463b9 /BJC-Utils2/src/main/java/bjc/utils/parserutils
parent0be891100df83544c89651c815105832e3e11eb9 (diff)
More properties
Diffstat (limited to 'BJC-Utils2/src/main/java/bjc/utils/parserutils')
-rw-r--r--BJC-Utils2/src/main/java/bjc/utils/parserutils/TokenUtils.java40
1 files changed, 12 insertions, 28 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 065aa2b..0ec00ee 100644
--- a/BJC-Utils2/src/main/java/bjc/utils/parserutils/TokenUtils.java
+++ b/BJC-Utils2/src/main/java/bjc/utils/parserutils/TokenUtils.java
@@ -16,39 +16,23 @@ import static bjc.utils.PropertyDB.applyFormat;
*
*/
public class TokenUtils {
- /*
- * This regex matches potential single character escape sequences.
- */
- private static Pattern possibleEscape = getCompiledRegex("possibleStringEscape");
+ private static String possibleEscapeString = getRegex("possibleStringEscape");
+
+ private static Pattern possibleEscapePatt = Pattern.compile(possibleEscapeString);
private static String shortEscape = getRegex("shortFormStringEscape");
private static String octalEscape = getRegex("octalStringEscape");
private static String unicodeEscape = getRegex("unicodeStringEscape");
- /*
- * This regex matches java-style string escapes
- */
private static String escapeString = applyFormat("stringEscape", shortEscape, octalEscape, unicodeEscape);
private static Pattern escapePatt = Pattern.compile(escapeString);
- /*
- * The regular expression does the following, making sure to capture the
- * string contents.
- *
- * Match one or more characters that aren't quotes or slashes.
- *
- * Match escape sequences.
- *
- * Match all of those things zero or more times, followed by a closing
- * quote
- */
- private static Pattern doubleQuotePatt = Pattern
- .compile("(\"(" + getRegex("nonEscape") + "|" + escapeString + ")*\")");
+ private static String doubleQuoteString = applyFormat("doubleQuotes", getRegex("nonEscape"),
+ possibleEscapeString);
+
+ private static Pattern doubleQuotePatt = Pattern.compile(doubleQuoteString);
- /*
- * This regular expression matches non-escaped quotes.
- */
private static Pattern quotePatt = getCompiledRegex("unescapedQuote");
/**
@@ -95,8 +79,8 @@ public class TokenUtils {
mt.appendReplacement(work, "");
/*
- * Add the string preceeeding the double-quoted string
- * and the double-quoted string to the list.
+ * Add the string preceding the double-quoted string and
+ * the double-quoted string to the list.
*/
res.add(work.toString());
res.add(mt.group(1));
@@ -149,7 +133,7 @@ public class TokenUtils {
StringBuffer work = new StringBuffer();
- Matcher possibleEscapeFinder = possibleEscape.matcher(inp);
+ Matcher possibleEscapeFinder = possibleEscapePatt.matcher(inp);
Matcher escapeFinder = escapePatt.matcher(inp);
while(possibleEscapeFinder.find()) {
@@ -254,7 +238,7 @@ public class TokenUtils {
return DoubleMatcher.floatingLiteral.matcher(inp).matches();
}
- private static Pattern intLitPattern = Pattern.compile("\\A[+\\-]?\\d+\\Z");
+ private static Pattern intLitPattern = getCompiledRegex("intLiteral");
/**
* Check if a given string would be successfully converted to a integer
@@ -270,4 +254,4 @@ public class TokenUtils {
public static boolean isInt(String inp) {
return intLitPattern.matcher(inp).matches();
}
-}
+} \ No newline at end of file