X-Git-Url: http://matita.cs.unibo.it/gitweb/?a=blobdiff_plain;ds=sidebyside;f=helm%2Fsoftware%2Fcomponents%2Fbinaries%2Ftranscript%2Fengine.ml;h=91633836834a041f773e4f903e4dbf5ba3d57c22;hb=0137a346eaaf9ae7a0b23c7a3b4c6628073b7dfb;hp=027b03575589bbd6ce3a1a747698b854798ddf3f;hpb=916c558005ed665c62699a7a4c5347870c8a3efb;p=helm.git diff --git a/helm/software/components/binaries/transcript/engine.ml b/helm/software/components/binaries/transcript/engine.ml index 027b03575..916338368 100644 --- a/helm/software/components/binaries/transcript/engine.ml +++ b/helm/software/components/binaries/transcript/engine.ml @@ -50,6 +50,7 @@ type status = { output_type: T.output_kind; input_ext: string; remove_lines: int; + excludes: string list; includes: (string * string) list; coercions: (string * string) list; files: string list; @@ -75,12 +76,13 @@ let load_registry registry = let set_files st = let eof ich = try Some (input_line ich) with End_of_file -> None in let trim l = Filename.chop_extension (Str.string_after l 2) in - let cmd = Printf.sprintf "cd %s && find -name *%s" st.input_path st.input_ext in + let cmd = Printf.sprintf "cd %s && find -name '*%s'" st.input_path st.input_ext in let ich = Unix.open_process_in cmd in - let rec aux files = - match eof ich with - | None -> List.rev files - | Some l -> aux (trim l :: files) + let rec aux files = match eof ich with + | None -> List.rev files + | Some l -> + let l = trim l in + if List.mem l st.excludes then aux files else aux (l :: files) in let files = aux [] in let _ = Unix.close_process_in ich in @@ -102,10 +104,11 @@ let init () = let make registry = let id x = x in let get_pairs = R.get_list (R.pair id id) in - let get_input_type key = - match R.get_string key with - | "gallina8" -> T.Gallina8, ".v" - | "grafite" -> T.Grafite, ".ma" + let get_input_type key1 key2 = + match R.get_string key1, R.get_string key2 with + | "gallina8", _ -> T.Gallina8, ".v", [] + | "grafite", "" -> T.Grafite "", ".ma", [] + | "grafite", s -> T.Grafite s, ".ma", [s] | _ -> failwith "unknown input type" in let get_output_type key = @@ -115,7 +118,9 @@ let make registry = | _ -> failwith "unknown output type" in load_registry registry; - let input_type, input_ext = get_input_type "package.input_type" in + let input_type, input_ext, excludes = + get_input_type "package.input_type" "package.theory_file" + in let st = { heading_path = R.get_string "transcript.heading_path"; heading_lines = R.get_int "transcript.heading_lines"; @@ -129,6 +134,7 @@ let make registry = output_type = get_output_type "package.output_type"; input_ext = input_ext; remove_lines = R.get_int "package.heading_lines"; + excludes = excludes; includes = get_pairs "package.include"; coercions = get_pairs "package.coercion"; files = []; @@ -206,8 +212,8 @@ let produce st = | _ -> true in let get_items = match st.input_type with - | T.Gallina8 -> Gallina8Parser.items Gallina8Lexer.token - | T.Grafite -> GrafiteParser.items GrafiteLexer.token + | T.Gallina8 -> Gallina8Parser.items Gallina8Lexer.token + | T.Grafite _ -> GrafiteParser.items GrafiteLexer.token in let produce st name = let in_base_uri = Filename.concat st.input_base_uri name in @@ -246,9 +252,9 @@ let produce st = let rec remove_lines ich n = if n > 0 then let _ = input_line ich in remove_lines ich (pred n) in - Printf.eprintf "processing file name: %s ...\n" name; flush stderr; - let file = Filename.concat st.input_path (name ^ st.input_ext) in - let ich = open_in file in + Printf.eprintf "processing file name: %s ...\n" name; flush stderr; + let file = Filename.concat st.input_path name in + let ich = open_in (file ^ st.input_ext) in begin try remove_lines ich st.remove_lines with End_of_file -> () end; let lexbuf = Lexing.from_channel ich in try @@ -259,12 +265,25 @@ let produce st = let comment = T.Line (Printf.sprintf "From %s" name) in if global_items <> [] then set_items st st.input_package (comment :: global_items); - init name; require st name st.input_package; set_includes st name; - set_items st name local_items; commit st name + init name; + begin match st.input_type with + | T.Grafite "" -> require st name file + | _ -> require st name st.input_package + end; + set_includes st name; set_items st name local_items; commit st name with e -> prerr_endline (Printexc.to_string e); close_in ich in is_ma st st.input_package; init st.input_package; require st st.input_package "preamble"; - List.iter (produce st) st.files; - commit st st.input_package + match st.input_type with + | T.Grafite "" -> + List.iter (produce st) st.files + | T.Grafite s -> + let theory = Filename.concat st.input_path s in + require st st.input_package theory; + List.iter (produce st) st.files; + commit st st.input_package + | _ -> + List.iter (produce st) st.files; + commit st st.input_package