Search in sources :

Example 61 with ParserRule

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

the class OverriddenValueInspectorTest method testAlternative_04.

@Test
public void testAlternative_04() throws Exception {
    StringConcatenation _builder = new StringConcatenation();
    _builder.append("grammar org.foo with org.eclipse.xtext.common.Terminals");
    _builder.newLine();
    _builder.append("generate metamodel \'foo.sample\'");
    _builder.newLine();
    _builder.append("First : (Second | multiName+=ID | id=INT) multiName+=ID;");
    _builder.newLine();
    _builder.append("Second: \'keyword\' name=ID id=INT;");
    _builder.newLine();
    String grammarAsString = _builder.toString();
    final Grammar grammar = this.getGrammar(grammarAsString);
    AbstractRule _findRuleForName = GrammarUtil.findRuleForName(grammar, "First");
    final ParserRule rule = ((ParserRule) _findRuleForName);
    this.validateRule(rule);
    Assert.assertTrue(this.warnings.toString(), this.warnings.isEmpty());
}
Also used : ParserRule(org.eclipse.xtext.ParserRule) StringConcatenation(org.eclipse.xtend2.lib.StringConcatenation) Grammar(org.eclipse.xtext.Grammar) AbstractRule(org.eclipse.xtext.AbstractRule) Test(org.junit.Test) AbstractXtextRuleInspectorTest(org.eclipse.xtext.xtext.AbstractXtextRuleInspectorTest)

Example 62 with ParserRule

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

the class OverriddenValueInspectorTest method testBug306281_10.

@Test
public void testBug306281_10() throws Exception {
    StringConcatenation _builder = new StringConcatenation();
    _builder.append("grammar org.foo with org.eclipse.xtext.common.Terminals");
    _builder.newLine();
    _builder.append("generate metamodel \'foo.sample\'");
    _builder.newLine();
    _builder.append("Model : name=ID (({Binary.left=current} operator = [Model] | {Binary.left=current} operator = [Model]) name=ID);");
    _builder.newLine();
    String grammarAsString = _builder.toString();
    final Grammar grammar = this.getGrammar(grammarAsString);
    AbstractRule _findRuleForName = GrammarUtil.findRuleForName(grammar, "Model");
    final ParserRule rule = ((ParserRule) _findRuleForName);
    this.validateRule(rule);
    Assert.assertTrue(this.warnings.toString(), this.warnings.isEmpty());
}
Also used : ParserRule(org.eclipse.xtext.ParserRule) StringConcatenation(org.eclipse.xtend2.lib.StringConcatenation) Grammar(org.eclipse.xtext.Grammar) AbstractRule(org.eclipse.xtext.AbstractRule) Test(org.junit.Test) AbstractXtextRuleInspectorTest(org.eclipse.xtext.xtext.AbstractXtextRuleInspectorTest)

Example 63 with ParserRule

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

the class OverriddenValueInspectorTest method testBug306281_11.

@Test
public void testBug306281_11() throws Exception {
    StringConcatenation _builder = new StringConcatenation();
    _builder.append("grammar org.foo with org.eclipse.xtext.common.Terminals");
    _builder.newLine();
    _builder.append("generate metamodel \'foo.sample\'");
    _builder.newLine();
    _builder.append("Model returns Model: SubModel ({Binary.params+=current} operator =\'+\' params+=SubModel)*;");
    _builder.newLine();
    _builder.append("SubModel returns Model: \'(\'Model\')\';");
    _builder.newLine();
    String grammarAsString = _builder.toString();
    final Grammar grammar = this.getGrammar(grammarAsString);
    AbstractRule _findRuleForName = GrammarUtil.findRuleForName(grammar, "Model");
    final ParserRule rule = ((ParserRule) _findRuleForName);
    this.validateRule(rule);
    Assert.assertTrue(this.warnings.toString(), this.warnings.isEmpty());
}
Also used : ParserRule(org.eclipse.xtext.ParserRule) StringConcatenation(org.eclipse.xtend2.lib.StringConcatenation) Grammar(org.eclipse.xtext.Grammar) AbstractRule(org.eclipse.xtext.AbstractRule) Test(org.junit.Test) AbstractXtextRuleInspectorTest(org.eclipse.xtext.xtext.AbstractXtextRuleInspectorTest)

