Legend:
Page
Library
Module
Module type
Parameter
Class
Class type
Source
Source file dunextract.ml
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134(**************************************************************************)(* *)(* Copyright 2021 OCamlPro *)(* *)(* All rights reserved. This file is distributed under the terms of *)(* the Lesser GNU Public License version 3.0. *)(* *)(* This software is distributed in the hope that it will be useful, *)(* but WITHOUT ANY WARRANTY; without even the implied warranty of *)(* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *)(* Lesser GNU General Public License for more details. *)(* *)(**************************************************************************)typesexp=Aofstring|Tofsexplistletatomstri=letrecescapedj=ifj>=String.lengthstrthenjelsematchstr.[j]with|'"'->j+1|'\\'->escaped(j+2)|_->escaped(j+1)inletrecunescapedj=ifj>=String.lengthstrthenjelsematchstr.[j]with|' '|'\n'|'\t'|'\r'|'('|')'->j|'\\'->unescaped(j+2)|_->unescaped(j+1)inletj=matchstr.[i]with|'"'->escaped(i+1)|_->unescaped(i+1)inj,String.substri(j-i)letrecsexp_parsestri=ifi>=String.lengthstrtheni,[]elsematchstr.[i]with|' '|'\n'|'\t'|'\r'->sexp_parsestr(i+1)|'('->leti,t1=sexp_parsestr(i+1)inleti,t=sexp_parsestriini,Tt1::t|')'->i+1,[]|';'->leti=tryString.index_fromstr(i+1)'\n'+1withNot_found->String.lengthstrinsexp_parsestri|_->leti,a=atomstriinleti,t=sexp_parsestriini,Aa::tletreccut_listaacc=function|x::r->ifx=athenacc,relsecut_lista(x::acc)r|[]->acc,[]letmodule_eqname=function|An->IndexMisc.capitalizen=name|_->falseletlist_find_optfl=trySome(List.findfl)withNot_found->Noneletrecget_lib_namemodname=function|T(A"library"::t)::r->ifList.mem(T[A"wrapped";A"false"])tthenget_lib_namemodnamerelseletlibname=matchlist_find_opt(functionT(A"name"::_)->true|_->false)twith|Some(T[_;Aname])->name|_->matchlist_find_opt(functionT(A"public_name"::_)->true|_->false)twith|Some(T[_;Aname])->List.hd(List.rev(IndexMisc.string_split'.'name))|_->""in(matchlist_find_opt(functionT(A"modules"::_)->true|_->false)twith|None->Somelibname|Some(T(_::ms))->letinc,exc=cut_list(A"\\")[]msinifnot(List.exists(module_eqmodname)exc)&&List.exists(funn->module_eqmodnamen||n=A":standard")incthenSomelibnameelseget_lib_namemodnamer|Some_->assertfalse)|_::r->get_lib_namemodnamer|[]->Noneletstring_of_channelic=letn=4096inlets=Bytes.createninletb=Buffer.create1024inletrecitericbs=letnread=tryinputics0nwithEnd_of_file->0inifnread>0then(Buffer.add_subbytesbs0nread;itericbs)initericbs;Buffer.contentsbletread_dunedir=tryletic=open_in(Filename.concatdir"dune")inlets=string_of_channelicinletr=sexp_parses0inclose_inic;SomerwithSys_error_->Noneletrm_extf=tryFilename.chop_extensionfwithInvalid_argument_->fletget_libnamefile=letmodname=IndexMisc.capitalize(Filename.(basename(rm_extfile)))inmatchread_dune(Filename.dirnamefile)with|Some(_,sexp)->get_lib_namemodnamesexp|None->None