Skip to content

Commit e8d9dd3

Browse files
committed
Ported to Coq 8.10
1 parent ba9b7a0 commit e8d9dd3

File tree

2 files changed

+42
-35
lines changed

2 files changed

+42
-35
lines changed

_CoqProject

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
-I src
33

44
src/smpl_plugin.mlpack
5-
src/smpl.ml4
5+
src/smpl.mlg
66

77
theories/Smpl.v
88
theories/Demo.v

src/smpl.ml4 renamed to src/smpl.mlg

Lines changed: 41 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,25 @@
1-
(*i camlp4deps: "parsing/grammar.cma" i*)
2-
(*i camlp4use: "pa_extend.cmp" i*)
31
(* Written for LVC by Sigurd Schneider (2016-2017) *)
42

3+
DECLARE PLUGIN "smpl_plugin"
4+
5+
{
6+
57
open Util
68
open Names
79
open Ltac_plugin
810
open Tacexpr
9-
open Misctypes
11+
open Locus
1012
open Tacintern
1113
open Tacinterp
1214
open Libobject
1315
open Stdarg
1416
open Extraargs
1517
open Pp
1618
open Tacarg
17-
open Genarg
1819
open Ltac_plugin
1920
open Pcoq.Prim
2021
open Taccoerce
2122

22-
DECLARE PLUGIN "smpl_plugin"
23-
2423
module StringMap = Map.Make(String)
2524

2625
type smpl_db_entry = {
@@ -39,7 +38,7 @@ let smpl_dbs = ref (StringMap.empty : smpl_db StringMap.t)
3938
(*** Summary ***)
4039

4140
let init () = smpl_dbs := StringMap.empty
42-
let freeze _ = !smpl_dbs
41+
let freeze ~marshallable = !smpl_dbs
4342
let unfreeze t = smpl_dbs := t
4443

4544
let _ = Summary.declare_summary "smpl"
@@ -51,7 +50,7 @@ let _ = Summary.declare_summary "smpl"
5150

5251
let intern_smpl_create name db =
5352
try let _ = StringMap.find name (!smpl_dbs) in
54-
CErrors.user_err (~hdr:"Smpl") (str "Smpl Database " ++ str name ++ str " already exists.")
53+
CErrors.user_err ~hdr:"Smpl" (str "Smpl Database " ++ str name ++ str " already exists.")
5554
with Not_found -> smpl_dbs := StringMap.add name db (!smpl_dbs)
5655

5756
let rec insert e l =
@@ -67,7 +66,7 @@ let intern_smpl_add entry name =
6766
try let db = StringMap.find name (!smpl_dbs) in
6867
let db' = { db with queue = insert entry db.queue } in
6968
smpl_dbs := StringMap.add name db' (!smpl_dbs)
70-
with Not_found -> CErrors.user_err (~hdr:"Smpl") (str "Unknown Smpl Database " ++ str name ++ str ".")
69+
with Not_found -> CErrors.user_err ~hdr:"Smpl" (str "Unknown Smpl Database " ++ str name ++ str ".")
7170

7271
type smpl_action =
7372
| CreateDb of string * smpl_db
@@ -126,12 +125,13 @@ let smpl_create db_name db =
126125
let pr_progress b =
127126
str "(" ++ (if b then str "" else str "no") ++ str "progress)"
128127

128+
let fresh_env () =
129+
let env = Global.env () in
130+
let sigma = Evd.from_env env in
131+
env, sigma
132+
129133
let smpl_print_entry e =
130-
let env =
131-
try
132-
let (_, env) = Pfedit.get_current_context () in
133-
env
134-
with e when CErrors.noncritical e -> Global.env ()
134+
let (env,_) = fresh_env ()
135135
in let msg = str "Priority " ++ Pp.int e.priority ++ str " "
136136
++ (match e.require_progress with
137137
| Some b -> pr_progress b
@@ -142,16 +142,16 @@ let smpl_print_entry e =
142142

143143
let smpl_db_exists db_name =
144144
try let db = StringMap.find db_name (!smpl_dbs) in db
145-
with Not_found -> CErrors.user_err (~hdr:"Smpl")
145+
with Not_found -> CErrors.user_err ~hdr:"Smpl"
146146
(str "Unknown Smpl Database " ++ str db_name ++ str ".")
147147

148148
let smpl_print db_name =
149149
try let db = StringMap.find db_name (!smpl_dbs) in
150150
let _ = Feedback.msg_info (str "Printing Smpl DB " ++ str db_name ++
151151
str " " ++ pr_progress db.progress_default ++ str ".") in
152152
let _ = Feedback.msg_info (str "Tactics in priority order:") in
153-
List.iter smpl_print_entry db.queue; ()
154-
with Not_found -> CErrors.user_err (~hdr:"Smpl")
153+
List.iter (smpl_print_entry) db.queue; ()
154+
with Not_found -> CErrors.user_err ~hdr:"Smpl"
155155
(str "Unknown Smpl Database " ++ str db_name ++ str ".")
156156

157157
let smpl_print_dbs () =
@@ -174,10 +174,11 @@ let call_tac glob_tac args =
174174
let cont = Id.of_string "cont" in
175175
Tacinterp.val_interp (default_ist ()) glob_tac
176176
(fun glob_tac_val ->
177-
let tac = TacCall (Loc.tag ((ArgVar (CAst.make cont)), args)) in
177+
let tac = TacCall (CAst.make (ArgVar (CAst.make cont), args)) in
178178
let ist = { lfun = Id.Map.add cont glob_tac_val bindings;
179-
extra = TacStore.empty; } in
180-
Tacinterp.eval_tactic_ist ist (TacArg (Loc.tag tac)))
179+
extra = TacStore.empty;
180+
poly = true; } in
181+
Tacinterp.eval_tactic_ist ist (TacArg (CAst.make tac)))
181182

182183
let smpl_tac_entry entry args =
183184
call_tac entry.tactic args
@@ -207,49 +208,55 @@ let smpl_tac db_name args =
207208
let pr_smpl_opts opts =
208209
prlist (fun s -> spc () ++ str s) opts
209210

210-
VERNAC ARGUMENT EXTEND smpl_opts
211-
PRINTED BY pr_smpl_opts
212-
| [ "[" ne_preident_list(l) "]" ] -> [ l ]
213-
| [ ] -> [ [] ]
211+
}
212+
213+
214+
VERNAC ARGUMENT EXTEND smpl_opts PRINTED BY {pr_smpl_opts}
215+
| [ "[" ne_preident_list(l) "]" ] -> { l }
216+
| [ ] -> { [] }
214217
END
215218

