0

In grako one can use the following name:e to add the result of e to the AST using name as key. For example

var_def
    =
    var+:ID {',' var+:ID}*

What would be a good translation of this to Xtext? I tried

var_def:
     var=ID (',' var=ID)*;

which is not failing, but is raising the following warning

Multiple markers at this line
- The possibly assigned value of feature 'var' may be overridden
   by subsequent assignments.
- This assignment will override the possibly assigned value of
   feature 'var'.

I think I am trying to mimic the name behavior, but do not have much success.

Apalala
  • 9,017
  • 3
  • 30
  • 48
Quantico
  • 2,398
  • 7
  • 35
  • 59
  • Not an answer, but it's worth noting that in recent versions of Grako it is possible to write:``var:','.{ID}`` – Apalala Apr 22 '16 at 17:19

1 Answers1

1

With your solution only the last ID will be available in the AST. I assume var should be a multi-valued feature holding all IDs, not only the last one. This can be expressed as

var_def:
    var+=ID (',' var+=ID)*;

In the resulting AST var is a list of IDs.

Miro Spönemann
  • 273
  • 1
  • 5