Example 64 with ParserRule

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

the class OverriddenValueInspectorTest method testUnassignedRule_03.

@Test
public void testUnassignedRule_03() throws Exception {
    StringConcatenation _builder = new StringConcatenation();
    _builder.append("grammar org.foo with org.eclipse.xtext.common.Terminals");
    _builder.newLine();
    _builder.append("generate metamodel \'foo.sample\'");
    _builder.newLine();
    _builder.append("First : Second (name=ID)?;");
    _builder.newLine();
    _builder.append("Second: id=INT (name=ID)?;");
    _builder.newLine();
    String grammarAsString = _builder.toString();
    final Grammar grammar = this.getGrammar(grammarAsString);
    AbstractRule _findRuleForName = GrammarUtil.findRuleForName(grammar, "First");
    final ParserRule rule = ((ParserRule) _findRuleForName);
    this.validateRule(rule);
    Assert.assertEquals(this.warnings.toString(), 2, this.warnings.size());
}
Also used : ParserRule(org.eclipse.xtext.ParserRule) StringConcatenation(org.eclipse.xtend2.lib.StringConcatenation) Grammar(org.eclipse.xtext.Grammar) AbstractRule(org.eclipse.xtext.AbstractRule) Test(org.junit.Test) AbstractXtextRuleInspectorTest(org.eclipse.xtext.xtext.AbstractXtextRuleInspectorTest)

Example 65 with ParserRule

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

the class OverriddenValueInspectorTest method testAlternative_03.

@Test
public void testAlternative_03() throws Exception {
    StringConcatenation _builder = new StringConcatenation();
    _builder.append("grammar org.foo with org.eclipse.xtext.common.Terminals");
    _builder.newLine();
    _builder.append("generate metamodel \'foo.sample\'");
    _builder.newLine();
    _builder.append("First : (Second | multiName+=ID | id=INT) multiName+=ID id=INT;");
    _builder.newLine();
    _builder.append("Second: \'keyword\' name=ID id=INT;");
    _builder.newLine();
    String grammarAsString = _builder.toString();
    final Grammar grammar = this.getGrammar(grammarAsString);
    AbstractRule _findRuleForName = GrammarUtil.findRuleForName(grammar, "First");
    final ParserRule rule = ((ParserRule) _findRuleForName);
    this.validateRule(rule);
    Assert.assertEquals(this.warnings.toString(), 3, this.warnings.size());
}
Also used : ParserRule(org.eclipse.xtext.ParserRule) StringConcatenation(org.eclipse.xtend2.lib.StringConcatenation) Grammar(org.eclipse.xtext.Grammar) AbstractRule(org.eclipse.xtext.AbstractRule) Test(org.junit.Test) AbstractXtextRuleInspectorTest(org.eclipse.xtext.xtext.AbstractXtextRuleInspectorTest)

Aggregations

ParserRule (org.eclipse.xtext.ParserRule)380 Test (org.junit.Test)172 Grammar (org.eclipse.xtext.Grammar)151 Action (org.eclipse.xtext.Action)144 Parameter (org.eclipse.xtext.Parameter)137 EPackage (org.eclipse.emf.ecore.EPackage)126 AbstractRule (org.eclipse.xtext.AbstractRule)94 StringConcatenation (org.eclipse.xtend2.lib.StringConcatenation)74 AbstractXtextRuleInspectorTest (org.eclipse.xtext.xtext.AbstractXtextRuleInspectorTest)49 RuleCall (org.eclipse.xtext.RuleCall)41 EObject (org.eclipse.emf.ecore.EObject)27 EnumRule (org.eclipse.xtext.EnumRule)21 TerminalRule (org.eclipse.xtext.TerminalRule)21 AbstractElement (org.eclipse.xtext.AbstractElement)18 Assignment (org.eclipse.xtext.Assignment)15 UnorderedGroup (org.eclipse.xtext.UnorderedGroup)12 EClass (org.eclipse.emf.ecore.EClass)11 Group (org.eclipse.xtext.Group)11 NamedArgument (org.eclipse.xtext.NamedArgument)11 TypeRef (org.eclipse.xtext.TypeRef)11