public void NormalTest1() { var evaluator = new MyEvaluator(); Assert.Equal(20, evaluator.Eval("(8 - 5 % 7) + 3 ** 2 + 8")); Assert.Equal(-5, evaluator.Eval("-9 // 2")); Assert.Throws <ArgumentException>(() => evaluator.Eval("(8 mod 5 % 7) + 3 ** 2 + 8")); }
static void Main(string[] args) { // I would like to make the evaluators definition as simple as possible // to allow extensibility // to avoid BNF rules syntax as there are already many tools to do that var ev = new MyEvaluator(); var val = ev.Eval<int>("1+2*3"); }
static void Main(string[] args) { // I would like to make the evaluators definition as simple as possible // to allow extensibility // to avoid BNF rules syntax as there are already many tools to do that var ev = new MyEvaluator(); var val = ev.Eval <int>("1+2*3"); }