/// <summary> /// Build the abstract syntax tree for a given formula. The formula string will /// be first tokenized. /// </summary> /// <param name="formulaText">A string containing the mathematical formula that must be converted /// into an abstract syntax tree.</param> /// <returns>The abstract syntax tree of the formula.</returns> private Operation BuildAbstractSyntaxTree(string formulaText) { TokenReader tokenReader = new TokenReader(cultureInfo); List<Token> tokens = tokenReader.Read(formulaText); AstBuilder astBuilder = new AstBuilder(FunctionRegistry); Operation operation = astBuilder.Build(tokens); if (optimizerEnabled) return optimizer.Optimize(operation, this.FunctionRegistry); else return operation; }