Skip to content

Motivation

Horacio Hoyos Rodriguez edited this page Jul 30, 2019 · 2 revisions

Motivation

The first point of contact for users starting to use Epsilon languages is usually through an Eclipse environment. Inside Eclipse, each of the Epsilon languages provides a Launch Configuration dialog hat allows users to configure the context required for the execution of a given script.

The Launch Configuration provides 5 main configuration options:

  • Source: Selects the script to run.
  • Models: Add and configure the models that are used by the script (Epsilon supports models from different technologies).
  • Parameters: Provide any external parameters required by the script.
  • Advanced: Select a specific implementation of the language engine
  • Profiling Configure profiling options.

When running in a non-eclipse environment, this configurations must also be done by the users. However, due to the internal implementation of Epsilon it is not straight forward to find where and when all the different configurations must be made.

Using Epsilon from Java

The following code snippet presents the general approach to using epsilon from Java:

module = createModule();
module.parse(getFileURI(getSource()));
    
if (module.getParseProblems().size() > 0) {
	System.err.println("Parse errors occurred...");
	for (ParseProblem problem : module.getParseProblems()) {
		System.err.println(problem.toString());
	}
	return;
}
    
for (IModel model : getModels()) {
	module.getContext().getModelRepository().addModel(model);
}
for (Variable parameter : parameters) {
	module.getContext().getFrameStack().put(parameter);
}
preProcess();
result = execute(module);
postProcess();

You can see that we need to parse the script file and detect any errors, then we need to load the models used, add the external parameters to the context and then execute the module. More complete implementations will also enable profiling and add additional native tool delegates (to interact with java from within the script).

The epsilon executors wrap this code and remove the need to know where the bits and pieces need to be added to.

Next - Using the executors

Clone this wiki locally