blob: ca7f7a0ba6f89d2af26929868dd7f8978931e7cf (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
|
(************************************************************************)
(* v * The Coq Proof Assistant / The Coq Development Team *)
(* <O___,, * INRIA - CNRS - LIX - LRI - PPS - Copyright 1999-2014 *)
(* \VV/ **************************************************************)
(* // * This file is distributed under the terms of the *)
(* * GNU Lesser General Public License Version 2.1 *)
(************************************************************************)
(** This module produces semi-structured pretty-printing. *)
(** A pretty printer module must use an instance of the following
functor to index annotations. The index must be used as Format.tag
during the pretty-printing. *)
(** The indices are Format.tags. *)
type index = Format.tag (* = string *)
module Indexer (Annotation : sig type t end) : sig
(** [index annotation] returns a fresh index for the [annotation]. *)
val index : Annotation.t -> index
(** [get_annotations ()] returns a function to retrieve annotations
from indices after pretty-printing. *)
val get_annotations : unit -> (index -> Annotation.t)
end
(** Each annotation of the semi-structures document refers to the
substring it annotates. *)
type 'annotation located = {
annotation : 'annotation;
startpos : int;
endpos : int
}
(** [rich_pp get_annotations ppcmds] returns the interpretation
of [ppcmds] as a string as well as a semi-structured document
that represents (located) annotations of this string. *)
val rich_pp :
(unit -> (index -> 'annotation)) ->
Pp.std_ppcmds ->
string * ('annotation located) Xml_datatype.gxml
(** [annotations_positions ssdoc] returns a list associating each
annotations with its position in the string from which [ssdoc] is
built. *)
val annotations_positions :
'annotation located Xml_datatype.gxml ->
('annotation * (int * int)) list
(** [xml_of_rich_pp ssdoc] returns an XML representation of the
semi-structured document [ssdoc]. *)
val xml_of_rich_pp :
('annotation -> string) ->
('annotation -> (string * string) list) ->
'annotation located Xml_datatype.gxml ->
Xml_datatype.xml
|