From b8193e0717e01edfcf826a6edce0866496537e8a Mon Sep 17 00:00:00 2001 From: Enrico Tassi Date: Tue, 19 Jul 2005 09:57:55 +0000 Subject: [PATCH] Bug fixed: matitaclean and matitadep now ignores every parsing errors and simply continues. Before it used to avoid cleaning things and --- much worst --- generating an empty .depend. --- helm/matita/matitacleanLib.ml | 36 ++++++++++++++++++++--------------- helm/matita/matitadep.ml | 30 +++++++++++++++-------------- 2 files changed, 37 insertions(+), 29 deletions(-) diff --git a/helm/matita/matitacleanLib.ml b/helm/matita/matitacleanLib.ml index 8b54e98d9..51635a30a 100644 --- a/helm/matita/matitacleanLib.ml +++ b/helm/matita/matitacleanLib.ml @@ -134,21 +134,27 @@ let baseuri_of_file file = let istream = Stream.of_channel ic in (try while true do - let stm = GrafiteParser.parse_statement istream in - match baseuri_of_baseuri_decl stm with - | Some buri -> - let u = MatitaMisc.strip_trailing_slash buri in - if String.length u < 5 || String.sub u 0 5 <> "cic:/" then - MatitaLog.error (file ^ " sets an incorrect baseuri: " ^ buri); - (try - ignore(HG.resolve u) - with - | HGT.Unresolvable_URI _ -> - MatitaLog.error (file ^ " sets an unresolvable baseuri: "^buri) - | HGT.Key_not_found _ -> ()); - uri := Some u; - raise End_of_file - | None -> () + try + let stm = GrafiteParser.parse_statement istream in + match baseuri_of_baseuri_decl stm with + | Some buri -> + let u = MatitaMisc.strip_trailing_slash buri in + if String.length u < 5 || String.sub u 0 5 <> "cic:/" then + MatitaLog.error (file ^ " sets an incorrect baseuri: " ^ buri); + (try + ignore(HG.resolve u) + with + | HGT.Unresolvable_URI _ -> + MatitaLog.error (file ^ " sets an unresolvable baseuri: "^buri) + | HGT.Key_not_found _ -> ()); + uri := Some u; + raise End_of_file + | None -> () + with + CicNotationParser.Parse_error _ as exn -> + prerr_endline ("Unable to parse: " ^ file); + prerr_endline (MatitaExcPp.to_string exn); + () done with End_of_file -> close_in ic); match !uri with diff --git a/helm/matita/matitadep.ml b/helm/matita/matitadep.ml index 56c60aff8..621b20ecf 100644 --- a/helm/matita/matitadep.ml +++ b/helm/matita/matitadep.ml @@ -87,22 +87,24 @@ let main () = let istream = Stream.of_channel ic in (try while true do - match GrafiteParser.parse_statement istream with - | TA.Executable (_, TA.Command (_, TA.Set (_, "baseuri", uri))) -> - let uri = MatitaMisc.strip_trailing_slash uri in - baseuri := (uri, file) :: !baseuri - | TA.Executable (_, TA.Command - (_, TA.Alias (_, TA.Ident_alias(_, uri)))) -> - Hashtbl.add aliases file uri - | TA.Executable (_, TA.Command (_, TA.Include (_, path))) -> - Hashtbl.add deps file (find path) - | _ -> () + try + match GrafiteParser.parse_statement istream with + | TA.Executable (_, TA.Command (_, TA.Set (_, "baseuri", uri))) -> + let uri = MatitaMisc.strip_trailing_slash uri in + baseuri := (uri, file) :: !baseuri + | TA.Executable (_, TA.Command + (_, TA.Alias (_, TA.Ident_alias(_, uri)))) -> + Hashtbl.add aliases file uri + | TA.Executable (_, TA.Command (_, TA.Include (_, path))) -> + Hashtbl.add deps file (find path) + | _ -> () + with + CicNotationParser.Parse_error _ as exn -> + prerr_endline ("Unable to parse: " ^ file); + prerr_endline (MatitaExcPp.to_string exn); + () done with - | CicNotationParser.Parse_error _ as exn -> - prerr_endline ("Unable to parse: " ^ file); - prerr_endline (MatitaExcPp.to_string exn); - exit 1 | End_of_file -> close_in ic); Hashtbl.iter (fun file alias -> -- 2.39.2