diff options
| author | ppedrot | 2013-11-10 04:02:18 +0000 |
|---|---|---|
| committer | ppedrot | 2013-11-10 04:02:18 +0000 |
| commit | 6544bd19001a18aea49c30e94a09649f2dcc61e4 (patch) | |
| tree | d8abecbdac9cf8671e0a2d8167e6327d47e8ac83 /tactics | |
| parent | 36e41e7581c86214a9f0f97436eb96a75b640834 (diff) | |
Removing the dependency of every level of tactic ATSs on glob_tactic_expr.
Instead of putting the body directly in the AST, we register it in a table.
This time it should work properly. Tactic notation are given kernel names to
ensure the unicity of their contents.
git-svn-id: svn+ssh://scm.gforge.inria.fr/svn/coq/trunk@17079 85f007b7-540e-0410-9357-904b9bb8a0f7
Diffstat (limited to 'tactics')
| -rw-r--r-- | tactics/tacenv.ml | 24 | ||||
| -rw-r--r-- | tactics/tacenv.mli | 21 | ||||
| -rw-r--r-- | tactics/tacintern.ml | 4 | ||||
| -rw-r--r-- | tactics/tacinterp.ml | 5 | ||||
| -rw-r--r-- | tactics/tacsubst.ml | 6 | ||||
| -rw-r--r-- | tactics/tactics.mllib | 1 |
6 files changed, 54 insertions, 7 deletions
diff --git a/tactics/tacenv.ml b/tactics/tacenv.ml new file mode 100644 index 0000000000..1a277c7405 --- /dev/null +++ b/tactics/tacenv.ml @@ -0,0 +1,24 @@ +(************************************************************************) +(* v * The Coq Proof Assistant / The Coq Development Team *) +(* <O___,, * INRIA - CNRS - LIX - LRI - PPS - Copyright 1999-2012 *) +(* \VV/ **************************************************************) +(* // * This file is distributed under the terms of the *) +(* * GNU Lesser General Public License Version 2.1 *) +(************************************************************************) + +open Util +open Pp +open Names +open Tacexpr + +type alias = KerName.t + +let alias_map = Summary.ref ~name:"tactic-alias" + (KNmap.empty : (DirPath.t * glob_tactic_expr) KNmap.t) + +let register_alias key dp tac = + alias_map := KNmap.add key (dp, tac) !alias_map + +let interp_alias key = + try KNmap.find key !alias_map + with Not_found -> Errors.anomaly (str "Unknown tactic alias: " ++ KerName.print key) diff --git a/tactics/tacenv.mli b/tactics/tacenv.mli new file mode 100644 index 0000000000..8fada39209 --- /dev/null +++ b/tactics/tacenv.mli @@ -0,0 +1,21 @@ +(************************************************************************) +(* v * The Coq Proof Assistant / The Coq Development Team *) +(* <O___,, * INRIA - CNRS - LIX - LRI - PPS - Copyright 1999-2012 *) +(* \VV/ **************************************************************) +(* // * This file is distributed under the terms of the *) +(* * GNU Lesser General Public License Version 2.1 *) +(************************************************************************) + +open Names +open Tacexpr + +(** This module centralizes the various ways of registering tactics. *) + +type alias = KerName.t +(** Type of tactic alias, used in the [TacAlias] node. *) + +val register_alias : alias -> DirPath.t -> glob_tactic_expr -> unit +(** Register a tactic alias. *) + +val interp_alias : alias -> (DirPath.t * glob_tactic_expr) +(** Recover the the body of an alias. *) diff --git a/tactics/tacintern.ml b/tactics/tacintern.ml index 42ea649ecd..edbec7a047 100644 --- a/tactics/tacintern.ml +++ b/tactics/tacintern.ml @@ -634,9 +634,9 @@ let rec intern_atomic lf ist x = | TacExtend (loc,opn,l) -> !assert_tactic_installed opn; TacExtend (adjust_loc loc,opn,List.map (intern_genarg ist) l) - | TacAlias (loc,s,l,(dir,body)) -> + | TacAlias (loc,s,l) -> let l = List.map (fun (id,a) -> (id,intern_genarg ist a)) l in - TacAlias (loc,s,l,(dir,body)) + TacAlias (loc,s,l) and intern_tactic onlytac ist tac = snd (intern_tactic_seq onlytac ist tac) diff --git a/tactics/tacinterp.ml b/tactics/tacinterp.ml index 248a5d36bf..e6afbbaf73 100644 --- a/tactics/tacinterp.ml +++ b/tactics/tacinterp.ml @@ -2231,7 +2231,8 @@ and interp_atomic ist tac = Proofview.V82.tclEVARS sigma <*> tac args ist end - | TacAlias (loc,s,l,(_,body)) -> + | TacAlias (loc,s,l) -> + let (_, body) = Tacenv.interp_alias s in Proofview.Goal.enter begin fun gl -> let env = Proofview.Goal.env gl in let rec f x = @@ -2332,7 +2333,7 @@ and interp_atomic ist tac = Proofview.Goal.return (Id.Map.add x v accu) in List.fold_right addvar l (Proofview.Goal.return ist.lfun) >>= fun lfun -> - let trace = push_trace (loc,LtacNotationCall s) ist in + let trace = push_trace (loc,LtacNotationCall (KerName.to_string s)) ist in let ist = { lfun = lfun; extra = TacStore.set ist.extra f_trace trace; } in diff --git a/tactics/tacsubst.ml b/tactics/tacsubst.ml index 7c968865ac..7491c9a8f8 100644 --- a/tactics/tacsubst.ml +++ b/tactics/tacsubst.ml @@ -219,9 +219,9 @@ let rec subst_atomic subst (t:glob_atomic_tactic_expr) = match t with (* For extensions *) | TacExtend (_loc,opn,l) -> TacExtend (dloc,opn,List.map (subst_genarg subst) l) - | TacAlias (_,s,l,(dir,body)) -> - TacAlias (dloc,s,List.map (fun (id,a) -> (id,subst_genarg subst a)) l, - (dir,subst_tactic subst body)) + | TacAlias (_,s,l) -> + let s = subst_kn subst s in + TacAlias (dloc,s,List.map (fun (id,a) -> (id,subst_genarg subst a)) l) and subst_tactic subst (t:glob_tactic_expr) = match t with | TacAtom (_loc,t) -> TacAtom (dloc, subst_atomic subst t) diff --git a/tactics/tactics.mllib b/tactics/tactics.mllib index 7b91665adf..f1227c2348 100644 --- a/tactics/tactics.mllib +++ b/tactics/tactics.mllib @@ -15,6 +15,7 @@ Equality Contradiction Inv Leminv +Tacenv Tacsubst Taccoerce Tacintern |
