123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111(************************************************************************)(* * 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) *)(************************************************************************)openPpopenCErrorsopenNamesopenLibnamesopenLibobjectopenLibopenNotation_term(* Syntactic definitions. *)typesyndef={syndef_pattern:interpretation;syndef_onlyparsing:bool;syndef_deprecation:Deprecation.toption;syndef_also_in_cases_pattern:bool;}letsyntax_table=Summary.ref(KNmap.empty:syndefKNmap.t)~name:"SYNDEFS"letadd_syntax_constantknsyndef=syntax_table:=KNmap.addknsyndef!syntax_tableletload_syntax_constanti((sp,kn),(_local,syndef))=ifNametab.exists_ccispthenuser_err~hdr:"cache_syntax_constant"(Id.print(basenamesp)++str" already exists");add_syntax_constantknsyndef;Nametab.push_syndef(Nametab.Untili)spknletis_alias_of_already_visible_namesp=function|_,NRef(ref,_)->let(dir,id)=repr_qualid(Nametab.shortest_qualid_of_globalId.Set.emptyref)inDirPath.is_emptydir&&Id.equalid(basenamesp)|_->falseletopen_syntax_constanti((sp,kn),(_local,syndef))=letpat=syndef.syndef_patterninifnot(Int.equali1&&is_alias_of_already_visible_namesppat)thenbeginNametab.push_syndef(Nametab.Exactlyi)spkn;ifnotsyndef.syndef_onlyparsingthen(* Redeclare it to be used as (short) name in case an other (distfix)
notation was declared in between *)Notation.declare_uninterpretation~also_in_cases_pattern:syndef.syndef_also_in_cases_pattern(Notation.SynDefRulekn)patendletcache_syntax_constantd=load_syntax_constant1d;open_syntax_constant1dletsubst_syntax_constant(subst,(local,syndef))=letsyndef_pattern=Notation_ops.subst_interpretationsubstsyndef.syndef_patternin(local,{syndefwithsyndef_pattern})letclassify_syntax_constant(local,_aso)=iflocalthenDisposeelseSubstituteoletfiltered_open_syntax_constantfi((_,kn),_aso)=letin_f=matchfwith|Unfiltered->true|Namesns->Globnames.(ExtRefSet.mem(SynDefkn)ns)inifin_fthenopen_syntax_constantioletin_syntax_constant:(bool*syndef)->obj=declare_object{(default_object"SYNDEF")withcache_function=cache_syntax_constant;load_function=load_syntax_constant;open_function=filtered_open_syntax_constant;subst_function=subst_syntax_constant;classify_function=classify_syntax_constant}letdeclare_syntactic_definition~local?(also_in_cases_pattern=true)deprecationid~onlyparsingpat=letsyndef={syndef_pattern=pat;syndef_onlyparsing=onlyparsing;syndef_deprecation=deprecation;syndef_also_in_cases_pattern=also_in_cases_pattern;}inlet_=add_leafid(in_syntax_constant(local,syndef))in()letpr_syndefkn=pr_qualid(Nametab.shortest_qualid_of_syndefId.Set.emptykn)letwarn_deprecated_syntactic_definition=Deprecation.create_warning~object_name:"Notation"~warning_name:"deprecated-syntactic-definition"pr_syndefletsearch_syntactic_definition?lockn=letsyndef=KNmap.findkn!syntax_tableinOption.iter(fund->warn_deprecated_syntactic_definition?loc(kn,d))syndef.syndef_deprecation;syndef.syndef_patternletsearch_filtered_syntactic_definition?locfilterkn=letsyndef=KNmap.findkn!syntax_tableinletres=filtersyndef.syndef_patterninifOption.has_someresthenOption.iter(fund->warn_deprecated_syntactic_definition?loc(kn,d))syndef.syndef_deprecation;res