package coq-serapi

  1. Overview
  2. Docs
Legend:
Page
Library
Module
Module type
Parameter
Class
Class type
Source

Source file sertop_arg.ml

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
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
(************************************************************************)
(*         *   The Coq Proof Assistant / The Coq Development Team       *)
(*  v      *   INRIA, CNRS and contributors - Copyright 1999-2018       *)
(* <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)         *)
(************************************************************************)

(************************************************************************)
(* Coq serialization API/Plugin                                         *)
(* Copyright 2016-2018 MINES ParisTech -- Dual License LGPL 2.1 / GPL3+ *)
(* Written by: Emilio J. Gallego Arias                                  *)
(************************************************************************)
(* Status: Very Experimental                                            *)
(************************************************************************)

open Cmdliner

[@@@ocaml.warning "-44-45"]
let prelude =
  let doc = "Load Coq.Init.Prelude from $(docv); plugins/ and theories/ should live there." in
  Arg.(value & opt string Coq_config.coqlib & info ["coqlib"] ~docv:"COQPATH" ~doc)

let require_lib =
  let doc = "Coq module to require." in
  Arg.(value & opt (some string) None & info ["require-lib"] ~doc)

let str_pp =
  let doc = "Pretty-print constr strings." in
  Arg.(value & flag & info ["str-pp"] ~doc)

let de_bruijn =
  let doc = "Print constrs with de Bruijn indices." in
  Arg.(value & flag & info ["de-bruijn"] ~doc)

let body =
  let doc = "Print bodies of constrs." in
  Arg.(value & flag & info ["body"] ~doc)

let async =
  let doc = "Enable async support using Coq binary $(docv) (experimental)." in
  Arg.(value & opt (some string) None & info ["async"] ~doc ~docv:"COQTOP")

let quick =
  let doc = "Skip checking opaque proofs (very experimental)." in
  Arg.(value & flag & info ["quick"] ~doc)

let async_full =
  let doc = "Enable Coq's async_full option." in
  Arg.(value & flag & info ["async-full"] ~doc)

let deep_edits =
  let doc = "Enable Coq's deep document edits option." in
  Arg.(value & flag & info ["deep-edits"] ~doc)

let async_workers =
  let doc = "Maximum number of async workers." in
  Arg.(value & opt int 3 & info ["async-workers"] ~doc)

let error_recovery =
  let doc = "Enable Coq's error recovery inside tactics and commands." in
  Arg.(value & flag & info ["error-recovery"] ~doc)

let implicit_stdlib =
  let doc = "No-op (used to allow loading unqualified stdlib libraries, which is now the default)." in
  Arg.(value & flag & info ["implicit"] ~doc)

let print_args = let open Sertop_ser in
  Arg.(enum ["sertop", SP_Sertop; "human", SP_Human; "mach", SP_Mach])

let print_args_doc = Arg.doc_alts
  ["sertop, a custom printer (UTF-8 with emacs-compatible quoting)";
   "human, sexplib's human-format printer (recommended for debug sessions)";
   "mach, sexplib's machine-format printer"
  ]

let printer =
  let open Sertop_ser in
  (* XXX Must improve argument information *)
  (* let doc = "Select S-expression printer." in *)
  Arg.(value & opt print_args SP_Sertop & info ["printer"] ~doc:print_args_doc)

let debug =
  let doc = "Enable debug mode for Coq." in
  Arg.(value & flag & info ["debug"] ~doc)

let disallow_sprop =
  let doc = "Forbid using the proof irrelevant SProp sort (allowed by default)" in
  Arg.(value & flag & info ["disallow-sprop"] ~doc)

let indices_matter =
  let doc = "Levels of indices (and nonuniform parameters) contribute to the level of inductives (disabled by default)" in
  Arg.(value & flag & info ["indices-matter"] ~doc)

let print0 =
  let doc = "End responses with a \\\\0 char." in
  Arg.(value & flag & info ["print0"] ~doc)

let length =
  let doc = "Emit a byte-length header before output. (deprecated)." in
  Arg.(value & flag & info ["length"] ~doc)

