ident.mli 3.39 KB
Newer Older
1 2 3
(********************************************************************)
(*                                                                  *)
(*  The Why3 Verification Platform   /   The Why3 Development Team  *)
4
(*  Copyright 2010-2014   --   INRIA - CNRS - Paris-Sud University  *)
5 6 7 8 9 10
(*                                                                  *)
(*  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.                           *)
(*                                                                  *)
(********************************************************************)
11

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

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

16 17 18 19 20
type label = private {
  lab_string : string;
  lab_tag    : int;
}

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

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

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

(** {2 Identifiers} *)
31 32

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

39 40 41
module Mid : Extmap.S with type key = ident
module Sid : Extset.S with module M = Mid
module Hid : Exthtbl.S with type key = ident
42
module Wid : Weakhtbl.S with type key = ident
43

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

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

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

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

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

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

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

70
(* DEPRECATED : retrieve preid name without registering *)
71
val preid_name : preid -> string
72

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

75
type ident_printer
76

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

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

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

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

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

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

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

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