Exemple #1
0
        // Set Clause to the prolog engine
        bool SetClause(PrologEngine plEngine, string code, bool reset = true,
                       string codeTitle = null)
        {
            bool error = false;

            if (reset)
            {
                plEngine.Reset();
            }

            // If no syntax error, consult the code to the prolog engine
            if (SyntaxCheck(code))
            {
                plEngine.ConsultFromString(code, codeTitle);
            }

            else
            {
                error = true;
            }

            return(!error);
        }
Exemple #2
0
        async void PrologInterpreter(string command)
#endif
        {
            string          result    = "";
            string          com       = "";
            List <Solution> solutions = new List <Solution>();

            // Get the first character of the command
// #if iOS
            if (command != null)
            {
// #else // else if UWP
//             if(command != "")
// #endif
                com = command.Substring(0, 1);
            }

            // Identify the command from the three characters
            switch (com)
            {
            case "":
            case null:
                AddPrompt(GetPromptText());
                return;

            case "l":       // List Segments of the current folder
                if (command == "ls.")
                {
                    result = ls();
                    break;
                }
                else
                {
                    goto default;
                }

            case "[":       // Load Program
#if SystemIO
                result = SetProgram(command);
#elif PCLStorage
                result = await SetProgram(command);
#endif
                break;


            case "h":       // Exit Prolog Interpreter
                if (command == "halt.")
                {
                    RunProlog = false;
                    prolog.Reset();
                    result = "\n";
                    //System.Diagnostics.Process.GetCurrentProcess().CloseMainWindow();
                    break;
                }
                else
                {
                    goto default;
                }
            //{
            //    result = "Command Invalid";
            //}
            //break;

            case "r":       // Reset Prolog Engine
                if (command == "reset.")
                {
                    prolog.Reset();
                    result = "\n";
                    break;
                }
                else
                {
                    goto default;
                }
            //{
            //    result = "Command Invalid";
            //}
            //break;


            default:        // Query Input
                solutions = GetSolutions(prolog, command);
                result    = SolutionsString(solutions);
                break;
            }

            // Display the Command Execute Result following the Command Line
            Console.Children.Add(new Label()
            {
                Text = result
            });

            // Store the result
            CommandLines.Last().Results = result;

            // Add a new Command Line
            AddPrompt(GetPromptText());
        }