Grammar errors in Xtext

I have a grammar rule

factoid: Element Place ; 

It depends on another rule:

 Place: name = ('sea' | 'air') ; 

The Factoid rule seems to contain identification errors related to Place:

Multiple tokens on this line - Cannot change type twice in a rule - An unassigned rule call is not allowed when the "current" has already been created.

I have no idea what that means. Can someone explain what it is and how to fix it?

+4
source share
1 answer

I think the Element rule generates an object. Since there is no assignment, it becomes current. A second unassigned call to the Place rule will also return an object. But the current pointer already contains a class of type Element and cannot contain the class Place. So, what you can try is assign a place to the factoid member called location:

 factoid: item=Element location=Place ; 

I'm not sure if element assignment to element is required. If Element is not assigned to a member, I expect this place to become a member of Element or something similar.

+3
source

All Articles