private TokenStream RewriteFunctions(TokenStream tokens)
{
List<Token> result = new List<Token>();
foreach (Token token in tokens)
{
if (token.Type == TokenType.Word)
{
string name = (string)token.Value;
MathExpressionFunction function = MathExpressionFunctionFactory.Default.GetFunction(name);
if (function != null)
{
result.Add(new Token(TokenType.Function, function.Name));
continue;
}
}
result.Add(token);
}
return new TokenStream(result, tokens.Notation);
}