@@ -251,7 +251,6 @@ type tactic_grammar_obj = {
251
251
tacobj_key : KerName .t ;
252
252
tacobj_local : locality_flag ;
253
253
tacobj_tacgram : tactic_grammar ;
254
- tacobj_body : Tacenv .alias_tactic ;
255
254
tacobj_forml : bool ;
256
255
}
257
256
@@ -265,71 +264,103 @@ let check_key key =
265
264
user_err Pp. (str " Conflicting tactic notations keys. This can happen when including \
266
265
twice the same module." )
267
266
268
- let cache_tactic_notation tobj =
267
+ let cache_tactic_notation ( tobj , body ) =
269
268
let key = tobj.tacobj_key in
270
269
let () = check_key key in
271
- Tacenv. register_alias key tobj.tacobj_body;
272
- extend_tactic_grammar key tobj.tacobj_forml tobj.tacobj_tacgram;
273
- Pptactic. declare_notation_tactic_pprule key (pprule tobj.tacobj_tacgram)
270
+ Tacenv. register_alias key body
274
271
275
- let open_tactic_notation i tobj =
276
- let key = tobj.tacobj_key in
277
- if Int. equal i 1 && not tobj.tacobj_local then
278
- extend_tactic_grammar key tobj.tacobj_forml tobj.tacobj_tacgram
272
+ let open_tactic_notation i _ = ()
279
273
280
- let load_tactic_notation i tobj =
274
+ let load_tactic_notation i ( tobj , body ) =
281
275
let key = tobj.tacobj_key in
282
276
let () = check_key key in
283
277
(* Only add the printing and interpretation rules. *)
284
- Tacenv. register_alias key tobj.tacobj_body;
285
- Pptactic. declare_notation_tactic_pprule key (pprule tobj.tacobj_tacgram);
286
- if Int. equal i 1 && not tobj.tacobj_local then
287
- extend_tactic_grammar key tobj.tacobj_forml tobj.tacobj_tacgram
278
+ Tacenv. register_alias key body
288
279
289
- let subst_tactic_notation (subst , tobj ) =
280
+ let subst_tactic_notation (subst , ( tobj , body ) ) =
290
281
let open Tacenv in
291
- let alias = tobj.tacobj_body in
292
282
{ tobj with
293
- tacobj_key = Mod_subst. subst_kn subst tobj.tacobj_key;
294
- tacobj_body = { alias with alias_body = Tacsubst. subst_tactic subst alias.alias_body };
295
- }
283
+ tacobj_key = Mod_subst. subst_kn subst tobj.tacobj_key
284
+ },
285
+ { body with alias_body = Tacsubst. subst_tactic subst body.alias_body }
296
286
297
287
let classify_tactic_notation tacobj = Substitute
298
288
299
289
let ltac_notation_cat = Libobject. create_category " ltac.notations"
300
290
301
- let inTacticGrammar : tactic_grammar_obj -> obj =
291
+ let inTacticGrammar : tactic_grammar_obj * Tacenv.alias_tactic -> obj =
302
292
declare_object {(default_object " TacticGrammar" ) with
303
293
open_function = simple_open ~cat: ltac_notation_cat open_tactic_notation;
304
294
load_function = load_tactic_notation;
305
295
cache_function = cache_tactic_notation;
306
296
subst_function = subst_tactic_notation;
307
297
classify_function = classify_tactic_notation}
308
298
299
+ let cache_tactic_syntax tobj =
300
+ let key = tobj.tacobj_key in
301
+ extend_tactic_grammar key tobj.tacobj_forml tobj.tacobj_tacgram;
302
+ Pptactic. declare_notation_tactic_pprule key (pprule tobj.tacobj_tacgram)
303
+
304
+ let open_tactic_syntax i tobj =
305
+ let key = tobj.tacobj_key in
306
+ if Int. equal i 1 && not tobj.tacobj_local then
307
+ extend_tactic_grammar key tobj.tacobj_forml tobj.tacobj_tacgram
308
+
309
+ let load_tactic_syntax i tobj =
310
+ let key = tobj.tacobj_key in
311
+ (* Only add the printing and interpretation rules. *)
312
+ Pptactic. declare_notation_tactic_pprule key (pprule tobj.tacobj_tacgram);
313
+ if Int. equal i 1 && not tobj.tacobj_local then
314
+ extend_tactic_grammar key tobj.tacobj_forml tobj.tacobj_tacgram
315
+
316
+ let subst_tactic_syntax (subst , tobj ) =
317
+ { tobj with
318
+ tacobj_key = Mod_subst. subst_kn subst tobj.tacobj_key
319
+ }
320
+
321
+ let classify_tactic_syntax tacobj = Substitute
322
+
323
+ let inTacticSyntax : tactic_grammar_obj -> obj =
324
+ declare_object {(default_object " TacticSyntax" ) with
325
+ object_stage = Summary.Stage. Synterp ;
326
+ open_function = simple_open ~cat: ltac_notation_cat open_tactic_syntax;
327
+ load_function = load_tactic_syntax;
328
+ cache_function = cache_tactic_syntax;
329
+ subst_function = subst_tactic_syntax;
330
+ classify_function = classify_tactic_syntax}
331
+
309
332
let cons_production_parameter = function
310
333
| TacTerm _ -> None
311
334
| TacNonTerm (_ , (_ , ido )) -> ido
312
335
313
- let add_glob_tactic_notation local ~level ?deprecation prods forml ids tac =
336
+ let add_glob_tactic_notation ?deprecation tacobj ids tac =
337
+ let open Tacenv in
338
+ let body =
339
+ { alias_args = ids; alias_body = tac; alias_deprecation = deprecation } in
340
+ Lib. add_leaf (inTacticGrammar (tacobj, body))
341
+
342
+ let add_glob_tactic_notation_syntax local ~level ?deprecation prods forml =
314
343
let parule = {
315
344
tacgram_level = level;
316
345
tacgram_prods = prods;
317
346
} in
318
- let open Tacenv in
319
347
let tacobj = {
320
348
tacobj_key = make_fresh_key prods;
321
349
tacobj_local = local;
322
350
tacobj_tacgram = parule;
323
- tacobj_body = { alias_args = ids; alias_body = tac; alias_deprecation = deprecation };
324
351
tacobj_forml = forml;
325
352
} in
326
- Lib. add_leaf (inTacticGrammar tacobj)
353
+ Lib. add_leaf (inTacticSyntax tacobj);
354
+ tacobj
327
355
328
- let add_tactic_notation local n ?deprecation prods e =
329
- let ids = List. map_filter cons_production_parameter prods in
330
- let prods = List. map interp_prod_item prods in
356
+ let add_tactic_notation ?deprecation tacobj e =
357
+ let ids = List. map_filter cons_production_parameter tacobj.tacobj_tacgram.tacgram_prods in
331
358
let tac = Tacintern. glob_tactic_env ids (Global. env() ) e in
332
- add_glob_tactic_notation local ~level: n ?deprecation prods false ids tac
359
+ add_glob_tactic_notation ?deprecation tacobj ids tac
360
+
361
+ let add_tactic_notation_syntax local n ?deprecation prods =
362
+ let prods = List. map interp_prod_item prods in
363
+ add_glob_tactic_notation_syntax local ~level: n ?deprecation prods false
333
364
334
365
(* *********************************************************************)
335
366
(* ML Tactic entries *)
@@ -381,7 +412,8 @@ let add_ml_tactic_notation name ~level ?deprecation prods =
381
412
let entry = { mltac_name = name; mltac_index = len - i - 1 } in
382
413
let map id = Reference (Locus. ArgVar (CAst. make id)) in
383
414
let tac = CAst. make (TacML (entry, List. map map ids)) in
384
- add_glob_tactic_notation false ~level ?deprecation prods true ids tac
415
+ let tacobj = add_glob_tactic_notation_syntax false ~level ?deprecation prods true in
416
+ add_glob_tactic_notation ?deprecation tacobj ids tac
385
417
in
386
418
List. iteri iter (List. rev prods);
387
419
(* We call [extend_atomic_tactic] only for "basic tactics" (the ones
0 commit comments