Skip to content

Commit

Permalink
RgroupList parsing - did not loop. We really just need if/else
Browse files Browse the repository at this point in the history
  • Loading branch information
johnmay authored and egonw committed Feb 20, 2022
1 parent c10d618 commit d44f11a
Showing 1 changed file with 23 additions and 28 deletions.
Expand Up @@ -202,35 +202,30 @@ public static boolean isValidOccurrenceSyntax(String occ) {
StringTokenizer st = new StringTokenizer(occ, ",");
while (st.hasMoreTokens()) {
String cond = st.nextToken().trim().replaceAll(" ", "");
do {
//Number: "n"
if (match("^\\d+$", cond)) {
if (Integer.parseInt(cond) < 0) // not allowed
return false;
break;
}
//Range: "n-m"
if (match("^\\d+-\\d+$", cond)) {
int from = Integer.parseInt(cond.substring(0, cond.indexOf('-')));
int to = Integer.parseInt(cond.substring(cond.indexOf('-') + 1, cond.length()));
if (from < 0 || to < 0 || to < from) // not allowed
return false;
break;
}
//Smaller than: "<n"
if (match("^<\\d+$", cond)) {
int n = Integer.parseInt(cond.substring(cond.indexOf('<') + 1, cond.length()));
if (n == 0) // not allowed
return false;
break;
}
//Greater than: ">n"
if (match("^>\\d+$", cond)) {
break;
}

//Number: "n"
if (match("^\\d+$", cond)) {
if (Integer.parseInt(cond) < 0) // not allowed
return false;
}
//Range: "n-m"
else if (match("^\\d+-\\d+$", cond)) {
int from = Integer.parseInt(cond.substring(0, cond.indexOf('-')));
int to = Integer.parseInt(cond.substring(cond.indexOf('-') + 1));
if (from < 0 || to < 0 || to < from) // not allowed
return false;
}
//Smaller than: "<n"
else if (match("^<\\d+$", cond)) {
int n = Integer.parseInt(cond.substring(cond.indexOf('<') + 1));
if (n == 0) // not allowed
return false;
}
//Greater than: ">n"
else if (match("^>\\d+$", cond)) {
// no-op?
}
else
return false;
} while (1 == 0);
}

return true;
Expand Down

0 comments on commit d44f11a

Please sign in to comment.