protected List<ISynState> shortestStackpruningPathTo(Iterator<RuleCall> stack, Predicate<ISynState> matches, boolean includeMatch) { List<ISynState> pathTo = new PdaUtil().shortestStackpruningPathTo(getPathToTarget(), stack, matches); if (pathTo != null) return pathTo.subList(1, pathTo.size() - (includeMatch ? 0 : 1)); return null; }
protected List<ISynState> shortestPathTo(Iterator<RuleCall> stack, Predicate<ISynState> matches, boolean includeMatch) { List<ISynState> pathTo = new PdaUtil().shortestPathTo(getPathToTarget(), stack, matches); if (pathTo != null) return pathTo.subList(1, pathTo.size() - (includeMatch ? 0 : 1)); return null; }
protected Pda<ISerState, RuleCall> createPDA(EObject context, EClass type) { Pda<ISerState, RuleCall> contextPda = pdaProvider.getContextPDA(context); Pda<ISerState, RuleCall> contextTypePda = null; if (contextProvider.getTypesForContext(context).size() > 1) { TypeFilter typeFilter = newTypeFilter(type); SerializerPDACloneFactory factory = new SerializerPDACloneFactory(); contextTypePda = new PdaUtil().filterEdges(contextPda, typeFilter, factory); } else contextTypePda = contextPda; return contextTypePda; }
public List<AbstractElementAlias> getAmbiguousSyntaxes() { if (ambiguousSyntaxes != null) return ambiguousSyntaxes; if (!isSyntacticallyAmbiguous()) return ambiguousSyntaxes = Collections.emptyList(); ambiguousSyntaxes = Lists.newArrayList(); Nfa<ISynState> nfa = new PdaUtil().filterUnambiguousPaths(getPathToTarget()); nfa = new NfaUtil().filter(nfa, new Filter()); AbstractElementAlias syntax = new NfaToProduction().nfaToGrammar(nfa, new GetGrammarElement(), new GrammarAliasFactory()); if (syntax instanceof GroupAlias) { GroupAlias group = (GroupAlias) syntax; for (AbstractElementAlias child : group.getChildren()) if (child.isMany() || child.isOptional() || child instanceof AlternativeAlias) ambiguousSyntaxes.add(child); } else ambiguousSyntaxes.add(syntax); return ambiguousSyntaxes; }