ident.mli 4.98 KB
Newer Older
Andrei Paskevich's avatar
Andrei Paskevich committed
1 2 3
(********************************************************************)
(*                                                                  *)
(*  The Why3 Verification Platform   /   The Why3 Development Team  *)
MARCHE Claude's avatar
MARCHE Claude committed
4
(*  Copyright 2010-2017   --   INRIA - CNRS - Paris-Sud University  *)
Andrei Paskevich's avatar
Andrei Paskevich committed
5 6 7 8
(*                                                                  *)
(*  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.                           *)
9
(*                                                                  *)
Andrei Paskevich's avatar
Andrei Paskevich committed
10
(********************************************************************)
11

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

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

Andrei Paskevich's avatar
Andrei Paskevich committed
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
Andrei Paskevich's avatar
Andrei Paskevich committed
25
val lab_equal : label -> label -> bool
Andrei Paskevich's avatar
Andrei Paskevich committed
26
val lab_hash : label -> int
Andrei Paskevich's avatar
Andrei Paskevich committed
27 28

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

30 31
(* functions for working with counterexample model labels *)

32
val remove_model_labels : labels : Slab.t -> Slab.t
Guillaume Melquiond's avatar
Guillaume Melquiond committed
33
(** Returns a copy of labels without labels ["model"] and ["model_projected"]. *)
34

35 36 37 38
val append_to_model_trace_label : labels : Slab.t ->
  to_append : string ->
  Slab.t
(** The returned set of labels will contain the same set of labels
Guillaume Melquiond's avatar
Guillaume Melquiond committed
39 40
    as argument labels except that a label of the form ["model_trace:*"]
    will be ["model_trace:*to_append"]. *)
41 42 43 44 45

val append_to_model_element_name : labels : Slab.t ->
  to_append : string ->
  Slab.t
(** The returned set of labels will contain the same set of labels
Guillaume Melquiond's avatar
Guillaume Melquiond committed
46 47
    as argument labels except that a label of the form ["model_trace:*@*"]
    will be ["model_trace:*to_append@*"]. *)
48 49

val get_model_element_name : labels : Slab.t -> string
Guillaume Melquiond's avatar
Guillaume Melquiond committed
50 51 52
(** If labels contain a label of the form ["model_trace:name@*"],
    return ["name"].
    Throws [Not_found] if there is no label of the form ["model_trace:*"]. *)
53

54
val get_model_trace_string : labels : Slab.t -> string
Guillaume Melquiond's avatar
Guillaume Melquiond committed
55 56 57
(** If labels contain a label of the form ["model_trace:mt_string"],
    return ["mt_string"].
    Throws [Not_found] if there is no label of the form ["model_trace:*"]. *)
58

59
val get_model_trace_label : labels : Slab.t -> Slab.elt
Guillaume Melquiond's avatar
Guillaume Melquiond committed
60 61
(** Return a label of the form ["model_trace:*"].
    Throws [Not_found] if there is no such label. *)
62

MARCHE Claude's avatar
MARCHE Claude committed
63
(** {2 Identifiers} *)
64 65

type ident = private {
Piotr Trojanek's avatar
Piotr Trojanek committed
66 67 68 69
  id_string : string;               (** non-unique name *)
  id_label  : Slab.t;               (** identifier labels *)
  id_loc    : Loc.position option;  (** optional location *)
  id_tag    : Weakhtbl.tag;         (** unique magical tag *)
70 71
}

72 73 74
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
75
module Wid : Weakhtbl.S with type key = ident
76

Andrei Paskevich's avatar
Andrei Paskevich committed
77
val id_compare : ident -> ident -> int
78
val id_equal : ident -> ident -> bool
Andrei Paskevich's avatar
Andrei Paskevich committed
79 80
val id_hash : ident -> int

Piotr Trojanek's avatar
Piotr Trojanek committed
81
(** a user-created type of unregistered identifiers *)
82 83 84 85 86
type preid = {
  pre_name  : string;
  pre_label : Slab.t;
  pre_loc   : Loc.position option;
}
87

Piotr Trojanek's avatar
Piotr Trojanek committed
88
(** register a pre-ident (you should never use this function) *)
89
val id_register : preid -> ident
90

Piotr Trojanek's avatar
Piotr Trojanek committed
91
(** create a fresh pre-ident *)
92
val id_fresh : ?label:Slab.t -> ?loc:Loc.position -> string -> preid
93

Piotr Trojanek's avatar
Piotr Trojanek committed
94
(** create a localized pre-ident *)
95
val id_user : ?label:Slab.t -> string -> Loc.position -> preid
96

Piotr Trojanek's avatar
Piotr Trojanek committed
97
(** create a duplicate pre-ident with given labels *)
98 99
val id_lab : Slab.t -> ident -> preid

Piotr Trojanek's avatar
Piotr Trojanek committed
100
(** create a duplicate pre-ident *)
101
val id_clone : ?label:Slab.t -> ident -> preid
102

Piotr Trojanek's avatar
Piotr Trojanek committed
103
(** create a derived pre-ident (inherit labels and location) *)
104
val id_derive : ?label:Slab.t -> string -> ident -> preid
105

106
(* DEPRECATED : retrieve preid name without registering *)
107
val preid_name : preid -> string
Francois Bobot's avatar
Francois Bobot committed
108

109 110
(** Unique persistent names for pretty printing *)

111
type ident_printer
112

113 114
val create_ident_printer :
  ?sanitizer : (string -> string) -> string list -> ident_printer
MARCHE Claude's avatar
MARCHE Claude committed
115
(** start a new printer with a sanitizing function and a blacklist *)
116

117 118
val id_unique :
  ident_printer -> ?sanitizer : (string -> string) -> ident -> string
119
(** use ident_printer to generate a unique name for ident
MARCHE Claude's avatar
MARCHE Claude committed
120
    an optional sanitizer is applied over the printer's sanitizer *)
121

122
val string_unique : ident_printer -> string -> string
MARCHE Claude's avatar
MARCHE Claude committed
123
(** Uniquify string *)
124

125
val forget_id : ident_printer -> ident -> unit
MARCHE Claude's avatar
MARCHE Claude committed
126
(** forget an ident *)
127

128
val forget_all : ident_printer -> unit
MARCHE Claude's avatar
MARCHE Claude committed
129
(** forget all idents *)
130

131 132 133
val sanitizer' : (char -> string) -> (char -> string) -> (char -> string) -> string -> string
(** generic sanitizer taking a separate encoder for the first and last letter *)

134
val sanitizer : (char -> string) -> (char -> string) -> string -> string
MARCHE Claude's avatar
MARCHE Claude committed
135 136 137
(** generic sanitizer taking a separate encoder for the first letter *)

(** various character encoders *)
138 139 140 141 142

val char_to_alpha : char -> string
val char_to_lalpha : char -> string
val char_to_ualpha : char -> string
val char_to_alnum : char -> string
143
val char_to_lalnum : char -> string
144
val char_to_alnumus : char -> string
145
val char_to_lalnumus : char -> string