Possible Duplicate:
Is there a string math evaluator in .NET?
I need to implement mathematical expression parser. It has to evaluate the following expressions:
- Basic operators(+,-,*,/,%[modulo operator])
- priority operations such as 2*(4-1)
- sin,cos,tan,cotan, log(base,number) functions
- allows compositions such as sin(cos(log(2,32)))
- power operation such as 2^5
First that I wanted to use JScript
eval function. But it's not unsafe and no power operator. Secondary I searched for some libraries in Internet. But as turned out, I cannot use them. So the question is the following: how safe is JScript eval function calling and are there any standard .net tools for my task? If not, which algorithm is the best? As of now I'm trying to build expression tree and then compile it to get result.