ident.mli 3.23 KB
Newer Older
Andrei Paskevich's avatar
Andrei Paskevich committed
1 2 3
(********************************************************************)
(*                                                                  *)
(*  The Why3 Verification Platform   /   The Why3 Development Team  *)
4
(*  Copyright 2010-2013   --   INRIA - CNRS - Paris-Sud University  *)
Andrei Paskevich's avatar
Andrei Paskevich committed
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

François Bobot's avatar
François Bobot committed
12 13
open Stdlib

MARCHE Claude's avatar
MARCHE Claude committed
14 15
(** Identifiers *)

MARCHE Claude's avatar
MARCHE Claude committed
16 17
(** {2 Labels} *)

Andrei Paskevich's avatar
Andrei Paskevich committed
18 19 20 21 22
type label = private {
  lab_string : string;
  lab_tag    : int;
}

23 24
module Mlab : Extmap.S with type key = label
module Slab : Extset.S with module M = Mlab
25

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

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

(** {2 Identifiers} *)
32 33

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

40 41 42
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
43
module Wid : Weakhtbl.S with type key = ident
44

45 46
val id_equal : ident -> ident -> bool

Andrei Paskevich's avatar
Andrei Paskevich committed
47 48
val id_hash : ident -> int

49 50
(* a user-created type of unregistered identifiers *)
type preid
51

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

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

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

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

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

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

70 71
(** Unique persistent names for pretty printing *)

72
type ident_printer
73

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

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

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

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

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

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

(** various character encoders *)
96 97 98 99 100

val char_to_alpha : char -> string
val char_to_lalpha : char -> string
val char_to_ualpha : char -> string
val char_to_alnum : char -> string
101
val char_to_lalnum : char -> string
102
val char_to_alnumus : char -> string
103
val char_to_lalnumus : char -> string
104