Mercurial > cpdt > repo
comparison tools/make_template.ml @ 571:3fc43e261f67
Spacing and indentation fixes in tools, from Chen Yiwu
author | Adam Chlipala <adam@chlipala.net> |
---|---|
date | Sun, 21 Apr 2019 16:09:55 -0400 |
parents | d07c77659c20 |
children |
comparison
equal
deleted
inserted
replaced
570:c3d4217e1da7 | 571:3fc43e261f67 |
---|---|
1 let read_line () = | 1 let read_line () = |
2 try | 2 try |
3 Some (read_line ()) | 3 Some (read_line ()) |
4 with End_of_file -> None | 4 with End_of_file -> None |
5 | 5 |
6 let rec initial last_was_empty = | 6 let rec initial last_was_empty = |
7 match read_line () with | 7 match read_line () with |
8 | None -> () | 8 | None -> () |
9 | Some "(* begin thide *)" -> thide last_was_empty | 9 | Some "(* begin thide *)" -> thide last_was_empty |
10 | Some "" -> | 10 | Some "" -> |
11 if not (last_was_empty) then | 11 if not (last_was_empty) then |
12 print_newline (); | 12 print_newline (); |
13 initial true | 13 initial true |
14 | Some line -> | 14 | Some line -> |
15 let idx = try Some (String.index line '(') with Not_found -> None in | 15 let idx = try Some (String.index line '(') with Not_found -> None in |
16 match idx with | 16 match idx with |
17 | Some idx -> | 17 | Some idx -> |
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 1 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 count 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.[0] = '(' && line.[1] = '*' then | 36 if String.length line >= 2 && line.[0] = '(' && line.[1] = '*' then |
37 if String.length line >= 2 && line.[String.length line - 2] = '*' | 37 if String.length line >= 2 && line.[String.length line - 2] = '*' |
38 && line.[String.length line - 1] = ')' then | 38 && line.[String.length line - 1] = ')' then |
39 comment count last_was_empty | 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] = '*' | |
43 && line.[String.length line - 1] = ')' then | |
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 | |
53 else | 40 else |
54 comment count last_was_empty | 41 comment (count+1) last_was_empty |
42 else if String.length line >= 2 && line.[String.length line - 2] = '*' | |
43 && line.[String.length line - 1] = ')' then | |
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 | |
53 else | |
54 comment count last_was_empty | |
55 | 55 |
56 and thide last_was_empty = | 56 and thide last_was_empty = |
57 match read_line () with | 57 match read_line () with |
58 | None -> () | 58 | None -> () |
59 | Some "(* end thide *)" -> initial last_was_empty | 59 | Some "(* end thide *)" -> initial last_was_empty |