comparison tools/make_template.ml @ 22:91e247c68ee8

Template generation
author Adam Chlipala <adamc@hcoop.net>
date Fri, 05 Sep 2008 16:46:32 -0400
parents
children c8070689f5ca
comparison
equal deleted inserted replaced
21:00366a62bd00 22:91e247c68ee8
1 let input_line () =
2 try
3 Some (input_line stdin)
4 with End_of_file -> None
5
6 let rec initial last_was_empty =
7 match input_line () with
8 | None -> ()
9 | Some "(* begin thide *)" -> thide last_was_empty
10 | Some "" ->
11 if not (last_was_empty) then
12 print_newline ();
13 initial true
14 | Some line ->
15 if String.length line >= 2 && line.[0] = '(' && line.[1] = '*' then
16 if line.[String.length line - 2] = '*' && line.[String.length line - 1] = ')' then
17 initial last_was_empty
18 else
19 comment last_was_empty
20 else begin
21 print_endline line;
22 initial false
23 end
24
25 and comment last_was_empty =
26 match input_line () with
27 | None -> ()
28 | Some line ->
29 if String.length line >= 2 && line.[String.length line - 2] = '*'
30 && line.[String.length line - 1] = ')' then
31 initial last_was_empty
32 else
33 comment last_was_empty
34
35 and thide last_was_empty =
36 match input_line () with
37 | None -> ()
38 | Some "(* end thide *)" -> initial last_was_empty
39 | Some _ -> thide last_was_empty
40
41 let () = initial false