Search in sources :

Example 1 with ISynAbsorberState

use of org.eclipse.xtext.serializer.analysis.ISyntacticSequencerPDAProvider.ISynAbsorberState 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 ISynAbsorberState

use of org.eclipse.xtext.serializer.analysis.ISyntacticSequencerPDAProvider.ISynAbsorberState 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 ISynAbsorberState

use of org.eclipse.xtext.serializer.analysis.ISyntacticSequencerPDAProvider.ISynAbsorberState 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 ISynAbsorberState

use of org.eclipse.xtext.serializer.analysis.ISyntacticSequencerPDAProvider.ISynAbsorberState 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 ISynAbsorberState

use of org.eclipse.xtext.serializer.analysis.ISyntacticSequencerPDAProvider.ISynAbsorberState 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

ISynAbsorberState (org.eclipse.xtext.serializer.analysis.ISyntacticSequencerPDAProvider.ISynAbsorberState)19 ISynTransition (org.eclipse.xtext.serializer.analysis.ISyntacticSequencerPDAProvider.ISynTransition)10 Test (org.junit.Test)8 ISerializationContext (org.eclipse.xtext.serializer.ISerializationContext)3 EClass (org.eclipse.emf.ecore.EClass)2 Grammar (org.eclipse.xtext.Grammar)2 ISyntacticSequencerPDAProvider (org.eclipse.xtext.serializer.analysis.ISyntacticSequencerPDAProvider)2 ISynNavigable (org.eclipse.xtext.serializer.analysis.ISyntacticSequencerPDAProvider.ISynNavigable)2 ISynState (org.eclipse.xtext.serializer.analysis.ISyntacticSequencerPDAProvider.ISynState)2 ParserRule (org.eclipse.xtext.ParserRule)1 INode (org.eclipse.xtext.nodemodel.INode)1 SynAbsorberNfaAdapter (org.eclipse.xtext.serializer.analysis.ISyntacticSequencerPDAProvider.SynAbsorberNfaAdapter)1 SerializationContextMap (org.eclipse.xtext.serializer.analysis.SerializationContextMap)1 RuleCallStack (org.eclipse.xtext.serializer.sequencer.RuleCallStack)1 Nfa (org.eclipse.xtext.util.formallang.Nfa)1