use of org.eclipse.xtext.Grammar in project xtext-core by eclipse.
the class RuleWithoutInstantiationInspectorTest method testAction_01.
@Test
public void testAction_01() throws Exception {
String grammarAsString = "grammar org.foo with org.eclipse.xtext.common.Terminals\n" + "generate metamodel 'foo.sample'\n" + "Model: x=X;\n" + "X : {X} ID?;";
Grammar grammar = getGrammar(grammarAsString);
ParserRule rule = (ParserRule) GrammarUtil.findRuleForName(grammar, "X");
validateRule(rule);
assertTrue(warnings.toString(), warnings.isEmpty());
}
use of org.eclipse.xtext.Grammar in project xtext-core by eclipse.
the class RuleWithoutInstantiationInspectorTest method testRuleCall_03.
@Test
public void testRuleCall_03() throws Exception {
String grammarAsString = "grammar org.foo with org.eclipse.xtext.common.Terminals\n" + "generate metamodel 'foo.sample'\n" + "Model: x=X;\n" + "X : INT (ID? {X} ID?);\n";
Grammar grammar = getGrammar(grammarAsString);
ParserRule rule = (ParserRule) GrammarUtil.findRuleForName(grammar, "X");
validateRule(rule);
assertTrue(warnings.toString(), warnings.isEmpty());
}
use of org.eclipse.xtext.Grammar in project xtext-core by eclipse.
the class RuleWithoutInstantiationInspectorTest method testAssignment_02.
@Test
public void testAssignment_02() throws Exception {
String grammarAsString = "grammar org.foo with org.eclipse.xtext.common.Terminals\n" + "generate metamodel 'foo.sample'\n" + "Model: x=X;\n" + "X : (x+='x')+;";
Grammar grammar = getGrammar(grammarAsString);
ParserRule rule = (ParserRule) GrammarUtil.findRuleForName(grammar, "X");
validateRule(rule);
assertTrue(warnings.toString(), warnings.isEmpty());
}
use of org.eclipse.xtext.Grammar in project xtext-core by eclipse.
the class RuleWithoutInstantiationInspectorTest method testDatatypes.
@Test
public void testDatatypes() throws Exception {
String grammarAsString = "grammar org.foo with org.eclipse.xtext.common.Terminals\n" + "generate metamodel 'foo.sample'\n" + "Model: x=X;\n" + "X : 'x';";
Grammar grammar = getGrammar(grammarAsString);
ParserRule rule = (ParserRule) GrammarUtil.findRuleForName(grammar, "X");
validateRule(rule);
assertTrue(warnings.toString(), warnings.isEmpty());
}
use of org.eclipse.xtext.Grammar in project xtext-core by eclipse.
the class RuleWithoutInstantiationInspectorTest method testUnorderedGroup_02.
@Test
public void testUnorderedGroup_02() throws Exception {
String grammarAsString = "grammar org.foo with org.eclipse.xtext.common.Terminals\n" + "generate metamodel 'foo.sample'\n" + "Model: x=X;\n" + "X : value='keyword0' & 'keyword1';\n";
Grammar grammar = getGrammar(grammarAsString);
ParserRule rule = (ParserRule) GrammarUtil.findRuleForName(grammar, "X");
validateRule(rule);
assertEquals(warnings.toString(), 0, warnings.size());
}
Aggregations