12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788(************************************************************************)(* v * The Coq Proof Assistant / The Coq Development Team *)(* <O___,, * INRIA - CNRS - LIX - LRI - PPS - Copyright 1999-2016 *)(* \VV/ **************************************************************)(* // * This file is distributed under the terms of the *)(* * GNU Lesser General Public License Version 2.1 *)(************************************************************************)(************************************************************************)(* Coq serialization API/Plugin *)(* Copyright 2016 MINES ParisTech *)(************************************************************************)(* Status: Very Experimental *)(************************************************************************)openFormat(** This module includes all of sertop custom Format-based printers
for Coq datatypes *)type'app=formatter->'a->unit(************************************************************************)(* Print Helpers *)(************************************************************************)letpp_strfmtstr=fprintffmt"%s"strletpp_optppfmtopt=matchoptwith|None->()|Somex->fprintffmt"%a"ppxletrecpp_list?sepppfmtl=matchlwith[]->fprintffmt""|csx::[]->fprintffmt"@[%a@]"ppcsx|csx::csl->fprintffmt"@[%a@]%a@;%a"ppcsx(pp_optpp_str)sep(pp_list?seppp)csl(************************************************************************)(* Statid *)(************************************************************************)letpp_stateidfmtid=fprintffmt"%d"(Stateid.to_intid)(************************************************************************)(* Feedback *)(************************************************************************)letpp_feedback_contentfmtfb=letopenFeedbackinmatchfbwith(* STM mandatory data (must be displayed) *)|Processed->fprintffmt"Processed"|Incomplete->fprintffmt"Incomplete"|Complete->fprintffmt"Complete"(* STM optional data *)|ProcessingIns->fprintffmt"ProcessingIn: %s"s|InProgressd->fprintffmt"InProgress: %d"d|WorkerStatus(w1,w2)->fprintffmt"WorkerStatus: %s, %s"w1w2(* Generally useful metadata *)|AddedAxiom->fprintffmt"AddedAxiom"|GlobRef(_loc,s1,s2,s3,s4)->fprintffmt"GlobRef: %s,%s,%s,%s"s1s2s3s4|GlobDef(_loc,s1,s2,s3)->fprintffmt"GlobDef: %s,%s,%s"s1s2s3|FileDependency(os,s)->fprintffmt"FileDep: %a, %s"(pp_optpp_str)oss|FileLoaded(s1,s2)->fprintffmt"FileLoaded: %s, %s"s1s2(* Extra metadata *)|Custom(_loc,msg,_xml)->fprintffmt"Custom: %s"msg(* Old generic messages *)|Message(_lvl,_loc,m)->fprintffmt"Msg: @[%a@]"Pp.pp_withmletpp_feedbackfmt(fb:Feedback.feedback)=letopenFeedbackinfprintffmt"feedback for [%a]: @[%a@]"pp_stateidfb.span_idpp_feedback_contentfb.Feedback.contents(************************************************************************)(* Xml *)(************************************************************************)letpp_attrfmt(xtag,att)=fprintffmt"%s = %s"xtagattletrecpp_xmlfmt(xml:Xml_datatype.xml)=matchxmlwith|Xml_datatype.Element(tag,att,more)->fprintffmt"@[<%s @[%a@]>@,%a@,</%s>@]"tag(pp_listpp_attr)att(pp_listpp_xml)moretag|Xml_datatype.PCDatastr->fprintffmt"%s"str