protected <S, D, T> List<D> clone(Production<S, T> grammarAdapter, Iterable<S> eles, ProductionFactory<D, T> factory) { List<D> result = Lists.newArrayList(); for (S ele : eles) result.add(clone(grammarAdapter, ele, factory)); return result; }
public <E, T> E find(Production<E, T> production, E element, Predicate<E> matches) { if (matches.apply(element)) return element; Iterable<E> children = getChildren(production, element); if (children != null) for (E child : children) { E found = find(production, child, matches); if (found != null) return found; } return null; }
protected <E, T> void findAll(Production<E, T> production, E element, Predicate<E> matches, List<E> result) { if (matches.apply(element)) result.add(element); Iterable<E> children = getChildren(production, element); if (children != null) for (E child : children) findAll(production, child, matches, result); }
protected <E, T> void getAllChildren(Production<E, T> production, E element, List<E> result) { result.add(element); Iterable<E> children = getChildren(production, element); if (children != null) for (E child : children) getAllChildren(production, child, result); }
protected <E, T> void getCallers(Cfg<E, T> cfg, E root, Multimap<E, E> callers) { for (E call : new ProductionUtil().getAllChildren(cfg, root)) { E called = cfg.getCall(call); if (called != null) { boolean contained = callers.containsKey(called) || called == cfg.getRoot(); callers.put(called, call); if (!contained) getCallers(cfg, called, callers); } } } }
E e; if (fol == null) { E root = new ProductionUtil().getRoot(cfg, ele); if (root == cfg.getRoot()) followerStates.add(pda.getStop());
return new ProductionUtil().clone(production, grammarFactory);
public <E, T> E findByToken(final Production<E, T> production, E element, final Predicate<T> matches) { return find(production, element, new Predicate<E>() { public boolean apply(E input) { T token = production.getToken(input); return token != null && matches.apply(token); } }); }
public <E, T> E findByToken(final Production<E, T> production, final T matches) { return findByToken(production, Predicates.equalTo(matches)); }
public <E, T> List<E> getAllChildren(Production<E, T> production, E element) { List<E> result = Lists.newArrayList(); getAllChildren(production, element, result); return result; }
public <E, T> List<E> findAll(Production<E, T> production, E element, Predicate<E> matches) { List<E> result = Lists.newArrayList(); findAll(production, element, matches, result); return result; }
protected <E, T> void getCallers(Cfg<E, T> cfg, E root, Multimap<E, E> callers) { for (E call : new ProductionUtil().getAllChildren(cfg, root)) { E called = cfg.getCall(call); if (called != null) { boolean contained = callers.containsKey(called) || called == cfg.getRoot(); callers.put(called, call); if (!contained) getCallers(cfg, called, callers); } } } }
protected <E, T> void getAllChildren(Production<E, T> production, E element, List<E> result) { result.add(element); Iterable<E> children = getChildren(production, element); if (children != null) for (E child : children) getAllChildren(production, child, result); }
E e; if (fol == null) { E root = new ProductionUtil().getRoot(cfg, ele); if (root == cfg.getRoot()) followerStates.add(pda.getStop());
root.sort(new ElementAliasComparator<TOKEN>(order)); AliasGrammarProvider<TOKEN> production = new AliasGrammarProvider<TOKEN>(root); return new ProductionUtil().clone(production, grammarFactory);
public <E, T> E findByToken(final Production<E, T> production, E element, final Predicate<T> matches) { return find(production, element, new Predicate<E>() { @Override public boolean apply(E input) { T token = production.getToken(input); return token != null && matches.apply(token); } }); }
public <E, T> E findByToken(final Production<E, T> production, final T matches) { return findByToken(production, Predicates.equalTo(matches)); }
public <E, T> List<E> getAllChildren(Production<E, T> production, E element) { List<E> result = Lists.newArrayList(); getAllChildren(production, element, result); return result; }
public <E, T> List<E> findAll(Production<E, T> production, E element, Predicate<E> matches) { List<E> result = Lists.newArrayList(); findAll(production, element, matches, result); return result; }
public <E, T> E find(Production<E, T> production, E element, Predicate<E> matches) { if (matches.apply(element)) return element; Iterable<E> children = getChildren(production, element); if (children != null) for (E child : children) { E found = find(production, child, matches); if (found != null) return found; } return null; }