Iterator<HiddenTokenAwareTree> iterator = token.getChildren().iterator();
HiddenTokenAwareTree nameToken = iterator.next();
InterpolableName name = toInterpolableName(nameToken, nameToken.getChildren());
if (!iterator.hasNext())
return new Declaration(token, name);
HiddenTokenAwareTree expressionToken = iterator.next();
ListExpressionOperator.Operator mergeOperator = null;
if (expressionToken.getType() == LessLexer.PLUS) {
expressionToken = iterator.next();
mergeOperator = ListExpressionOperator.Operator.COMMA;
if (expressionToken.getType() == LessLexer.UNDERSCORE) {
expressionToken = iterator.next();
mergeOperator = ListExpressionOperator.Operator.EMPTY_OPERATOR;
}
}
if (expressionToken.getType() == LessLexer.IMPORTANT_SYM)
return new Declaration(token, name, null, true, mergeOperator);
Expression expression = (Expression) switchOn(expressionToken);
if (!iterator.hasNext())
return new Declaration(token, name, expression, mergeOperator);
HiddenTokenAwareTree importantToken = iterator.next();
if (importantToken.getType() == LessLexer.IMPORTANT_SYM)
return new Declaration(token, name, expression, true, mergeOperator);
throw new BugHappened(GRAMMAR_MISMATCH, token);
}