Mercurial > cpdt > repo
diff tools/prepare_spellcheck.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 | 6833a1b778c0 |
children |
line wrap: on
line diff
--- a/tools/prepare_spellcheck.ml Sun Jan 20 15:44:31 2019 -0500 +++ b/tools/prepare_spellcheck.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 @@ -17,8 +17,8 @@ try let pos = Str.search_forward (Str.regexp "\\[\\|%\\|#") s n in let ender = match s.[pos] with - | '[' -> ']' - | _ -> s.[pos] in + | '[' -> ']' + | _ -> s.[pos] in let pos' = String.index_from s (pos+1) ender in san (pos'+1) (acc ^ String.sub s n (pos-n)) with Not_found -> acc ^ Str.string_after s n @@ -28,52 +28,52 @@ match read_line () with | None -> () | Some line -> - match strstr "(**" line with - | None -> initial () - | Some pos -> - match strstr "*)" line with - | None -> - begin match strstr "[[" line with - | None -> - print_endline (sanitize (Str.string_after line (pos+3))); - comment () - | Some _ -> runTo "]]" - end - | Some pos' -> - let rest = Str.string_after line (pos+3) in - if not (prefix " printing" rest || prefix " begin" rest || prefix " end" rest) then - print_endline (sanitize (String.sub line (pos+3) (pos' - (pos+3)))); - initial () + match strstr "(**" line with + | None -> initial () + | Some pos -> + match strstr "*)" line with + | None -> + begin match strstr "[[" line with + | None -> + print_endline (sanitize (Str.string_after line (pos+3))); + comment () + | Some _ -> runTo "]]" + end + | Some pos' -> + let rest = Str.string_after line (pos+3) in + if not (prefix " printing" rest || prefix " begin" rest || prefix " end" rest) then + print_endline (sanitize (String.sub line (pos+3) (pos' - (pos+3)))); + initial () and comment () = match read_line () with | None -> () | Some line -> - match strstr "*)" line with - | None -> - begin match strstr "[[" line with - | None -> - begin match strstr "<<" line with - | None -> - print_endline (sanitize line); - comment () - | Some _ -> runTo ">>" - end - | Some _ -> runTo "]]" - end - | Some pos -> - print_endline (sanitize (Str.string_before line pos)); - initial () + match strstr "*)" line with + | None -> + begin match strstr "[[" line with + | None -> + begin match strstr "<<" line with + | None -> + print_endline (sanitize line); + comment () + | Some _ -> runTo ">>" + end + | Some _ -> runTo "]]" + end + | Some pos -> + print_endline (sanitize (Str.string_before line pos)); + initial () and runTo ender = match read_line () with | None -> () | Some line -> - match strstr ender line with - | None -> runTo ender - | _ -> - match strstr "*)" line with - | None -> comment () - | _ -> initial () + match strstr ender line with + | None -> runTo ender + | _ -> + match strstr "*)" line with + | None -> comment () + | _ -> initial () let () = initial ()