X-Git-Url: http://matita.cs.unibo.it/gitweb/?p=helm.git;a=blobdiff_plain;f=matita%2Fmatita%2Fcontribs%2Flambdadelta%2Fbin%2Frecomm%2FrecommOutput.ml;h=c48ba9304804a8adc1802271ee09b12eea018723;hp=187a2984b73bcd042279cfe585be40facc1b810b;hb=8fdf1af656038d0245eba64ff2531bbe94ce0e9e;hpb=77c9255de3c5f7780aeacd745703a1cc76328a68 diff --git a/matita/matita/contribs/lambdadelta/bin/recomm/recommOutput.ml b/matita/matita/contribs/lambdadelta/bin/recomm/recommOutput.ml index 187a2984b..c48ba9304 100644 --- a/matita/matita/contribs/lambdadelta/bin/recomm/recommOutput.ml +++ b/matita/matita/contribs/lambdadelta/bin/recomm/recommOutput.ml @@ -1,3 +1,4 @@ +module EL = RecommLib module ET = RecommTypes let width = ref 78 @@ -23,24 +24,24 @@ let complete s n = end let out_src och = function - | ET.Line s -> + | ET.Line s -> Printf.fprintf och "%s" s - | ET.Text s -> + | ET.Text s -> Printf.fprintf och "%s" s - | ET.Mark s -> + | ET.Mark s -> Printf.fprintf och "(* *%s*)" s - | ET.Key (s1, s2) -> + | ET.Key (s1, s2) -> let s3 = if s1 = "NOTE" then complete (s1^s2) 0 else "" in Printf.fprintf och "(* %s%s%s*)" s1 s2 s3 - | ET.Title ss -> + | ET.Title ss -> let s = String.concat " " ss in Printf.fprintf och "(* %s %s*)" s (complete s 1) - | ET.Slice ss -> + | ET.Slice ss -> let s = String.capitalize_ascii (String.concat " " ss) in Printf.fprintf och "(* %s %s*)" s (complete s 1) - | ET.Other (s1, s2, s3) -> + | ET.Other (_, s1, s2, s3) -> Printf.fprintf och "%s%s%s" s1 s2 s3 let write_srcs file srcs = @@ -55,3 +56,33 @@ let write_srcs file srcs = let och = open_out target in List.iter (out_src och) srcs; close_out och + +let write_subst och n s = + Printf.fprintf och "%s %s\n" s n + +let rec write_fst och = function + | [] -> () + | ET.Other (2, _, s, _) :: ET.Line _ :: ET.Text t :: tl -> + write_snd och tl s (EL.split_on_char ' ' t) + | ET.Other (2, _, s, _) :: tl -> + Printf.eprintf "skipping fst: %S\n" s; + write_fst och tl + | _ :: tl -> write_fst och tl + +and write_snd och tl s = function + | "definition" :: n :: _ + | "fact" :: n :: _ + | "lemma" :: n :: _ + | "inductive" :: n :: _ + | "theorem" :: n :: _ -> + let ss = EL.split_on_char ' ' s in + List.iter (write_subst och n) (List.tl ss); + write_fst och tl + | t :: _ -> + Printf.eprintf "skipping snd: %S %S\n" s t; + write_fst och tl + | [] -> + Printf.eprintf "skipping snd: %S\n" s; + write_fst och tl + +let write_substs = write_fst