return parseAngularExpressionInToken(token);
}
AngularExpression parseAngularExpressionInToken(Token token) {
List<Token> tokens = splitAtBar(token);
Expression mainExpression = parseDartExpressionInToken(tokens.get(0));
// parse formatters
List<AngularFormatterNode> formatters = Lists.newArrayList();
for (int i = 1; i < tokens.size(); i++) {
Token formatterToken = tokens.get(i);
Token barToken = formatterToken;
formatterToken = formatterToken.getNext();
// parse name
Expression nameExpression = parseDartExpressionInToken(formatterToken);
if (!(nameExpression instanceof SimpleIdentifier)) {
reportErrorForNode(AngularCode.INVALID_FORMATTER_NAME, nameExpression);
continue;
}
SimpleIdentifier name = (SimpleIdentifier) nameExpression;
formatterToken = name.getEndToken().getNext();
// parse arguments
List<AngularFormatterArgument> arguments = Lists.newArrayList();
while (formatterToken.getType() != TokenType.EOF) {
// skip ":"
Token colonToken = formatterToken;
if (colonToken.getType() == TokenType.COLON) {
formatterToken = formatterToken.getNext();
} else {
reportErrorForToken(AngularCode.MISSING_FORMATTER_COLON, colonToken);
}
// parse argument
Expression argument = parseDartExpressionInToken(formatterToken);
arguments.add(new AngularFormatterArgument(colonToken, argument));
// next token
formatterToken = argument.getEndToken().getNext();
}
formatters.add(new AngularFormatterNode(barToken, name, arguments));
}
// done
return new AngularExpression(mainExpression, formatters);