Legend:
Page
Library
Module
Module type
Parameter
Class
Class type
Source
Source file printing.ml
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889(**************************************************************************)(* *)(* VSCoq *)(* *)(* Copyright INRIA and contributors *)(* (see version control and README file for authors & dates) *)(* *)(**************************************************************************)(* *)(* This file is distributed under the terms of the MIT License. *)(* See LICENSE file. *)(* *)(**************************************************************************)openUtilopenPpx_yojson_conv_lib.Yojson_conv.Primitivestypepp_tag=string[@@derivingyojson]typeblock_type=Pp.block_type=|Pp_hbox|Pp_vboxofint|Pp_hvboxofint|Pp_hovboxofint[@@derivingyojson]typepp=|Ppcmd_empty|Ppcmd_stringofstring|Ppcmd_glueofpplist|Ppcmd_boxofblock_type*pp|Ppcmd_tagofpp_tag*pp|Ppcmd_print_breakofint*int|Ppcmd_force_newline|Ppcmd_commentofstringlist[@@derivingyojson]letrecregroup_tags_auxacc=function|[]->acc|hd::tl->matchPp.reprhdwith|Pp.Ppcmd_gluel->letacc=regroup_tags_auxacclinregroup_tags_auxacctl|Pp.Ppcmd_tag(s,pp)whenString.starts_with~prefix:Pp.start_pfxs->letpp=regroup_tags[pp]inregroup_tags_aux(pp::acc)tl|Pp.Ppcmd_tag(s,pp)whenString.starts_with~prefix:Pp.end_pfxs->letpp=regroup_tags[pp]inletn=String.lengthPp.end_pfxinlettag=String.subsn(String.lengths-n)inbeginmatchaccwith|acc0::acc1::tlacc->letacc1=Pp.tagtag(Pp.seq((List.revacc0)@pp))::acc1inregroup_tags_aux(acc1::tlacc)tl|_->failwith("extra closing tag: "^tag)end|_->letacc=(hd::List.hdacc)::List.tlaccinregroup_tags_auxacctlandregroup_tagsl=matchregroup_tags_aux[[]]lwith[l]->List.revl|_->failwith"tag not closed"[%%ifcoq="8.18"||coq="8.19"||coq="8.20"||coq="9.0"]letrecpp_of_coqppt=matchPp.reprtwith|Pp.Ppcmd_empty->Ppcmd_empty|Pp.Ppcmd_strings->Ppcmd_strings|Pp.Ppcmd_gluel->(* We are working around a Coq hack here *)letl=regroup_tagslinPpcmd_glue(List.mappp_of_coqppl)|Pp.Ppcmd_box(bt,pp)->Ppcmd_box(bt,pp_of_coqpppp)|Pp.Ppcmd_tag(tag,pp)->Ppcmd_tag(tag,pp_of_coqpppp)|Pp.Ppcmd_print_break(m,n)->Ppcmd_print_break(m,n)|Pp.Ppcmd_force_newline->Ppcmd_force_newline|Pp.Ppcmd_commentl->Ppcmd_commentl[%%else]letrecpp_of_coqppt=matchPp.reprtwith|Pp.Ppcmd_empty->Ppcmd_empty|Pp.Ppcmd_strings->Ppcmd_strings|Pp.Ppcmd_sized_string(l,(s:string))->Ppcmd_strings(*TODO: Add support for sized strings ???*)|Pp.Ppcmd_gluel->(* We are working around a Coq hack here *)letl=regroup_tagslinPpcmd_glue(List.mappp_of_coqppl)|Pp.Ppcmd_box(bt,pp)->Ppcmd_box(bt,pp_of_coqpppp)|Pp.Ppcmd_tag(tag,pp)->Ppcmd_tag(tag,pp_of_coqpppp)|Pp.Ppcmd_print_break(m,n)->Ppcmd_print_break(m,n)|Pp.Ppcmd_force_newline->Ppcmd_force_newline|Pp.Ppcmd_commentl->Ppcmd_commentl[%%endif]