home *** CD-ROM | disk | FTP | other *** search
- -------------------------------------------------------------------------------
- -- --
- -- Program: Fuzzy Prolog --
- -- --
- -- Author: Bradley L. Richards --
- -- --
- -- Version Date Notes . . . --
- -- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - --
- -- 1.0 16 Jun 86 Initial Version --
- -- 2.1 20 Jul 86 Extracted consult/reconsult and put in Prover --
- -- (Demonstration baseline version) --
- -- 2.2 28 Jul 86 Initial operational version --
- -- 2.3 Interim versions during final enhancement and --
- -- to Aug/Sep 86 debug phase. These versions were never --
- -- 2.9 formally baselined, and are not well --
- -- in the unit headers. --
- -- 3.0 10 Oct 86 Final thesis product --
- -- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - --
- -- --
- -- Library units used: Data_def, Listing, Parser, Prover, Text_io --
- -- --
- -- Description: This is the main program for the Fuzzy Prolog interpreter. --
- -- It parses user requests and, if they have no errors, passes then to --
- -- the Prover for processing. It stops when the user enters a single --
- -- predicate "halt." --
- -- --
- -------------------------------------------------------------------------------
- with data_def, listing, parser, prover, text_io;
- use data_def, listing, parser, prover, text_io;
- procedure fuzzy_prolog is
-
- request : AST_ptr;
- eof : boolean;
-
- procedure start_fuzzy_prolog is
- begin
- put_line("Fuzzy Prolog v3.00 -- 10 October 1986");
- end start_fuzzy_prolog;
-
- procedure stop_fuzzy_prolog is
- begin
- put_line("Goodbye");
- end stop_fuzzy_prolog;
-
- procedure sys_error( error_name : string ) is
- begin
- new_line;
- put_line("Fuzzy Prolog has encountered a system error. The exception");
- put_line(" raised was " & error_name & ". This indicates a bug in");
- put_line(" the interpreter, and Fuzzy Prolog terminated at this");
- put_line(" point. Please contact the instructor or system manager");
- put_line(" with documentation of this error so that it can be");
- put_line(" promptly corrected. Thank you.");
- new_line;
- end sys_error;
-
- begin -- fuzzy_prolog
- start_fuzzy_prolog;
- loop
- put("?- ");
- start_parser("", ""); -- start parser in interactive mode
- parse_request(request, eof); -- parse a user request
- stop_parser;
- if number_of_errors = 0 then
- if request.node_type = predicate then
- if request.name.name = "HALT" then
- exit;
- end if;
- end if;
- --
- -- if the user didn't want to halt the intermpreter then
- -- send his goal to the prover
- --
- prove(request);
- end if;
- if eof then
- new_line;
- put_line("Unexpected end of file on input");
- put_line("Fuzzy Prolog terminated" & ascii.bel);
- exit;
- end if;
- end loop;
- stop_fuzzy_prolog;
-
- exception
- when prover_error =>
- sys_error("Prover_Error");
- when storage_error =>
- sys_error("Storage_Error");
- when constraint_error =>
- sys_error("Constraint_Error");
- when others =>
- sys_error("unknown");
- end fuzzy_prolog;
-