Remove more pointless stuff
[llpp.git] / keystoml.ml
blobe5dc52fd71af50a750189eafaa894ef5f00fbd8b
1 let r_dash = Str.regexp " - ";;
2 let tabify s =
3 let dashpos = try Str.search_forward r_dash s 0 with Not_found -> -1 in
4 if dashpos < 1
5 then
6 let l = String.length s in
7 if l > 11 && String.sub s 0 5 = "-----"
8 then
9 "\xc2\xb7" ^ String.sub s 5 (l - 10)
10 else
12 else
13 let rec findnonwsback i =
14 if i = -1 then 0 else
15 if s.[i] = ' '
16 then findnonwsback (i-1)
17 else i
19 let nonwspos = findnonwsback dashpos in
20 let b = Buffer.create 80 in
21 Buffer.add_substring b s 0 (nonwspos+1);
22 Buffer.add_char b '\t';
23 Buffer.add_substring b s (dashpos+1) (String.length s - dashpos - 1);
24 Buffer.contents b
27 let lines =
28 let rec fold accu =
29 match input_line stdin with
30 | line -> fold (tabify line :: accu)
31 | exception End_of_file -> List.rev accu
33 fold []
36 let _ =
37 print_endline "let keys = [";
38 List.iter (Printf.printf " %S;\n") lines;
39 print_endline "];;"