/** * Unfolds alternations (brace lists) into a list. */ public static Iterable<String> expandGlob(String glob) { return new GlobBraceParser(glob).expandGlob(); }
Iterable<String> expandList() { Iterable<String> result = expandS(); checkEndOfInput(); return result; }
Iterable<String> expandGlob() { Iterable<String> result = expandE(); checkEndOfInput(); return result; }
/** * Similar to {@code expandGlob} but considers the input * string to be a comma separated list. Equivalient to calling * {@code expandGlob("{" + glob + "}")}. */ public static Iterable<String> expandList(String glob) { return new GlobBraceParser(glob).expandList(); } }
private Iterable<String> expandF() { if (scanner.peek().equals("{")) { scanner.next(); Iterable<String> left = expandS(); String token = scanner.next(); if (!token.equals("}")) { throw new IllegalArgumentException("Expected '}' instead of '" + token + '\''); } Iterable<String> right = expandE(); return cartesianProduct(left, right); } else { return singletonList(""); } }
private Iterable<String> expandE() { switch (scanner.peek()) { case "{": case "}": case ",": return expandF(); default: return cartesianProduct(singletonList(scanner.next()), expandF()); } }
private Iterable<String> expandT() { switch (scanner.peek()) { case ",": scanner.next(); return expandS(); default: return emptyList(); } }