private object[] CompileCollection()
{
Token token = this.NextToken();
IList<object> elements = new List<object>();
while (token != null)
{
switch (token.Type)
{
case TokenType.Integer:
elements.Add(Convert.ToInt32(token.Value));
break;
case TokenType.Real:
elements.Add(Convert.ToDouble(token.Value));
break;
case TokenType.Symbol:
case TokenType.String:
case TokenType.Name:
elements.Add(token.Value);
break;
case TokenType.Punctuation:
if (token.Value == ")")
return elements.ToArray();
if (token.Value == "(")
elements.Add(this.CompileCollection());
else
throw new ParserException("Expected ')'");
break;
default:
throw new ParserException("Expected ')'");
}
token = this.NextToken();
}
return elements.ToArray();
}