12345678910111213141516171819202122232425262728293031323334353637383940414243444546(*
* Copyright (c) 2018 Thomas Gazagnaire <thomas@gazagnaire.org>
*
* Permission to use, copy, modify, and distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
* copyright notice and this permission notice appear in all copies.
*
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*)typesyntax=Syntax.t=Normal|Cram|Mlitypeline=Sectionof(int*string)|Textofstring|BlockofBlock.ttypet=linelistletpp_line?syntaxppf(l:line)=matchlwith|Blockb->Fmt.pfppf"%a\n"(Block.pp?syntax)b|Section(d,s)->Fmt.pfppf"%s %s\n"(String.maked'#')s|Texts->(matchsyntaxwith|SomeMli->Fmt.pfppf"%s"s|_->Fmt.pfppf"%s\n"s)letpp?syntaxppft=Fmt.pfppf"%a\n"Fmt.(list~sep:(unit"\n")(pp_line?syntax))tletto_string=Fmt.to_to_stringppletenvst=List.fold_left(funaccline->matchlinewith|Blockb->(matchb.valuewith|OCaml{env;_}|Toplevel{env;_}->Ocaml_env.Set.addenvacc|Raw_|Cram_|Include_->acc)|Section_|Text_->acc)Ocaml_env.Set.emptyt