Search in sources :

Example 96 with Grammar

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());
}
Also used : ParserRule(org.eclipse.xtext.ParserRule) Grammar(org.eclipse.xtext.Grammar) Test(org.junit.Test)

Example 97 with Grammar

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());
}
Also used : ParserRule(org.eclipse.xtext.ParserRule) Grammar(org.eclipse.xtext.Grammar) Test(org.junit.Test)

Example 98 with Grammar

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());
}
Also used : ParserRule(org.eclipse.xtext.ParserRule) Grammar(org.eclipse.xtext.Grammar) Test(org.junit.Test)

Example 99 with Grammar

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());
}
Also used : ParserRule(org.eclipse.xtext.ParserRule) Grammar(org.eclipse.xtext.Grammar) Test(org.junit.Test)

Example 100 with Grammar

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());
}
Also used : ParserRule(org.eclipse.xtext.ParserRule) Grammar(org.eclipse.xtext.Grammar) Test(org.junit.Test)

Aggregations

Grammar (org.eclipse.xtext.Grammar)356 Test (org.junit.Test)273 ParserRule (org.eclipse.xtext.ParserRule)151 AbstractRule (org.eclipse.xtext.AbstractRule)106 StringConcatenation (org.eclipse.xtend2.lib.StringConcatenation)101 EObject (org.eclipse.emf.ecore.EObject)70 AbstractXtextRuleInspectorTest (org.eclipse.xtext.xtext.AbstractXtextRuleInspectorTest)49 XtextResource (org.eclipse.xtext.resource.XtextResource)33 RuleCall (org.eclipse.xtext.RuleCall)28 StringConcatenationClient (org.eclipse.xtend2.lib.StringConcatenationClient)23 TypeReference (org.eclipse.xtext.xtext.generator.model.TypeReference)23 AbstractMetamodelDeclaration (org.eclipse.xtext.AbstractMetamodelDeclaration)21 Assignment (org.eclipse.xtext.Assignment)21 EPackage (org.eclipse.emf.ecore.EPackage)20 AbstractElement (org.eclipse.xtext.AbstractElement)17 TerminalRule (org.eclipse.xtext.TerminalRule)17 Resource (org.eclipse.emf.ecore.resource.Resource)16 EClassifier (org.eclipse.emf.ecore.EClassifier)13 InternalEObject (org.eclipse.emf.ecore.InternalEObject)13 ILeafNode (org.eclipse.xtext.nodemodel.ILeafNode)12