12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667(************************************************************************)(* * The Coq Proof Assistant / The Coq Development Team *)(* v * INRIA, CNRS and contributors - Copyright 1999-2018 *)(* <O___,, * (see CREDITS file for the list of authors) *)(* \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) *)(************************************************************************)(************************************************************************)(* Coq Language Server Protocol *)(* Copyright 2019 MINES ParisTech -- Dual License LGPL 2.1 / GPL3+ *)(* Copyright 2019-2022 Inria -- Dual License LGPL 2.1 / GPL3+ *)(* Written by: Emilio J. Gallego Arias *)(************************************************************************)moduleInfo=structtype'at={res:'a;feedback:Message.tlist}endletget_feedbackfb_queue=letres=!fb_queueinfb_queue:=[];restype'ainterp_result='aInfo.tProtect.R.tletcoq_interp~stcmd=letst=State.to_coqstinletcmd=Ast.to_coqcmdinVernacinterp.interp~stcmd|>State.of_coqletinterp~st~fb_queuecmd=Protect.evalcmd~f:(funcmd->letres=coq_interp~stcmdin(* It is safe to call the printer here as the state is guaranteed to be
the right one after `coq_interp`, but beware! *)letfeedback=List.rev@@get_feedbackfb_queuein{Info.res;feedback})letmarshal_outfocres=matchreswith|Protect.R.Interrupted->()|Protect.R.Completedres->(matchreswith|Okres->Marshal.to_channeloc0[];focres.Info.res|Error(loc,msg)->Marshal.to_channeloc1[];Marshal.to_channelocloc[];Marshal.to_channelocmsg[];())letmarshal_infic=lettag:int=Marshal.from_channeliciniftag=0thenletres=ficinProtect.R.Completed(Ok{Info.res;feedback=[]})elseletloc:Loc.toption=Marshal.from_channelicinletmsg:Pp.t=Marshal.from_channelicinProtect.R.Completed(Error(loc,msg))