* stringListAttribute := attributeKey STRING (COMMA STRING)*
* @param key
* @throws RecognitionException
*/
private AttributeDescr stringListAttribute( String[] key ) throws RecognitionException {
AttributeDescrBuilder attribute = null;
try {
StringBuilder builder = new StringBuilder();
for ( String k : key ) {
if ( "-".equals( k ) ) {
match( input,
DRLLexer.MINUS,
k,
null,
DroolsEditorType.KEYWORD ); // part of the keyword
if ( state.failed ) return null;
} else {
match( input,
DRLLexer.ID,
k,
null,
DroolsEditorType.KEYWORD );
if ( state.failed ) return null;
}
builder.append( k );
}
if ( state.backtracking == 0 ) {
attribute = helper.start( AttributeDescrBuilder.class,
builder.toString(),
null );
}
builder = new StringBuilder();
builder.append( "[ " );
Token value = match( input,
DRLLexer.STRING,
null,
null,
DroolsEditorType.STRING_CONST );
if ( state.failed ) return null;
builder.append( value.getText() );
while ( input.LA( 1 ) == DRLLexer.COMMA ) {
match( input,
DRLLexer.COMMA,
null,
null,
DroolsEditorType.SYMBOL );
if ( state.failed ) return null;
builder.append( ", " );
value = match( input,
DRLLexer.STRING,
null,
null,
DroolsEditorType.STRING_CONST );
if ( state.failed ) return null;
builder.append( value.getText() );
}
builder.append( " ]" );
if ( state.backtracking == 0 ) {
attribute.value( builder.toString() );
attribute.type( AttributeDescr.Type.LIST );
}
} finally {
if ( attribute != null ) {
helper.end( AttributeDescrBuilder.class,
null );
}
}
return attribute != null ? attribute.getDescr() : null;
}