This commit is contained in:
Jesse Boyd 2017-06-09 17:07:38 +10:00
parent 6554370b57
commit f26543f7da
No known key found for this signature in database
GPG Key ID: 59F1DE6293AF6E1F
1 changed files with 8 additions and 8 deletions

View File

@ -62,9 +62,9 @@ public abstract class FaweParser<T> extends InputParser<T> {
int len = command.length(); int len = command.length();
String current = null; String current = null;
int end = -1; int end = -1;
boolean newEntry = true;
for (int i = 0; i < len; i++) { for (int i = 0; i < len; i++) {
boolean newEntry = i == 0; int prefix = 0;
boolean prefix = false;
boolean or = false; boolean or = false;
char c = command.charAt(i); char c = command.charAt(i);
if (i < end) continue; if (i < end) continue;
@ -72,7 +72,7 @@ public abstract class FaweParser<T> extends InputParser<T> {
case '&': case '&':
or = true; or = true;
case ',': { case ',': {
prefix = true; prefix = 1;
if (current == null) { if (current == null) {
throw new InputParseException("Duplicate separator"); throw new InputParseException("Duplicate separator");
} }
@ -98,18 +98,18 @@ public abstract class FaweParser<T> extends InputParser<T> {
} }
String arg = command.substring(i + 1, end); String arg = command.substring(i + 1, end);
args.add(arg); args.add(arg);
// start
break; break;
} }
} }
if (newEntry) { if (newEntry) {
int index = StringMan.indexOf(command, i + 1, '[', '&', ','); newEntry = false;
int index = StringMan.indexOf(command, i + prefix, '[', '&', ',');
if (index < 0) index = len; if (index < 0) index = len;
end = index; end = index;
current = command.substring(i + (prefix ? 1 : 0), end); current = command.substring(i + prefix, end);
args = new ArrayList<>(); if (prefix == 1) args = new ArrayList<>();
ParseEntry entry = new ParseEntry(current, or); ParseEntry entry = new ParseEntry(current, or);
keys.add(new AbstractMap.SimpleEntry<ParseEntry, List<String>>(entry, args)); keys.add(new AbstractMap.SimpleEntry<>(entry, args));
} }
} }
for (int i = 0; i < keys.size() - 1; i++) { // Apply greedy and for (int i = 0; i < keys.size() - 1; i++) { // Apply greedy and