annotate tools/make_template.ml @ 473:39c204d2262c

Remove hyperlinks to standard library, which were broken anyway
author Adam Chlipala <adam@chlipala.net>
date Mon, 22 Oct 2012 13:28:54 -0400
parents d07c77659c20
children 3fc43e261f67
rev   line source
adamc@23 1 let read_line () =
adamc@22 2 try
adamc@23 3 Some (read_line ())
adamc@22 4 with End_of_file -> None
adamc@22 5
adamc@22 6 let rec initial last_was_empty =
adamc@23 7 match read_line () with
adamc@22 8 | None -> ()
adamc@22 9 | Some "(* begin thide *)" -> thide last_was_empty
adamc@22 10 | Some "" ->
adamc@22 11 if not (last_was_empty) then
adamc@22 12 print_newline ();
adamc@22 13 initial true
adamc@22 14 | Some line ->
adamc@41 15 let idx = try Some (String.index line '(') with Not_found -> None in
adamc@41 16 match idx with
adamc@41 17 | Some idx ->
adamc@49 18 if String.length line > idx+1 && line.[idx+1] = '*'
adamc@49 19 && not (String.length line > idx+4 && String.sub line (idx+2) 3 = " EX") then
adamc@41 20 if line.[String.length line - 2] = '*' && line.[String.length line - 1] = ')' then
adamc@41 21 initial last_was_empty
adamc@41 22 else
adamc@77 23 comment 1 last_was_empty
adamc@41 24 else begin
adamc@41 25 print_endline line;
adamc@41 26 initial false
adamc@41 27 end
adamc@41 28 | None ->
adamc@41 29 print_endline line;
adamc@41 30 initial false
adamc@22 31
adamc@77 32 and comment count last_was_empty =
adamc@23 33 match read_line () with
adamc@22 34 | None -> ()
adamc@22 35 | Some line ->
adamc@77 36 if String.length line >= 2 && line.[0] = '(' && line.[1] = '*' then
adamc@77 37 if String.length line >= 2 && line.[String.length line - 2] = '*'
adamc@77 38 && line.[String.length line - 1] = ')' then
adamc@77 39 comment count last_was_empty
adamc@77 40 else
adamc@77 41 comment (count+1) last_was_empty
adamc@77 42 else if String.length line >= 2 && line.[String.length line - 2] = '*'
adamc@22 43 && line.[String.length line - 1] = ')' then
adamc@77 44 if try
adamc@77 45 let idx = String.index line '(' in
adamc@77 46 idx < String.length line - 1 && line.[idx + 1] = '*'
adamc@77 47 with Not_found -> false then
adamc@77 48 comment count last_was_empty
adamc@77 49 else if count = 1 then
adamc@77 50 initial last_was_empty
adamc@77 51 else
adamc@77 52 comment (count-1) last_was_empty
adamc@22 53 else
adamc@77 54 comment count last_was_empty
adamc@22 55
adamc@22 56 and thide last_was_empty =
adamc@23 57 match read_line () with
adamc@22 58 | None -> ()
adamc@22 59 | Some "(* end thide *)" -> initial last_was_empty
adamc@22 60 | Some _ -> thide last_was_empty
adamc@22 61
adamc@22 62 let () = initial false