use of org.eclipse.xtext.serializer.analysis.ISerState.SerStateType in project xtext-core by eclipse.
the class ContextPDAProvider method filterUnneededUnassignedRuleCalls.
protected Pda<ISerState, RuleCall> filterUnneededUnassignedRuleCalls(Pda<ISerState, RuleCall> pda, Map<ParserRule, Integer> indexedRules) {
Set<ParserRule> exclude = findRuleCallsToExclude(pda, indexedRules);
if (exclude.isEmpty())
return pda;
SerializerPDA filtered = pdaUtil.filter(pda, new Predicate<ISerState>() {
@Override
public boolean apply(ISerState input) {
SerStateType type = input.getType();
if (type == SerStateType.PUSH || type == SerStateType.POP) {
AbstractRule rule = ((RuleCall) input.getGrammarElement()).getRule();
return !exclude.contains(rule);
}
return true;
}
}, new SerializerPDACloneFactory());
return filtered;
}
use of org.eclipse.xtext.serializer.analysis.ISerState.SerStateType in project xtext-core by eclipse.
the class ContextPDAProvider method collectExtracted.
protected void collectExtracted(ISerState orig, Collection<? extends ISerState> precedents, SerializerPDAState copy, Map<Pair<AbstractElement, SerStateType>, SerializerPDAState> oldToNew, final CallStack inTop, SerializerPDAState start) {
for (ISerState pre : precedents) {
CallStack top = inTop;
AbstractElement element = pre.getGrammarElement();
switch(pre.getType()) {
case START:
if (top.call == null)
connect(start, copy);
continue;
case POP:
top = new CallStack(top, (RuleCall) element);
if (top.isLoop())
continue;
break;
case PUSH:
if (top.call == null) {
connect(start, copy);
continue;
} else if (top.call == element) {
top = top.parent;
} else {
continue;
}
default:
break;
}
Pair<AbstractElement, SerStateType> key = Tuples.create(element, pre.getType());
SerializerPDAState pre2 = oldToNew.get(key);
if (pre2 == null) {
pre2 = new SerializerPDAState(element, pre.getType());
oldToNew.put(key, pre2);
}
if (GrammarUtil.isAssignedAction(pre.getGrammarElement())) /* && pre.getType() != STOP */
{
Set<ISerState> entries = collectPushForAction(pre);
collectExtracted(pre, entries, pre2, oldToNew, top, start);
} else {
if (top.visited.add(pre))
collectExtracted(pre, pre.getPrecedents(), pre2, oldToNew, top, start);
}
connect(pre2, copy);
}
}
Aggregations