|
Re: How do I customize grammar for my topology feature? [message #1760288 is a reply to message #1760287] |
Tue, 25 April 2017 14:30 |
|
Hi,
i did not get your question, can you please elaborate.
do you want to have a different syntax that creates the tree? or just for the joints?
so you want to have syntax a (show should that look like) that creates an ast that looks like in the metamodel?
maybe you need a
- derived or manual second metamodel that is closer to your wanted synatax
- use a IDerivedStateComputer (maybe in comb. with SyntheticLinkingSupport) to create the instance of the external metamodel
Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
|
|
|
Re: How do I customize grammar for my topology feature? [message #1760296 is a reply to message #1760288] |
Tue, 25 April 2017 15:17 |
Susie Agerholm Messages: 54 Registered: April 2017 |
Member |
|
|
Hi Christian, thank you for a very reply!
Here are some more details:
The metamodel I am trying to do a grammar for sort of has two different levels of description.
- the lower level of description tell us about the individual parts of the robot and their attributes (links are physical shapes, that have attributes like geometry, mass, etc - and joints connect the links, joints have a joint type, certain limits for bending, etc etc)
- the higher level of description tells us about the topology of the robot - how the individual joints and links are connected in child/parent relations.
The description would be a lot more easy to read, if this higher level of description was made more explicit by adding a special topology syntax for it - and removing it from the part, that defines individual Links and Joints and their attributes...
The concrete syntax for the topology should look something like this - arrows represent Joints connecting Links:
Link name=RobotsUpperArm -> Link name=RobotsLowerArm etc...
I hope this were the details you were looking for. If not let me know and I'll explain further
|
|
|
|
|
|
|
|
|
|
|
|
|
Re: How do I customize grammar for my topology feature? [message #1760968 is a reply to message #1760287] |
Thu, 04 May 2017 16:46 |
|
Sven, Christian,
I'm working with Susie on this, and I follow this discussion as well. The solution suggested seems to be adaptable to what we need, but I would like to ask the same question in a different way, just to rule out that we are missing something obvious.
The case we are looking at, is not very exotic: we have a DSL where objects can be used without declaration, but some objects can be declared (in here the objects are "links"). So basically, we want a reference to be resolved to an existing object (link) if it was already declared, and otherwise, if the object is not declared, it should be declared and instantiated automatically.
Since automatic variable definition is seen in some programming languages, I was wondering if Xtext had some direct support for this. Are we on the right track using IDerivedState? Or is there a more direct way in the Xtext DSL?
|
|
|
|
Re: How do I customize grammar for my topology feature? [message #1761045 is a reply to message #1760969] |
Fri, 05 May 2017 14:56 |
|
I usually solve that by
- modeling the name of such an object as a cross reference within the grammar
- disable the errors for such broken cross references since it is not an error but a declaration (override LinkingDiagnosticMessageProvider#getUnresolvedProxyMessage to return null in such cases).
- implement an 'IQualifiedNameProvider' to get the name from the object's node (see 'NodeModelUtils')
|
|
|
|
|
|
|
|
|
|
|
Re: How do I customize grammar for my topology feature? [message #1763558 is a reply to message #1763554] |
Wed, 17 May 2017 11:57 |
|
sorry i still cannot follow you. thus i cannot help you.
you have model x that is parsed.
then you have the derived state computer that produces model y.
that ever you do there lies in your hand.
but i dont see anything that i can reproduce .....
i have never seens an example model i can use. nor how the ast should look like you want to produce.
a robot has topologies.
a topology has references to (other ?!? robots???)
Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
|
|
|
Powered by
FUDForum. Page generated in 0.06541 seconds