Skip to main content



      Home
Home » Modeling » TMF (Xtext) » [XText] Grouping parser rule assignment into a reusable block in grouping pattern
[XText] Grouping parser rule assignment into a reusable block in grouping pattern [message #1711873] Tue, 20 October 2015 04:29 Go to next message
Eclipse UserFriend
Hi,
I'm refactoring an XText grammar to not use un-ordered groups as it causes XText to run out of memory even after assigning 3GB. Reading the article, from the bottom, https://www.eclipse.org/forums/index.php/t/164906/ Sebastian Zarnekow suggests an elegent way of refactoring the groups. However, I have many single value properties I wish to intersperse amongst my groups. This means I must restate my grouping grammars many times which is a pain. Is there a handy way of defining them once and reusing?

For example:

MyRule returns myMM::MyRule:
'mykeyword' name=(ID) (';' |
'{'
(group1+=Group1|group2+=Group2|group3+=Group3)*
('description' description=(ConcenatedString|QuotedConcenatedString) ';'
(group1+=Group1|group2+=Group2|group3+=Group3)*?
('reference' reference=(ConcenatedString|QuotedConcenatedString) ';'
(group1+=Group1|group2+=Group2|group3+=Group3)*?
('status' status=StatusKind ';'
(group1+=Group1|group2+=Group2|group3+=Group3)*?
'}')
;

Obviously the (group1+=Group1|group2+=Group2|group3+=Group3)* part is not very maintainable if I have to repeat it 10->20 times.

Thanks!
Ronan

[Updated on: Tue, 20 October 2015 04:32] by Moderator

Re: [XText] Grouping parser rule assignment into a reusable block for "unordered group" ty [message #1711874 is a reply to message #1711873] Tue, 20 October 2015 04:34 Go to previous messageGo to next message
Eclipse UserFriend
are you free in your metamodel? if yes you could move them to a subrule
Re: [XText] Grouping parser rule assignment into a reusable block for "unordered group" ty [message #1711895 is a reply to message #1711874] Tue, 20 October 2015 05:25 Go to previous messageGo to next message
Eclipse UserFriend
In Xtext 2.9 this will be possible with rule fragments.
Re: [XText] Grouping parser rule assignment into a reusable block for "unordered group" ty [message #1711946 is a reply to message #1711895] Tue, 20 October 2015 07:51 Go to previous messageGo to next message
Eclipse UserFriend
HI,
Thanks for the replies. I'm free in my metamodel to an extend but I have these groupings in many many places, with different members of the group depending on the rule, so it would make my model terribly complex to refactor in the groupings there.

I think rule fragments would be great. I don't like altering my model to suit the grammar in many cases. I can live with repetition in the grammar for the moment knowing a solution is coming Smile

As a follow up question, I have noticed that as a consequence of using the pattern I have used the description, reference and status properties now must be in the stated order, this was not my intention. Is there a workaround for that? I cannot repeat them after each grouping in an OR as this would cause overwriting.

Thanks!
Ronan

[Updated on: Tue, 20 October 2015 07:52] by Moderator

Re: [XText] Grouping parser rule assignment into a reusable block for "unordered group like [message #1712118 is a reply to message #1711873] Wed, 21 October 2015 07:49 Go to previous messageGo to next message
Eclipse UserFriend
On 20.10.15 10:29, Ronan B wrote:
> Hi,
> I'm refactoring an XText grammar to not use un-ordered groups as it
> causes XText to run out of memory even after assigning 3GB. [..]

Would it be possible for you to file a ticket and provide some details
about the memory problems?

Best,
Sebastian
--
Looking for professional support for Xtext, Xtend or Eclipse Modeling?
Find help at http://xtext.itemis.com or xtext(@)itemis.com
Blog: zarnekow.blogspot.com
Twitter: @szarnekow
Google+: https://www.google.com/+SebastianZarnekow
Re: [XText] Grouping parser rule assignment into a reusable block for "unordered group like [message #1712261 is a reply to message #1712118] Thu, 22 October 2015 09:18 Go to previous message
Eclipse UserFriend
Hi,
Done, see https://bugs.eclipse.org/bugs/show_bug.cgi?id=480421

Do you have any suggestions for the follow up question I had? "I have noticed that as a consequence of using the pattern I have used the description, reference and status properties now must be in the stated order, this was not my intention. Is there a workaround for that?"

Regards,
Ronan
Previous Topic:How to run generated java code
Next Topic:How to include a second DSL as a containment
Goto Forum:
  


Current Time: Tue Jul 22 17:00:42 EDT 2025

Powered by FUDForum. Page generated in 0.04551 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top