home *** CD-ROM | disk | FTP | other *** search
/ Programmer 7500 / MAX_PROGRAMMERS.iso / CLIPPER / MISC / FUZZY.ZIP / FUZZY_PR.A < prev    next >
Encoding:
Text File  |  1986-11-30  |  4.1 KB  |  95 lines

  1. -------------------------------------------------------------------------------
  2. --                                                                           --
  3. --  Program:  Fuzzy Prolog                                                   --
  4. --                                                                           --
  5. --  Author:  Bradley L. Richards                                             --
  6. --                                                                           --
  7. --     Version     Date     Notes . . .                                      --
  8. --    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -    --
  9. --       1.0    16 Jun 86   Initial Version                                  --
  10. --       2.1    20 Jul 86   Extracted consult/reconsult and put in Prover    --
  11. --                            (Demonstration baseline version)               --
  12. --       2.2    28 Jul 86   Initial operational version                      --
  13. --       2.3                Interim versions during final enhancement and    --
  14. --        to   Aug/Sep 86     debug phase.  These versions were never        --
  15. --       2.9                  formally baselined, and are not well           --
  16. --                            in the unit headers.                           --
  17. --       3.0    10 Oct 86   Final thesis product                             --
  18. --    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -    --
  19. --                                                                           --
  20. --  Library units used:  Data_def, Listing, Parser, Prover, Text_io          --
  21. --                                                                           --
  22. --  Description:  This is the main program for the Fuzzy Prolog interpreter. --
  23. --     It parses user requests and, if they have no errors, passes then to   --
  24. --     the Prover for processing.  It stops when the user enters a single    --
  25. --     predicate "halt."                                                     --
  26. --                                                                           --
  27. -------------------------------------------------------------------------------
  28. with data_def, listing, parser, prover, text_io;
  29. use data_def, listing, parser, prover, text_io;
  30. procedure fuzzy_prolog is
  31.  
  32.     request : AST_ptr;
  33.     eof : boolean;
  34.  
  35.     procedure start_fuzzy_prolog is
  36.       begin
  37.     put_line("Fuzzy Prolog v3.00 -- 10 October 1986");
  38.       end start_fuzzy_prolog;
  39.  
  40.     procedure stop_fuzzy_prolog is
  41.       begin
  42.     put_line("Goodbye");
  43.       end stop_fuzzy_prolog;
  44.  
  45.     procedure sys_error( error_name : string ) is
  46.       begin
  47.     new_line;
  48.     put_line("Fuzzy Prolog has encountered a system error.  The exception");
  49.     put_line("  raised was " & error_name & ".  This indicates a bug in");
  50.     put_line("  the interpreter, and Fuzzy Prolog terminated at this");
  51.     put_line("  point.  Please contact the instructor or system manager");
  52.     put_line("  with documentation of this error so that it can be");
  53.     put_line("  promptly corrected.  Thank you.");
  54.     new_line;
  55.       end sys_error;
  56.  
  57.   begin -- fuzzy_prolog
  58.     start_fuzzy_prolog;
  59.     loop
  60.       put("?- ");
  61.       start_parser("", "");  -- start parser in interactive mode
  62.       parse_request(request, eof);  -- parse a user request
  63.       stop_parser;
  64.       if number_of_errors = 0 then
  65.         if request.node_type = predicate then
  66.       if request.name.name = "HALT" then
  67.         exit;
  68.       end if;
  69.         end if;
  70.         --
  71.         --  if the user didn't want to halt the intermpreter then
  72.     --  send his goal to the prover
  73.         --
  74.         prove(request);
  75.       end if;
  76.       if eof then
  77.     new_line;
  78.     put_line("Unexpected end of file on input");
  79.     put_line("Fuzzy Prolog terminated" & ascii.bel);
  80.     exit;
  81.       end if;
  82.     end loop;
  83.     stop_fuzzy_prolog;
  84.  
  85.    exception
  86.      when prover_error =>
  87.        sys_error("Prover_Error");
  88.      when storage_error =>
  89.        sys_error("Storage_Error");
  90.      when constraint_error =>
  91.        sys_error("Constraint_Error");
  92.      when others =>
  93.        sys_error("unknown");
  94.   end fuzzy_prolog;
  95.