use of org.eclipse.xtext.serializer.analysis.ISyntacticSequencerPDAProvider in project xtext-core by eclipse.
the class SyntacticSequencerPDAProviderNavigatorTest method getParserRule.
protected ISynAbsorberState getParserRule(String body, String name, String typeName) throws Exception {
Grammar grammar = (Grammar) getModel(HEADER + body);
// SyntacticSequencerPDA2SimpleDot.drawGrammar("pdf/" + getName(),
// grammar);
// SyntacticSequencerPDA2ExtendedDot.drawGrammar(createSequenceParserPDAProvider(),
// "pdf/" + getName(), grammar);
ISyntacticSequencerPDAProvider pdaProvider = get(ISyntacticSequencerPDAProvider.class);
SerializationContextMap<ISynAbsorberState> pdas = pdaProvider.getSyntacticSequencerPDAs(grammar);
for (SerializationContextMap.Entry<ISynAbsorberState> e : pdas.sortedCopy().values()) {
for (ISerializationContext context : e.getContexts()) {
if (context.getAssignedAction() != null)
continue;
ISynAbsorberState pda = e.getValue();
ParserRule rule = context.getParserRule();
EClass type = context.getType();
boolean nameMatches = rule == null || name == null || rule.getName().equals(name);
boolean typeMatches = type == null || typeName == null || typeName.equals(type.getName());
if (nameMatches && typeMatches)
return pda;
}
}
throw new IllegalStateException();
}
use of org.eclipse.xtext.serializer.analysis.ISyntacticSequencerPDAProvider in project xtext-core by eclipse.
the class SyntacticSequencerPDAProviderTest method getParserRule.
// public void drawGrammar(String path, Grammar grammar) {
// try {
// IContextPDAProvider contexts = get(IContextPDAProvider.class);
// IContextTypePDAProvider types = get(IContextTypePDAProvider.class);
// SyntacticSequencerPDA2ExtendedDot seq2dot = get(SyntacticSequencerPDA2ExtendedDot.class);
// for (EObject ctx : contexts.getAllContexts(grammar))
// for (EClass type : types.getTypesForContext(grammar, ctx))
// seq2dot.draw(new Pair<EObject, EClass>(ctx, type),
// path + "-" + new Context2NameFunction().toFunction(grammar).apply(ctx) + "_"
// + (type == null ? "null" : type.getName()) + "-PDA.pdf",
// "-T pdf");
// } catch (IOException e) {
// e.printStackTrace();
// }
// }
protected String getParserRule(String body) throws Exception {
Grammar grammar = (Grammar) getModel(HEADER + body);
// StackTraceElement ele = Thread.currentThread().getStackTrace()[2];
// drawGrammar("pdf/" + ele.getMethodName(), grammar);
ISyntacticSequencerPDAProvider pdaProvider = get(ISyntacticSequencerPDAProvider.class);
SerializationContextMap<ISynAbsorberState> pdas = pdaProvider.getSyntacticSequencerPDAs(grammar);
List<String> result = Lists.newArrayList();
for (Entry<ISynAbsorberState> e : pdas.sortedCopy().values()) {
result.add(Joiner.on(", ").join(e.getContexts()) + ":");
result.addAll(pda2lines2(e.getValue()));
}
return Joiner.on("\n").join(result);
}
Aggregations