How to create an expression evaluator?

Asked

Viewed 41 times

3

I am creating a program that will allow the user to create and execute their own expressions.
Looking into it, I found the Compute of DataTable.
Ex:

DataTable dt = new DataTable();
var exp = dt.Compute("10 * (12+4) / 3", "");

With this command the user can type only mathematical formulas, but not for example a code for him (user) create a text box at runtime.
Ex:

DataTable dt = new DataTable();
var exp = dt.Compute(@"MessageBox.Show(""Teste de messagebox"", ""Título"");", "");

How can I do that?
If possible, without any external bookstore.

  • 1

    Related or duplicate: http://answall.com/q/15428/101

  • Is the idea just a math evaluator? Or do you want something else? Which operators would you like to implement?

  • That I could type anything, like classes.

  • Ah, so it’s already answered.

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.