123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112(************************************************************************)(* * 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) *)(************************************************************************)(* Created by Hugo Herbelin from code formerly dispatched in
syntax_def.ml or tacinterp.ml, Sep 2009 *)(* This file provides high-level name globalization functions *)(* *)openPpopenCErrorsopenLibnamesopenGlobnamesopenAbbreviationopenNotation_termletglobal_of_extended_global_head=function|TrueGlobalref->ref|Abbrevkn->let_,syn_def=search_abbreviationkninletrechead_of=function|NRef(ref,None)->ref|NApp(rc,_)->head_ofrc|NCast(rc,_,_)->head_ofrc|NLetIn(_,_,_,rc)->head_ofrc|_->raiseNot_foundinhead_ofsyn_defletglobal_of_extended_global_exn=function|TrueGlobalref->ref|Abbrevkn->matchsearch_abbreviationknwith|[],NRef(ref,None)->ref|[],NApp(NRef(ref,None),[])->ref|_->raiseNot_foundletlocate_global_with_alias?(head=false)qid=letref=Nametab.locate_extendedqidintryifheadthenglobal_of_extended_global_headrefelseglobal_of_extended_global_exnrefwithNot_found->user_err?loc:qid.CAst.loc(pr_qualidqid++str" is bound to a notation that does not denote a reference.")letglobal_of_extended_globalx=trySome(global_of_extended_global_exnx)withNot_found->Noneletglobal_constant_with_aliasqid=trymatchlocate_global_with_aliasqidwith|Names.GlobRef.ConstRefc->c|ref->user_err?loc:qid.CAst.loc(pr_qualidqid++spc()++str"is not a reference to a constant.")withNot_foundasexn->let_,info=Exninfo.captureexninNametab.error_global_not_found~infoqidletglobal_inductive_with_aliasqid=trymatchlocate_global_with_aliasqidwith|Names.GlobRef.IndRefind->ind|ref->user_err?loc:qid.CAst.loc(pr_qualidqid++spc()++str"is not an inductive type.")withNot_foundasexn->let_,info=Exninfo.captureexninNametab.error_global_not_found~infoqidletglobal_constructor_with_aliasqid=trymatchlocate_global_with_aliasqidwith|Names.GlobRef.ConstructRefc->c|ref->user_err?loc:qid.CAst.loc(pr_qualidqid++spc()++str"is not a constructor of an inductive type.")withNot_foundasexn->let_,info=Exninfo.captureexninNametab.error_global_not_found~infoqidletglobal_with_alias?headqid=trylocate_global_with_alias?headqidwithNot_foundasexn->let_,info=Exninfo.captureexninNametab.error_global_not_found~infoqidletsmart_global?(head=false)=letopenConstrexprinCAst.with_loc_val(fun?loc->function|ANr->global_with_alias~headr|ByNotation(ntn,sc)->Notation.interp_notation_as_global_reference?loc~head(fun_->true)ntnsc)letsmart_global_kindfdestis=letopenConstrexprinCAst.with_loc_val(fun?loc->function|ANr->fr|ByNotation(ntn,sc)->dest(Notation.interp_notation_as_global_reference?loc~head:falseisntnsc))letsmart_global_constant=smart_global_kindglobal_constant_with_aliasdestConstRefisConstRefletsmart_global_inductive=smart_global_kindglobal_inductive_with_aliasdestIndRefisIndRefletsmart_global_constructor=smart_global_kindglobal_constructor_with_aliasdestConstructRefisConstructRef