Skip to content
Newer
Older
100644 106 lines (80 sloc) 3.34 KB
fccc685 Initial open-source release
MLstate authored Jun 21, 2011
1 (*
2 Copyright © 2011 MLstate
3
4 This file is part of OPA.
5
6 OPA is free software: you can redistribute it and/or modify it under the
7 terms of the GNU Affero General Public License, version 3, as published by
8 the Free Software Foundation.
9
10 OPA is distributed in the hope that it will be useful, but WITHOUT ANY
11 WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
12 FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for
13 more details.
14
15 You should have received a copy of the GNU Affero General Public License
16 along with OPA. If not, see <http://www.gnu.org/licenses/>.
17 *)
18 (**
19 Ident for AST.
20 *)
21
22 (**
23 This kind of ident is used for generating code.
24 It has a support for renaming, and packages separation.
25
26 This was originally Ident, but now is exported
27 there since we use it in ocamllang too.
28
29 So, we need probably to change some opa-specificities.
30 (in a next commit)
31 *)
32
33 type uniq
34 type t = private
35 | Source of string
36 | FakeSource of string
37 | Internal of uniq
38
39 (** comparaison. equal implementation is [compare a b = 0]*)
40 val compare : t -> t -> int
41 val equal : t -> t -> bool
42 val hash : t -> int
43
44 (** Constructors *)
45 val next : ?filename:string -> ?descr:string -> string -> t (** Fixed : don't allow anonymous internal *)
46 (** Fixed : don't allow anonymous internal *)
47 val nextf : ?filename:string -> ?descr:string -> ('a, unit, string, t) format4 -> 'a
48
49 val source : string -> t
50 val fake_source : string -> t
51
52 (** this is like to_string but raise an error if it is a db *)
53 val stident : t -> string
54
55 val is_operator : t -> bool
56
57 (** see if it is really used -- it is possibly a good idea *)
58 (* val active_alpha_protection : unit -> unit *)
59
60 (** beware of usability of `id with backquote` : with libconvert it becomes a nightmare
61 Beware: this function behaves differently whether we are testing mode
62 or not => it is for debug
63 If you want something else, then use either [stdident], [original_name]
64 (or [refresh] insteand of [next (to_string _)])
65 *)
66 val to_string : t -> string
67
68 (** guaranties unicity of string, fails for source ident *)
69 val to_uniq_string: t -> string
70
71 (** gives back the non-uniq'ed name -- for hacking only *)
72 val original_name : t -> string
73
74 val refresh : ?map:(string -> string) -> t -> t
75 (**
76 equivalent to fun x -> ExprIdent.next (map (origrepr x))
77 except that the description and filename is kept
78 *)
79
80 val refreshf : map:(string -> string, unit, string) format -> t -> t
81 (**
82 example of use: [refreshf ~map:"coucou_%s" ident]
83 *)
84
85 val concrete_string : t -> string
86
87 (** used for printing opa-ligth, before or after renaming
88 dont_protect_operator is [false] by default, it means that
89 the identitifier should not be protect with backquote, typically
90 for infix application printing *)
91 val opa_syntax : ?dont_protect_operator:bool -> t -> string
92
93 (** used for printing a lighter code with opatrack, we do not print the
94 description, just the local stamp.
95 Beware: do not use for generating code, just for debugging.
96 *)
97 val light_ident : t -> string
98
99 (** works only on internal identifiers *)
100 val get_package_name : t -> string
101
102 (** returns none when the identifier is not internal *)
103 val safe_get_package_name : t -> string option
104
105 val renaming_should_warn_when : t -> [`used | `unused | `never]
Something went wrong with that request. Please try again.