Problem with importURI and standalone generator [message #995180] |
Sat, 29 December 2012 04:39  |
Eclipse User |
|
|
|
Hello all,
I have the following grammar (the url of eclipse.org have been replaced to escape forum restrictions) :
grammar org.xtext.example.mydsl.MyDsl with org.eclipse.xtext.common.Terminals
import "eclipse-org-site/xtext/common/JavaVMTypes" as jvmTypes
generate myDsl "xtext-org-site/example/mydsl/MyDsl"
Model: (greetings+=Greeting | imports+=Import | goodbyes+=Goodbye)*;
Greeting: "Hello" name=ID;
Import: "import" importURI=STRING;
Goodbye: "Bye" ref=[Greeting] ;
The generator is a simple one, just to test:
public class MyDslGenerator implements IGenerator {
@Override
public void doGenerate(Resource resource, IFileSystemAccess fsa) {
StringBuilder output = new StringBuilder();
Iterator<?> it = resource.getAllContents();
while (it.hasNext()) {
Object o = it.next();
if (o instanceof Greeting) {
output.append("Hello " + ((Greeting) o).getName() + "\n");
} else if (o instanceof Goodbye) {
output.append("Goodbye " + ((Goodbye) o).getRef().getName() + "\n");
}
}
fsa.generateFile(resource.getURI().lastSegment() + ".output", output);
}
}
With the following file test3.mydsl:
import "test2/test2.mydsl"
Hello aek
Bye aek
Bye eak
test2/test2.mydsl simply contains "Hello eak". It works perfectly fine in the Eclipse launch but if I call org.xtext.example.mydsl.generator.Main on test3.mydsl, I get the following error:
ERROR:Couldn't resolve reference to Greeting 'eak'. (src/test3.mydsl line : 6)
Has anyone any clue on how to resolve that?
A subsidiary thing which is not blocking but that I'd like to have working is to be able to use jvmTypes in the same times that I can use importURI but it seems that the TypesGeneratorFragment is needed for jvmTypes but it stop importURI feature from working.
Thank you all for the help.
|
|
|
|
|
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.24325 seconds