Script with condition [message #893413] |
Wed, 04 July 2012 03:23 |
Nicolas Rousseau Messages: 18 Registered: July 2009 |
Junior Member |
|
|
Hello,
I have a script with something like:
Parameter:
(name=EString ':'value=EString)
;
Parameters:
(parameter+=Parameter)
( "," parameter+=Parameter)*
;
(model simplified)
However what i'd like is to avoid to display the parameter if the value is empty (or null)
Means if i have:
Parameter.name = 'D'
Parameter.value = ''
or
Parameter.name = 'E'
Parameter.value = null (<not set>)
I simply want to display the result like:
A:a,
B:b,
C:c
and not:
A:a,
B:b,
C:c,
D:,
E:
How to achieve this?
I tried even things like extends the "isTransient".
But it generate things like:
A:a,
B:b,
C:c,,
(means with empty parameter but with comma..)
I guess there is something really better than this and more simple than modify the isTransient...
note: I'm still using the version 1.0.1 of xtext....
Thanks in advance !
|
|
|
|
Re: Script with condition [message #893470 is a reply to message #893438] |
Wed, 04 July 2012 09:00 |
Nicolas Rousseau Messages: 18 Registered: July 2009 |
Junior Member |
|
|
in fact to give more concrete example, here's one part of the (real) grammar:
As you can see, based on emf model directly.
SubjobType returns talendFile::SubjobType:
{talendFile::SubjobType}
'addSubjob'
'{'
(elementParameter+=(ElementParameterType | SchemaElementParameterType))
("," elementParameter+=(SchemaElementParameterType | ElementParameterType))*
'}';
ElementParameterType returns talendFile::ElementParameterType:
{talendFile::ElementParameterType}
(name=EString ':' value=EExpression);
SchemaElementParameterType returns talendFile::ElementParameterType:
{talendFile::ElementParameterType}
(name=EString '{' elementValue+=ElementValueType ("," elementValue+=ElementValueType)* '}')?;
Everything works well here...
but if the value of ElementParameterType is empty or null, i'd like to don't generate anything.
Actually, with this grammar, when i give EMF model and try to get the script, i can get things like:
addSubjob {
A:a,
B:b,
C:c,
D:,
E:
}
(only considering the ElementParameterType)
but i'd prefer generate only something like:
addSubjob {
A:a,
B:b,
C:c
}
(with real values only)
|
|
|
Powered by
FUDForum. Page generated in 0.02659 seconds