Debian Codegraph @

tools/coqdoc/alpha.ml

raw symbols SCIP
1 (************************************************************************)
2 (* * The Rocq Prover / The Rocq Development Team *)
3 (* v * Copyright INRIA, CNRS and contributors *)
4 (* <O___,, * (see version control and CREDITS file for authors & dates) *)
5 (* \VV/ **************************************************************)
6 (* // * This file is distributed under the terms of the *)
7 (* * GNU Lesser General Public License Version 2.1 *)
8 (* * (see LICENSE file for the text of the license) *)
9 (************************************************************************)
10
11 open Common
12
13 let norm_char_latin1 c = match Char.uppercase_ascii c with
14 | '\192'..'\198' -> 'A'
15 | '\199' -> 'C'
16 | '\200'..'\203' -> 'E'
17 | '\204'..'\207' -> 'I'
18 | '\209' -> 'N'
19 | '\210'..'\214' -> 'O'
20 | '\217'..'\220' -> 'U'
21 | '\221' -> 'Y'
22 | c -> c
23
24 let norm_char_utf8 c = Char.uppercase_ascii c
25
26 let norm_char c =
27 if !prefs.encoding.utf8 then norm_char_utf8 c else
28 if !prefs.encoding.latin1 then norm_char_latin1 c else
29 Char.uppercase_ascii c
30
31 let norm_string = String.map (fun s -> norm_char s)
32
33 let compare_char c1 c2 = match norm_char c1, norm_char c2 with
34 | ('A'..'Z' as c1), ('A'..'Z' as c2) -> compare c1 c2
35 | 'A'..'Z', _ -> -1
36 | _, 'A'..'Z' -> 1
37 | '_', _ -> -1
38 | _, '_' -> 1
39 | c1, c2 -> compare c1 c2
40
41 let compare_string s1 s2 =
42 let n1 = String.length s1 in
43 let n2 = String.length s2 in
44 let rec cmp i =
45 if i == n1 || i == n2 then
46 n1 - n2
47 else
48 let c = compare_char s1.[i] s2.[i] in
49 if c == 0 then cmp (succ i) else c
50 in
51 cmp 0