use of org.eclipse.xtext.AbstractRule in project xtext-core by eclipse.
the class OverriddenValueInspectorTest method testUnassignedRule_04.
@Test
public void testUnassignedRule_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 (name=ID)? id=INT;");
_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(), 4, this.warnings.size());
}
use of org.eclipse.xtext.AbstractRule in project xtext-core by eclipse.
the class OverriddenValueInspectorTest method testOptionalAction_03.
@Test
public void testOptionalAction_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 ({First.second=current} id=INT)+ name=ID;");
_builder.newLine();
_builder.append("Second: \'keyword\' 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.assertTrue(this.warnings.toString(), this.warnings.isEmpty());
}
use of org.eclipse.xtext.AbstractRule in project xtext-core by eclipse.
the class OverriddenValueInspectorTest method testFragment_08.
@Test
public void testFragment_08() 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("EntryRule:");
_builder.newLine();
_builder.append("\t");
_builder.append("name=ID FragmentWithAction");
_builder.newLine();
_builder.append(";");
_builder.newLine();
_builder.append("fragment FragmentWithAction returns EntryRule:");
_builder.newLine();
_builder.append("\t");
_builder.append("name=ID {EntryRule.prev=current} name=ID");
_builder.newLine();
_builder.append(";");
_builder.newLine();
String grammarAsString = _builder.toString();
final Grammar grammar = this.getGrammar(grammarAsString);
AbstractRule _findRuleForName = GrammarUtil.findRuleForName(grammar, "EntryRule");
final ParserRule rule = ((ParserRule) _findRuleForName);
this.validateRule(rule);
Assert.assertEquals(this.warnings.toString(), 2, this.warnings.size());
AbstractRule _findRuleForName_1 = GrammarUtil.findRuleForName(grammar, "FragmentWithAction");
final ParserRule fragment = ((ParserRule) _findRuleForName_1);
this.validateRule(fragment);
Assert.assertEquals(this.warnings.toString(), 0, this.warnings.size());
}
use of org.eclipse.xtext.AbstractRule in project xtext-core by eclipse.
the class OverriddenValueInspectorTest method testFragment_05.
@Test
public void testFragment_05() 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 : Named*;");
_builder.newLine();
_builder.append("fragment Named: 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(), 1, this.warnings.size());
AbstractRule _findRuleForName_1 = GrammarUtil.findRuleForName(grammar, "Named");
final ParserRule fragment = ((ParserRule) _findRuleForName_1);
this.validateRule(fragment);
Assert.assertEquals(this.warnings.toString(), 0, this.warnings.size());
}
use of org.eclipse.xtext.AbstractRule in project xtext-core by eclipse.
the class OverriddenValueInspectorTest method testBug280011_02.
@Test
public void testBug280011_02() 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("Q : \'x\' a = ID \'y\' b = ID ;");
_builder.newLine();
String grammarAsString = _builder.toString();
final Grammar grammar = this.getGrammar(grammarAsString);
AbstractRule _findRuleForName = GrammarUtil.findRuleForName(grammar, "Q");
final ParserRule rule = ((ParserRule) _findRuleForName);
this.validateRule(rule);
Assert.assertTrue(this.warnings.toString(), this.warnings.isEmpty());
}
Aggregations