Search in sources :

Example 1 with ISynTransition

use of org.eclipse.xtext.serializer.analysis.ISyntacticSequencerPDAProvider.ISynTransition in project xtext-core by eclipse.

the class SyntacticSequencerPDAProviderNavigatorTest method testSimple.

@Test
public void testSimple() throws Exception {
    ISynAbsorberState start = getParserRule("Rule: a1=ID 'kw1' a2=ID;");
    ISynTransition trans = findTransition(start, "a1=ID", "a2=ID");
    assertFalse(trans.involvesUnassignedTokenRuleCalls());
    assertFalse(trans.isSyntacticallyAmbiguous());
    // assertEquals(1, trans.getDistanceWithStackToAbsorber(newStack()));
    assertEquals("['kw1']", trans.getShortestPathToAbsorber(newStack()).toString());
}
Also used : ISynAbsorberState(org.eclipse.xtext.serializer.analysis.ISyntacticSequencerPDAProvider.ISynAbsorberState) ISynTransition(org.eclipse.xtext.serializer.analysis.ISyntacticSequencerPDAProvider.ISynTransition) Test(org.junit.Test)

Example 2 with ISynTransition

use of org.eclipse.xtext.serializer.analysis.ISyntacticSequencerPDAProvider.ISynTransition in project xtext-core by eclipse.

the class SyntacticSequencerPDAProviderNavigatorTest method testAmbiguousAlternative.

@Test
public void testAmbiguousAlternative() throws Exception {
    ISynAbsorberState start = getParserRule("Rule: a1=ID ('kw1' 'kw2' | 'kw3') a2=ID;");
    ISynTransition trans = findTransition(start, "a1=ID", "a2=ID");
    assertFalse(trans.involvesUnassignedTokenRuleCalls());
    assertTrue(trans.isSyntacticallyAmbiguous());
    // assertEquals(1, trans.getDistanceWithStackToAbsorber(newStack()));
    assertEquals("['kw3']", trans.getShortestPathToAbsorber(newStack()).toString());
}
Also used : ISynAbsorberState(org.eclipse.xtext.serializer.analysis.ISyntacticSequencerPDAProvider.ISynAbsorberState) ISynTransition(org.eclipse.xtext.serializer.analysis.ISyntacticSequencerPDAProvider.ISynTransition) Test(org.junit.Test)

Example 3 with ISynTransition

use of org.eclipse.xtext.serializer.analysis.ISyntacticSequencerPDAProvider.ISynTransition in project xtext-core by eclipse.

the class SyntacticSequencerPDAProviderNavigatorTest method testTerminal.

@Test
public void testTerminal() throws Exception {
    ISynAbsorberState start = getParserRule("Rule: a1=ID FOO a2=ID; terminal FOO: '$';");
    ISynTransition trans = findTransition(start, "a1=ID", "a2=ID");
    assertTrue(trans.involvesUnassignedTokenRuleCalls());
    assertFalse(trans.isSyntacticallyAmbiguous());
    // assertEquals(1, trans.getDistanceWithStackToAbsorber(newStack()));
    assertEquals("[FOO]", trans.getShortestPathToAbsorber(newStack()).toString());
}
Also used : ISynAbsorberState(org.eclipse.xtext.serializer.analysis.ISyntacticSequencerPDAProvider.ISynAbsorberState) ISynTransition(org.eclipse.xtext.serializer.analysis.ISyntacticSequencerPDAProvider.ISynTransition) Test(org.junit.Test)

Example 4 with ISynTransition

use of org.eclipse.xtext.serializer.analysis.ISyntacticSequencerPDAProvider.ISynTransition in project xtext-core by eclipse.

the class SyntacticSequencerPDAProviderNavigatorTest method testDatatype.

@Test
public void testDatatype() throws Exception {
    ISynAbsorberState start = getParserRule("Rule: a1=ID Foo a2=ID; Foo: ID;");
    ISynTransition trans = findTransition(start, "a1=ID", "a2=ID");
    assertTrue(trans.involvesUnassignedTokenRuleCalls());
    assertFalse(trans.isSyntacticallyAmbiguous());
    // assertEquals(1, trans.getDistanceWithStackToAbsorber(newStack()));
    assertEquals("[Foo]", trans.getShortestPathToAbsorber(newStack()).toString());
}
Also used : ISynAbsorberState(org.eclipse.xtext.serializer.analysis.ISyntacticSequencerPDAProvider.ISynAbsorberState) ISynTransition(org.eclipse.xtext.serializer.analysis.ISyntacticSequencerPDAProvider.ISynTransition) Test(org.junit.Test)

Example 5 with ISynTransition

use of org.eclipse.xtext.serializer.analysis.ISyntacticSequencerPDAProvider.ISynTransition in project xtext-core by eclipse.

the class SyntacticSequencerPDAProviderNavigatorTest method testAmbiguousOptional.

@Test
public void testAmbiguousOptional() throws Exception {
    ISynAbsorberState start = getParserRule("Rule: a1=ID 'kw1' 'kw2'? a2=ID;");
    ISynTransition trans = findTransition(start, "a1=ID", "a2=ID");
    assertFalse(trans.involvesUnassignedTokenRuleCalls());
    assertTrue(trans.isSyntacticallyAmbiguous());
    // assertEquals(1, trans.getDistanceWithStackToAbsorber(newStack()));
    assertEquals("['kw1']", trans.getShortestPathToAbsorber(newStack()).toString());
}
Also used : ISynAbsorberState(org.eclipse.xtext.serializer.analysis.ISyntacticSequencerPDAProvider.ISynAbsorberState) ISynTransition(org.eclipse.xtext.serializer.analysis.ISyntacticSequencerPDAProvider.ISynTransition) Test(org.junit.Test)

Aggregations

ISynTransition (org.eclipse.xtext.serializer.analysis.ISyntacticSequencerPDAProvider.ISynTransition)11 ISynAbsorberState (org.eclipse.xtext.serializer.analysis.ISyntacticSequencerPDAProvider.ISynAbsorberState)10 Test (org.junit.Test)8 GrammarElementTitleSwitch (org.eclipse.xtext.grammaranalysis.impl.GrammarElementTitleSwitch)1 RuleCallStack (org.eclipse.xtext.serializer.sequencer.RuleCallStack)1