1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586(*****************************************************************************)(* *)(* Open Source License *)(* Copyright (c) 2018 Dynamic Ledger Solutions, Inc. <contact@tezos.com> *)(* *)(* Permission is hereby granted, free of charge, to any person obtaining a *)(* copy of this software and associated documentation files (the "Software"),*)(* to deal in the Software without restriction, including without limitation *)(* the rights to use, copy, modify, merge, publish, distribute, sublicense, *)(* and/or sell copies of the Software, and to permit persons to whom the *)(* Software is furnished to do so, subject to the following conditions: *)(* *)(* The above copyright notice and this permission notice shall be included *)(* in all copies or substantial portions of the Software. *)(* *)(* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR*)(* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, *)(* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL *)(* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER*)(* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING *)(* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER *)(* DEALINGS IN THE SOFTWARE. *)(* *)(*****************************************************************************)type'alazyt=unit->'atype'alazy_list_t=LConsof'a*'alazy_list_ttzresultLwt.tlazyttype'alazy_list='alazy_list_ttzresultLwt.tlet[@coq_struct"i"]rec(-->)ij=(* [i; i+1; ...; j] *)ifCompare.Int.(i>j)then[]elsei::(succi-->j)let[@coq_struct"i"]rec(--->)ij=(* [i; i+1; ...; j] *)ifCompare.Int32.(i>j)then[]elsei::(Int32.succi--->j)letsplitdelim?(limit=max_int)path=letl=String.lengthpathinletrecdo_slashesacclimiti=ifCompare.Int.(i>=l)thenList.revaccelseifCompare.Char.(path.[i]=delim)thendo_slashesacclimit(i+1)elsedo_splitacclimitianddo_splitacclimiti=ifCompare.Int.(limit<=0)thenifCompare.Int.(i=l)thenList.revaccelseList.rev(String.subpathi(l-i)::acc)elsedo_componentacc(predlimit)iianddo_componentacclimitij=ifCompare.Int.(j>=l)thenifCompare.Int.(i=j)thenList.revaccelseList.rev(String.subpathi(j-i)::acc)elseifCompare.Char.(path.[j]=delim)thendo_slashes(String.subpathi(j-i)::acc)limitjelsedo_componentacclimiti(j+1)inifCompare.Int.(limit>0)thendo_slashes[]limit0else[path][@@coq_axiom_with_reason"non-top-level mutual recursion"]letpp_print_paragraphppfdescription=Format.fprintfppf"@[%a@]"Format.(pp_print_list~pp_sep:pp_print_spacepp_print_string)(split' 'description)lettakenl=letrecloopaccnxs=ifCompare.Int.(n<=0)thenSome(List.revacc,xs)elsematchxswith[]->None|x::xs->loop(x::acc)(n-1)xsinloop[]nlletremove_prefix~prefixs=letx=String.lengthprefixinletn=String.lengthsinifCompare.Int.(n>=x)&&Compare.String.(String.subs0x=prefix)thenSome(String.subsx(n-x))elseNoneletrecremove_elem_from_listnb=function|[]->[]|_::_aslwhenCompare.Int.(nb<=0)->l|_::tl->remove_elem_from_list(nb-1)tl