Mercurial > cpdt > repo
diff 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 |
line wrap: on
line diff
--- a/tools/make_template.ml Sun Jan 20 15:44:31 2019 -0500 +++ b/tools/make_template.ml Sun Apr 21 16:09:55 2019 -0400 @@ -1,4 +1,4 @@ -let read_line () = +let read_line () = try Some (read_line ()) with End_of_file -> None @@ -8,50 +8,50 @@ | None -> () | Some "(* begin thide *)" -> thide last_was_empty | Some "" -> - if not (last_was_empty) then - print_newline (); - initial true + if not (last_was_empty) then + print_newline (); + initial true | Some line -> - let idx = try Some (String.index line '(') with Not_found -> None in - match idx with - | Some idx -> - if String.length line > idx+1 && line.[idx+1] = '*' - && not (String.length line > idx+4 && String.sub line (idx+2) 3 = " EX") then - if line.[String.length line - 2] = '*' && line.[String.length line - 1] = ')' then - initial last_was_empty - else - comment 1 last_was_empty - else begin - print_endline line; - initial false - end - | None -> - print_endline line; - initial false + let idx = try Some (String.index line '(') with Not_found -> None in + match idx with + | Some idx -> + if String.length line > idx+1 && line.[idx+1] = '*' + && not (String.length line > idx+4 && String.sub line (idx+2) 3 = " EX") then + if line.[String.length line - 2] = '*' && line.[String.length line - 1] = ')' then + initial last_was_empty + else + comment 1 last_was_empty + else begin + print_endline line; + initial false + end + | None -> + print_endline line; + initial false and comment count last_was_empty = match read_line () with | None -> () | Some line -> - if String.length line >= 2 && line.[0] = '(' && line.[1] = '*' then - if String.length line >= 2 && line.[String.length line - 2] = '*' - && line.[String.length line - 1] = ')' then - comment count last_was_empty - else - comment (count+1) last_was_empty - else if String.length line >= 2 && line.[String.length line - 2] = '*' - && line.[String.length line - 1] = ')' then - if try - let idx = String.index line '(' in - idx < String.length line - 1 && line.[idx + 1] = '*' - with Not_found -> false then - comment count last_was_empty - else if count = 1 then - initial last_was_empty - else - comment (count-1) last_was_empty + if String.length line >= 2 && line.[0] = '(' && line.[1] = '*' then + if String.length line >= 2 && line.[String.length line - 2] = '*' + && line.[String.length line - 1] = ')' then + comment count last_was_empty else - comment count last_was_empty + comment (count+1) last_was_empty + else if String.length line >= 2 && line.[String.length line - 2] = '*' + && line.[String.length line - 1] = ')' then + if try + let idx = String.index line '(' in + idx < String.length line - 1 && line.[idx + 1] = '*' + with Not_found -> false then + comment count last_was_empty + else if count = 1 then + initial last_was_empty + else + comment (count-1) last_was_empty + else + comment count last_was_empty and thide last_was_empty = match read_line () with