|
|
Re: how to parse a xtext grammar [message #1705683 is a reply to message #1705604] |
Tue, 18 August 2015 11:12 |
Bruno Oliveira Messages: 5 Registered: February 2012 |
Junior Member |
|
|
Yes, it is what i want. I follow the instructions and i am still confuse.
First, i got several errors related to the code:
resourceSet.createResource is not recognized
resource.load(in, resourceSet.getLoadOptions(); has an error and eclipse suggests a cast to ((ResourceImpl) resource).load(in, resourceSet.getLoadOptions());
Model is not recognized
There any xtext jar file (library) that i need to import to use these resources?
I want to create a java application without any relation to eclipse or emf.
[Updated on: Tue, 18 August 2015 11:24] Report message to a moderator
|
|
|
Re: how to parse a xtext grammar [message #1705686 is a reply to message #1705683] |
Tue, 18 August 2015 11:42 |
|
Hi,
simply place the code in a class in the .yourdsl project.
make sure you have the correct imports
org.eclipse.emf.ecore.resource.Resource
org.eclipse.emf.ecore.resource.ResourceSet
org.eclipse.emf.common.util.URI
If that does not work please share you complete class.
if your class is a java main you can use the export->
java-> runnable jar wizard to create a all in one jar
if you dont want to use the pseudo workspace use
URI.createURI("path/file.extension") and omit the
new org.eclipse.emf.mwe.utils.StandaloneSetup().setPlatformUri("../");
Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
[Updated on: Tue, 18 August 2015 11:44] Report message to a moderator
|
|
|
|
Re: how to parse a xtext grammar [message #1705738 is a reply to message #1705737] |
Tue, 18 August 2015 16:33 |
|
Hey Bruno,
the "Model" class is only an example. You have to adjust it to the entry rule of your Grammar.
EMF knows how to validate your model because you ran the StandaloneSetup. This registers your language's validator in the validator registry.
You can also use injector.getInstance(IResourceValidator) if you would like to use the Xtext validation API instead.
In general, injector.getInstance(...) allows you to get any service related to your language, so you could also run the code generator or whatever else you like.
Cheers,
Stefan
|
|
|
Powered by
FUDForum. Page generated in 0.04208 seconds