src/Pure/ProofGeneral/proof_general_pgip.ML
changeset 22699 938c1011ac94
parent 22678 23963361278c
child 23178 07ba6b58b3d2
equal deleted inserted replaced
22698:7e6412e8d64b 22699:938c1011ac94
   212  (Output.writeln_fn := (fn s => normalmsg Message Normal false s);
   212  (Output.writeln_fn := (fn s => normalmsg Message Normal false s);
   213   Output.priority_fn := (fn s => normalmsg Message Normal true s);
   213   Output.priority_fn := (fn s => normalmsg Message Normal true s);
   214   Output.tracing_fn := (fn s => normalmsg  Message Tracing false s);
   214   Output.tracing_fn := (fn s => normalmsg  Message Tracing false s);
   215   Output.warning_fn := (fn s => errormsg Warning s);
   215   Output.warning_fn := (fn s => errormsg Warning s);
   216   Output.error_fn := (fn s => errormsg Fatal s);
   216   Output.error_fn := (fn s => errormsg Fatal s);
   217   Output.panic_fn := (fn s => errormsg Panic s);
       
   218   Output.debug_fn := (fn s => errormsg Debug s));
   217   Output.debug_fn := (fn s => errormsg Debug s));
   219 
   218 
       
   219 fun panic s = (errormsg Panic ("## SYSTEM EXIT ##\n" ^ s); exit 1);
   220 fun nonfatal_error s = errormsg Nonfatal s;
   220 fun nonfatal_error s = errormsg Nonfatal s;
   221 fun log_msg s = errormsg Log s;
   221 fun log_msg s = errormsg Log s;
   222 
   222 
   223 
   223 
   224 (* immediate messages *)
   224 (* immediate messages *)
   397         val ex = File.exists path
   397         val ex = File.exists path
   398 
   398 
   399         val wwwpage =
   399         val wwwpage =
   400             (Url.explode (isabelle_www()))
   400             (Url.explode (isabelle_www()))
   401             handle ERROR _ =>
   401             handle ERROR _ =>
   402                    (Output.panic
   402                    (panic ("Error in URL in environment variable ISABELLE_HOMEPAGE.");
   403                         ("Error in URL in environment variable ISABELLE_HOMEPAGE.");
       
   404                         Url.explode isabellewww)
   403                         Url.explode isabellewww)
   405 
   404 
   406         val proverinfo =
   405         val proverinfo =
   407             Proverinfo { name = "Isabelle",
   406             Proverinfo { name = "Isabelle",
   408                          version = version,
   407                          version = version,
   413     in
   412     in
   414         if ex then
   413         if ex then
   415             (issue_pgip proverinfo;
   414             (issue_pgip proverinfo;
   416              issue_pgip_rawtext (File.read path);
   415              issue_pgip_rawtext (File.read path);
   417              issue_pgip (lexicalstructure_keywords()))
   416              issue_pgip (lexicalstructure_keywords()))
   418         else Output.panic ("PGIP configuration file \"" ^ config_file() ^ "\" not found")
   417         else panic ("PGIP configuration file \"" ^ config_file() ^ "\" not found")
   419     end;
   418     end;
   420 end
   419 end
   421 
   420 
   422 
   421 
   423 (* Preferences: tweak for PGIP interfaces *)
   422 (* Preferences: tweak for PGIP interfaces *)
  1062     end handle e => handler (e,SOME src)  (* error in XML parse or Ready issue *)
  1061     end handle e => handler (e,SOME src)  (* error in XML parse or Ready issue *)
  1063 
  1062 
  1064 and handler (e,srco) =
  1063 and handler (e,srco) =
  1065     case (e,srco) of
  1064     case (e,srco) of
  1066         (XML_PARSE,SOME src) =>
  1065         (XML_PARSE,SOME src) =>
  1067         Output.panic "Invalid XML input, aborting" (* TODO: attempt recovery  *)
  1066         panic "Invalid XML input, aborting" (* TODO: attempt recovery  *)
  1068       | (Interrupt,SOME src) =>
  1067       | (Interrupt,SOME src) =>
  1069         (Output.error_msg "Interrupt during PGIP processing"; loop true src)
  1068         (Output.error_msg "Interrupt during PGIP processing"; loop true src)
  1070       | (Toplevel.UNDEF,SOME src) =>
  1069       | (Toplevel.UNDEF,SOME src) =>
  1071         (Output.error_msg "No working context defined"; loop true src)
  1070         (Output.error_msg "No working context defined"; loop true src)
  1072       | (e,SOME src) =>
  1071       | (e,SOME src) =>
  1102 
  1101 
  1103 (* init *)
  1102 (* init *)
  1104 
  1103 
  1105 val initialized = ref false;
  1104 val initialized = ref false;
  1106 
  1105 
  1107 fun init_pgip false =
  1106 fun init_pgip false = panic "No Proof General interface support for Isabelle/classic mode."
  1108       Output.panic "No Proof General interface support for Isabelle/classic mode."
       
  1109   | init_pgip true =
  1107   | init_pgip true =
  1110       (! initialized orelse
  1108       (! initialized orelse
  1111         (Output.no_warnings init_outer_syntax ();
  1109         (Output.no_warnings init_outer_syntax ();
  1112           PgipParser.init ();
  1110           PgipParser.init ();
  1113           setup_preferences_tweak ();
  1111           setup_preferences_tweak ();