From b7aa648034f73c390ba2b49c8d47c3c8277002ef Mon Sep 17 00:00:00 2001 From: ddr Date: Wed, 20 Feb 2002 11:06:07 +0000 Subject: Changé le nom du module Errors (errors.mli, errors.ml) en Cerrors parce qu'il entre en conflit avec le module Errors ajouté dans OCaml courant (future version OCaml 3.05). git-svn-id: svn+ssh://scm.gforge.inria.fr/svn/coq/trunk@2489 85f007b7-540e-0410-9357-904b9bb8a0f7 --- toplevel/cerrors.ml | 121 ++++++++++++++++++++++++++++++++++++++++++ toplevel/cerrors.mli | 24 +++++++++ toplevel/coqtop.ml | 4 +- toplevel/errors.ml | 121 ------------------------------------------ toplevel/errors.mli | 24 --------- toplevel/protectedtoplevel.ml | 4 +- toplevel/toplevel.ml | 8 +-- 7 files changed, 153 insertions(+), 153 deletions(-) create mode 100644 toplevel/cerrors.ml create mode 100644 toplevel/cerrors.mli delete mode 100644 toplevel/errors.ml delete mode 100644 toplevel/errors.mli (limited to 'toplevel') diff --git a/toplevel/cerrors.ml b/toplevel/cerrors.ml new file mode 100644 index 0000000000..da9ae4a4de --- /dev/null +++ b/toplevel/cerrors.ml @@ -0,0 +1,121 @@ +(***********************************************************************) +(* v * The Coq Proof Assistant / The Coq Development Team *) +(* ") + else + (int (fst loc) ++ str"-" ++ int (snd loc)) + +let guill s = "\""^s^"\"" + +let where s = + if !Options.debug then (str"in " ++ str s ++ str":" ++ spc ()) else (mt ()) + +let report () = (str "." ++ spc () ++ str "Please report.") + +(* assumption : explain_sys_exn does NOT end with a 'FNL anymore! *) + +let rec explain_exn_default = function + | Stream.Failure -> + hov 0 (str "Anomaly: Uncaught Stream.Failure.") + | Stream.Error txt -> + hov 0 (str "Syntax error: " ++ str txt) + | Token.Error txt -> + hov 0 (str "Syntax error: " ++ str txt) + | Sys_error msg -> + hov 0 (str "Error: OS: " ++ str msg) + | UserError(s,pps) -> + hov 1 (str"Error: " ++ where s ++ pps) + | Out_of_memory -> + hov 0 (str "Out of memory") + | Stack_overflow -> + hov 0 (str "Stack overflow") + | Ast.No_match s -> + hov 0 (str "Anomaly: Ast matching error: " ++ str s ++ report ()) + | Anomaly (s,pps) -> + hov 1 (str "Anomaly: " ++ where s ++ pps ++ report ()) + | Match_failure(filename,pos1,pos2) -> + hov 1 (str "Anomaly: Match failure in file " ++ + str (guill filename) ++ str " from char #" ++ + int pos1 ++ str " to #" ++ int pos2 ++ + report ()) + | Not_found -> + hov 0 (str "Anomaly: Search error" ++ report ()) + | Failure s -> + hov 0 (str "Anomaly: Failure " ++ str (guill s) ++ report ()) + | Invalid_argument s -> + hov 0 (str "Anomaly: Invalid argument " ++ str (guill s) ++ report ()) + | Sys.Break -> + hov 0 (fnl () ++ str"User Interrupt.") + | Univ.UniverseInconsistency -> + hov 0 (str "Error: Universe Inconsistency.") + | TypeError(ctx,te) -> + hov 0 (str "Error:" ++ spc () ++ Himsg.explain_type_error ctx te) + | PretypeError(ctx,te) -> + hov 0 (str "Error:" ++ spc () ++ Himsg.explain_pretype_error ctx te) + | InductiveError e -> + hov 0 (str "Error:" ++ spc () ++ Himsg.explain_inductive_error e) + | Cases.PatternMatchingError (env,e) -> + hov 0 + (str "Error:" ++ spc () ++ Himsg.explain_pattern_matching_error env e) + | Logic.RefinerError e -> + hov 0 (str "Error:" ++ spc () ++ Himsg.explain_refiner_error e) + | Nametab.GlobalizationError q -> + hov 0 (str "Error:" ++ spc () ++ + str "The reference" ++ spc () ++ Nametab.pr_qualid q ++ + spc () ++ str "was not found" ++ + spc () ++ str "in the current" ++ spc () ++ str "environment") + | Nametab.GlobalizationConstantError q -> + hov 0 (str "Error:" ++ spc () ++ + str "No constant of this name:" ++ spc () ++ Nametab.pr_qualid q) + | Tacmach.FailError i -> + hov 0 (str "Error: Fail tactic always fails (level " ++ + int i ++ str").") + | Stdpp.Exc_located (loc,exc) -> + hov 0 (if loc = Ast.dummy_loc then (mt ()) + else (str"At location " ++ print_loc loc ++ str":" ++ fnl ()) ++ + explain_exn_default exc) + | Lexer.Error Illegal_character -> + hov 0 (str "Syntax error: Illegal character.") + | Lexer.Error Unterminated_comment -> + hov 0 (str "Syntax error: Unterminated comment.") + | Lexer.Error Unterminated_string -> + hov 0 (str "Syntax error: Unterminated string.") + | Lexer.Error Undefined_token -> + hov 0 (str "Syntax error: Undefined token.") + | Lexer.Error (Bad_token s) -> + hov 0 (str "Syntax error: Bad token" ++ spc () ++ str s ++ str ".") + | Assert_failure (s,b,e) -> + hov 0 (str "Anomaly: assert failure" ++ spc () ++ + if s <> "" then + (str ("(file \"" ^ s ^ "\", characters ") ++ + int b ++ str "-" ++ int e ++ str ")") + else + (mt ()) ++ + report ()) + | reraise -> + hov 0 (str "Anomaly: Uncaught exception " ++ + str (Printexc.to_string reraise) ++ report ()) + +let raise_if_debug e = + if !Options.debug then raise e + +let explain_exn_function = ref explain_exn_default + +let explain_exn e = !explain_exn_function e diff --git a/toplevel/cerrors.mli b/toplevel/cerrors.mli new file mode 100644 index 0000000000..2207608a87 --- /dev/null +++ b/toplevel/cerrors.mli @@ -0,0 +1,24 @@ +(***********************************************************************) +(* v * The Coq Proof Assistant / The Coq Development Team *) +(* std_ppcmds + +val explain_exn : exn -> std_ppcmds + +val explain_exn_function : (exn -> std_ppcmds) ref +val explain_exn_default : exn -> std_ppcmds + +val raise_if_debug : exn -> unit diff --git a/toplevel/coqtop.ml b/toplevel/coqtop.ml index b273034df9..c174877dff 100644 --- a/toplevel/coqtop.ml +++ b/toplevel/coqtop.ml @@ -206,9 +206,9 @@ let parse_args () = try Stream.empty s; exit 1 with Stream.Failure -> - msgnl (Errors.explain_exn e); exit 1 + msgnl (Cerrors.explain_exn e); exit 1 end - | e -> begin msgnl (Errors.explain_exn e); exit 1 end + | e -> begin msgnl (Cerrors.explain_exn e); exit 1 end (* To prevent from doing the initialization twice *) diff --git a/toplevel/errors.ml b/toplevel/errors.ml deleted file mode 100644 index da9ae4a4de..0000000000 --- a/toplevel/errors.ml +++ /dev/null @@ -1,121 +0,0 @@ -(***********************************************************************) -(* v * The Coq Proof Assistant / The Coq Development Team *) -(* ") - else - (int (fst loc) ++ str"-" ++ int (snd loc)) - -let guill s = "\""^s^"\"" - -let where s = - if !Options.debug then (str"in " ++ str s ++ str":" ++ spc ()) else (mt ()) - -let report () = (str "." ++ spc () ++ str "Please report.") - -(* assumption : explain_sys_exn does NOT end with a 'FNL anymore! *) - -let rec explain_exn_default = function - | Stream.Failure -> - hov 0 (str "Anomaly: Uncaught Stream.Failure.") - | Stream.Error txt -> - hov 0 (str "Syntax error: " ++ str txt) - | Token.Error txt -> - hov 0 (str "Syntax error: " ++ str txt) - | Sys_error msg -> - hov 0 (str "Error: OS: " ++ str msg) - | UserError(s,pps) -> - hov 1 (str"Error: " ++ where s ++ pps) - | Out_of_memory -> - hov 0 (str "Out of memory") - | Stack_overflow -> - hov 0 (str "Stack overflow") - | Ast.No_match s -> - hov 0 (str "Anomaly: Ast matching error: " ++ str s ++ report ()) - | Anomaly (s,pps) -> - hov 1 (str "Anomaly: " ++ where s ++ pps ++ report ()) - | Match_failure(filename,pos1,pos2) -> - hov 1 (str "Anomaly: Match failure in file " ++ - str (guill filename) ++ str " from char #" ++ - int pos1 ++ str " to #" ++ int pos2 ++ - report ()) - | Not_found -> - hov 0 (str "Anomaly: Search error" ++ report ()) - | Failure s -> - hov 0 (str "Anomaly: Failure " ++ str (guill s) ++ report ()) - | Invalid_argument s -> - hov 0 (str "Anomaly: Invalid argument " ++ str (guill s) ++ report ()) - | Sys.Break -> - hov 0 (fnl () ++ str"User Interrupt.") - | Univ.UniverseInconsistency -> - hov 0 (str "Error: Universe Inconsistency.") - | TypeError(ctx,te) -> - hov 0 (str "Error:" ++ spc () ++ Himsg.explain_type_error ctx te) - | PretypeError(ctx,te) -> - hov 0 (str "Error:" ++ spc () ++ Himsg.explain_pretype_error ctx te) - | InductiveError e -> - hov 0 (str "Error:" ++ spc () ++ Himsg.explain_inductive_error e) - | Cases.PatternMatchingError (env,e) -> - hov 0 - (str "Error:" ++ spc () ++ Himsg.explain_pattern_matching_error env e) - | Logic.RefinerError e -> - hov 0 (str "Error:" ++ spc () ++ Himsg.explain_refiner_error e) - | Nametab.GlobalizationError q -> - hov 0 (str "Error:" ++ spc () ++ - str "The reference" ++ spc () ++ Nametab.pr_qualid q ++ - spc () ++ str "was not found" ++ - spc () ++ str "in the current" ++ spc () ++ str "environment") - | Nametab.GlobalizationConstantError q -> - hov 0 (str "Error:" ++ spc () ++ - str "No constant of this name:" ++ spc () ++ Nametab.pr_qualid q) - | Tacmach.FailError i -> - hov 0 (str "Error: Fail tactic always fails (level " ++ - int i ++ str").") - | Stdpp.Exc_located (loc,exc) -> - hov 0 (if loc = Ast.dummy_loc then (mt ()) - else (str"At location " ++ print_loc loc ++ str":" ++ fnl ()) ++ - explain_exn_default exc) - | Lexer.Error Illegal_character -> - hov 0 (str "Syntax error: Illegal character.") - | Lexer.Error Unterminated_comment -> - hov 0 (str "Syntax error: Unterminated comment.") - | Lexer.Error Unterminated_string -> - hov 0 (str "Syntax error: Unterminated string.") - | Lexer.Error Undefined_token -> - hov 0 (str "Syntax error: Undefined token.") - | Lexer.Error (Bad_token s) -> - hov 0 (str "Syntax error: Bad token" ++ spc () ++ str s ++ str ".") - | Assert_failure (s,b,e) -> - hov 0 (str "Anomaly: assert failure" ++ spc () ++ - if s <> "" then - (str ("(file \"" ^ s ^ "\", characters ") ++ - int b ++ str "-" ++ int e ++ str ")") - else - (mt ()) ++ - report ()) - | reraise -> - hov 0 (str "Anomaly: Uncaught exception " ++ - str (Printexc.to_string reraise) ++ report ()) - -let raise_if_debug e = - if !Options.debug then raise e - -let explain_exn_function = ref explain_exn_default - -let explain_exn e = !explain_exn_function e diff --git a/toplevel/errors.mli b/toplevel/errors.mli deleted file mode 100644 index 2207608a87..0000000000 --- a/toplevel/errors.mli +++ /dev/null @@ -1,24 +0,0 @@ -(***********************************************************************) -(* v * The Coq Proof Assistant / The Coq Development Team *) -(* std_ppcmds - -val explain_exn : exn -> std_ppcmds - -val explain_exn_function : (exn -> std_ppcmds) ref -val explain_exn_default : exn -> std_ppcmds - -val raise_if_debug : exn -> unit diff --git a/toplevel/protectedtoplevel.ml b/toplevel/protectedtoplevel.ml index 730b6768db..0e28a8373f 100644 --- a/toplevel/protectedtoplevel.ml +++ b/toplevel/protectedtoplevel.ml @@ -55,7 +55,7 @@ let acknowledge_command_ref = str "successfully executed " ++ int command_count ++ fnl () ++ str "error message" ++ fnl () ++ (match opt_exn with - Some e -> Errors.explain_exn e + Some e -> Cerrors.explain_exn e | None -> (mt ())) ++ fnl () ++ str "E-n-d---M-e-s-s-a-g-e" ++ fnl ())) @@ -151,7 +151,7 @@ let rec parse_one_command_group input_channel = let protected_loop input_chan = let rec explain_and_restart e = begin - output_results_nl(Errors.explain_exn e); + output_results_nl(Cerrors.explain_exn e); rearm_break(); looprec input_chan; end diff --git a/toplevel/toplevel.ml b/toplevel/toplevel.ml index 8bd6ba8e4a..29c0e60551 100644 --- a/toplevel/toplevel.ml +++ b/toplevel/toplevel.ml @@ -11,7 +11,7 @@ open Pp open Util open Options -open Errors +open Cerrors open Vernac open Pcoq open Protectedtoplevel @@ -124,7 +124,7 @@ let print_highlight_location ib (bp,ep) = str sn ++ str dn) in (l1 ++ li ++ ln) in - (str"Toplevel input, characters " ++ Errors.print_loc (bp,ep) ++ fnl () ++ + (str"Toplevel input, characters " ++ Cerrors.print_loc (bp,ep) ++ fnl () ++ highlight_lines ++ fnl ()) (* Functions to report located errors in a file. *) @@ -147,7 +147,7 @@ let print_location_in_file s fname (bp,ep) = let (line, bol) = line_of_pos 1 0 0 in close_in ic; (errstrm ++ str", line " ++ int line ++ - str", characters " ++ Errors.print_loc (bp-bol,ep-bol) ++ fnl ()) + str", characters " ++ Cerrors.print_loc (bp-bol,ep-bol) ++ fnl ()) with e -> (close_in ic; (errstrm ++ str", invalid location." ++ fnl ())) let print_command_location ib dloc = @@ -235,7 +235,7 @@ let print_toplevel_error exc = raise Vernacinterp.Quit | _ -> (if is_pervasive_exn exc then (mt ()) else locstrm) ++ - Errors.explain_exn exc + Cerrors.explain_exn exc (* Read the input stream until a dot is encountered *) let parse_to_dot = -- cgit v1.2.3