public AST.Program ParseProgram (TextReader r) { program.SetExternalPredicateCallbacks (GetExternalPredicates (r)); var engine = new Runtime.Engine (); IEnumerable <Runtime.ISolutionTreeNode> solutions = engine.Run (program); return solutions.Select (ConvertToAst).FirstOrDefault (); }
public AST.Program ParseProgram(TextReader r) { program.SetExternalPredicateCallbacks(GetExternalPredicates(r)); var engine = new Runtime.Engine(); IEnumerable <Runtime.ISolutionTreeNode> solutions = engine.Run(program); return(solutions.Select(ConvertToAst).FirstOrDefault()); }
private static void AssertSolutionCount (string text, int expectedSolutionCount) { var externalPredicates = new [] {Concat.GetConcat (), Lexer.GetLexer (new StringReader (text))}; program.SetExternalPredicateCallbacks (externalPredicates); var engine = new Engine (); //var tracer = new Tracer(); //engine.Unified += tracer.Engine_Unified; //engine.Failed += tracer.Engine_Failed; var solutions = engine.Run (program).Select (Print).ToArray (); Assert.AreEqual (expectedSolutionCount, solutions.Count ()); }
public static IEnumerable <Runtime.ISolutionTreeNode> Solve(Runtime.Engine engine, AST.Goal [] goals, Compiled.Program program) { Compiled.Goal[] compiledGoals = Compile(goals, program.predicatesByName); return(engine.Solve(compiledGoals)); }