Search in sources :

Example 1 with ConcreteParserRule

use of org.eclipse.xtext.grammarinheritance.foo.ConcreteParserRule in project xtext-core by eclipse.

the class InheritanceTest method testSimple.

@Test
public void testSimple() throws Exception {
    ConcreteParserRule model = (ConcreteParserRule) getModel("model 23.34 : element A element B");
    assertEquals(23.34, model.getMagicNumber(), 0.0001);
    assertEquals("A", model.getElements().get(0).getName());
    assertEquals("B", model.getElements().get(1).getName());
}
Also used : ConcreteParserRule(org.eclipse.xtext.grammarinheritance.foo.ConcreteParserRule) Test(org.junit.Test)

Example 2 with ConcreteParserRule

use of org.eclipse.xtext.grammarinheritance.foo.ConcreteParserRule in project xtext-core by eclipse.

the class ConcreteTestLanguageSemanticSequencer 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 == AmetamodelPackage.eINSTANCE)
        switch(semanticObject.eClass().getClassifierID()) {
            case AmetamodelPackage.AMODEL:
                if (rule == grammarAccess.getAbstractCallExtendedParserRuleRule()) {
                    sequence_AbstractCallExtendedParserRule(context, (AModel) semanticObject);
                    return;
                } else if (rule == grammarAccess.getAbstractCallOverridenParserRuleRule()) {
                    sequence_AbstractCallOverridenParserRule(context, (AModel) semanticObject);
                    return;
                } else
                    break;
            case AmetamodelPackage.ATYPE:
                if (rule == grammarAccess.getInheritedParserRuleRule()) {
                    sequence_InheritedParserRule(context, (AType) semanticObject);
                    return;
                } else if (rule == grammarAccess.getOverridableParserRuleRule()) {
                    sequence_OverridableParserRule(context, (AType) semanticObject);
                    return;
                } else
                    break;
        }
    else if (epackage == FooPackage.eINSTANCE)
        switch(semanticObject.eClass().getClassifierID()) {
            case FooPackage.ATYPE2:
                sequence_OverridableParserRule2(context, (AType2) semanticObject);
                return;
            case FooPackage.CALL_EXTENDED_PARSER_RULE:
                sequence_CallExtendedParserRule(context, (CallExtendedParserRule) semanticObject);
                return;
            case FooPackage.CALL_OVERRIDEN_PARSER_RULE:
                sequence_CallOverridenParserRule(context, (CallOverridenParserRule) semanticObject);
                return;
            case FooPackage.CONCRETE_PARSER_RULE:
                sequence_ConcreteParserRule(context, (ConcreteParserRule) semanticObject);
                return;
            case FooPackage.SUBRULE1:
                sequence_Subrule1(context, (Subrule1) semanticObject);
                return;
            case FooPackage.SUBRULE2:
                sequence_Subrule2(context, (Subrule2) semanticObject);
                return;
            case FooPackage.SUBRULE3:
                sequence_Subrule3(context, (Subrule3) semanticObject);
                return;
        }
    if (errorAcceptor != null)
        errorAcceptor.accept(diagnosticProvider.createInvalidContextOrTypeDiagnostic(semanticObject, context));
}
Also used : AType(org.eclipse.xtext.grammarinheritance.ametamodel.AType) CallOverridenParserRule(org.eclipse.xtext.grammarinheritance.foo.CallOverridenParserRule) CallExtendedParserRule(org.eclipse.xtext.grammarinheritance.foo.CallExtendedParserRule) ParserRule(org.eclipse.xtext.ParserRule) ConcreteParserRule(org.eclipse.xtext.grammarinheritance.foo.ConcreteParserRule) Action(org.eclipse.xtext.Action) AModel(org.eclipse.xtext.grammarinheritance.ametamodel.AModel) Parameter(org.eclipse.xtext.Parameter) EPackage(org.eclipse.emf.ecore.EPackage)

Aggregations

ConcreteParserRule (org.eclipse.xtext.grammarinheritance.foo.ConcreteParserRule)2 EPackage (org.eclipse.emf.ecore.EPackage)1 Action (org.eclipse.xtext.Action)1 Parameter (org.eclipse.xtext.Parameter)1 ParserRule (org.eclipse.xtext.ParserRule)1 AModel (org.eclipse.xtext.grammarinheritance.ametamodel.AModel)1 AType (org.eclipse.xtext.grammarinheritance.ametamodel.AType)1 CallExtendedParserRule (org.eclipse.xtext.grammarinheritance.foo.CallExtendedParserRule)1 CallOverridenParserRule (org.eclipse.xtext.grammarinheritance.foo.CallOverridenParserRule)1 Test (org.junit.Test)1