public void Test() { string code = "(+ 7 10 (* 2 8))"; LispCompiler<Blackboard> lispCompiler = new LispCompiler<Blackboard>(); Blackboard blackboard = new Blackboard(); LispOperator<Blackboard> func = lispCompiler.Compile(blackboard, code); Debug.WriteLine(func.BuildParseTree().ToCode()); Debug.WriteLine(func.TryEvaluateToFloat()); }
public void Test(string code, float extected) { LispCompiler<Blackboard> lispCompiler = new LispCompiler<Blackboard>(); Blackboard blackboard = new Blackboard(); LispOperator<Blackboard> func = lispCompiler.Compile(blackboard, code); float result = func.TryEvaluateToFloat(); Debug.WriteLine(func.BuildParseTree().ToCode() + " => " + result); result.Should().Be(extected); }
public void BoolTest() { string code = "(And True False)"; LispCompiler<Blackboard> lispCompiler = new LispCompiler<Blackboard>(); Blackboard blackboard = new Blackboard(); LispOperator<Blackboard> func = lispCompiler.Compile(blackboard, code); Debug.WriteLine(func.BuildParseTree().ToCode()); Debug.WriteLine(func.TryEvaluateToBool()); }
public void Test3() { string code = "5"; LispCompiler<Blackboard> lispCompiler = new LispCompiler<Blackboard>(); Blackboard blackboard = new Blackboard(); LispOperator<Blackboard> func = lispCompiler.Compile(blackboard, code); Debug.WriteLine(func.BuildParseTree().ToCode()); func.Should().BeOfType<IntConstant<Blackboard>>(); }
public void Test2() { string code = "(* 2 Pi (+ A B))"; LispCompiler<Blackboard> lispCompiler = new LispCompiler<Blackboard>(); Blackboard blackboard = new Blackboard(); LispOperator<Blackboard> func = lispCompiler.Compile(blackboard, code); Debug.WriteLine(func.BuildParseTree().ToCode()); Debug.WriteLine(func.TryEvaluateToFloat()); }