Unordered Groups - any Alternatives? [message #1795610] |
Wed, 26 September 2018 04:24  |
Eclipse User |
|
|
|
I am working on an xtext-based project with a rather large grammar. I essentially use this grammar to have a textual way of describing a complex emf-model. Essentially, the language allows to specify nested objects with certain properties:
ParentObject name {
Property1 = "Test";
Property2 = "Test2";
// ...
ChildObject name {
PropertyA = "ABC";
PropertyB = "CDE";
// ...
}
}
Of course, every property setting is meant to occur only once or not at all. The current grammar is available here [0].
So far it is working fine, but it requires the user to know the expected "order" of the properties in the grammar. Sure, code completion helps a lot, but I would like to allow for more flexibility for the novice user. For instance, I would like to allow a specification like this one (order of properties is reversed):
ParentObject name {
Property2 = "Test";
Property1 = "Test2";
// ...
ChildObject name {
PropertyB = "ABC";
PropertyA = "CDE";
// ...
}
}
I tried with unordered groups, but pretty quickly the xtext generator in the mwe2 workflow required more than 16GB of heap space - even without adding the full flexibility in the grammar. This approach is not viable, because it does not fit the ressources of our CI environment.
As an alternative approach, I stumbled over this [1], which allows more flexibilty in the grammar, but uses a checker to enforce single occurance of properties. However, going this route would require a major redesign of the meta-model to have "generic property lists" in all places, which could be checked. I feel this would not help the longterm maintainability and readability of my xcore model [2] - just for the sake of more flexibility in the input language.
Are there any other approaches I could try? I like the idea of having a more flexible grammar and implement a checker on top of that, but I would like to minimize the effect on the meta-model.
Thank you -
Robert
[0]: https://github.com/RobertHilbrich/assist-public/blob/master/ch.hilbri.assist.mapping.dsl/src/ch/hilbri/assist/mapping/dsl/MappingDSL.xtext
[1]: https://stackoverflow.com/questions/23701169/free-order-of-rules-in-xtext
[2]: https://github.com/RobertHilbrich/assist-public/blob/master/ch.hilbri.assist.model/model/ASSIST-Model.xcore
|
|
|
|
|
|
|
|
|
|
|
|
|
Re: Unordered Groups - any Alternatives? [message #1799457 is a reply to message #1799401] |
Fri, 07 December 2018 02:19  |
Eclipse User |
|
|
|
Good Morning,
Thanks for the feedback - I tried to reproduce a minimal example which exhibits this behaviour ... and failed to do so. After digging through the serializer and nfa code, I discovered a stupid error in my code.
So, no worries. The serializer is working fine for me.
|
|
|
Powered by
FUDForum. Page generated in 0.25465 seconds