Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    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 08:29 Go to next message
Ronan B is currently offline Ronan BFriend
Messages: 273
Registered: July 2009
Senior Member
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 08:32]

Report message to a 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 08:34 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14665
Registered: July 2009
Senior Member
are you free in your metamodel? if yes you could move them to a subrule

Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
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 09:25 Go to previous messageGo to next message
Stefan Oehme is currently offline Stefan OehmeFriend
Messages: 159
Registered: April 2010
Location: Kiel
Senior Member

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 11:51 Go to previous messageGo to next message
Ronan B is currently offline Ronan BFriend
Messages: 273
Registered: July 2009
Senior Member
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 11:52]

Report message to a 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 11:49 Go to previous messageGo to next message
Sebastian Zarnekow is currently offline Sebastian ZarnekowFriend
Messages: 3118
Registered: July 2009
Senior Member
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 13:18 Go to previous message
Ronan B is currently offline Ronan BFriend
Messages: 273
Registered: July 2009
Senior Member
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: Thu Apr 25 22:41:52 GMT 2024

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

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

Back to the top