-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathsig_file_column.ml
57 lines (51 loc) · 1.26 KB
/
sig_file_column.ml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
open! Core
open Little_logger
module U = Utils
type t = Spans | Spans_end | Spans_start | Signature
let reverse_index = function
| Spans ->
0
| Spans_end ->
1
| Spans_start ->
2
| Signature ->
3
let to_string = function
| Spans ->
"spans"
| Spans_end ->
"spans_end"
| Spans_start ->
"spans_start"
| Signature ->
"signature"
let position_name = function
| Spans ->
"last"
| Spans_end ->
"second to last"
| Spans_start ->
"third to last"
| Signature ->
"fourth to last"
let check ary col =
let name = to_string col in
let position_name = position_name col in
match U.get_from_end ary (reverse_index col) with
| Ok s ->
let is_good = String.(s = name) in
if not is_good then
Logger.error (fun () ->
[%string
"The %{position_name} column the signature file should be \
'%{name}'. Got '%{s}'."] ) ;
is_good
| Error err ->
Logger.error (fun () ->
let msg = Error.to_string_hum err in
[%string
"Couldn't get '%{name}' column from header. It's probably too \
short. %{msg}"] ) ;
false
let get_from_header header t = U.get_from_end header @@ reverse_index t