Debian Codegraph @

src/rocq_elpi_programs.mli

raw symbols SCIP
1 (* coq-elpi: Coq terms as the object language of elpi *)
2 (* license: GNU Lesser General Public License Version 2.1 or later *)
3 (* ------------------------------------------------------------------------- *)
4
5 open Elpi.API
6 open Rocq_elpi_utils
7
8 type cunit = Full of Names.KerName.t * Compile.compilation_unit | Signature of Names.KerName.t * Compile.compilation_unit_signature
9 val name_of_cunit : cunit -> string
10 type program_name = Loc.t * qualified_name
11 type what = Code | SignatureOnly
12
13 type src =
14 | File of src_file
15 | DatabaseBody of qualified_name
16 | DatabaseHeader of src_db_header
17 and src_file = {
18 fname : string;
19 fast : cunit;
20 }
21 and src_db_header = {
22 dast : cunit;
23 }
24
25 type nature = Command of { raw_args : bool } | Tactic | Program of { raw_args : bool }
26
27
28 module Chunk : sig
29 type t =
30 | Base of {
31 hash : int;
32 base : cunit list;
33 }
34 | Snoc of {
35 source_rev : cunit list;
36 prev : t;
37 hash : int
38 }
39 val hash : t -> int
40 val eq : t -> t -> bool
41 val pp : Format.formatter -> t -> unit
42
43 end
44
45 module Code : sig
46 type 'db t =
47 | Base of {
48 hash : int;
49 base : cunit;
50 }
51 | Snoc of {
52 source : cunit;
53 prev : 'db t;
54 hash : int;
55 cacheme: bool;
56 }
57 | Snoc_db of {
58 chunks : 'db;
59 prev : 'db t;
60 hash : int
61 }
62 val hash : 'db t -> int
63 val cache : 'db t -> bool
64 val eq : ('db -> 'db -> bool) -> 'db t -> 'db t -> bool
65 val pp : (Format.formatter -> 'db -> unit) -> Format.formatter -> 'db t -> unit
66 val snoc_opt : cunit -> 'db t option -> 'db t
67 end
68
69 module SLMap : Map.S with type key = qualified_name
70
71 val combine_hash : int -> int -> int
72
73
74 (* runtime *)
75
76 module type Programs = sig
77
78 val debug_vars : Compile.StrSet.t ref
79 val cc_flags : unit -> Compile.flags
80 val unit_from_ast : ?error_header:string -> elpi:Setup.elpi -> base:Compile.program -> loc:Loc.t -> Compile.scoped_program -> cunit
81 val parse_goal : elpi:Setup.elpi -> loc:Loc.t -> Ast.Loc.t -> string -> Ast.query
82
83 val db_exists : qualified_name -> bool
84 val program_exists : qualified_name -> bool
85 val declare_db : program_name -> unit
86 val declare_program : program_name -> nature -> unit
87 val declare_file : program_name -> unit
88 val get_nature : qualified_name -> nature
89
90 val init_program : program_name -> loc:Loc.t -> (Ast.Loc.t * string) -> unit
91 val init_command : program_name -> loc:Loc.t -> unit
92 val init_tactic : program_name -> loc:Loc.t -> unit
93 val init_db : program_name -> loc:Loc.t -> (Ast.Loc.t * string) -> unit
94 val init_file : program_name -> loc:Loc.t -> (Ast.Loc.t * string) -> unit
95
96 val ast_of_elpifile : qualified_name -> Compile.scoped_program list
97
98 type db_header
99 val header_of_db : qualified_name -> db_header
100
101 val accumulate_file_to_program : loc:Loc.t -> program:qualified_name -> what:what -> file:string -> unit
102 val accumulate_ast_to_program : loc:Loc.t -> program:qualified_name -> what:what -> ast:Compile.scoped_program -> unit
103 val accumulate_string_to_program : loc:Loc.t -> program:qualified_name -> code:(Ast.Loc.t * string) -> unit
104 val accumulate_plugin_to_program : loc:Loc.t -> program:qualified_name -> plugin:Elpi.API.Setup.builtins -> unit
105 val accumulate_db_to_program : loc:Loc.t -> program:qualified_name -> db:qualified_name -> unit
106 val accumulate_header_to_program : loc:Loc.t -> program:qualified_name -> header:db_header -> unit
107
108 val accumulate_file_to_db : loc:Loc.t -> db:qualified_name -> what:what -> file:string -> scope:Rocq_elpi_utils.clause_scope -> unit
109 val accumulate_ast_to_db : loc:Loc.t -> db:qualified_name -> what:what -> ast:Compile.scoped_program -> scope:Rocq_elpi_utils.clause_scope -> unit
110 val accumulate_string_to_db : loc:Loc.t -> db:qualified_name -> code:(Ast.Loc.t * string) -> scope:Rocq_elpi_utils.clause_scope -> unit
111 val accumulate_units_to_db : loc:Loc.t -> db:qualified_name -> units:cunit list -> secvars:Names.Id.t list -> scope:Rocq_elpi_utils.clause_scope -> unit
112 val accumulate_header_to_db : loc:Loc.t -> db:qualified_name -> header:db_header -> scope:Rocq_elpi_utils.clause_scope -> unit
113
114 val load_command : loc:Loc.t -> string -> unit
115 val load_tactic : loc:Loc.t -> string -> unit
116
117 val ensure_initialized : unit -> Setup.elpi
118
119 val code : ?even_if_empty:bool -> qualified_name -> Chunk.t Code.t option
120
121 val in_stage : string -> string
122 val stage : Summary.Stage.t
123 val db_inspect : qualified_name -> int
124
125 val get_and_compile_existing_db : loc:Loc.t -> qualified_name -> Compile.program
126 val get_and_compile : loc:Loc.t -> ?even_if_empty:bool -> qualified_name -> (Compile.program * bool) option
127
128
129 end
130
131 (** [resolve_file_path ~must_exist ~allow_absolute ~only_elpi file] interprets
132 file path [file] according to the Coq directory path configuration, taking
133 into account the -Q and -R Coq options. If [file] is an absolute path, the
134 functions returns [file] unchanged if [allow_absolute] is set, and gives a
135 user error otherwise. Otherwise, [file] is expected to be of the following
136 form: <coq_dir_path>/<rel_path>. The <coq_dir_path> part is expected to be
137 a logical Coq directory, as mapped with -Q or -R. The <rel_path> part is a
138 relative path from the corresponding directory. When [must_exist] is true,
139 a user error is given when the resolved file does not exist (even if it is
140 handled as an absolute path). When [only_elpi] is true, the function gives
141 a path to a file with the ".elpi" extension, even in the case where [file]
142 does not have an extension. *)
143 val resolve_file_path :
144 must_exist:bool -> allow_absolute:bool -> only_elpi:bool -> string -> string
145
146 module Synterp : Programs
147 module Interp : Programs
148
149 val group_clauses :
150 (qualified_name * Ast.program * Names.variable list * clause_scope) list ->
151 (qualified_name * Ast.program list * Names.variable list * clause_scope) list
152 val document_builtins : unit -> unit