protected String stateToString(Pda<STATE, STACKITEM> pda, STATE state) { STACKITEM push = pda.getPush(state); STACKITEM pop = pda.getPop(state); if (pushFormatter != null && push != null) return pushFormatter.apply(push); if (popFormatter != null && pop != null) return popFormatter.apply(pop); String prefix = push != null && pop != null ? "<>" : push != null ? ">>" : pop != null ? "<<" : ""; if (stateFormatter != null) { String fmt = stateFormatter.apply(state); return fmt.startsWith(prefix) ? fmt : prefix + fmt; } if (state == null) return prefix + "null"; String fmt = state.toString(); return fmt.startsWith(prefix) ? fmt : prefix + fmt; } }
protected String title(Pda<STATE, STACKITEM> pda, STATE state) { STACKITEM push = pda.getPush(state); STACKITEM pop = pda.getPop(state); StringBuilder result = new StringBuilder(); if (push != null) { result.append(">>"); result.append(stackitemFormatter.apply(push)); } if (pop != null) { result.append("<<"); result.append(stackitemFormatter.apply(pop)); } if (result.length() == 0) result.append(stateFormatter.apply(state)); return result.toString(); }
protected String title(Pda<STATE, STACKITEM> pda, STATE state) { STACKITEM push = pda.getPush(state); STACKITEM pop = pda.getPop(state); StringBuilder result = new StringBuilder(); if (push != null) { result.append(">>"); result.append(stackitemFormatter.apply(push)); } if (pop != null) { result.append("<<"); result.append(stackitemFormatter.apply(pop)); } if (result.length() == 0) result.append(stateFormatter.apply(state)); return result.toString(); }
protected String stateToString(Pda<STATE, STACKITEM> pda, STATE state) { STACKITEM push = pda.getPush(state); STACKITEM pop = pda.getPop(state); if (pushFormatter != null && push != null) return pushFormatter.apply(push); if (popFormatter != null && pop != null) return popFormatter.apply(pop); String prefix = push != null && pop != null ? "<>" : push != null ? ">>" : pop != null ? "<<" : ""; if (stateFormatter != null) { String fmt = stateFormatter.apply(state); return fmt.startsWith(prefix) ? fmt : prefix + fmt; } if (state == null) return prefix + "null"; String fmt = state.toString(); return fmt.startsWith(prefix) ? fmt : prefix + fmt; } }
public <S, P, D extends Pda<S, P>> Map<P, Pair<S, S>> collectPopsAndPushs(Pda<S, P> pda) { Map<P, Pair<S, S>> result = Maps.newLinkedHashMap(); for (S s : nfaUtil.collect(pda)) { P push = pda.getPush(s); if (push != null) { Pair<S, S> o = result.get(push); Pair<S, S> n = Tuples.create(s, o == null ? null : o.getSecond()); result.put(push, n); } P pop = pda.getPop(s); if (pop != null) { Pair<S, S> o = result.get(pop); Pair<S, S> n = Tuples.create(o == null ? null : o.getFirst(), s); result.put(pop, n); } } return result; }
@Override public CyclicStackItem<P> enter(Pda<S, P> pda, S state, CyclicStackItem<P> previous) { P item; if ((item = pda.getPush(state)) != null) return previous.push(item); if ((item = pda.getPop(state)) != null) return previous.pop(item); if (previous == null) return new CyclicStackItem<P>(); return previous; }
public CyclicStackItem<P> enter(Pda<S, P> pda, S state, CyclicStackItem<P> previous) { P item; if ((item = pda.getPush(state)) != null) return previous.push(item); if ((item = pda.getPop(state)) != null) return previous.pop(item); if (previous == null) return new CyclicStackItem<P>(); return previous; }
return new TraceItem<S, P>(trace, follower, trace.stackitem); if (canPass.apply(follower)) { P push = pda.getPush(follower); visited.add(follower); if (push != null) {
if (pda.getPop(orig) != null) { orig2copy.put(orig, fact.createPop(result, orig)); } else if (pda.getPush(orig) != null) { orig2copy.put(orig, fact.createPush(result, orig)); } else {
return new TraceItem<S, P>(trace, follower, trace.stackitem); if (canPass.apply(follower)) { P push = pda.getPush(follower); visited.add(follower); if (push != null) {
protected <S, P, T, D extends Pda<S, P>> S clone(S state, Pda<S, P> src, D target, Function<S, T> tokens, PdaFactory<D, S, P, T> fact, Identity<S> identity) { if (state == src.getStart()) return target.getStart(); if (state == src.getStop()) return target.getStop(); P push = src.getPush(state); if (push != null) return identity.get(fact.createPush(target, tokens.apply(state))); P pop = src.getPop(state); if (pop != null) return identity.get(fact.createPop(target, tokens.apply(state))); return identity.get(fact.createState(target, tokens.apply(state))); }
protected <S, P, T, D extends Pda<S, P>> S clone(S state, Pda<S, P> src, D target, Function<S, T> tokens, PdaFactory<D, S, P, T> fact, Identity<S> identity) { if (state == src.getStart()) return target.getStart(); if (state == src.getStop()) return target.getStop(); P push = src.getPush(state); if (push != null) return identity.get(fact.createPush(target, tokens.apply(state))); P pop = src.getPop(state); if (pop != null) return identity.get(fact.createPop(target, tokens.apply(state))); return identity.get(fact.createState(target, tokens.apply(state))); }
else if (pda.getPop(old) != null) old2new.put(old, factory.createPop(result, old)); else if (pda.getPush(old) != null) old2new.put(old, factory.createPush(result, old)); else
P push = pda.getPush(follower); visited.add(follower); if (push != null) {
P push = pda.getPush(follower); visited.add(follower); if (push != null) {
else if (pda.getPop(old) != null) old2new.put(old, factory.createPop(result, old)); else if (pda.getPush(old) != null) old2new.put(old, factory.createPush(result, old)); else