use of org.eclipse.xtext.serializer.sequencer.RuleCallStack in project xtext-core by eclipse.
the class SyntacticSequencerPDAProviderNavigatorTest method newStack.
protected RuleCallStack newStack(ISynTransition start, String... ruleCalls) {
RuleCallStack result = new RuleCallStack();
for (String name : ruleCalls) {
ISynEmitterState emitter = findEmitter(start, name, Sets.<ISynFollowerOwner>newHashSet());
result.push((RuleCall) emitter.getGrammarElement());
}
return result;
}
use of org.eclipse.xtext.serializer.sequencer.RuleCallStack in project xtext-core by eclipse.
the class SyntacticSequencerPDAProviderNavigatorTest method testAmbiguousRecursion.
@Test
public void testAmbiguousRecursion() throws Exception {
StringBuilder grammar = new StringBuilder();
grammar.append("Addition returns Expr: Prim ({Add.left=current} '+' right=Prim)*;\n");
grammar.append("Prim returns Expr: {Val} name=ID | '(' Addition ')';\n");
ISynAbsorberState start = getParserRule(grammar.toString(), "Prim", "Val");
ISynTransition trans1 = findTransition(start, "start", "name=ID");
assertFalse(trans1.involvesUnassignedTokenRuleCalls());
assertTrue(trans1.isSyntacticallyAmbiguous());
// assertEquals(1, trans1.getDistanceWithStackToAbsorber(newStack()));
assertEquals("[{Val}]", trans1.getShortestPathToAbsorber(newStack()).toString());
RuleCallStack stack2 = newStack();
ISynTransition trans2 = findTransition(start, "name=ID", "stop");
assertFalse(trans2.involvesUnassignedTokenRuleCalls());
assertFalse(trans2.isSyntacticallyAmbiguous());
// assertEquals(0, trans2.getDistanceWithStackToAbsorber(stack2));
assertEquals("[]", trans2.getShortestPathToAbsorber(stack2).toString());
// RuleCallStack stack3 = newStack(trans1, ">>Addition", ">>Prim");
// ISynTransition trans3 = findTransition(start, "name=ID", "stop");
// assertFalse(trans3.involvesUnassignedTokenRuleCalls());
// assertFalse(trans3.isSyntacticallyAmbiguous());
// // assertEquals(3, trans3.getDistanceWithStackToAbsorber(stack3));
// assertEquals("[<<Prim, <<Addition, ')']", trans3.getShortestStackpruningPathToAbsorber(stack3).toString());
}
Aggregations