Beispiel #1
0
        Frame Unify(Compiled.Clause clause)
        {
            var boundVariables       = new BoundVariableSet();
            var argumentInstantiator = new ArgumentInstantiator();

            var clauseHeadArguments = clause.Head.Arguments.Select(a => a.Accept(argumentInstantiator)).ToArray();

            if (boundVariables.ZipUnify(Arguments, clauseHeadArguments))
            {
                Goal [] goals = EngineInternals.InstantiateGoals(clause.Body, argumentInstantiator);

                return(new Frame(goals, this, boundVariables, argumentInstantiator.Variables));
            }

            return(null);
        }
Beispiel #2
0
        static void Main(string [] args)
        {
            Compiled.Program program = GetProgram (args[0]);

            var externalPredicates = new [] {Concat.GetConcat (), Lexer.GetLexer (new StringReader ("ордена ленина полк"))};

            program.SetExternalPredicateCallbacks (externalPredicates);

            var engine = new EngineInternals ();

            var events = engine.Run (program);

            Application.EnableVisualStyles ();            
            Application.SetCompatibleTextRenderingDefault (false);
            Application.Run (new Form1 (events));
        }
Beispiel #3
0
        public IEnumerable <ISolutionTreeNode> Solve(Compiled.Goal [] goalDefs)
        {
            solution = null;

            if (Start != null)
            {
                Start();
            }

            var engine = new EngineInternals();

            foreach (var @event in engine.Solve(goalDefs))
            {
                @event.Accept(this);

                if (solution != null)
                {
                    yield return(solution.Tree);

                    solution = null;
                }
            }
        }
Beispiel #4
0
        public IEnumerable <ISolutionTreeNode> Solve (Compiled.Goal [] goalDefs)
        {
            solution = null;

            if (Start != null)
            {
                Start ();
            }

            var engine = new EngineInternals ();

            foreach (var @event in engine.Solve (goalDefs))
            {
                @event.Accept (this);

                if (solution != null)
                {
                    yield return solution.Tree;

                    solution = null;
                }
            }
        }