comparison tools/make_template.ml @ 77:d07c77659c20

Templatizing Subset
author Adam Chlipala <adamc@hcoop.net>
date Fri, 03 Oct 2008 15:27:39 -0400
parents 827d7e8a7d9e
children 3fc43e261f67
comparison
equal deleted inserted replaced
76:82a2189fa283 77:d07c77659c20
18 if String.length line > idx+1 && line.[idx+1] = '*' 18 if String.length line > idx+1 && line.[idx+1] = '*'
19 && not (String.length line > idx+4 && String.sub line (idx+2) 3 = " EX") then 19 && not (String.length line > idx+4 && String.sub line (idx+2) 3 = " EX") then
20 if line.[String.length line - 2] = '*' && line.[String.length line - 1] = ')' then 20 if line.[String.length line - 2] = '*' && line.[String.length line - 1] = ')' then
21 initial last_was_empty 21 initial last_was_empty
22 else 22 else
23 comment last_was_empty 23 comment 1 last_was_empty
24 else begin 24 else begin
25 print_endline line; 25 print_endline line;
26 initial false 26 initial false
27 end 27 end
28 | None -> 28 | None ->
29 print_endline line; 29 print_endline line;
30 initial false 30 initial false
31 31
32 and comment last_was_empty = 32 and comment count last_was_empty =
33 match read_line () with 33 match read_line () with
34 | None -> () 34 | None -> ()
35 | Some line -> 35 | Some line ->
36 if String.length line >= 2 && line.[String.length line - 2] = '*' 36 if String.length line >= 2 && line.[0] = '(' && line.[1] = '*' then
37 if String.length line >= 2 && line.[String.length line - 2] = '*'
38 && line.[String.length line - 1] = ')' then
39 comment count last_was_empty
40 else
41 comment (count+1) last_was_empty
42 else if String.length line >= 2 && line.[String.length line - 2] = '*'
37 && line.[String.length line - 1] = ')' then 43 && line.[String.length line - 1] = ')' then
38 initial last_was_empty 44 if try
45 let idx = String.index line '(' in
46 idx < String.length line - 1 && line.[idx + 1] = '*'
47 with Not_found -> false then
48 comment count last_was_empty
49 else if count = 1 then
50 initial last_was_empty
51 else
52 comment (count-1) last_was_empty
39 else 53 else
40 comment last_was_empty 54 comment count last_was_empty
41 55
42 and thide last_was_empty = 56 and thide last_was_empty =
43 match read_line () with 57 match read_line () with
44 | None -> () 58 | None -> ()
45 | Some "(* end thide *)" -> initial last_was_empty 59 | Some "(* end thide *)" -> initial last_was_empty