@Override public T apply(E from) { return production.getToken(from); }
public T apply(E from) { return production.getToken(from); }
@Override public boolean apply(E input) { T token = production.getToken(input); return token != null && matches.apply(token); } });
public boolean apply(E input) { T token = production.getToken(input); return token != null && matches.apply(token); } });
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>"; }
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); }