Skip to main content



      Home
Home » Modeling » TMF (Xtext) » Parser Rule Fragments
Parser Rule Fragments [message #1725076] Mon, 29 February 2016 09:43 Go to next message
Eclipse UserFriend
Hi,
I was reading https://www.eclipse.org/forums/index.php/t/1072927/ and hoping to solve my unordered group issue as outlined a while back in https://www.eclipse.org/forums/index.php/t/1071359/.

It seems the Parser Rule Fragments concept introduced in Xtext 2.9 is rather restrictive in that it cannot be used in unordered groups. When I use the following fragment XText complains "Unassigned rule calls may not be used in unordered groups"

fragment X returns xyz::Element :
(( children+=Node ) | ( properties += Property ))*
;

Element returns xyz::Element:
'element'name=OptionallyQuotedName'{'
(
X
& 'des' des=(ConcatenatedString|QuotedConcatenatedString) ';'?
& X
& 'ref' ref=(ConcatenatedString|QuotedConcatenatedString) ';'?
& X
)
'}';

Also I think it is odd that the fragment must have an explicit return type matching the rule from which it is used, or have I misunderstood?

Thanks!
Ronan

[Updated on: Mon, 29 February 2016 14:38] by Moderator

Re: Parser Rule Fragments [message #1725196 is a reply to message #1725076] Tue, 01 March 2016 09:40 Go to previous messageGo to next message
Eclipse UserFriend
Hi,
A quick follow up. I don't see any documentation of "rule fragments". Can someone provide a few samples, or even confirm my suspiction that they cannot be used in unordered groups.
Thanks!
Ronan
Re: Parser Rule Fragments [message #1725251 is a reply to message #1725196] Wed, 02 March 2016 02:14 Go to previous messageGo to next message
Eclipse UserFriend
Hi Ronan,
seems like it is the unassigned call to 'X' that the error is about.
Also you don't need to specify the return type, but you can if you want to have a common type for the features used in a fragment.
Sven
Re: Parser Rule Fragments [message #1742897 is a reply to message #1725251] Thu, 08 September 2016 09:00 Go to previous messageGo to next message
Eclipse UserFriend
I just stumbled across the same issue. It seems to be caused by the "and" operator.
Super:
	A | B;
fragment frag returns Super:
	name = ID;
A:
	frag |
	something = ID;
B:
	frag &
	something = ID;

While A works without any issues, B throws the same error "Unassigned rule calls may not be used in unordered groups".
Is there any reason behind that?

Greets,
Martin
Re: Parser Rule Fragments [message #1742911 is a reply to message #1742897] Thu, 08 September 2016 10:27 Go to previous message
Eclipse UserFriend
looks like a bug to me
Previous Topic:xtext get parser rule name based on context
Next Topic:Xtext project from ecore models
Goto Forum:
  


Current Time: Mon Jul 14 08:31:00 EDT 2025

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

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

Back to the top