YACEP : yet another csharp expression parser
YACEP是一款基于netstandard2.0构建的轻量级高性能表达式解析器
特性:
样例代码 :
var state = new { x = 7, y = 43.0f, z = new Dictionary<string, string> { ["yacep"] = "yet another csharp expression parser", ["tupac-amaru"] = "was the last indigenous monarch (Sapa Inca) of the Neo-Inca State" }, rand = new Func<object>(() => new Random().Next(1, 3)), array = Enumerable.Range(1971, 1996 - 1971) }; var expr = "x + y - z['yacep'].Length + max([1, 2, 3]) + (this.rand() > 2 ? 1971 : 1996) - len(array)"; var evaluator = expr.Compile(); var value = evaluator.EvaluateAs<decimal>(state);