I want to implement an array inside a rule in Xtext and use Xtend templates to generate code. I've already checked this Post but the problem is, that the generator automaticaly adds square brackets to the generated output.
My Xtext rule look like the following example:
Rule:
'Rule' name=ID
('myarray' myarray+=DOUBLE(',' myarray+=DOUBLE)*)? &
'end' 'Rule'
;
terminal DOUBLE returns ecore::EDouble:
'-'? (("." INT) |
(INT ("." (INT)?)? (("e" | "E") ("+" | "-")? INT)?))
;
When I generate via Xtend, for example with the values 1,2,3
the output is [1,2,3]
but I want to skip the square brackets and get the output 1,2,3
.
How is it possible?
simply use appropriate methods to output the list
e.g.
'''«myarray.join(",")»'''
or
'''«FOR e : myarray SEPARATOR ","»«e»«ENDFOR»'''