Search in sources :

Example 16 with Alternatives

use of org.eclipse.xtext.Alternatives in project xtext-core by eclipse.

the class GrammarParserTest method testPrecedencies_02.

@Test
public void testPrecedencies_02() throws Exception {
    UnorderedGroup group = (UnorderedGroup) getModel("('keyword' | 'keyword') & ('keyword' | 'keyword')");
    assertNotNull(group);
    assertEquals(2, group.getElements().size());
    assertTrue(group.getElements().get(0) instanceof Alternatives);
    assertTrue(group.getElements().get(1) instanceof Alternatives);
}
Also used : UnorderedGroup(org.eclipse.xtext.UnorderedGroup) Alternatives(org.eclipse.xtext.Alternatives) Test(org.junit.Test)

Example 17 with Alternatives

use of org.eclipse.xtext.Alternatives in project xtext-core by eclipse.

the class GrammarParserTest method testAlternatives.

@Test
public void testAlternatives() throws Exception {
    Alternatives alternatives = (Alternatives) getModel("'keyword'|'keyword'");
    assertNotNull(alternatives);
    assertEquals(2, alternatives.getElements().size());
}
Also used : Alternatives(org.eclipse.xtext.Alternatives) Test(org.junit.Test)

Example 18 with Alternatives

use of org.eclipse.xtext.Alternatives in project xtext-core by eclipse.

the class TreeConstTest method testMultiAction4.

@Test
public void testMultiAction4() throws Exception {
    AbstractRule rule = parseRule("Model: 'a' {Type1} | 'b' {Type2} | 'c' | name=ID;");
    Alternatives alt = (Alternatives) rule.getAlternatives();
    assertTypes(nfa.getNFA(alt).getTypes(), "Type1", "Type2", "Model", "null");
    assertTypes(nfa.getNFA(alt.getElements().get(0)).getTypesToCheck(), "Type1");
    assertTypes(nfa.getNFA(alt.getElements().get(1)).getTypesToCheck(), "Type2");
    assertTypes(nfa.getNFA(alt.getElements().get(2)).getTypesToCheck());
    assertTypes(nfa.getNFA(alt.getElements().get(3)).getTypesToCheck(), "Model");
}
Also used : AbstractRule(org.eclipse.xtext.AbstractRule) Alternatives(org.eclipse.xtext.Alternatives) Test(org.junit.Test)

Aggregations

Alternatives (org.eclipse.xtext.Alternatives)18 AbstractElement (org.eclipse.xtext.AbstractElement)9 Test (org.junit.Test)9 Assignment (org.eclipse.xtext.Assignment)8 Group (org.eclipse.xtext.Group)8 RuleCall (org.eclipse.xtext.RuleCall)7 Action (org.eclipse.xtext.Action)6 Grammar (org.eclipse.xtext.Grammar)6 ParserRule (org.eclipse.xtext.ParserRule)6 UnorderedGroup (org.eclipse.xtext.UnorderedGroup)6 EObject (org.eclipse.emf.ecore.EObject)5 AbstractRule (org.eclipse.xtext.AbstractRule)5 TerminalRule (org.eclipse.xtext.TerminalRule)4 XtextSwitch (org.eclipse.xtext.util.XtextSwitch)3 ImmutableSet (com.google.common.collect.ImmutableSet)2 ArrayList (java.util.ArrayList)2 InternalEObject (org.eclipse.emf.ecore.InternalEObject)2 CompoundElement (org.eclipse.xtext.CompoundElement)2 Keyword (org.eclipse.xtext.Keyword)2 LiteralCondition (org.eclipse.xtext.LiteralCondition)2