(* We handle the conversion here *)

let no_init =
  let doc = "Omits the creation of a new document; this means the user \
             will have to call `(NewDoc ...)` before Coq can be used \
             and set there the proper loadpath, requires, ..." in
  Arg.(value & flag & info ["no_init"] ~doc)

let topfile =
  let doc = "Set the toplevel name as though compiling $(docv)" in
  Arg.(value & opt (some string) None & info ["topfile"] ~doc ~docv:"TOPFILE")



let no_prelude =
  let doc = "Omits requiring any module on start, thus `Prelude`, ltac, etc... won't be available" in
  Arg.(value & flag & info ["no_prelude"] ~doc)

let coq_lp_conv ~implicit (unix_path,lp) = Loadpath.{
    path_spec = VoPath {
        coq_path  = Libnames.dirpath_of_string lp;
        unix_path;
        has_ml    = AddRecML;
        implicit;
      };
    recursive = true;
  }

let rload_path : Loadpath.coq_path list Term.t =
  let doc = "Bind a logical loadpath LP to a directory DIR and implicitly open its namespace." in
  Term.(const List.(map (coq_lp_conv ~implicit:true)) $
        Arg.(value & opt_all (pair dir string) [] & info ["R"; "rec-load-path"] ~docv:"DIR,LP"~doc))

let load_path : Loadpath.coq_path list Term.t =
  let doc = "Bind a logical loadpath LP to a directory DIR" in
  Term.(const List.(map (coq_lp_conv ~implicit:false)) $
        Arg.(value & opt_all (pair dir string) [] & info ["Q"; "load-path"] ~docv:"DIR,LP" ~doc))

let coq_include_conv unix_path = Loadpath.{
    path_spec = MlPath unix_path;
    recursive = false;
  }

let ml_include_path : Loadpath.coq_path list Term.t =
  let doc = "Include DIR in default loadpath, for locating ML files" in
  Term.(const List.(map coq_include_conv) $
        Arg.(value & opt_all dir [] & info ["I"; "ml-include-path"] ~docv:"DIR" ~doc))

(* Low-level serialization options for display *)
let omit_loc : bool Term.t =
  let doc = "[debug option] shorten location printing" in
  Arg.(value & flag & info ["omit_loc"] ~doc)

let omit_att : bool Term.t =
  let doc = "[debug option] omit attribute nodes" in
  Arg.(value & flag & info ["omit_att"] ~doc)

let exn_on_opaque : bool Term.t =
  let doc = "[debug option] raise an exception on non-serializeble terms" in
  Arg.(value & flag & info ["exn_on_opaque"] ~doc)

(* sertop options *)
type comp_mode = | C_parse | C_stats | C_print | C_sexp | C_check | C_vo | C_env

let comp_mode_args =
  Arg.(enum
         [ "parse", C_parse
         ; "stats", C_stats
         ; "print", C_print
         ; "sexp",  C_sexp
         ; "check", C_check
         ; "vo",    C_vo
         ; "kenv",  C_env
         ])

let comp_mode_doc = Arg.doc_alts
  [ "parse: parse the file and remain silent (except for Coq output)"
  ; "stats: output stats on the input file"
  ; "print: output using the Coq pretty printer"
  ;  "sexp: output serialized version of the input file"
  ; "check: check proofs in the file and remain silent (except for Coq output)"
  ;    "vo: check proofs and output .vo version of the input file"
  ;  "kenv: check proofs and output the final kernel enviroment"
  ]

let comp_mode =
  Arg.(value & opt comp_mode_args C_parse & info ["mode"] ~doc:comp_mode_doc)

type comp_input = | I_vernac | I_sexp

let comp_input_args =
  Arg.(enum
         [ "vernac", I_vernac
         ; "sexp", I_sexp])

let comp_input_doc = Arg.doc_alts
  [ "vernac: Coq vernacular"
  ;   "sexp: serialized Coq vernacular"
  ]

let comp_input =
  Arg.(value & opt comp_input_args I_vernac & info ["input"] ~doc:comp_input_doc)
OCaml

Innovation. Community. Security.