123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853(************************************************************************)(* * 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) *)(************************************************************************)(*i*)openCErrorsopenUtilopenPpopenCAstopenNamesopenLibnamesopenPputilsopenPpextendopenGlob_termopenConstrexpropenConstrexpr_ops(*i*)moduleTag=structletkeyword="constr.keyword"letevar="constr.evar"letuniv="constr.type"letnotation="constr.notation"letvariable="constr.variable"letreference="constr.reference"letpath="constr.path"endletdo_not_tag_x=xlettagts=Pp.tagtslettag_keyword=tagTag.keywordlettag_evar=tagTag.evarlettag_type=tagTag.univlettag_unparsing=function|UnpTerminals->tagTag.notation|_->do_not_tag()lettag_constr_expr=do_not_taglettag_path=tagTag.pathlettag_ref=tagTag.referencelettag_var=tagTag.variableletkeywords=tag_keyword(strs)letsep_v=fun_->str","++spc()letpr_tight_coma()=str","++cut()letlatom=0letlprod=200letllambda=200letlif=200letlletin=200letlletpattern=200letlfix=200letlcast=100letlarg=9letlapp=Notation.app_levelletlposint=0letlnegint=35(* must be consistent with Notation "- x" *)letltop=LevelLe200letlproj=1letldelim=1letlsimpleconstr=LevelLe8letlsimplepatt=LevelLe1letno_after=Noneletoverlap_right_leftwhichslev_after=let{notation_printing_unparsing=unpl}=find_notation_printing_rulewhichsinletrecaux=function|[]->false|[UnpMetaVarsubentry|UnpListMetaVar(subentry,_)]->ifNotationextern.notation_entry_eqsubentry.notation_subentryInConstrEntrythenNotation.may_capture_cont_afterlev_aftersubentry.notation_relative_levelelse(* Handled in constextern.ml *)false|[UnpBox(b,sub)]->aux(List.mapsndsub)|(UnpMetaVar_|UnpListMetaVar_|UnpBinderMetaVar_|UnpBinderListMetaVar_|UnpTerminal_|UnpBox_|UnpCut_)::l->auxlinauxunplletprec_of_prim_token=function|Number(NumTok.SPlus,_)->lposint|Number(NumTok.SMinus,_)->lnegint|String_->latomletadjust_levelsidelev_afterl_notprec=matchsidewith|Some_when!Constrextern.print_parentheses->no_after,LevelLe0|SomeRight->(ifNotation.may_capture_cont_afterlev_afterprecthenno_afterelselev_after),prec|SomeLeft->Somel_not,prec|None->no_after,prec(* should we care about the separator being possibly empty? *)letprint_hunksl_notlev_afterprpr_pattpr_binders(terms,termlists,binders,binderlists)unps=letenv=reftermsandenvlist=reftermlistsandbl=refbindersandbll=refbinderlistsinletpopr=leta=List.hd!rinr:=List.tl!r;ainletreturnunppp1pp2=(tag_unparsingunppp1)++pp2in(* Warning:
The following function enforces a very precise order of
evaluation of sub-components.
Do not modify it unless you know what you are doing! *)letrecaux=function|[]->mt()|UnpMetaVar{notation_relative_level=prec;notation_position=side}asunp::l->letc=popenvinletpp2=auxlinletlev_after,prec=adjust_levelsidelev_afterl_notprecinletpp1=prlev_afterpreccinreturnunppp1pp2|UnpBinderMetaVar(subentry,style)asunp::l->letc,bk=popblinletpp2=auxlinletpp1=pr_pattsubentry.notation_relative_levelstylebkcinreturnunppp1pp2|UnpListMetaVar({notation_relative_level=prec;notation_position=side},sl)asunp::l->letlev_after',prec'=adjust_levelsidelev_afterl_notprecinletpp1=matchpopenvlistwith|[]->assertfalse|[c]->prlev_after'prec'c|c1::cl->letcn,cl=List.sep_lastclinprlev_after'precc1++prlist(func->auxsl++pr(ifList.is_emptyslthenSomel_notelseno_after)precc)cl++auxsl++prlev_afterprec'cninletpp2=auxlinreturnunppp1pp2|UnpBinderListMetaVar(isopen,withquote,sl)asunp::l->letcl=popbllinletpp2=auxlinletpp1=pr_binders(fun()->auxsl)isopenwithquoteclinreturnunppp1pp2|UnpTerminalsasunp::l->letpp2=auxlinletpp1=strsinreturnunppp1pp2|UnpBox(b,sub)asunp::l->letpp1=ppcmd_of_boxb(aux(List.mapsndsub))inletpp2=auxlinreturnunppp1pp2|UnpCutcutasunp::l->letpp2=auxlinletpp1=ppcmd_of_cutcutinreturnunppp1pp2inauxunpsletpr_notationlev_afterprpr_pattpr_binderswhichsenv=let{notation_printing_unparsing=unpl;notation_printing_level=level}=find_notation_printing_rulewhichsinprint_hunkslevellev_afterprpr_pattpr_bindersenvunplletpr_delimitersdepthkeystrm=letd=matchdepthwithDelimOnlyTmpScope->"%_"|DelimUnboundedScope->"%"instrm++str(d^key)letpr_generalizationbkc=lethd,tl=matchbkwith|NonMaxImplicit->"[","]"|MaxImplicit->"{","}"|Explicit->"(",")"in(* TODO: syntax Abstraction Kind *)str"`"++strhd++c++strtlletpr_com_atn=if!Flags.beautify&¬(Int.equaln0)thencomment(Pputils.extract_commentsn)elsemt()letpr_with_comments?locpp=pr_located(funx->x)(loc,pp)letpr_sep_comsepfc=pr_with_comments?loc:(constr_locc)(sep()++fc)letpr_sort_name_expr=function|CSProp->str"SProp"|CProp->str"Prop"|CSet->str"Set"|CTypeqid->pr_qualidqid|CRawTypes->Univ.Level.raw_prsletpr_univ_level_expr=function|UNameds->tag_type(pr_sort_name_exprs)|UAnonymous{rigid=UnivRigid}->tag_type(str"Type")|UAnonymous{rigid=UnivFlexibleb}->assert(notb);tag_type(str"_")letpr_univ_expr(u,n)=tag_type(pr_sort_name_expru)++(matchnwith0->mt()|_->str"+"++intn)letpr_univl=matchlwith|UNamed[x]->pr_univ_exprx|UNamedl->str"max("++prlist_with_sep(fun()->str",")pr_univ_exprl++str")"|UAnonymous{rigid=UnivRigid}->tag_type(str"Type")|UAnonymous{rigid=UnivFlexibleb}->tag_type(str"Type")letpr_qvar_expr=function|CQAnon_->tag_type(str"_")|CQVarqid->tag_type(pr_qualidqid)|CRawQVarq->(* TODO names *)tag_type(Sorts.QVar.raw_prq)letpr_relevance=function|CRelevant->str"Relevant"|CIrrelevant->str"Irrelevant"|CRelevanceVarq->pr_qvar_exprqletpr_relevance_info=function|None->mt()|Somer->str"(* "++pr_relevancer++str" *) "letpr_quality_exprq=matchqwith|CQConstantq->tag_type(Sorts.Quality.Constants.prq)|CQualVarq->pr_qvar_exprqletpr_quality_univ(q,l)=matchqwith|None->pr_univl|Someq->pr_qvar_exprq++spc()++str"|"++spc()++pr_univlletpr_univ_annotprx=str"@{"++prx++str"}"letpr_sort_expr:sort_expr->Pp.t=function|None,UNamed[CSProp,0]->tag_type(str"SProp")|None,UNamed[CProp,0]->tag_type(str"Prop")|None,UNamed[CSet,0]->tag_type(str"Set")|None,UAnonymous{rigid=UnivRigid}->tag_type(str"Type")|u->hov0(tag_type(str"Type")++pr_univ_annotpr_quality_univu)letpr_qualidsp=let(sl,id)=repr_qualidspinletid=tag_ref(Id.printid)inletsl=matchList.rev(DirPath.reprsl)with|[]->mt()|sl->letprdir=tag_path(Id.printdir)++str"."inprlistprslinsl++idletpr_id=Id.printletpr_qualid=pr_qualidletpr_patvar=pr_idletpr_inside_universe_instance(ql,ul)=(ifList.is_emptyqlthenmt()elseprlist_with_sepspcpr_quality_exprql++strbrk" | ")++prlist_with_sepspcpr_univ_level_exprulletpr_universe_instancel=pr_opt_no_spc(pr_univ_annotpr_inside_universe_instance)lletpr_referenceqid=ifqualid_is_identqidthentag_var(pr_id@@qualid_basenameqid)elsepr_qualidqidletpr_crefrefus=pr_referenceref++pr_universe_instanceusletpr_expl_argsprlev_after(a,expl)=matchexplwith|None->prlev_after(LevelLtlapp)a|Some{v=pos}->letpr_pos=function|ExplByNameid->pr_idid|ExplByPosp->intpinstr"("++pr_pospos++str":="++prno_afterltopa++str")"letis_anonymous_hole=function|Some(GNamedHole_)->false|_->trueletpr_opt_type_spcpr=function|{CAst.v=CHoleh}whenis_anonymous_holeh->mt()|t->str" :"++pr_sep_com(fun()->brk(1,4))(prno_afterltop)tletpr_prim_token=function|Numbern->NumTok.Signed.printn|Strings->qssletpr_evarpridl=hov0(tag_evar(str"?"++pr_lidentid)++(matchlwith|[]->mt()|l->letf(id,c)=pr_lidentid++str":="++prno_afterltopcinstr"@{"++hov0(prlist_with_seppr_semicolonf(List.revl))++str"}"))(* Assuming "{" and "}" brackets, prints
- if there is enough room
{ a; b; c }
- otherwise
{
a;
b;
c
}
Alternatively, replace outer hv with h to get instead:
{ a;
b;
c }
Replace the inner hv with hov to respectively get instead (if enough room):
{
a; b;
c
}
or
{ a; b;
c }
*)letpr_recordleftrightpr=function|[]->strleft++str" "++strright|l->hv0(strleft++brk(1,String.lengthleft)++hv0(prlist_with_seppr_semicolonprl)++brk(1,0)++strright)letpr_record_bodyleftrightprl=letpr_defined_field(id,c)=hov2(pr_referenceid++str" :="++prc)inpr_recordleftrightpr_defined_fieldlletlas=lappletlpator=0letlpatrec=0letlpatcast=LevelLe100letlpattop=LevelLe200letrecpr_patt_argsprlev_afterargs=matchargswith|[]->mt()|args->letlast,args=List.sep_lastargsinprlist(pr_pattspcpr(Somelapp)(LevelLtlapp))args++pr_pattspcprlev_after(LevelLtlapp)lastandpr_pattsepprlev_afterinhp=letreturncmdsprec=letno_surround=Notation.prec_lessprecinhinletlev_after=ifno_surroundthenlev_afterelseno_afterinletpp=cmdslev_afterinletpp=ifno_surroundthenppelsesurroundppinpr_with_comments?loc:p.CAst.loc(sep()++pp)inmatchCAst.(p.v)with|CPatRecordl->return(funlev_after->pr_record_body"{|""|}"(pr_pattspcprno_afterlpattop)l)lpatrec|CPatAlias(p,na)->return(funlev_after->pr_pattmtprlev_after(LevelLelas)p++str" as "++pr_lnamena)las|CPatCstr(c,None,[])->return(funlev_after->pr_referencec)latom|CPatCstr(c,None,args)->return(funlev_after->pr_referencec++pr_patt_argsprlev_afterargs)lapp|CPatCstr(c,Someargs,[])->return(funlev_after->str"@"++pr_referencec++pr_patt_argsprlev_afterargs)lapp|CPatCstr(c,Someexpl_args,extra_args)->return(funlev_after->surround(str"@"++pr_referencec++pr_patt_argsprlev_afterexpl_args)++pr_patt_argsprlev_afterextra_args)lapp|CPatAtom(None)->return(funlev_after->str"_")latom|CPatAtom(Somer)->return(funlev_after->pr_referencer)latom|CPatOrpl->return(funlev_after->letppp=hov0(pr_pattmtprlev_afterlpattopp)insurround(hov0(prlist_with_seppr_spcbarpppl)))lpator|CPatNotation(_,(_,"( _ )"),([p],[],[]),[])->return(funlev_after->pr_patt(fun()->str"(")prno_afterlpattopp++str")")latom|CPatNotation(which,s,(l,ll,bl),args)->letl_not=(find_notation_printing_rulewhichs).notation_printing_levelinletno_inner_surrounding=List.is_emptyargs||Notation.prec_lessl_not(LevelLtlapp)inreturn(funlev_after->letlev_after'=ifno_inner_surroundingthenlev_afterelseno_afterinletstrm_not=pr_notationlev_after(pr_pattmtpr)(pr_patt_binderpr)(fun____->mt())whichs(l,ll,bl,[])in(ifList.is_emptyargsthenstrm_notelseifoverlap_right_leftwhichslev_afterthensurroundstrm_notelseifNotation.prec_lessl_not(LevelLtlapp)thenstrm_notelsesurroundstrm_not)++pr_patt_argsprlev_after'args)(ifnot(List.is_emptyargs)thenlappelseifno_inner_surroundingthenl_notelselatom)|CPatPrimp->return(funlev_after->pr_prim_tokenp)latom|CPatDelimiters(depth,k,p)->return(funlev_after->pr_delimitersdepthk(pr_pattmtpr(Some1)lsimplepattp))1|CPatCast(p,t)->return(funlev_after->pr_pattmtpr(Some1)lpatcastp++spc()++str":"++ws1++prt)1andpr_patt_binderprprecstylebkc=matchbkwith|MaxImplicit->str"{"++pr_pattmtprno_afterlpattopc++str"}"|NonMaxImplicit->str"["++pr_pattmtprno_afterlpattopc++str"]"|Explicit->matchstyle,cwith|NotQuotedPattern,_|_,{v=CPatAtom_}->pr_pattmtprno_afterprecc|QuotedPattern,_->str"'"++pr_pattmtprno_afterpreccletpr_patt=pr_pattmtletpr_eqnpr{loc;v=(pl,rhs)}=spc()++hov4(pr_with_comments?loc(str"| "++hov0(prlist_with_seppr_spcbar(funp->hov0(prlist_with_sepsep_v(pr_patt(prno_afterltop)no_afterltop)p))pl++str" =>")++pr_sep_comspc(prno_afterltop)rhs))letbegin_of_binderl_bi=letb_locl=fst(Option.cataLoc.unloc(0,0)l)inmatchl_biwith|CLocalDef({loc},_,_,_)->b_locloc|CLocalAssum({loc}::_,_,_,_)->b_locloc|CLocalPattern{loc}->b_locloc|_->assertfalseletbegin_of_binders=function|b::_->begin_of_binderb|_->0letsurround_implkp=matchkwith|Explicit->str"("++p++str")"|NonMaxImplicit->str"["++p++str"]"|MaxImplicit->str"{"++p++str"}"letsurround_implicitkp=matchkwith|Explicit->p|NonMaxImplicit->str"["++p++str"]"|MaxImplicit->(str"{"++p++str"}")letpr_bindermanypr(nal,r,k,t)=letr=pr_relevance_inforinmatchkwith|Generalized(b',t')->beginmatchnalwith|[{loc;v=Anonymous}]->hov1(str"`"++(surround_implb'(r++(ift'thenstr"!"elsemt())++prt)))|[{loc;v=Nameid}]->hov1(str"`"++(surround_implb'(pr_lidentCAst.(make?locid)++str" : "++r++(ift'thenstr"!"elsemt())++prt)))|_->anomaly(Pp.str"List of generalized binders have always one element.")end|Defaultb->matchtwith|{CAst.v=CHoleh}whenis_anonymous_holeh->lets=prlist_with_sepspcpr_lnamenalinhov1(r++surround_implicitbs)|_->lets=prlist_with_sepspcpr_lnamenal++str" : "++r++prtinhov1(ifmanythensurround_implbselsesurround_implicitbs)letpr_binder_among_manywithquotepr_c=function|CLocalAssum(nal,r,k,t)->pr_bindertruepr_c(nal,r,k,t)|CLocalDef(na,r,c,topt)->surround(pr_lnamena++pr_relevance_infor++pr_opt_no_spc(funt->str" :"++ws1++pr_ct)topt++str" :="++spc()++pr_cc)|CLocalPatternp->str(ifwithquotethen"'"else"")++pr_pattpr_cno_afterlsimplepattpletpr_undelimited_binderssepwithquotepr_c=prlist_with_sepsep(pr_binder_among_manywithquotepr_c)letpr_delimited_binderskwsepwithquotepr_cbl=letn=begin_of_bindersblinmatchblwith|[CLocalAssum(nal,r,k,t)]->kwn++pr_binderfalsepr_c(nal,r,k,t)|(CLocalAssum_|CLocalPattern_|CLocalDef_)::_asbdl->kwn++pr_undelimited_binderssepwithquotepr_cbdl|[]->anomaly(Pp.str"The ast is malformed, found lambda/prod without proper binders.")letpr_binders_genpr_csepis_openwithquote=ifis_openthenpr_delimited_binderspr_com_atsepwithquotepr_celsepr_undelimited_binderssepwithquotepr_cletpr_recursive_declprpr_danglinglev_afterkwdangling_with_foridblannottc=letpr_body=ifdangling_with_forthenpr_danglingelseprinhov0(strkw++brk(1,2)++pr_idid++(ifbl=[]thenmt()elsebrk(1,2))++hov0(pr_undelimited_bindersspctrue(prno_afterltop)bl++annot)++pr_opt_type_spcprt++str" :=")++pr_sep_com(fun()->brk(1,2))(pr_bodylev_afterltop)cletpr_guard_annotpr_auxblro=matchrowith|None->mt()|Some{loc;v=ro}->matchrowith|CStructRec{v=id}->letnames_of_binder=function|CLocalAssum(nal,_,_,_)->nal|CLocalDef(_,_,_,_)->[]|CLocalPattern_->assertfalseinletids=List.flatten(List.mapnames_of_binderbl)inifList.lengthids>1thenspc()++str"{"++keyword"struct"++brk(1,1)++pr_idid++str"}"elsemt()|CWfRec(id,c)->spc()++str"{"++keyword"wf"++brk(1,1)++pr_auxc++brk(1,1)++pr_lidentid++str"}"|CMeasureRec(id,m,r)->spc()++str"{"++keyword"measure"++brk(1,1)++pr_auxm++matchidwithNone->mt()|Someid->brk(1,1)++pr_lidentid++(matchrwithNone->mt()|Somer->str" on "++pr_auxr)++str"}"letpr_fixdeclprprdlev_afterkwdangling_with_for({v=id},_,ro,bl,t,c)=letannot=pr_guard_annot(prno_afterlsimpleconstr)blroinpr_recursive_declprprdlev_afterkwdangling_with_foridblannottcletpr_cofixdeclprprdlev_afterkwdangling_with_for({v=id},_,bl,t,c)=pr_recursive_declprprdlev_afterkwdangling_with_foridbl(mt())tcletpr_recursivelev_afterkwpr_declid=function|[]->anomaly(Pp.str"(co)fixpoint with no definition.")|[d1]->pr_decllev_afterkwfalsed1|d1::dl->pr_declno_afterkwtrued1++fnl()++prlist_with_sep(fun()->fnl())(pr_declno_after"with"true)dl++fnl()++keyword"for"++spc()++pr_ididletpr_as_inprnaindnalopt=(matchnawith(* Decision of printing "_" or not moved to constrextern.ml *)|Somena->spc()++keyword"as"++spc()++pr_lnamena|None->mt())++(matchindnaloptwith|None->mt()|Somet->spc()++keyword"in"++spc()++pr_pattprno_afterlsimplepattt)letpr_case_itempr(tm,as_clause,in_clause)=hov0(prno_after(LevelLelcast)tm++pr_as_in(prno_afterltop)as_clausein_clause)letpr_case_typeprpo=matchpowith|None->mt()|Some{CAst.v=CHoleh}whenis_anonymous_holeh->mt()|Somep->spc()++hov2(keyword"return"++pr_sep_comspc(prno_afterlsimpleconstr)p)letpr_simple_return_typeprnapo=(matchnawith|Some{v=Nameid}->spc()++keyword"as"++spc()++pr_idid|_->mt())++pr_case_typeprpoletpr_projprpr_appafl=hov0(pr(Somelproj)(LevelLelproj)a++cut()++str".("++pr_appprno_afterfl++str")")letpr_appexplprlev_after(f,us)l=letpargs=matchlwith|[]->mt()|args->letlast,l=List.sep_lastlinprlist(pr_sep_comspc(pr(Somelapp)(LevelLtlapp)))l++pr_sep_comspc(prlev_after(LevelLtlapp))lastinhov2(str"@"++pr_referencef++pr_universe_instanceus++pargs)letpr_appprlev_afteral=letpargs=matchlwith|[]->mt()|args->letlast,l=List.sep_lastlinprlist(funa->spc()++pr_expl_argspr(Somelapp)a)l++spc()++pr_expl_argsprlev_afterlastinhov2(pr(Somelapp)(LevelLtlapp)a++pargs)letpr_foralln=keyword"forall"++pr_com_atn++spc()letpr_funn=keyword"fun"++pr_com_atn++spc()letpr_fun_sep=spc()++str"=>"letpr_dangling_with_forsepprlev_afterinheriteda=matcha.vwith|(CFix(_,[_])|CCoFix(_,[_]))->prseplev_after(LevelLelatom)a|_->prseplev_afterinheritedaletpr_cast=letopenConstrinfunction|SomeDEFAULTcast->str":"|SomeVMcast->str"<:"|SomeNATIVEcast->str"<<:"|None->str":>"typeraw_or_glob_genarg=|RawargofGenarg.raw_generic_argument|GlobargofGenarg.glob_generic_argumentletpr_genargreturnarg=(* In principle this may use the env/sigma, in practice not sure if it
does except through pr_constr_expr in beautify mode. *)letenv=Global.env()inletsigma=Evd.from_envenvinletname,parg=letopenGenarginmatchargwith|Globargarg->letGenArg(Glbwittag,_)=arginbeginmatchtagwith|ExtraArgtag->ArgT.reprtag,Pputils.pr_glb_genericenvsigmaarg|_->assertfalseend|Rawargarg->letGenArg(Rawwittag,_)=arginbeginmatchtagwith|ExtraArgtag->ArgT.reprtag,Pputils.pr_raw_genericenvsigmaarg|_->assertfalseendinletname=(* cheat the name system
there should be a better way to handle this *)ifString.equalname"tactic"then"ltac"elseifString.equalname"ltac2:in-constr"then"ltac2"elseifString.equalname"ltac2:quotation"then""elsenameinletpp=ifString.is_emptynamethenpargelsestrname++str":"++surroundparginreturn(fun_->pp)latomletprprseplev_afterinheriteda=letreturncmdsprec=letno_surround=Notation.prec_lessprecinheritedinletlev_after=ifno_surroundthenlev_afterelseno_afterinletpp=tag_constr_expra(cmdslev_after)inletpp=ifno_surroundthenppelsesurroundppinpr_with_comments?loc:a.CAst.loc(sep()++pp)inmatchCAst.(a.v)with|CRef(r,us)->return(fun_->pr_crefrus)latom|CFix(id,fix)->return(funlev_after->hv0(pr_recursivelev_after"fix"(pr_fixdecl(prmt)(pr_dangling_with_formtpr))id.vfix))lfix|CCoFix(id,cofix)->return(funlev_after->hv0(pr_recursivelev_after"cofix"(pr_cofixdecl(prmt)(pr_dangling_with_formtpr))id.vcofix))lfix|CProdN(bl,a)->return(funlev_after->hov0(hov2(pr_delimited_binderspr_forallspctrue(prmtno_afterltop)bl)++str","++prspclev_afterltopa))lprod|CLambdaN(bl,a)->return(funlev_after->hov0(hov2(pr_delimited_binderspr_funspctrue(prmtno_afterltop)bl)++pr_fun_sep++prspclev_afterltopa))llambda|CLetIn({v=Namex},({v=CFix({v=x'},[_])}|{v=CCoFix({v=x'},[_])}asfx),t,b)whenId.equalxx'->return(funlev_after->hv0(hov2(keyword"let"++spc()++prmtno_afterltopfx++spc()++keyword"in")++prspclev_afterltopb))lletin|CLetIn(x,a,t,b)->return(funlev_after->hv0(hov2(keyword"let"++spc()++pr_lnamex++pr_opt_no_spc(funt->str" :"++ws1++prmtno_afterltopt)t++str" :="++prspcno_afterltopa++spc()++keyword"in")++prspclev_afterltopb))lletin|CProj(true,(f,us),l,c)->letl=List.map(function(c,None)->c|_->assertfalse)linreturn(funlev_after->pr_proj(prmt)pr_appexplc(f,us)l)lproj|CProj(false,(f,us),l,c)->return(funlev_after->pr_proj(prmt)pr_appc(CAst.make(CRef(f,us)))l)lproj|CAppExpl((qid,us),[t])|CApp({v=CRef(qid,us)},[t,None])whenqualid_is_identqid&&Id.equal(qualid_basenameqid)Notation_ops.ldots_var->return(funlev_after->hov0(str".."++prspcno_after(LevelLelatom)t++spc()++str".."))larg|CAppExpl((f,us),l)->return(funlev_after->pr_appexpl(prmt)lev_after(f,us)l)lapp|CApp(a,l)->return(funlev_after->pr_app(prmt)lev_afteral)lapp|CRecordl->return(funlev_after->pr_record_body"{|""|}"(prspcno_afterltop)l)latom|CCases(Constr.LetPatternStyle,rtntypopt,[c,as_clause,in_clause],[{v=([[p]],b)}])->return(funlev_after->hv0(keyword"let"++spc()++str"'"++hov0(pr_patt(prmtno_afterltop)no_afterltopp++pr_as_in(prmtno_afterltop)as_clausein_clause++str" :="++prspcno_afterltopc++pr_case_type(pr_dangling_with_formtpr)rtntypopt++spc()++keyword"in"++prspclev_afterltopb)))lletpattern|CCases(_,rtntypopt,c,eqns)->return(funlev_after->v0(hv0(keyword"match"++brk(1,2)++hov0(prlist_with_sepsep_v(pr_case_item(pr_dangling_with_formtpr))c++pr_case_type(pr_dangling_with_formtpr)rtntypopt)++spc()++keyword"with")++prlist(pr_eqn(prmt))eqns++spc()++keyword"end"))latom|CLetTuple(nal,(na,po),c,b)->return(funlev_after->hv0(hov2(keyword"let"++spc()++hov1(str"("++prlist_with_sepsep_vpr_lnamenal++str")"++pr_simple_return_type(prmt)napo++str" :=")++prspcno_afterltopc++keyword" in")++prspclev_afterltopb))lletin|CIf(c,(na,po),b1,b2)->(* On force les parenthèses autour d'un "if" sous-terme (même si le
parsing est lui plus tolérant) *)return(funlev_after->hv0(hov1(keyword"if"++spc()++prmtno_afterltopc++pr_simple_return_type(prmt)napo)++spc()++hov0(keyword"then"++pr(fun()->brk(1,1))no_afterltopb1)++spc()++hov0(keyword"else"++pr(fun()->brk(1,1))lev_afterltopb2)))lif|CHole(Some(GNamedHole(false,id)))->return(funlev_after->str"?["++pr_idid++str"]")latom|CHole(Some(GNamedHole(true,id)))->return(funlev_after->str"?[?"++pr_idid++str"]")latom|CHole_->return(funlev_after->str"_")latom|CGenargarg->pr_genargreturn(Rawargarg)|CGenargGlobarg->pr_genargreturn(Globargarg)|CEvar(n,l)->return(funlev_after->pr_evar(prmt)nl)latom|CPatVarp->return(funlev_after->str"@?"++pr_patvarp)latom|CSorts->return(funlev_after->pr_sort_exprs)latom|CCast(a,k,b)->return(funlev_after->hv0(prmtno_after(LevelLtlcast)a++spc()++(pr_castk)++ws1++prmtlev_after(LevelLelprod)b))lcast|CNotation(_,(_,"( _ )"),([t],[],[],[]))->return(funlev_after->pr(fun()->str"(")no_afterltopt++str")")latom|CNotation(which,s,env)->letl_not=(find_notation_printing_rulewhichs).notation_printing_levelinletl_not=ifoverlap_right_leftwhichslev_afterthenmax_intelsel_notinreturn(funlev_after->pr_notationlev_after(prmt)(pr_patt_binder(prmtno_afterltop))(pr_binders_gen(prmtno_afterltop))whichsenv)l_not|CGeneralization(bk,c)->return(funlev_after->pr_generalizationbk(prmtno_afterltopc))latom|CPrimp->return(funlev_after->pr_prim_tokenp)(prec_of_prim_tokenp)|CDelimiters(depth,sc,a)->return(funlev_after->pr_delimitersdepthsc(prmt(Someldelim)(LevelLeldelim)a))ldelim|CArray(u,t,def,ty)->return(funlev_after->hov0(str"[| "++prvect_with_sep(fun()->str"; ")(prmtno_afterltop)t++(ifnot(Array.is_emptyt)thenstr" "elsemt())++str"|"++spc()++prmtno_afterltopdef++pr_opt_type_spc(prmt)ty++str" |]"++pr_universe_instanceu))0typeterm_pr={pr_constr_expr:Environ.env->Evd.evar_map->constr_expr->Pp.t;pr_lconstr_expr:Environ.env->Evd.evar_map->constr_expr->Pp.t;pr_constr_pattern_expr:Environ.env->Evd.evar_map->constr_pattern_expr->Pp.t;pr_lconstr_pattern_expr:Environ.env->Evd.evar_map->constr_pattern_expr->Pp.t}letmodular_constr_pr=prletrecfixrfx=rf(fixrf)xletpr=fixmodular_constr_prmtletprlev_afterprec=function(* A toplevel printer hack mimicking parsing, incidentally meaning
that we cannot use [pr] correctly anymore in a recursive loop
if the current expr is followed by other exprs which would be
interpreted as arguments *)|{CAst.v=CAppExpl((f,us),[])}->str"@"++pr_creffus|c->prlev_afterprecclettransfenvsigmac=if!Flags.beautify_filethenletr=Constrintern.intern_gen~strict_check:falseWithoutTypeConstraintenvsigmacinConstrextern.(extern_glob_constr(extern_envenvsigma))relsecletpr_exprenvsigmalev_afterprecc=prlev_afterprec(transfenvsigmac)letpr_simpleconstr_envenvsigma=pr_exprenvsigmano_afterlsimpleconstrletpr_top_envenvsigma=pr_exprenvsigmano_afterltopletdefault_term_pr={pr_constr_expr=pr_simpleconstr_env;pr_lconstr_expr=pr_top_env;pr_constr_pattern_expr=pr_simpleconstr_env;pr_lconstr_pattern_expr=pr_top_env;}letterm_pr=refdefault_term_prletset_term_pr=(:=)term_prletpr_simpleconstr=prno_afterlsimpleconstrletpr_top=prno_afterltopletpr_constr_expr_nnc=pr_exprncno_afterletpr_constr_exprc=!term_pr.pr_constr_exprcletpr_lconstr_exprc=!term_pr.pr_lconstr_exprcletpr_constr_pattern_exprc=!term_pr.pr_constr_pattern_exprcletpr_lconstr_pattern_exprc=!term_pr.pr_lconstr_pattern_exprcletpr_cases_pattern_expr=pr_patt(prno_afterltop)no_afterltopletpr_bindersenvsigma=pr_undelimited_bindersspctrue(pr_exprenvsigmano_afterltop)