/// <summary> /// Initializes a new instance of the <see cref="ExpressionTree"/> class. /// </summary> /// <param name="expression">Symbolic expression (e.g. "sin(x^2) + 10/x").</param> /// <exception cref="ArgumentException"> /// <para><paramref name="expression"/> has unknown tokens.</para> /// </exception> /// <exception cref="ArgumentNullException"> /// <para><paramref name="serviceProvider"/> is <see langword="null"/>.</para> /// -or- /// <para><paramref name="expression"/> is <see langword="null"/>.</para> /// -or- /// <para><paramref name="expression"/> is an empty string.</para> /// </exception> /// <exception cref="ExpressionSyntaxException">Specified <paramref name="expression"/> has syntax errors.</exception> public ExpressionTree(INuGenServiceProvider serviceProvider, String expression) { if (serviceProvider == null) { throw new ArgumentNullException("serviceProvider"); } if (String.IsNullOrEmpty(expression)) { throw new ArgumentNullException("expression"); } _serviceProvider = serviceProvider; _expression = expression; ExpressionToken[] tokens = ExpressionToken.GetTokens(ServiceProvider, expression); foreach (ExpressionToken token in tokens) { if (token.IsUnknownToken) { throw new ArgumentException(String.Format(Resources.Argument_UnknownToken, _expression, token.TokenBody)); } } _parsedExpression = ""; CreateTree(tokens); _variables = (String[])new ArrayList(FindVariables(_root).Keys).ToArray(typeof(String)); }