|
|
|
|
|
Re: How do I use my language [message #712427 is a reply to message #712139] |
Sun, 07 August 2011 08:29 |
|
Hi,
i don't get it: hendrik pointed to b3 as an example for an interpreter so have a look at b3s sourcecode.
i still do not understand what problems ou have with processing since it is just instances of java classes
you walk over. can you be a bit more elaborating why this makes problems to you
or ask questions on concrete problems?
~Christian
Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
|
|
|
Re: How do I use my language [message #712442 is a reply to message #712427] |
Sun, 07 August 2011 08:49 |
|
Hi,
and just do complete this: here is a "very fancy" interpreter for the Xtexts Hello World Greeting DSL
import org.eclipse.emf.common.util.URI;
import org.eclipse.emf.ecore.resource.Resource;
import org.eclipse.emf.ecore.resource.ResourceSet;
import org.xtext.example.mydsl.MyDslStandaloneSetup;
import org.xtext.example.mydsl.myDsl.Greeting;
import org.xtext.example.mydsl.myDsl.Model;
import com.google.inject.Injector;
public class Interpreter {
public static void main(String[] args) {
Injector injector = new MyDslStandaloneSetup().createInjectorAndDoEMFRegistration();
ResourceSet rs = injector.getInstance(ResourceSet.class);
Resource r = rs.getResource(URI.createURI("src/model.mydsl"), true);
Model m = (Model) r.getContents().get(0);
for (Greeting g : m.getGreetings()) {
System.out.println("Hello, " + g.getName());
}
}
}
~Christian
Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
|
|
|
|
|
Re: How do I use my language [message #713173 is a reply to message #712802] |
Mon, 08 August 2011 07:20 |
|
src: Sources that are ment to be manually maintained
src-gen: Generated sources from Xtext. Do not touch. They will be regenerated when you start the generator workflow.
xtend-gen: Generated sources from .xtend files. Do not touch. They will be regenerated when you save an .xtend file.
Xtext follows the Generation Gap Pattern. You can read about it on the web. Short: Strict seperation of manual, generated and generic code.
~Karsten
Need professional support for Xtext, EMF, Eclipse IDE?
Go to: http://devhub.karakun.com
Twitter : @kthoms
Blog : www.karsten-thoms.de
|
|
|
Powered by
FUDForum. Page generated in 0.03941 seconds