use of org.eclipse.gemoc.gexpressions.GProgram in project gemoc-studio by eclipse.
the class AbstractGExpressionsSemanticSequencer 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 == GexpressionsPackage.eINSTANCE)
switch(semanticObject.eClass().getClassifierID()) {
case GexpressionsPackage.GADDITION_EXPRESSION:
sequence_GAdditionExpression(context, (GAdditionExpression) semanticObject);
return;
case GexpressionsPackage.GAND_EXPRESSION:
sequence_GAndExpression(context, (GAndExpression) semanticObject);
return;
case GexpressionsPackage.GBOOLEAN_EXPRESSION:
sequence_GBooleanExpression(context, (GBooleanExpression) semanticObject);
return;
case GexpressionsPackage.GBRACE_EXPRESSION:
sequence_GBraceExpression(context, (GBraceExpression) semanticObject);
return;
case GexpressionsPackage.GDOUBLE_EXPRESSION:
sequence_GDoubleExpression(context, (GDoubleExpression) semanticObject);
return;
case GexpressionsPackage.GENUM_LITERAL_EXPRESSION:
sequence_GEnumLiteralExpression(context, (GEnumLiteralExpression) semanticObject);
return;
case GexpressionsPackage.GEQUALITY_EXPRESSION:
sequence_GEqualityExpression(context, (GEqualityExpression) semanticObject);
return;
case GexpressionsPackage.GIF_EXPRESSION:
sequence_GIfExpression(context, (GIfExpression) semanticObject);
return;
case GexpressionsPackage.GIMPORT_STATEMENT:
sequence_GImportStatement(context, (GImportStatement) semanticObject);
return;
case GexpressionsPackage.GINTEGER_EXPRESSION:
sequence_GIntegerExpression(context, (GIntegerExpression) semanticObject);
return;
case GexpressionsPackage.GMULTIPLICATION_EXPRESSION:
sequence_GMultiplicationExpression(context, (GMultiplicationExpression) semanticObject);
return;
case GexpressionsPackage.GNAVIGATION_EXPRESSION:
sequence_GNavigationExpression(context, (GNavigationExpression) semanticObject);
return;
case GexpressionsPackage.GNEGATION_EXPRESSION:
sequence_GNegationExpression(context, (GNegationExpression) semanticObject);
return;
case GexpressionsPackage.GOR_EXPRESSION:
sequence_GOrExpression(context, (GOrExpression) semanticObject);
return;
case GexpressionsPackage.GPROGRAM:
sequence_GProgram(context, (GProgram) semanticObject);
return;
case GexpressionsPackage.GREFERENCE_EXPRESSION:
sequence_GReferenceExpression(context, (GReferenceExpression) semanticObject);
return;
case GexpressionsPackage.GRELATION_EXPRESSION:
sequence_GRelationExpression(context, (GRelationExpression) semanticObject);
return;
case GexpressionsPackage.GSTRING_EXPRESSION:
sequence_GStringExpression(context, (GStringExpression) semanticObject);
return;
case GexpressionsPackage.GXOR_EXPRESSION:
sequence_GXorExpression(context, (GXorExpression) semanticObject);
return;
}
if (errorAcceptor != null)
errorAcceptor.accept(diagnosticProvider.createInvalidContextOrTypeDiagnostic(semanticObject, context));
}
use of org.eclipse.gemoc.gexpressions.GProgram in project gemoc-studio by eclipse.
the class TestXtextSerializer2 method loadGexpressionTestFile.
public static void loadGexpressionTestFile() {
// Getting the serializer
GExpressionsStandaloneSetup setup = new GExpressionsStandaloneSetup();
Injector injector = setup.createInjectorAndDoEMFRegistration();
GexpressionsPackage.eINSTANCE.eClass();
Serializer serializer = injector.getInstance(Serializer.class);
// Load the model
URI modelURI = URI.createFileURI("/home/flatombe/thesis/gemoc/git/gemoc-dev/org/eclipse/gemoc/GEL/org.eclipse.gemoc.gel.gexpressions.test/model/test.gexpressions");
XtextResourceSet resSet = injector.getInstance(XtextResourceSet.class);
resSet.addLoadOption(XtextResource.OPTION_RESOLVE_ALL, Boolean.TRUE);
Resource resource = resSet.getResource(modelURI, true);
GProgram program = (GProgram) resource.getContents().get(0);
List<GExpression> exps = program.getExpressions();
for (GExpression exp : exps) {
// Serializing
String s = serializer.serialize(exp);
System.out.println(s);
}
}
use of org.eclipse.gemoc.gexpressions.GProgram in project gemoc-studio by eclipse.
the class GexpressionsExample method main.
/**
* <!-- begin-user-doc -->
* Load all the argument file paths or URIs as instances of the model.
* <!-- end-user-doc -->
* @param args the file paths or URIs.
* @generated
*/
public static void main(String[] args) {
// Create a resource set to hold the resources.
//
ResourceSet resourceSet = new ResourceSetImpl();
// Register the appropriate resource factory to handle all file extensions.
//
resourceSet.getResourceFactoryRegistry().getExtensionToFactoryMap().put(Resource.Factory.Registry.DEFAULT_EXTENSION, new XMIResourceFactoryImpl());
// Register the package to ensure it is available during loading.
//
resourceSet.getPackageRegistry().put(GexpressionsPackage.eNS_URI, GexpressionsPackage.eINSTANCE);
//
if (args.length == 0) {
System.out.println("Enter a list of file paths or URIs that have content like this:");
try {
Resource resource = resourceSet.createResource(URI.createURI("http:///My.gexpressions"));
GProgram root = GexpressionsFactory.eINSTANCE.createGProgram();
resource.getContents().add(root);
resource.save(System.out, null);
} catch (IOException exception) {
exception.printStackTrace();
}
} else {
//
for (int i = 0; i < args.length; ++i) {
// Construct the URI for the instance file.
// The argument is treated as a file path only if it denotes an existing file.
// Otherwise, it's directly treated as a URL.
//
File file = new File(args[i]);
URI uri = file.isFile() ? URI.createFileURI(file.getAbsolutePath()) : URI.createURI(args[i]);
try {
// Demand load resource for this file.
//
Resource resource = resourceSet.getResource(uri, true);
System.out.println("Loaded " + uri);
//
for (EObject eObject : resource.getContents()) {
Diagnostic diagnostic = Diagnostician.INSTANCE.validate(eObject);
if (diagnostic.getSeverity() != Diagnostic.OK) {
printDiagnostic(diagnostic, "");
}
}
} catch (RuntimeException exception) {
System.out.println("Problem loading " + uri);
exception.printStackTrace();
}
}
}
}
Aggregations