@Override public boolean apply(E input) { return cfg.getCall(input) != null; }
public <E, T> Multimap<E, E> getCallers(Cfg<E, T> cfg) { Multimap<E, E> result = ArrayListMultimap.create(); getCallers(cfg, cfg.getRoot(), 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 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); } } } }
public <E, T> Multimap<E, E> getCallers(Cfg<E, T> cfg) { Multimap<E, E> result = ArrayListMultimap.create(); getCallers(cfg, cfg.getRoot(), result); return result; }
public boolean apply(E input) { return cfg.getCall(input) != null; }
public <S, P, E, T1, T2, D extends Pda<S, P>> D create(Cfg<E, T1> cfg, FollowerFunction<E> ff, Function<E, T2> element2token, PdaFactory<D, S, P, ? super T2> fact) { D pda = fact.create(null, null); Map<E, S> states = Maps.newLinkedHashMap(); Map<E, S> stops = Maps.newLinkedHashMap(); Multimap<E, E> callers = new CfgUtil().getCallers(cfg); create(cfg, pda, pda.getStart(), cfg.getRoot(), ff.getStarts(cfg.getRoot()), ff, element2token, fact, states, stops, callers); return pda; }
public <S, P, E, T1, T2, D extends Pda<S, P>> D create(Cfg<E, T1> cfg, FollowerFunction<E> ff, Function<E, T2> element2token, PdaFactory<D, S, P, ? super T2> fact) { D pda = fact.create(null, null); Map<E, S> states = Maps.newHashMap(); Map<E, S> stops = Maps.newHashMap(); Multimap<E, E> callers = new CfgUtil().getCallers(cfg); create(cfg, pda, pda.getStart(), cfg.getRoot(), ff.getStarts(cfg.getRoot()), true, ff, element2token, fact, states, stops, callers); return pda; }