summaryrefslogtreecommitdiff
path: root/base/src/main/java/bjc/utils/parserutils
diff options
context:
space:
mode:
Diffstat (limited to 'base/src/main/java/bjc/utils/parserutils')
-rw-r--r--base/src/main/java/bjc/utils/parserutils/TokenUtils.java56
1 files changed, 28 insertions, 28 deletions
diff --git a/base/src/main/java/bjc/utils/parserutils/TokenUtils.java b/base/src/main/java/bjc/utils/parserutils/TokenUtils.java
index 20c8ed2..a734477 100644
--- a/base/src/main/java/bjc/utils/parserutils/TokenUtils.java
+++ b/base/src/main/java/bjc/utils/parserutils/TokenUtils.java
@@ -17,14 +17,14 @@ import bjc.utils.parserutils.splitter.TokenSplitter;
/**
* Utilities useful for operating on PL tokens.
*
- * @author EVE
+ * @author Ben Culkin
*
*/
public class TokenUtils {
/**
* Simple implementation of TokenSplitter for removing double-quoted strings.
*
- * @author EVE
+ * @author Ben Culkin
*
*/
public static class StringTokenSplitter implements TokenSplitter {
@@ -70,15 +70,15 @@ public class TokenUtils {
*
* Splits a string around instances of java-style double-quoted strings.
*
- * @param inp
+ * @param input
* The string to split.
*
* @return An list containing alternating bits of the string and the embedded
* double-quoted strings that separated them.
*/
- public static List<String> removeDQuotedStrings(final String inp) {
+ public static List<String> removeDQuotedStrings(final String input) {
/* Validate input. */
- if (inp == null)
+ if (input == null)
throw new NullPointerException("inp must not be null");
/*
@@ -90,16 +90,16 @@ public class TokenUtils {
/*
* Matcher for proper strings and single quotes.
*/
- final Matcher mt = doubleQuotePatt.matcher(inp);
- final Matcher corr = quotePatt.matcher(inp);
+ final Matcher mt = doubleQuotePatt.matcher(input);
+ final Matcher corr = quotePatt.matcher(input);
if (corr.find() && !corr.find()) {
/*
* There's a unmatched opening quote with no strings.
*/
final String msg = String.format(
- "Unclosed string literal '%s'. Opening quote was at position %d", inp,
- inp.indexOf("\""));
+ "Unclosed string literal '%s'. Opening quote was at position %d", input,
+ input.indexOf("\""));
throw new IllegalArgumentException(msg);
}
@@ -135,8 +135,8 @@ public class TokenUtils {
* There's a unmatched opening quote with at least one string.
*/
final String msg = String.format(
- "Unclosed string literal '%s'. Opening quote was at position %d", inp,
- inp.lastIndexOf("\""));
+ "Unclosed string literal '%s'. Opening quote was at position %d", input,
+ input.lastIndexOf("\""));
throw new IllegalArgumentException(msg);
}
@@ -157,23 +157,23 @@ public class TokenUtils {
* Use {@link StringDescaper} for customizable escapes. This only handles the
* ones that are built into Java strings.
*
- * @param inp
+ * @param input
* The string to replace escape sequences in.
*
* @return The string with escape sequences replaced by their equivalent
* characters.
*/
- public static String descapeString(final String inp) {
+ public static String descapeString(final String input) {
/* Validate input. */
- if (inp == null)
+ if (input == 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);
+ final Matcher possibleEscapeFinder = possibleEscapePatt.matcher(input);
+ final Matcher escapeFinder = escapePatt.matcher(input);
/* Go through all possible escapes. */
while (possibleEscapeFinder.find()) {
@@ -292,29 +292,29 @@ public class TokenUtils {
* Check if a given string would be successfully converted to a double by
* {@link Double#parseDouble(String)}.
*
- * @param inp
+ * @param input
* The string to check.
* @return Whether the string is a valid double or not.
*/
- public static boolean isDouble(final String inp) {
- return DoubleMatcher.doubleLiteral.matcher(inp).matches();
+ public static boolean isDouble(final String input) {
+ return DoubleMatcher.doubleLiteral.matcher(input).matches();
}
/**
* Check if a given string would be successfully converted to a double by
* {@link Double#parseDouble(String)} if a given suffix was removed.
*
- * @param inp
+ * @param input
* The string to check.
* @param suffix
* The suffix to remove
* @return Whether the string is a valid double or not.
*/
- public static boolean isSuffixedDouble(final String inp, final String suffix) {
+ public static boolean isSuffixedDouble(final String input, final String suffix) {
Function<String, Pattern> patInit;
patInit = (String sfx) -> Pattern.compile("\\A" + DoubleMatcher.rawDouble + suffix + "\\Z");
- return SUFFIX_MAP.computeIfAbsent(suffix, patInit).matcher(inp).matches();
+ return SUFFIX_MAP.computeIfAbsent(suffix, patInit).matcher(input).matches();
}
/**
@@ -324,13 +324,13 @@ public class TokenUtils {
* NOTE: This only checks syntax. Using values out of the range of integers will
* still cause errors.
*
- * @param inp
+ * @param input
* The input to check.
* @return Whether the string is a valid integer or not.
*/
- public static boolean isInt(final String inp) {
+ public static boolean isInt(final String input) {
try {
- Integer.parseInt(inp);
+ Integer.parseInt(input);
return true;
} catch (NumberFormatException nfex) {
return false;
@@ -341,16 +341,16 @@ public class TokenUtils {
* Split a line into a series of space-separated arguments, including string
* literals.
*
- * @param com
+ * @param command
* The command to split from
* @return The split arguments.
*/
- public static List<String> processArguments(String com) {
+ public static List<String> processArguments(String command) {
List<String> strings = new ArrayList<>();
BooleanToggle togg = new BooleanToggle();
- for (String strang : removeDQuotedStrings(com)) {
+ for (String strang : removeDQuotedStrings(command)) {
if (togg.get()) {
strings.add(descapeString(strang));
} else {