Skip to main content



      Home
Home » Modeling » TMF (Xtext) » Not valid for cross reference
Not valid for cross reference [message #1839377] Fri, 19 March 2021 11:16 Go to next message
Eclipse UserFriend
Hi all,
I have the following grammar:


Element:
name="element"
;
Type:
A | B | C
;
A:
name=ID
;
B:
name=ID
;
C:
name=ID
;
Machine:
name = ID find = [Type | Element]

However, I get the following error:
The rule 'Element' is not valid for a cross reference since it
does not return an EString. You'll have to wrap it in a data
type rule.

Any idea on how to solve that?

Thanks,
John
Re: Not valid for cross reference [message #1839384 is a reply to message #1839377] Fri, 19 March 2021 12:26 Go to previous messageGo to next message
Eclipse UserFriend
find = [Type | Element] means reference a Type and Parse an Element.
do you mean Type or Element? then you need a common rule: TypeOrElement: Type|Element; find=[TypeOrElement|ID] ir short find=[TypeOrElement]
or just type which would be find=[Type|ID]
Re: Not valid for cross reference [message #1839409 is a reply to message #1839384] Sat, 20 March 2021 07:27 Go to previous messageGo to next message
Eclipse UserFriend
Hi Christian,

If I try to follow your approach by having the following grammar:

Element:
name="element"
;
Type:
A | B | C
;
A:
name=ID
;
B:
name=ID
;
C:
name=ID
;
TypeorElement:
Type | Element
;
Machine:
name = ID find = [TypeorElement]

I get this error:

Decision can match input such as "RULE_ID" using multiple alternatives: 1, 2, 3.
I believe this is because A,B,C are identified by an ID and Xtext will now know if what we are writing belong to A,B, or C. How could it work in this case? Without changing the ID for A,B,C.

Furthermore, one other thing is that A,B,C are reachable from the root rule, while Element is not. I want to say that the rule Element has this specific keyword "element", and when I am at the rule Machine, I will either get suggestions for the names of A,B,C which I have defined prior, or the "element" suggestion.

Hope this is clear enough :)

Thank you!

[Updated on: Sat, 20 March 2021 07:27] by Moderator

Re: Not valid for cross reference [message #1839412 is a reply to message #1839409] Sat, 20 March 2021 08:15 Go to previous messageGo to next message
Eclipse UserFriend
Your rules A B C are identical and thus ambiguous
Re: Not valid for cross reference [message #1839413 is a reply to message #1839412] Sat, 20 March 2021 08:24 Go to previous messageGo to next message
Eclipse UserFriend
Yes, but I cannot change that, so would there be a solution in this case so that find can consider both the Type and Element ?
Re: Not valid for cross reference [message #1839415 is a reply to message #1839413] Sat, 20 March 2021 11:23 Go to previous message
Eclipse UserFriend
As I said. The Problem is a b c and not type element

Consider this model

z

Is this an a or a b or a c

You may also need a

MY_ID: ID|"element";

And then use thiamine in the by clause of the reference

name = ID find = [TypeorElemement|MY_ID]

[Updated on: Sat, 20 March 2021 13:36] by Moderator

Previous Topic:How to get xtext comment information?
Next Topic:Grammar ambiguity
Goto Forum:
  


Current Time: Mon Jul 14 19:14:23 EDT 2025

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

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

Back to the top