This project is a simple mathematical expression parser written in C#. It's the refactoring of an old project and uses an AST-evaluation algorithm. You can use built-in or add your functions and variables to global scope. It was written primarily for fun and and as programming exercise; anyway if you anyone find it useful, please send feature requests or issues; but please take note that
this is still a work in progress.
At the moment
specification is just a draft.
At glance
var myvar1 = Evaluator.EvaluateAs<double>("pi - 2");
var context = new Context()
.SetVariable("myvar1", myvar1)
.SetVariable("myvar2", 12.345D)
.SetFunction("myfunc",
(args) => (TypeConverter.ToNumber(args[0]) + MyMath.DoCalc(args[1])));
var result = context.EvaluateAs<double>("myvar1 + (.999 * myfunc(myvar1, 7.789))");
var isTrue = context.EvaluateAs<bool>("myvar2 == 12.345");
VersionsCodePlex (package download):
0.6.0.1 alfa.
GitHub (source repository):
0.6.0.5 alfa.
NuGet:
not yet released.
Until the it stabilizes you're invited to use the more recent version possible.Contacts