| 242 | private static final java.util.regex.Pattern RANGE = compile("\\{(\\d+)-(\\d+)}"); |
| 243 | |
| 244 | private static Repeat parse(String str) { |
| 245 | Matcher nOrMore = N_OR_MORE.matcher(str); |
| 246 | if (nOrMore.matches()) { |
| 247 | int min = Integer.parseInt(nOrMore.group(1)); |
| 248 | return new Repeat(min, MAX); |
| 249 | } |
| 250 | Matcher n = N.matcher(str); |
| 251 | if (n.matches()) { |
| 252 | int times = Integer.parseInt(n.group(1)); |
| 253 | return new Repeat(times, times); |
| 254 | } |
| 255 | Matcher range = RANGE.matcher(str); |
| 256 | if (range.matches()) { |
| 257 | int min = Integer.parseInt(range.group(1)); |
| 258 | int max = Integer.parseInt(range.group(2)); |
| 259 | return new Repeat(min, max); |
| 260 | } |
| 261 | throw new IllegalArgumentException("Invalid parameter repetition: " + str); |
| 262 | } |
| 263 | |
| 264 | @Override |
| 265 | public String toString() { |