Eclipse Community Forums - RDF feed
https://www.eclipse.org/forums/
Eclipse Community ForumsOptional arguments
https://www.eclipse.org/forums/index.php/mv/msg/453573/1009506/#msg_1009506
in my grammar there is a definition Func which can hold 0 to n params.
Simplified xtext fragment:
Now I want some parameters to be optional to edit code like:
Func (7, , 15);
My question:
How can I change the grammar to omit single params? It then must be possible accessing the values where the omitted values keep some empty/null value like:
params[0] // value is 7
params[1] // value is empty/null
params[2] // value is 15
Therefore, I can not make the single params completely optional like
(params+=INT)? // this would not set an empty/null value to an omitted param
Any suggestions?
Thanks in advance,
Gaspar
]]>Gaspar Din2013-02-15T08:47:13-00:00Re: Optional arguments
https://www.eclipse.org/forums/index.php/mv/msg/453573/1009585/#msg_1009585
(params+=INT)? makes the assignment optional, not only the text
But unfortunately, when I define
Func: {Func} '(' ( params+=INT(',' params+=INT?)* )? ')' ';';
it is really possible editing
Func (7, , , 15);
but calling func.getParams() only holds the two values 7 and 15.
The size of func.getParams() is two.
But how can I find out at which position the arguments are located?
Regards,
Gaspar
]]>Gaspar Din2013-02-15T14:28:20-00:00Re: Optional arguments
https://www.eclipse.org/forums/index.php/mv/msg/453573/1009694/#msg_1009694
what about
and a custom valueconverter that handles the "null/strip away the comma" problem]]>Christian Dietrich2013-02-15T14:37:27-00:00Re: Optional arguments
https://www.eclipse.org/forums/index.php/mv/msg/453573/1010831/#msg_1010831
I've tested with the OINT and it works for me!
Thank you
Gaspar]]>Gaspar Din2013-02-18T10:04:28-00:00