Problem with Super Grammar and an Ecore based SubGrammar [message #1114519] |
Sun, 22 September 2013 21:42 |
|
I have a super grammar(mydsl7) and a subgrammar(mydsl8) which is based on an predefined ecore model(My8,ecore). In the sub grammar I get the following error:
Cannot find compatible feature greetings in sealed EClass Model8 from imported package http:/www.xtext.org/example/mydsl8/Mydsl8: The existing reference 'greetings' has an incompatible type 'Greeting7'. The expected type is 'Greeting7'.
I guess I missed something to configure.
Can any body give me a hint how to fix this?
I prepared an example setup see the atached zip file.
It is an eclipse kepler setup. I remove the anlr jar and the class files
|
|
|
Re: Problem with Super Grammar and an Ecore based SubGrammar [message #1114730 is a reply to message #1114519] |
Mon, 23 September 2013 05:55 |
|
No idea what you want to do (you dont generate anything, you refer the
"will be deleted" ecore from the current grammar etc.
maybe you want to:
grammar org.xtext.example.mydsl8.MyDsl8 with org.xtext.example.mydsl7.MyDsl7
import "http://www.xtext.org/example/mydsl7/MyDsl7" as model7
import "http://www.eclipse.org/emf/2002/Ecore" as ecore
Model8 returns model7::Model7:
greetings+=Greeting7 ( "," greetings+=Greeting7)*
;
Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
|
|
|
Re: Problem with Super Grammar and an Ecore based SubGrammar [message #1115244 is a reply to message #1114730] |
Mon, 23 September 2013 22:10 |
|
Thank you for your answer. My problem is I have super grammar that has a generated ecore model from Xtext and I have a grammar that is inheriting form that grammar but this one has a predifined ecore model and I want to reuse the rules from the super grammar to form the rules for the current grammar. But the error indicates some type mismatches in the ecore models.
Even though in Model8 the greetings feature is declared with the Greeting7 type from the MyDsl7 the Xtext editor for Model8 shows up the mentioned error.
When you opened my example didn't you see the error in the Xtext editor of Model8 ?
If you don't see the error then something is wrong with my environment.
If you see the error then you hopefully can explain to me what's the reason and how to fix it.
Thanks
|
|
|
Re: Problem with Super Grammar and an Ecore based SubGrammar [message #1115445 is a reply to message #1115244] |
Tue, 24 September 2013 05:50 |
|
Hi,
no
bad idea to but it to src gen. i get Multiple markers at this line - The imported package is not on the classpath of this project which may lead
to follow up errors.
next to this you will need a genmodel for this metamodel too.
and you should register it in the standalonesetup (same as xtext does for xbase)
and you should consider to move it to a separate (empty emf) project. (dont forget to add xtext nature)
Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
|
|
|
Re: Problem with Super Grammar and an Ecore based SubGrammar [message #1115972 is a reply to message #1115445] |
Tue, 24 September 2013 20:50 |
|
Hi,
Christian Dietrich wrote on Tue, 24 September 2013 01:50
Hi,
no
no - you did not open it because you got mutiliple markers ?
Quote:
bad idea to but it to src gen. i get Multiple markers at this line - The imported
What I should not have put to src-gen ?
Quote:
package is not on the classpath of this project which may lead
to follow up errors.
next to this you will need a genmodel for this metamodel too.
I have a genmodel (/org.xtext.example.mydsl8.ecore/model/My8.genmodel) and it is a separate project.
Quote:
and you should register it in the standalonesetup (same as xtext does for xbase)
You think of this ?
registerGeneratedEPackage = "org.xtext.example.mydsl7.myDsl7.MyDsl7Package"
registerGenModelFile = "platform:/resource/org.xtext.example.mydsl7/model/generated/MyDsl7.genmodel"
registerGeneratedEPackage = "my8.My8Package"
registerGenModelFile = "platform:/resource/org.xtext.example.mydsl8.ecore/model/My8.genmodel"
The error message seems to point to the fact that the reference type of greetings in Model7 is more specific (qualified) than in Model8 (unqualified)
Caused by: java.lang.IllegalStateException: Problem parsing 'classpath:/org/xtext/example/mydsl8/MyDsl8.xtext':[TransformationDiagnostic: null:8 Cannot find compatible feature greetings in sealed EClass Model8 from imported package http:/www.xtext.org/example/mydsl8/Mydsl8: The existing reference 'greetings' has an incompatible type 'Greeting7' [org.xtext.example.mydsl7.myDsl7.Greeting7]. The expected type is 'Greeting7'. (ErrorCode: CannotCreateTypeInSealedMetamodel)]
Because I reference the genmodel od Model7 in Model8 and now inherit Model8 from Model7 the greetings feature in Model8 is inherited from Model7 and should have the same type as in Model7.
For me it smells to be a bug in Xtext incorrectly matching the types of inherited grammar rules and predefined ecore model feature types.
I made some corrections to the project files and hope you can open it with only the mentioned error. They are ready to use eclipse projects except you need to download the antlr runtime and build the projects to generate the class files.
Thank you for taking the time to investigate the problem.
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.02509 seconds