use of org.eclipse.xtext.ParserRule in project xtext-core by eclipse.
the class TreeTestLanguageSemanticSequencer method sequence.
@Override
public void sequence(ISerializationContext context, EObject semanticObject) {
EPackage epackage = semanticObject.eClass().getEPackage();
ParserRule rule = context.getParserRule();
Action action = context.getAssignedAction();
Set<Parameter> parameters = context.getEnabledBooleanParameters();
if (epackage == TreeTestLanguagePackage.eINSTANCE)
switch(semanticObject.eClass().getClassifierID()) {
case TreeTestLanguagePackage.MODEL:
sequence_Model(context, (Model) semanticObject);
return;
case TreeTestLanguagePackage.NODE:
sequence_Node(context, (Node) semanticObject);
return;
}
if (errorAcceptor != null)
errorAcceptor.accept(diagnosticProvider.createInvalidContextOrTypeDiagnostic(semanticObject, context));
}
use of org.eclipse.xtext.ParserRule in project xtext-core by eclipse.
the class KeywordInspectorTest method testBug285146_02.
@Test
public void testBug285146_02() throws Exception {
String grammarAsString = "grammar org.xtext.example.MyDsl7 with org.eclipse.xtext.common.Terminals\n" + "generate myDsl \"http://www.xtext.org/example/MyDsl\"\n" + "Type : 'type' '#' name=ID;\n" + "terminal POUND: '#'?;";
Grammar grammar = getGrammar(grammarAsString);
ParserRule rule = (ParserRule) GrammarUtil.findRuleForName(grammar, "Type");
validateRule(rule);
assertEquals(errors.toString(), 0, errors.size());
}
use of org.eclipse.xtext.ParserRule in project xtext-core by eclipse.
the class KeywordInspectorTest method testBug285146_04.
@Test
public void testBug285146_04() throws Exception {
String grammarAsString = "grammar org.xtext.example.MyDsl7 with org.eclipse.xtext.common.Terminals\n" + "generate myDsl \"http://www.xtext.org/example/MyDsl\"\n" + "Type : 'type' '#' name=ID;\n" + "terminal POUND: '#' '#';";
Grammar grammar = getGrammar(grammarAsString);
ParserRule rule = (ParserRule) GrammarUtil.findRuleForName(grammar, "Type");
validateRule(rule);
assertEquals(errors.toString(), 0, errors.size());
}
use of org.eclipse.xtext.ParserRule in project xtext-core by eclipse.
the class PartialParserTest method performTest.
public void performTest(String toBeDeleted) throws Exception {
String grammarAsText = "grammar TestLanguage with org.eclipse.xtext.common.Terminals\n" + "generate test 'myEcoreModel'\n" + "Root: value=Test;\n" + "Test: (" + toBeDeleted.trim() + " 'foo')*;";
XtextResource resource = getResourceFromString(grammarAsText);
Grammar g = (Grammar) resource.getContents().get(0);
ParserRule rule = (ParserRule) g.getRules().get(1);
assertEquals("*", rule.getAlternatives().getCardinality());
resource.update(grammarAsText.indexOf(toBeDeleted), toBeDeleted.length(), "");
// make sure we did a partial parse pass
assertSame(rule, ((Grammar) resource.getContents().get(0)).getRules().get(1));
assertEquals("*", rule.getAlternatives().getCardinality());
}
use of org.eclipse.xtext.ParserRule in project xtext-core by eclipse.
the class RuleWithoutInstantiationInspectorTest method testFragment_02.
@Test
public void testFragment_02() throws Exception {
String grammarAsString = "grammar org.foo with org.eclipse.xtext.common.Terminals\n" + "generate metamodel 'foo.sample'\n" + "Model: name=ID X;\n" + "fragment X*: 'x';";
Grammar grammar = getGrammar(grammarAsString);
ParserRule rule = (ParserRule) GrammarUtil.findRuleForName(grammar, "X");
validateRule(rule);
assertTrue(warnings.toString(), warnings.isEmpty());
}
Aggregations