Not valid for cross reference [message #1839377] |
Fri, 19 March 2021 11:16  |
Eclipse User |
|
|
|
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 #1839409 is a reply to message #1839384] |
Sat, 20 March 2021 07:27   |
Eclipse User |
|
|
|
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 #1839415 is a reply to message #1839413] |
Sat, 20 March 2021 11:23  |
Eclipse User |
|
|
|
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
|
|
|
Powered by
FUDForum. Page generated in 0.04531 seconds