1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192(************************************************************************)(* * 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) *)(************************************************************************)(************************************************************************)(* SerAPI: Coq interaction protocol with bidirectional serialization *)(************************************************************************)(* Copyright 2016-2019 MINES ParisTech -- License LGPL 2.1+ *)(* Copyright 2019-2023 Inria -- License LGPL 2.1+ *)(* Written by: Emilio J. Gallego Arias and others *)(************************************************************************)letreccoq_pp_opt(d:Pp.t)=letopenPpinletrecflatten_gluel=matchlwith|[]->[]|(Ppcmd_glueg::l)->flatten_glue(List.mapreprg@flatten_gluel)|(Ppcmd_strings1::Ppcmd_strings2::l)->flatten_glue(Ppcmd_string(s1^s2)::flatten_gluel)|(x::l)->x::flatten_gluelin(* let rec flatten_glue l = match l with *)(* | (Ppcmd_string s1 :: Ppcmd_string s2 :: l) -> Ppcmd_string (s1 ^ s2) :: flatten_glue l *)unrepr(matchreprdwith|Ppcmd_glue[]->Ppcmd_empty|Ppcmd_glue[x]->repr(coq_pp_optx)|Ppcmd_gluel->Ppcmd_glueList.(mapcoq_pp_opt(mapunrepr(flatten_glue(mapreprl))))|Ppcmd_box(bt,d)->Ppcmd_box(bt,coq_pp_optd)|Ppcmd_tag(t,d)->Ppcmd_tag(t,coq_pp_optd)|d->d)(* Adjust positions from byte to UTF-8 chars *)(* XXX: Move to serapi/ *)(* We only do adjustement for messages for now. *)moduleF=Feedbackletfeedback_content_pos_filtertxt(fbc:F.feedback_content):F.feedback_content=letadjust_txtloc=locinmatch(fbc:F.feedback_content)with|F.Message(lvl,loc,msg)->F.Message(lvl,adjusttxtloc,msg)|_->fbcletfeedback_pos_filtertext(fb:F.feedback):F.feedback={fbwithF.contents=feedback_content_pos_filtertextfb.F.contents;}(* Optimizes and filters feedback *)typefb_filter_opts={pp_opt:bool;}letdefault_fb_filter_opts={pp_opt=true;}letfeedback_content_tr(fb:F.feedback_content):Serapi.Serapi_protocol.feedback_content=matchfbwith|F.Message(level,loc,pp)->letstr=Pp.string_of_ppcmdsppinMessage{level;loc;pp;str}|F.Processed->Processed|F.Incomplete->Incomplete|F.Complete->Complete|F.ProcessingIns->ProcessingIns|F.InProgressi->InProgressi|F.WorkerStatus(s1,s2)->WorkerStatus(s1,s2)|F.AddedAxiom->AddedAxiom|F.GlobRef(_,_,_,_,_)->assertfalse|F.GlobDef(_,_,_,_)->assertfalse|F.FileDependency(o,p)->FileDependency(o,p)|F.FileLoaded(o,p)->FileLoaded(o,p)|F.Custom(_,_,_)->assertfalseletfeedback_tr(fb:Feedback.feedback):Serapi.Serapi_protocol.feedback=matchfbwith|{doc_id;span_id;route;contents}->letcontents=feedback_content_trcontentsin{doc_id;span_id;route;contents}letfeedback_opt_filter?(opts=default_fb_filter_opts)=letopenFeedbackinfunction|{F.contents=Message(lvl,loc,msg);_}asfb->Some(ifopts.pp_optthen{fbwithcontents=Message(lvl,loc,coq_pp_optmsg)}elsefb)|{F.contents=FileDependency_;_}->None|fb->Somefb