Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » Unassigned Rule Calls - 'current' already created
Unassigned Rule Calls - 'current' already created [message #1822587] Tue, 10 March 2020 09:50 Go to next message
Rob K is currently offline Rob KFriend
Messages: 5
Registered: January 2020
Junior Member
Hi,

PROBLEM:
The following code snippet has the following error at 'TypeReference' and 'VectorTypeConstructor' in Type: 'An unassigned rule call is not allowed, when the 'current' was already created.'

Type:
	isImmutable?='immutable' (TypeReference | VectorTypeConstructor) (range = Range)?
;

VectorTypeConstructor:
	type = [TypeDecl] (dimensions += Dimension)+
;

TypeReference:
	type = [TypeDecl]
;

This is caused when I added 'isImmutable?='immutable'' to the start of Type.

WHY THIS IS A PROBLEM:
I can add an assignment : 'type = (TypeReference | VectorTypeConstructor)' but that breaks a lot of existing code (i'm editing a big project). Getting the TypeDecl object from Type would change from 'Type.type' to 'Type.type.type'

SOLUTIONS TRIED:
Removing the 'isImmutable?='immutable'' part removes the error, as does replacing the contents of VectorTypeConstructor and TypeReference with a literal (e.g. 'test'). However that removes functionality from the grammar which is obviously unacceptable

Using assignments by changing to
({TypeReference.type = current} | {VectorTypeConstructor.type = current})

changes the error to the lines containing 'type = [TypeDecl]', with the text 'A feature 'type' with a different cardinality or containment configuration already exists in type 'VectorTypeConstructor/TypeReference''.

Im not very familiar with Xtext, so any help would be greatly appreciated!
Re: Unassigned Rule Calls - 'current' already created [message #1822595 is a reply to message #1822587] Tue, 10 March 2020 10:54 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 13628
Registered: July 2009
Senior Member
Hmmm

Maybe you can add the immutable to the two rules instead


Need professional support for Xtext, Xpand, EMF?
Go to: https://www.itemis.com/en/it-services/methods-and-tools/xtext
Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: Unassigned Rule Calls - 'current' already created [message #1822611 is a reply to message #1822595] Tue, 10 March 2020 13:36 Go to previous messageGo to next message
Rob K is currently offline Rob KFriend
Messages: 5
Registered: January 2020
Junior Member
Christian Dietrich wrote on Tue, 10 March 2020 10:54
Hmmm

Maybe you can add the immutable to the two rules instead


It works! however, this solution requires copy/pasting code, something I obviously would prefer to avoid!

So if anyone has an even better solution I would love to hear it
Re: Unassigned Rule Calls - 'current' already created [message #1822637 is a reply to message #1822611] Tue, 10 March 2020 16:02 Go to previous message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 13628
Registered: July 2009
Senior Member
You may have a look at the concept of fragments (unfortunately undocumented )

Need professional support for Xtext, Xpand, EMF?
Go to: https://www.itemis.com/en/it-services/methods-and-tools/xtext
Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Previous Topic:Xtext Embedded editor not shown in wizard
Next Topic:Test generated code that includes Maven dependencies
Goto Forum:
  


Current Time: Thu Oct 22 00:53:35 GMT 2020

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

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

Back to the top