public BranchPattern(final List<? extends Pattern> children) { this.children = list(children); }
public BranchPattern(final List<? extends Pattern> children) { this.children = list(children); }
public static <T> List<T> list(final T[] elements) { final List<T> list = list(); for (final T element : elements) { list.add(element); } return list; }
public static <T> List<T> list(final T element) { final List<T> list = list(); list.add(element); return list; }
public static <T> List<T> list(final Iterable<? extends T> elements) { final List<T> list = list(); for (final T element : elements) { list.add(element); } return list; }
public static <T> List<T> list(final T element) { final List<T> list = list(); list.add(element); return list; }
public static <T> List<T> list(final Iterable<? extends T> elements) { final List<T> list = list(); for (final T element : elements) { list.add(element); } return list; }
public static <T> List<T> list(final T[] elements) { final List<T> list = list(); for (final T element : elements) { list.add(element); } return list; }
public static List<String> split(final String self) { return list(self.trim().split("\\s+")); }
public static List<String> split(final String self) { return list(self.trim().split("\\s+")); }
@Override protected final List<Pattern> flat(final Class<?>... types) { if (in(getClass(), types)) { return list((Pattern) this); } // >>> return sum([child.flat(*types) for child in self.children], []) { final List<Pattern> result = list(); for (final Pattern child : children) { result.addAll(child.flat(types)); } return result; } }
@Override protected final List<Pattern> flat(final Class<?>... types) { if (in(getClass(), types)) { return list((Pattern) this); } // >>> return sum([child.flat(*types) for child in self.children], []) { final List<Pattern> result = list(); for (final Pattern child : children) { result.addAll(child.flat(types)); } return result; } }
public static List<String> split(final String pattern, final String string) { if (!hasGrouping(pattern)) { return list(string.split(pattern)); } final Matcher matcher = Pattern.compile(pattern, 0).matcher(string); final List<String> matches = list(); int start = 0; while (matcher.find()) { matches.add(string.substring(start, matcher.start())); for (int i = 0; i < matcher.groupCount(); i++) { matches.add(matcher.group(i + 1)); } start = matcher.end(); } matches.add(string.substring(start)); return matches; }
public static List<String> split(final String pattern, final String string) { if (!hasGrouping(pattern)) { return list(string.split(pattern)); } final Matcher matcher = Pattern.compile(pattern, 0).matcher(string); final List<String> matches = list(); int start = 0; while (matcher.find()) { matches.add(string.substring(start, matcher.start())); for (int i = 0; i < matcher.groupCount(); i++) { matches.add(matcher.group(i + 1)); } start = matcher.end(); } matches.add(string.substring(start)); return matches; }
public static Tokens fromPattern(String source) { source = Re.sub("([\\[\\]\\(\\)\\|]|\\.\\.\\.)", " $1 ", source); List<String> $source; // >>> source = [s for s in re.split('\s+|(\S*<.*?>)', source) if s] { $source = list(); for (final String s : Re.split("\\s+|(\\S*<.*?>)", source)) { if (bool(s)) { $source.add(s); } } } return Tokens.withLanguageError($source); }
public static Tokens fromPattern(String source) { source = Re.sub("([\\[\\]\\(\\)\\|]|\\.\\.\\.)", " $1 ", source); List<String> $source; // >>> source = [s for s in re.split('\s+|(\S*<.*?>)', source) if s] { $source = list(); for (final String s : Re.split("\\s+|(\\S*<.*?>)", source)) { if (bool(s)) { $source.add(s); } } } return Tokens.withLanguageError($source); }
@Override protected MatchResult match(List<LeafPattern> left, List<LeafPattern> collected) { if (collected == null) { collected = list(); } for (final Pattern pattern : getChildren()) { final MatchResult u = pattern.match(left, collected); left = u.getLeft(); collected = u.getCollected(); } return new MatchResult(true, left, collected); } }
@Override protected MatchResult match(List<LeafPattern> left, List<LeafPattern> collected) { if (collected == null) { collected = list(); } for (final Pattern pattern : getChildren()) { final MatchResult u = pattern.match(left, collected); left = u.getLeft(); collected = u.getCollected(); } return new MatchResult(true, left, collected); } }