protected boolean filter(E ele) { if (filter != null) return filter.apply(ele); return production.getSequentialChildren(ele) == null && production.getAlternativeChildren(ele) == null && production.getUnorderedChildren(ele) == null; }
protected boolean filter(E ele) { if (filter != null) return filter.apply(ele); return production.getSequentialChildren(ele) == null && production.getAlternativeChildren(ele) == null && production.getUnorderedChildren(ele) == null; }
public <E, T> Iterable<E> getChildren(Production<E, T> production, E element) { Iterable<E> result; if ((result = production.getSequentialChildren(element)) != null) return result; if ((result = production.getAlternativeChildren(element)) != null) return result; if ((result = production.getUnorderedChildren(element)) != null) return result; return null; }
public <E, T> Iterable<E> getChildren(Production<E, T> production, E element) { Iterable<E> result; if ((result = production.getSequentialChildren(element)) != null) return result; if ((result = production.getAlternativeChildren(element)) != null) return result; if ((result = production.getUnorderedChildren(element)) != null) return result; return null; }
public String format(Production<ELEMENT, TOKEN> adapter, ELEMENT grammarElement, boolean needParenthesis) { TOKEN token = adapter.getToken(grammarElement); if (token != null) { String cardinality = getCardinality(adapter, grammarElement); if (cardinality == null) return tokenToString.apply(token); return tokenToString.apply(token) + cardinality; } Iterable<ELEMENT> alternative = adapter.getAlternativeChildren(grammarElement); if (alternative != null) return format(adapter, grammarElement, alternative, " | ", false, needParenthesis, 5); Iterable<ELEMENT> group = adapter.getSequentialChildren(grammarElement); if (group != null) return format(adapter, grammarElement, group, " ", false, needParenthesis, 5); Iterable<ELEMENT> ungroup = adapter.getUnorderedChildren(grammarElement); if (ungroup != null) return format(adapter, grammarElement, ungroup, " & ", false, needParenthesis, 5); return "<unknown>"; }
public String format(Production<ELEMENT, TOKEN> adapter, ELEMENT grammarElement, boolean needParenthesis) { TOKEN token = adapter.getToken(grammarElement); if (token != null) { String cardinality = getCardinality(adapter, grammarElement); if (cardinality == null) return tokenToString.apply(token); return tokenToString.apply(token) + cardinality; } Iterable<ELEMENT> alternative = adapter.getAlternativeChildren(grammarElement); if (alternative != null) return format(adapter, grammarElement, alternative, " | ", false, needParenthesis); Iterable<ELEMENT> group = adapter.getSequentialChildren(grammarElement); if (group != null) return format(adapter, grammarElement, group, " ", false, needParenthesis); Iterable<ELEMENT> ungroup = adapter.getUnorderedChildren(grammarElement); if (ungroup != null) return format(adapter, grammarElement, ungroup, " & ", false, needParenthesis); return "<unknown>"; }
protected void collectChildren(E element, Set<E> result, Set<E> visited) { Iterable<E> children; if ((children = production.getSequentialChildren(element)) != null) collectChildrenSequence(element, children, result, visited); else if ((children = production.getAlternativeChildren(element)) != null) collectChildrenAlternative(element, children, result, visited); else if ((children = production.getUnorderedChildren(element)) != null) switch (unorderedStrategy) { case SEQUENCE: collectChildrenSequence(element, children, result, visited); break; case MULIT_ALTERNATIVE: collectChildrenUnorderedAlt(element, children, result, visited); break; } else { if (production.isMany(element) /* && filter(element) */) collectElement(element, result, visited); collectByParent(element, result, visited); } }
protected void collectChildren(E element, Set<E> result, Set<E> visited) { Iterable<E> children; if ((children = production.getSequentialChildren(element)) != null) collectChildrenSequence(element, children, result, visited); else if ((children = production.getAlternativeChildren(element)) != null) collectChildrenAlternative(element, children, result, visited); else if ((children = production.getUnorderedChildren(element)) != null) switch (unorderedStrategy) { case SEQUENCE: collectChildrenSequence(element, children, result, visited); break; case MULIT_ALTERNATIVE: collectChildrenUnorderedAlt(element, children, result, visited); break; } else { if (production.isMany(element) /* && filter(element) */) collectElement(element, result, visited); collectByParent(element, result, visited); } }
public <S, D, T> D clone(Production<S, T> production, S ele, ProductionFactory<D, T> factory) { boolean many = production.isMany(ele); boolean optional = production.isOptional(ele); T token = production.getToken(ele); if (token != null) return factory.createForToken(many, optional, token); Iterable<S> alternative = production.getAlternativeChildren(ele); if (alternative != null) return factory.createForAlternativeChildren(many, optional, clone(production, alternative, factory)); Iterable<S> group = production.getSequentialChildren(ele); if (group != null) return factory.createForSequentialChildren(many, optional, clone(production, group, factory)); Iterable<S> unorderedgroup = production.getUnorderedChildren(ele); if (unorderedgroup != null) return factory.createForUnordertedChildren(many, optional, clone(production, unorderedgroup, factory)); return factory.createForToken(many, optional, null); }
public <S, D, T> D clone(Production<S, T> production, S ele, ProductionFactory<D, T> factory) { boolean many = production.isMany(ele); boolean optional = production.isOptional(ele); T token = production.getToken(ele); if (token != null) return factory.createForToken(many, optional, token); Iterable<S> alternative = production.getAlternativeChildren(ele); if (alternative != null) return factory.createForAlternativeChildren(many, optional, clone(production, alternative, factory)); Iterable<S> group = production.getSequentialChildren(ele); if (group != null) return factory.createForSequentialChildren(many, optional, clone(production, group, factory)); Iterable<S> unorderedgroup = production.getUnorderedChildren(ele); if (unorderedgroup != null) return factory.createForUnordertedChildren(many, optional, clone(production, unorderedgroup, factory)); return factory.createForToken(many, optional, null); }