-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathdocument.mli
89 lines (65 loc) · 3.21 KB
/
document.mli
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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
(************************************************************************)
(* * The Coq Proof Assistant / The Coq Development Team *)
(* v * INRIA, CNRS and contributors - Copyright 1999-2019 *)
(* <O___,, * (see CREDITS file for the list of authors) *)
(* \VV/ **************************************************************)
(* // * This file is distributed under the terms of the *)
(* * GNU Lesser General Public License Version 2.1 *)
(* * (see LICENSE file for the text of the license) *)
(************************************************************************)
open Types
(** This file defines operations on the content of a document (text, parsing
of sentences, scheduling). *)
type parsing_state_hook = sentence_id -> Vernacstate.Parser.t option
(** The document gathers the text, which is partially validated (parsed into
sentences *)
type document
val create_document : string -> document
(** [create_document text] creates a fresh document with content defined by
[text]. *)
val id_of_doc : document -> int
(** Unique id of the document *)
val validate_document : parsing_state_hook:parsing_state_hook ->
document -> sentence_id_set * document
(** [validate_document doc] parses the document without forcing any execution
and returns the set of invalidated sentences *)
val parse_errors : document -> (sentence_id * (Loc.t option * string)) list
(** [parse_errors doc] returns the list of sentences which failed to parse
(see validate_document) together with their error message *)
type text_edit = Range.t * string
val apply_text_edits : document -> text_edit list -> document
(** [apply_text_edits doc edits] updates the text of [doc] with [edits]. The
new text is not parsed or executed. *)
type parsed_ast =
| ValidAst of ast * Tok.t list (* the list of tokens generating ast, a sort of fingerprint to compare ASTs *)
| ParseError of string Loc.located
type sentence = {
start : int;
stop : int;
parsing_state : Vernacstate.Parser.t; (* st used to parse this sentence *)
scheduler_state_before : Scheduler.state;
scheduler_state_after : Scheduler.state;
ast : parsed_ast;
id : sentence_id;
}
val sentences : document -> sentence list
val get_sentence : document -> sentence_id -> sentence option
val sentences_before : document -> int -> sentence list
val find_sentence : document -> int -> sentence option
(** [find_sentence doc loc] finds the sentence containing the loc *)
val find_sentence_before : document -> int -> sentence option
(** [find_sentence_before doc loc] finds the last sentence before the loc *)
val more_to_parse : document -> bool
(** [more_to_parse doc] is false if the entire text was parsed *)
val parsed_loc : document -> int
(** the last loc of the document which was parsed *)
val end_loc : document -> int
(** the last loc of the document *)
val schedule : document -> Scheduler.schedule
val text : document -> string
(** the whole text *)
(* Fishy APIs *)
val range_of_exec_id : document -> Stateid.t -> Range.t
val range_of_coq_loc : document -> Loc.t -> Range.t
val position_of_loc : document -> int -> Position.t
val position_to_loc : document -> Position.t -> int