Debian Codegraph @

clib/unicode.mli

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 (** Unicode utilities *)
12
13 type status
14
15 (** Classify a unicode char into 3 classes or unknown. *)
16 val classify : int -> status
17
18 (** Return [None] if a given string can be used as a (Rocq) identifier.
19 Return [Some (b,s)] otherwise, where [s] is an explanation and [b] is severity. *)
20 val ident_refutation : string -> (bool * string) option
21
22 (** Tells if a valid initial character for an identifier *)
23 val is_valid_ident_initial : status -> bool
24
25 (** Tells if a valid non-initial character for an identifier *)
26 val is_valid_ident_trailing : status -> bool
27
28 (** Tells if a letter *)
29 val is_letter : status -> bool
30
31 (** Tells if a character is unclassified *)
32 val is_unknown : status -> bool
33
34 (** First char of a string, converted to lowercase
35 @raise Assert_failure if the input string is empty. *)
36 val lowercase_first_char : string -> string
37
38 (** Split a string supposed to be an ident at the first letter;
39 as an optimization, return None if the first character is a letter *)
40 val split_at_first_letter : string -> (string * string) option
41
42 (** Return [true] if all UTF-8 characters in the input string are just plain
43 ASCII characters. Returns [false] otherwise. *)
44 val is_basic_ascii : string -> bool
45
46 (** [ascii_of_ident s] maps UTF-8 string to a string composed solely from ASCII
47 characters. The non-ASCII characters are translated to ["_UUxxxx_"] where
48 {i xxxx} is the Unicode index of the character in hexadecimal (from four
49 to six hex digits). To avoid potential name clashes, any preexisting
50 substring ["_UU"] is turned into ["_UUU"]. *)
51 val ascii_of_ident : string -> string
52
53 (** Validate an UTF-8 string *)
54 val is_utf8 : string -> bool
55
56 (** Return the length of a valid UTF-8 string. *)
57 val utf8_length : string -> int
58
59 (** Variant of {!String.sub} for UTF-8 strings. *)
60 val utf8_sub : string -> int -> int -> string
61
62 (** Return a "%XX"-escaped string if it contains non UTF-8 characters. *)
63 val escaped_if_non_utf8 : string -> string