|
|
|
|
|
Re: How can I generate code from my XText DSL without IDE? [message #1299912 is a reply to message #1299850] |
Thu, 17 April 2014 07:36 |
Joerg Reichert Messages: 80 Registered: July 2009 Location: Leipzig |
Member |
|
|
Hi Simon,
you don't need to start Eclipse.
This a little example:
public class Main {
public static void main(String[] args) {
Injector injector = new Mwe2StandaloneSetup().createInjectorAndDoEMFRegistration();
Mwe2Runner runner = injector.getInstance(Mwe2Runner.class);
URI createURI = URI.createFileURI("src/org/xtext/example/mydsl/generator/MyDslGeneratorMWE.mwe2");
Map<String, String> params = new HashMap<String, String>();
params.put("modelPath", "samples/");
params.put("targetDir", "output");
runner.run(createURI, params);
}
}
As an alternative, you even can pre-generate a Main class by using this snippet in the grammar mwe2 file:
fragment = generator.GeneratorFragment auto-inject {
generateMwe = true
generateJavaMain = true
}
This code doesn't use the Mwe2Runner and takes only one resource as input but you may adapt this to your needs as well.
Joerg
--
Need professional support for Xtext and EMF?
Go to: http://xtext.itemis.com
|
|
|
Powered by
FUDForum. Page generated in 0.03326 seconds