Chad
Chad

Reputation: 2071

In Xtext, How to define terminal with same definition? Or Circumvent EString requirement in crosslinking?

I have the following grammar defined in XText.

Object:
    "object" (name=INT)? ("extends" superType=[Object|INT] "{" 
        (comps+=Component)* 
    "}"
;

I'm having problems defining the cross-reference since apparently INT does not return an ecore::EString object.

I tried defining an STRINT terminal:

STRINT returns ecore::EString:
    INT
;

However this hides the INT terminal previously defined, which is another problem.

Questions:

Upvotes: 0

Views: 186

Answers (1)

Sebastian Zarnekow
Sebastian Zarnekow

Reputation: 6729

If you define STRINT as a data type rule, it'll not hide another terminal. So basically what you described will work:

STRINT:
  INT
;

Upvotes: 1

Related Questions