123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118(************************************************************************)(* * 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) *)(************************************************************************)(* This file is (C) Copyright 2006-2015 Microsoft Corporation and Inria. *)openPpopenNamesopenSsrastletpr_spc()=str" "letpr_bar()=Pp.cut()++str"|"letpr_list=prlist_with_sepletpp_concathd?(sep=str", ")=function[]->hd|x::xs->hd++List.fold_left(funaccx->acc++sep++x)xxs(* Term printing utilities functions for deciding bracketing. *)letpr_parenprxx=hov1(str"("++prxx++str")")(* String lexing utilities *)letskip_wscharss=letrecloopi=matchs.[i]with'\n'..' '->loop(i+1)|_->iinloop(* We also guard characters that might interfere with the ssreflect *)(* tactic syntax. *)letguard_termkindsi=matchs.[i]with|'('->false|'{'|'/'|'='->true|_->kind=Ssrmatching_plugin.Ssrmatching.InParens(* We also guard characters that might interfere with the ssreflect *)(* tactic syntax. *)letpr_guardedguardprcc=pp_withFormat.str_formatter(prcc);lets=Format.flush_str_formatter()^"$"inifguards(skip_wscharss0)thenpr_parenprccelseprccletwith_global_env_evmfx=letenv=Global.env()inletsigma=Evd.from_envenvinfenvsigmaxletprl_constr_expr=with_global_env_evmPpconstr.pr_lconstr_exprletpr_glob_constr=with_global_env_evmPrinter.pr_glob_constr_envletprl_glob_constr=with_global_env_evmPrinter.pr_lglob_constr_envletpr_glob_constr_and_expr=function|_,Somec->with_global_env_evmPpconstr.pr_constr_exprc|c,None->pr_glob_constrcletpr_term(k,c)=pr_guarded(guard_termk)pr_glob_constr_and_exprcletpr_hyp(SsrHyp(_,id))=Id.printidletpr_hyps=pr_listpr_spcpr_hypletpr_occ=function|Some(true,occ)->ifCList.is_emptyoccthenmt()elsestr"{-"++pr_listpr_spcintocc++str"}"|Some(false,occ)->ifCList.is_emptyoccthenmt()elsestr"{+"++pr_listpr_spcintocc++str"}"|None->str"{}"letpr_clear_neclr=ifCList.is_emptyclrthenmt()elsestr"{"++pr_hypsclr++str"}"letpr_clearsepclr=sep()++pr_clear_neclrletpr_dir=functionL2R->str"->"|R2L->str"<-"letpr_simpl=function|Simpl-1->str"/="|Cut-1->str"//"|Simpln->str"/"++intn++str"="|Cutn->str"/"++intn++str"/"|SimplCut(-1,-1)->str"//="|SimplCut(n,-1)->str"/"++intn++str"/="|SimplCut(-1,n)->str"//"++intn++str"="|SimplCut(n,m)->str"/"++intn++str"/"++intm++str"="|Nop->mt()(* New terms *)letpr_ast_closure_term{body}=letenv=Global.env()inletsigma=Evd.from_envenvinPpconstr.pr_constr_exprenvsigmabodyletpr_view2=pr_listmt(func->str"/"++pr_ast_closure_termc)letrecpr_ipatp=matchpwith|IPatIdid->Id.printid|IPatSimplsim->pr_simplsim|IPatClearclr->pr_clearmtclr|IPatCase(Regulariorpat)->hov1(str"["++pr_iorpatiorpat++str"]")|IPatCase(Blockm)->hov1(str"["++pr_blockm++str"]")|IPatDispatch(Regulariorpat)->hov1(str"("++pr_iorpatiorpat++str")")|IPatDispatch(Blockm)->hov1(str"("++pr_blockm++str")")|IPatInjiorpat->hov1(str"[="++pr_iorpatiorpat++str"]")|IPatRewrite(occ,dir)->pr_occocc++pr_dirdir|IPatAnonAll->str"*"|IPatAnonDrop->str"_"|IPatAnon(One_)->str"?"|IPatViewv->pr_view2v|IPatAnonTemporary->str"+"|IPatNoop->str"-"|IPatAbstractVarsl->str"[:"++pr_listspcId.printl++str"]"|IPatFastNondep->str">"andpr_ipatsipats=pr_listspcpr_ipatipatsandpr_iorpatiorpat=pr_listpr_barpr_ipatsiorpatandpr_block=function(Prefixid)->str"^"++Id.printid|(SuffixIdid)->str"^~"++Id.printid|(SuffixNumn)->str"^~"++intnletdebug_ssr=CDebug.create~name:"ssreflect"()