From ab85be0ab41251ece3b583c3ff38f08f546f6414 Mon Sep 17 00:00:00 2001 From: gareuselesinge Date: Thu, 8 Aug 2013 18:52:29 +0000 Subject: 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 --- plugins/decl_mode/g_decl_mode.ml4 | 20 +++++++++----------- 1 file changed, 9 insertions(+), 11 deletions(-) (limited to 'plugins/decl_mode') 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) -- cgit v1.2.3