ident.mli 3.32 KB
Newer Older
Andrei Paskevich's avatar
Andrei Paskevich committed
1 2 3
(********************************************************************)
(*                                                                  *)
(*  The Why3 Verification Platform   /   The Why3 Development Team  *)
4
(*  Copyright 2010-2015   --   INRIA - CNRS - Paris-Sud University  *)
Andrei Paskevich's avatar
Andrei Paskevich committed
5 6 7 8 9
(*                                                                  *)
(*  This software is distributed under the terms of the GNU Lesser  *)
(*  General Public License version 2.1, with the special exception  *)
(*  on linking described in file LICENSE.                           *)
(********************************************************************)
10

MARCHE Claude's avatar
MARCHE Claude committed
11 12
(** Identifiers *)

MARCHE Claude's avatar
MARCHE Claude committed
13 14
(** {2 Labels} *)

Andrei Paskevich's avatar
Andrei Paskevich committed
15 16 17 18 19
type label = private {
  lab_string : string;
  lab_tag    : int;
}

20 21
module Mlab : Extmap.S with type key = label
module Slab : Extset.S with module M = Mlab
22

Andrei Paskevich's avatar
Andrei Paskevich committed
23
val lab_compare : label -> label -> int
Andrei Paskevich's avatar
Andrei Paskevich committed
24
val lab_equal : label -> label -> bool
Andrei Paskevich's avatar
Andrei Paskevich committed
25
val lab_hash : label -> int
Andrei Paskevich's avatar
Andrei Paskevich committed
26 27

val create_label : string -> label
MARCHE Claude's avatar
MARCHE Claude committed
28 29

(** {2 Identifiers} *)
30 31

type ident = private {
32
  id_string : string;               (* non-unique name *)
33
  id_label  : Slab.t;               (* identifier labels *)
34
  id_loc    : Loc.position option;  (* optional location *)
Andrei Paskevich's avatar
Andrei Paskevich committed
35
  id_tag    : Weakhtbl.tag;         (* unique magical tag *)
36 37
}

38 39 40
module Mid : Extmap.S with type key = ident
module Sid : Extset.S with module M = Mid
module Hid : Exthtbl.S with type key = ident
Andrei Paskevich's avatar
Andrei Paskevich committed
41
module Wid : Weakhtbl.S with type key = ident
42

Andrei Paskevich's avatar
Andrei Paskevich committed
43
val id_compare : ident -> ident -> int
44
val id_equal : ident -> ident -> bool
Andrei Paskevich's avatar
Andrei Paskevich committed
45 46
val id_hash : ident -> int

47
(* a user-created type of unregistered identifiers *)
48 49 50 51 52
type preid = {
  pre_name  : string;
  pre_label : Slab.t;
  pre_loc   : Loc.position option;
}
53

54
(* register a pre-ident (you should never use this function) *)
55
val id_register : preid -> ident
56

57
(* create a fresh pre-ident *)
58
val id_fresh : ?label:Slab.t -> ?loc:Loc.position -> string -> preid
59

60
(* create a localized pre-ident *)
61
val id_user : ?label:Slab.t -> string -> Loc.position -> preid
62 63

(* create a duplicate pre-ident *)
64
val id_clone : ?label:Slab.t -> ident -> preid
65

66
(* create a derived pre-ident (inherit labels and location) *)
67
val id_derive : ?label:Slab.t -> string -> ident -> preid
68

69
(* DEPRECATED : retrieve preid name without registering *)
70
val preid_name : preid -> string
Francois Bobot's avatar
Francois Bobot committed
71

72 73
(** Unique persistent names for pretty printing *)

74
type ident_printer
75

76 77
val create_ident_printer :
  ?sanitizer : (string -> string) -> string list -> ident_printer
MARCHE Claude's avatar
MARCHE Claude committed
78
(** start a new printer with a sanitizing function and a blacklist *)
79

80 81
val id_unique :
  ident_printer -> ?sanitizer : (string -> string) -> ident -> string
82
(** use ident_printer to generate a unique name for ident
MARCHE Claude's avatar
MARCHE Claude committed
83
    an optional sanitizer is applied over the printer's sanitizer *)
84

85
val string_unique : ident_printer -> string -> string
MARCHE Claude's avatar
MARCHE Claude committed
86
(** Uniquify string *)
87

88
val forget_id : ident_printer -> ident -> unit
MARCHE Claude's avatar
MARCHE Claude committed
89
(** forget an ident *)
90

91
val forget_all : ident_printer -> unit
MARCHE Claude's avatar
MARCHE Claude committed
92
(** forget all idents *)
93 94

val sanitizer : (char -> string) -> (char -> string) -> string -> string
MARCHE Claude's avatar
MARCHE Claude committed
95 96 97
(** generic sanitizer taking a separate encoder for the first letter *)

(** various character encoders *)
98 99 100 101 102

val char_to_alpha : char -> string
val char_to_lalpha : char -> string
val char_to_ualpha : char -> string
val char_to_alnum : char -> string
103
val char_to_lalnum : char -> string
104
val char_to_alnumus : char -> string
105
val char_to_lalnumus : char -> string
106