Esempio n. 1
0
        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 ();
        }
Esempio n. 2
0
        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());
        }
Esempio n. 3
0
        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 ());
        }
Esempio n. 4
0
        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));
        }