Eclipse Community Forums - RDF feed
https://www.eclipse.org/forums/
Eclipse Community ForumsCreate dynamically primitive types that are defined in a types ecore model
https://www.eclipse.org/forums/index.php/mv/msg/1092100/1783039/#msg_1783039
beside my dsl I have a second ecore model that specify types.
In that model there is for example the root class type and the class primitive types that extends from types.
Now I want to create dynamically instances of the primitive types with the name integer, string and boolean so that i can refer to these types out of my dsl.
Where can I do this stuff? In the Scoping? And how?
A small example would be really helpful. Basically I think xbase should do similar things.
Many thanks!
]]>Chris X2018-03-07T05:50:26-00:00Re: Create dynamically primitive types that are defined in a types ecore model
https://www.eclipse.org/forums/index.php/mv/msg/1092100/1783040/#msg_1783040
Chris X2018-03-07T06:16:42-00:00Re: Create dynamically primitive types that are defined in a types ecore model
https://www.eclipse.org/forums/index.php/mv/msg/1092100/1783041/#msg_1783041
https://projects.eclipse.org/proposals/eclipse-xsemantics
It allows to define (static) type system rules and produces the Xtext artifacts for supporting that type system.
For more information on it contact Lorenzo Bettini direct.]]>Karsten Thoms2018-03-07T06:19:38-00:00Re: Create dynamically primitive types that are defined in a types ecore model
https://www.eclipse.org/forums/index.php/mv/msg/1092100/1783044/#msg_1783044
many thanks! I will take a look into it ]]>Chris X2018-03-07T06:36:00-00:00Re: Create dynamically primitive types that are defined in a types ecore model
https://www.eclipse.org/forums/index.php/mv/msg/1092100/1783053/#msg_1783053
after I take a look to the Xsemantics I'm not sure if it will help me.
Maybe I will concretize my scenario:
I have a dsl and the model of the dsl is generated automatically with the generate keyword. It has the extension ".myDsl"
In my dsl it's possible to refer to external emf model elements that has been created by a user in an graphical emf editor (.boxmodel). In the editor the user can create Elements of the class
"BoxType". For instance a BoxType can contain a different number of contacts.
So the class of "BoxType" looks like this:
BoxType:
name : EString
contacts: Contact (0...* as containments)
At the end the user can create for example BoxType B1 (with 10 contacts) and BoyType B2 (with 12 contacts)
Now it my dsl it should be possible to declare a variable for a specific BoxType or for a primitive type.
So that the user can write the following:
set int x = 5;
set B1 y;
set B2 z;
Now I had the following approach: I create a third model for types (.types).
The meta-model of the type-model looks like this:
Type
name : EString
PrimitiveType-> Type
ModelType-> Type
The BoxType of the Metamodel (.boxmodel) extends from ModelType.
In a variable declaration I can refer to Elements of Type
But currently I have the problem that I can not refer to default primitive Types like ('int', 'string', etc.) because I have to instantiate them dynamically for the first time and have to but them to the index. So at the end I need the possibility to instantiate a primitive type with name = 'int' and so on. More or less it's a dynamically created library that provides the default primitive types.
But I have no idea where to do this stuff.
PS: In the dsl itself the user has no chance to define types. So he can only define boxTypes with a graphical emf editor or he can use the primitive types.
Maybe the upper approach is to complicated and there is a easier approach.
About suggestions for improvement, I would be very happy.
]]>Chris X2018-03-07T09:51:36-00:00Re: Create dynamically primitive types that are defined in a types ecore model
https://www.eclipse.org/forums/index.php/mv/msg/1092100/1783059/#msg_1783059
or you could provide some std lib .yourdsl files and put them onto classpath]]>Christian Dietrich2018-03-07T10:11:57-00:00Re: Create dynamically primitive types that are defined in a types ecore model
https://www.eclipse.org/forums/index.php/mv/msg/1092100/1783062/#msg_1783062
first many thanks. Could you give me a small example how I can dynamically instantiate an element of an external model element and how to put it then to the scope?]]>Chris X2018-03-07T10:19:21-00:00Re: Create dynamically primitive types that are defined in a types ecore model
https://www.eclipse.org/forums/index.php/mv/msg/1092100/1783063/#msg_1783063
EObjectDEscription.create(.....) / Scopes.scopeFor......]]>Christian Dietrich2018-03-07T10:20:15-00:00Re: Create dynamically primitive types that are defined in a types ecore model
https://www.eclipse.org/forums/index.php/mv/msg/1092100/1783064/#msg_1783064
Christian Dietrich2018-03-07T10:21:19-00:00Re: Create dynamically primitive types that are defined in a types ecore model
https://www.eclipse.org/forums/index.php/mv/msg/1092100/1783067/#msg_1783067
What is generally shitty on this concept? And what would be a better approach? I would be very happy about some tips or hints.]]>Chris X2018-03-07T10:26:38-00:00Re: Create dynamically primitive types that are defined in a types ecore model
https://www.eclipse.org/forums/index.php/mv/msg/1092100/1783068/#msg_1783068
Christian Dietrich2018-03-07T10:29:21-00:00Re: Create dynamically primitive types that are defined in a types ecore model
https://www.eclipse.org/forums/index.php/mv/msg/1092100/1783070/#msg_1783070
Christian Dietrich2018-03-07T10:30:28-00:00Re: Create dynamically primitive types that are defined in a types ecore model
https://www.eclipse.org/forums/index.php/mv/msg/1092100/1783083/#msg_1783083
Unfortunately implementations that I have are closed source and don't have the time to anonymize that. But would be worth a blog post some day.
]]>Karsten Thoms2018-03-07T13:39:49-00:00Re: Create dynamically primitive types that are defined in a types ecore model
https://www.eclipse.org/forums/index.php/mv/msg/1092100/1783092/#msg_1783092
many thanks for your help! A blog post would be really helpful.
But already your support here on the forum is really grateful.
Currently I try the stdlib approach as proposed from Christian and as described in the book of "Implementing Domain-Specific Languages with Xtext and Xtend".
I also tried the example of the book and therefore I have the same problem. I also deleted the runtime workspace and double check the dependencies as proposed from Christian.
But hope I will find a way to solve the problem in the next hours ;)
Thx and have a nice evening!]]>Chris X2018-03-07T19:23:17-00:00Re: Create dynamically primitive types that are defined in a types ecore model
https://www.eclipse.org/forums/index.php/mv/msg/1092100/1783093/#msg_1783093
Chris X2018-03-07T19:23:43-00:00Re: Create dynamically primitive types that are defined in a types ecore model
https://www.eclipse.org/forums/index.php/mv/msg/1092100/1783095/#msg_1783095
Christian Dietrich2018-03-07T20:18:47-00:00Re: Create dynamically primitive types that are defined in a types ecore model
https://www.eclipse.org/forums/index.php/mv/msg/1092100/1783148/#msg_1783148
I removed the runtime-workspace again and checked that the autobuild is selected.]]>Chris X2018-03-08T14:06:39-00:00Re: Create dynamically primitive types that are defined in a types ecore model
https://www.eclipse.org/forums/index.php/mv/msg/1092100/1783155/#msg_1783155
Karsten Thoms2018-03-08T15:01:10-00:00