Debian Codegraph @

interp/dumpglob.mli

raw symbols SCIP
1 (************************************************************************)
2 (* * The Rocq Prover / The Rocq Development Team *)
3 (* v * Copyright INRIA, CNRS and contributors *)
4 (* <O___,, * (see version control and CREDITS file for authors & dates) *)
5 (* \VV/ **************************************************************)
6 (* // * This file is distributed under the terms of the *)
7 (* * GNU Lesser General Public License Version 2.1 *)
8 (* * (see LICENSE file for the text of the license) *)
9 (************************************************************************)
10
11 (** This file implements the Coq's [.glob] file format, which
12 provides information about the objects that are defined and referenced
13 from a Coq file.
14
15 The [.glob] file format is notably used by [coqdoc] and [coq2html]
16 to generate links and other documentation meta-data.
17
18 Note that we consider this format a legacy one, and no stability
19 guarantees are provided as of today, as we search to replace this
20 format with a more structured and strongly-typed API.
21
22 However, we do provide up to date documentation about the format of
23 [.glob] files below.
24
25 *)
26
27 (** {2 The [.glob] file format}
28
29 [.glob] files contain a header, and then a list of entries, with
30 one line per entry.
31
32 {3 [.glob] header }
33
34 The header consists of two lines:
35
36 [DIGEST: %md5sum_of_file]
37 [F%modpath]
38
39 where %modpath is the fully-qualified module name of the library that the
40 [.glob] file refers to. [%md5sum_of_file] may be NO if [-dump-glob file] was used.
41
42 {3 [.glob] entries }
43
44 There are 2 kinds of [.glob] entries:
45
46 - *definitions*: these entries correspond to definitions of inductives,
47 functions, binders, notations. They are written as:
48
49 [%kind %bc:%ec %secpath %name]
50
51 where [%kind] is one of
52 [{ax,def,coe,subclass,canonstruc,ex,scheme,proj,inst,meth,defax,prfax,thm,prim,class,var,indrec,rec,corec,ind,variant,coind,constr,not,binder,lib,mod,modtype}],
53 meaning:
54 + [ax] Axiom, Parameter or Variable(s), Hypothes{i,e}s, Context outside any section
55 + [def] Definition
56 + [coe] Coertion
57 + [thm] Theorem
58 + [subclass] Sub Class
59 + [canonstruc] Canonical Declaration
60 + [ex] Example
61 + [scheme] Scheme
62 + [class] Class declaration
63 + [proj] Projection from a structure
64 + [inst] Instance
65 + [meth] Class Method
66 + [defax] Definitional assumption
67 + [prfax] Logical assumption
68 + [prim] Primitive
69 + [var] section Variable reference (Variable{,s}, Hypothes{i,e}s, Context)
70 + [indrec] Inductive
71 + [rec] Inductive (variant)
72 + [corec] Coinductive
73 + [ind] Record
74 + [variant] Record (variant)
75 + [coind] Coinductive Record
76 + [constr] Constructor
77 + [not] Notation
78 + [binder] Binder
79 + [lib] Require
80 + [mod] Module Reference (Import, Module start / end)
81 + [modtype] Module Type
82
83 [%bc] and [%ec] are respectively the start and end byte locations in the file (0-indexed), multiple entries can share the same [%bc] and [%ec]
84 [%secpath] the section path (or [<>] if no section path) and [%name] the name of the
85 defined object, or also [<>] in where no name applies.
86
87 Section paths are ...
88
89 + In the case of notations, [%name] is encoded as [:entry:scope:notation_key] where [_] is used to replace
90 spaces in the notation key, [%entry] is left empty if the notation entry is [constr],
91 and similarly [%scope] is empty if the corresponding notation has no associated scope.
92
93 + For binding variables, [:number] is added to distinguish uniquely different binding variables of the same name in a file.
94
95 - *references*: which identify the object a particular document piece of text points to;
96 their format is:
97
98 [R%bc:%ec %filepath %secpath %name %kind]
99
100 where [%bc], [%ec], [%name], and [%kind] are as the above; [%filepath] contains the
101 file module path the object that the references lives in, whereas [%name] may contain
102 non-file non-directory module names.
103
104 *)
105
106 type glob_file = { vfile : string; vofile : string }
107
108 val dump : unit -> bool
109
110 type glob_output =
111 | NoGlob
112 | Feedback
113 | MultFiles of glob_file (* one glob file per .v file *)
114 | File of string (* Single file for all coqc arguments *)
115
116 (** [push_output o] temporarily overrides the output location to [o].
117 The original output can be restored using [pop_output] *)
118 val push_output : glob_output -> unit
119
120 (** Restores the original output that was overridden by [push_output] *)
121 val pop_output : unit -> unit
122
123 (** Alias for [push_output NoGlob] *)
124 val pause : unit -> unit
125
126 (** Deprecated alias for [pop_output] *)
127 val continue : unit -> unit
128 [@@ocaml.deprecated "(8.13) Use pop_output"]
129
130 val with_glob_output : glob_output -> (unit -> 'a) -> unit -> 'a
131
132 val add_glob : ?loc:Loc.t -> Names.GlobRef.t -> unit
133 val add_glob_kn : ?loc:Loc.t -> Names.KerName.t -> unit
134
135 val dump_definition : Names.lident -> bool -> string -> unit
136 val dump_moddef : ?loc:Loc.t -> Names.ModPath.t -> string -> unit
137 val dump_modref : ?loc:Loc.t -> Names.ModPath.t -> string -> unit
138 val dump_reference : ?loc:Loc.t -> string -> string -> string -> unit
139 val dump_secvar : ?loc:Loc.t -> Names.Id.t -> unit
140 val dump_libref : ?loc:Loc.t -> Names.DirPath.t -> string -> unit
141 val dump_notation_location : (int * int) list -> Constrexpr.notation ->
142 (Notation.notation_location * Notation_term.scope_name option) -> unit
143 val dump_binding : ?loc:Loc.t -> string -> unit
144 val dump_notation :
145 Constrexpr.notation CAst.t ->
146 Notation_term.scope_name option -> bool -> unit
147
148 val dump_constraint : Names.lname -> bool -> string -> unit
149
150 val dump_string : string -> unit
151
152 val type_of_global_ref : Names.GlobRef.t -> string
153
154 (** Registration of constant information *)
155 val add_constant_kind : Names.Constant.t -> Decls.logical_kind -> unit
156 val constant_kind : Names.Constant.t -> Decls.logical_kind