219+
{
216220
let pr_smpldb _prc _prlc _prt s = str s
221+
}
217222

218223
ARGUMENT EXTEND smpldb
219-
TYPED AS preident
220-
PRINTED BY pr_smpldb
221-
| [ preident(i) ] -> [ let _ = smpl_db_exists i in i ]
224+
TYPED AS preident
225+
PRINTED BY { pr_smpldb }
226+
| [ preident(i) ] -> { let _ = smpl_db_exists i in i }
222227
END
223228

224-
229+
{
225230
let rec is_opt_set opt opts =
226231
match opts with
227232
| o::opts -> if String.compare o opt == 0 then Some true
228233
else if String.compare o (String.concat "" ["no"; opt]) == 0 then Some false
229234
else is_opt_set opt opts
230235
| [] -> None
231236

237+
}
238+
232239
VERNAC COMMAND EXTEND SmplCreate CLASSIFIED AS SIDEFF
233240
| [ "Smpl" "Create" preident(db) smpl_opts(opts) ] ->
234-
[ smpl_create db { queue = [];
235-
progress_default = bool_unopt (is_opt_set "progress" opts) false } ]
241+
{ smpl_create db { queue = [];
242+
progress_default = bool_unopt (is_opt_set "progress" opts) false } }
236243
END
237244

238245
VERNAC COMMAND EXTEND SmplAdd CLASSIFIED AS SIDEFF
239246
| [ "Smpl" "Add" natural_opt(n) smpl_opts(opts) tactic(tac) ":" preident (db) ] ->
240-
[ smpl_add n (glob_tactic tac) (is_opt_set "progress" opts) db ]
247+
{ smpl_add n (glob_tactic tac) (is_opt_set "progress" opts) db }
241248
END
242249

243250
VERNAC COMMAND EXTEND SmplPrint CLASSIFIED AS QUERY
244251
| [ "Smpl" "Print" preident(db) ] ->
245-
[ smpl_print db ]
252+
{ smpl_print db }
246253
END
247254

248255
VERNAC COMMAND EXTEND SmplPrintAll CLASSIFIED AS QUERY
249256
| [ "Smpl" "Databases" ] ->
250-
[ smpl_print_dbs () ]
257+
{ smpl_print_dbs () }
251258
END
252259

253260
TACTIC EXTEND smpl
254-
| [ "smpl" smpldb(db) uconstr_list(args) ] -> [ smpl_tac db args ]
261+
| [ "smpl" smpldb(db) uconstr_list(args) ] -> { smpl_tac db args }
255262
END

0 commit comments

Comments
 (0)