aboutsummaryrefslogtreecommitdiff
path: root/plugins/decl_mode
diff options
context:
space:
mode:
authorgareuselesinge2013-08-08 18:52:29 +0000
committergareuselesinge2013-08-08 18:52:29 +0000
commitab85be0ab41251ece3b583c3ff38f08f546f6414 (patch)
tree90f90a92f23c84485b943b20fb73937fe95f33c5 /plugins/decl_mode
parent262fa2306196fb279a9b473c0f89fd061458cb0c (diff)
Vernac classification streamlined (handles VERNAC EXTEND)
The warning output by vernacextend when the classifier is missing is the documentation of this commit: Warning: Vernac entry "Foo" misses a classifier. A classifier is a function that returns an expression of type vernac_classification (see Vernacexpr). You can: - Use '... EXTEND Foo CLASSIFIED AS QUERY ...' if the new vernacular command does not alter the system state; - Use '... EXTEND Foo CLASSIFIED AS SIDEFF ...' if the new vernacular command alters the system state but not the parser nor it starts a proof or ends one; - Use '... EXTEND Foo CLASSIFIED BY f ...' to specify a global function f. The function f will be called passing "Foo" as the only argument; - Add a specific classifier in each clause using the syntax: '[...] => [ f ] -> [...]'. Specific classifiers have precedence over global classifiers. Only one classifier is called. git-svn-id: svn+ssh://scm.gforge.inria.fr/svn/coq/trunk@16680 85f007b7-540e-0410-9357-904b9bb8a0f7
Diffstat (limited to 'plugins/decl_mode')
-rw-r--r--plugins/decl_mode/g_decl_mode.ml420
1 files changed, 9 insertions, 11 deletions
diff --git a/plugins/decl_mode/g_decl_mode.ml4 b/plugins/decl_mode/g_decl_mode.ml4
index 072737dab2..f79f717124 100644
--- a/plugins/decl_mode/g_decl_mode.ml4
+++ b/plugins/decl_mode/g_decl_mode.ml4
@@ -16,6 +16,7 @@ open Tok
open Decl_expr
open Names
open Pcoq
+open Vernacexpr
open Pcoq.Constr
open Pcoq.Tactic
@@ -114,11 +115,13 @@ let wit_proof_instr =
let _ = Pptactic.declare_extra_genarg_pprule wit_proof_instr
pr_raw_proof_instr pr_glob_proof_instr pr_proof_instr
+let classify_proof_instr _ = VtProofStep, VtLater
+
(* We use the VERNAC EXTEND facility with a custom non-terminal
to populate [proof_mode] with a new toplevel interpreter.
The "-" indicates that the rule does not start with a distinguished
string. *)
-VERNAC proof_mode EXTEND ProofInstr
+VERNAC proof_mode EXTEND ProofInstr CLASSIFIED BY classify_proof_instr
[ - proof_instr(instr) ] -> [ vernac_proof_instr instr ]
END
@@ -163,10 +166,13 @@ let _ =
}
(* Two new vernacular commands *)
-VERNAC COMMAND EXTEND DeclProof
+let classify_decl _ = VtProofStep, VtNow
+
+VERNAC COMMAND EXTEND DeclProof CLASSIFIED BY classify_decl
[ "proof" ] -> [ vernac_decl_proof () ]
END
-VERNAC COMMAND EXTEND DeclReturn
+VERNAC COMMAND EXTEND DeclReturn CLASSIFIED BY classify_decl
+
[ "return" ] -> [ vernac_return () ]
END
@@ -396,11 +402,3 @@ GLOBAL: proof_instr;
[[ e=emphasis;i=bare_proof_instr;"." -> {emph=e;instr=i}]]
;
END;;
-
-open Vernacexpr
-
-let () =
- Vernac_classifier.declare_vernac_classifier "decl_mode" (function
- | VernacExtend (("DeclProof"|"DeclReturn"), _) -> VtProofStep, VtNow
- | VernacExtend ("ProofInstr", _) -> VtProofStep, VtLater
- | _ -> VtUnknown, VtNow)