expr = new InlineList(toPos(t.startPos,closingCurly.endPos));
}
else if (peekToken(TokenKind.COLON,true)) {
closingCurly = eatToken(TokenKind.RCURLY);
// empty map '{:}'
expr = new InlineMap(toPos(t.startPos,closingCurly.endPos));
}
else {
SpelNodeImpl firstExpression = eatExpression();
// Next is either:
// '}' - end of list
// ',' - more expressions in this list
// ':' - this is a map!
if (peekToken(TokenKind.RCURLY)) { // list with one item in it
List<SpelNodeImpl> listElements = new ArrayList<SpelNodeImpl>();
listElements.add(firstExpression);
closingCurly = eatToken(TokenKind.RCURLY);
expr = new InlineList(toPos(t.startPos,closingCurly.endPos),listElements.toArray(new SpelNodeImpl[listElements.size()]));
}
else if (peekToken(TokenKind.COMMA, true)) { // multi item list
List<SpelNodeImpl> listElements = new ArrayList<SpelNodeImpl>();
listElements.add(firstExpression);
do {
listElements.add(eatExpression());
}
while (peekToken(TokenKind.COMMA,true));
closingCurly = eatToken(TokenKind.RCURLY);
expr = new InlineList(toPos(t.startPos,closingCurly.endPos),listElements.toArray(new SpelNodeImpl[listElements.size()]));
}
else if (peekToken(TokenKind.COLON, true)) { // map!
List<SpelNodeImpl> mapElements = new ArrayList<SpelNodeImpl>();
mapElements.add(firstExpression);
mapElements.add(eatExpression());
while (peekToken(TokenKind.COMMA,true)) {
mapElements.add(eatExpression());
eatToken(TokenKind.COLON);
mapElements.add(eatExpression());
}
closingCurly = eatToken(TokenKind.RCURLY);
expr = new InlineMap(toPos(t.startPos,closingCurly.endPos),mapElements.toArray(new SpelNodeImpl[mapElements.size()]));
}
else {
raiseInternalException(t.startPos, SpelMessage.OOD);
}
}