1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677(************************************************************************)(* * The Coq Proof Assistant / The Coq Development Team *)(* v * Copyright INRIA, CNRS and contributors *)(* <O___,, * (see version control and CREDITS file for authors & dates) *)(* \VV/ **************************************************************)(* // * This file is distributed under the terms of the *)(* * GNU Lesser General Public License Version 2.1 *)(* * (see LICENSE file for the text of the license) *)(************************************************************************)openNames(* spiwack: I'm choosing, for now, to have [goal_selector] be a
different type than [goal_reference] mostly because if it makes sense
to print a goal that is out of focus (or already solved) it doesn't
make sense to apply a tactic to it. Hence it the types may look very
similar, they do not seem to mean the same thing. *)typet=|SelectAlreadyFocused|SelectNthofint|SelectListof(int*int)list|SelectIdofId.t|SelectAllletpr_range_selector(i,j)=ifi=jthenPp.intielsePp.(inti++str"-"++intj)letpr_goal_selector=function|SelectAlreadyFocused->Pp.str"!"|SelectAll->Pp.str"all"|SelectNthi->Pp.inti|SelectListl->Pp.(str"["++prlist_with_seppr_commapr_range_selectorl++str"]")|SelectIdid->Names.Id.printidletparse_goal_selector=function|"!"->SelectAlreadyFocused|"all"->SelectAll|i->leterr_msg="The default selector must be \"all\", \"!\" or a natural number."inbegintryleti=int_of_stringiinifi<0thenCErrors.user_errPp.(strerr_msg);SelectNthiwithFailure_->CErrors.user_errPp.(strerr_msg)end(* Default goal selector: selector chosen when a tactic is applied
without an explicit selector. *)let{Goptions.get=get_default_goal_selector}=Goptions.declare_interpreted_string_option_and_refparse_goal_selector(funv->Pp.string_of_ppcmds@@pr_goal_selectorv)~key:["Default";"Goal";"Selector"]~value:(SelectNth1)()(* Select a subset of the goals *)lettclSELECT?nosuchgoalgtac=matchgwith|SelectNthi->Proofview.tclFOCUS?nosuchgoaliitac|SelectListl->Proofview.tclFOCUSLIST?nosuchgoalltac|SelectIdid->Proofview.tclFOCUSID?nosuchgoalidtac|SelectAll->tac|SelectAlreadyFocused->letopenProofview.NotationsinProofview.numgoals>>=funn->ifn==1thentacelselete=CErrors.UserErrorPp.(str"Expected a single focused goal but "++intn++str" goals are focused.")inletinfo=Exninfo.reify()inProofview.tclZERO~infoe