123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176openOdoc_utils(** Returns [true] on chars that are part of operators. *)letoperator_char=function(* https://ocaml.org/manual/5.2/lex.html#core-operator-char *)|'$'|'&'|'*'|'+'|'-'|'/'|'='|'>'|'@'|'^'|'|'|'~'|'!'|'?'|'%'|'<'|':'|'.'(* https://ocaml.org/manual/5.2/lex.html#infix-symbol *)|'#'(* https://ocaml.org/manual/5.2/indexops.html#s:index-operators *)|'('|')'|'['|']'|'{'|'}'->true|_->falseletis_operator=function|"asr"|"land"|"lor"|"lsl"|"lsr"|"lxor"|"mod"|"or"->true|name->String.existsoperator_charnameletparenthesisename=ifis_operatornamethen"("^name^")"elsenameletcontains_double_underscores=letlen=String.lengthsinletrecauxi=ifi>len-2thenfalseelseifs.[i]='_'&&s.[i+1]='_'thentrueelseaux(i+1)inaux0moduletypeName=sigtypetvalto_string:t->stringvalto_string_unsafe:t->stringvalmake_std:string->tvalof_ident:Ident.t->tvalhidden_of_string:string->tvalhidden_of_ident:Ident.t->tvalshadowed_of_string:string->tvalshadowed_of_ident:Ident.t->tvalequal_modulo_shadowing:t->t->boolvalequal:t->t->boolvalcompare:t->t->intvalfmt:Format.formatter->t->unitvalis_hidden:t->boolendletinternal_counter=ref0letunique_id=refNoneletset_unique_identid=match!unique_idwith|Some_->failwith"Unique id already set"|None->unique_id:=SomeidmoduleName:Name=structtypet=|Hiddenofstring|Shadowedofstring*int*string|Stdofstringletto_string=function|Stds->parenthesises|Hiddens->Printf.sprintf"%s"s|Shadowed(s,i,s2)->Printf.sprintf"{%s}%d/shadowed/(%s)"sis2letto_string_unsafe=function|Stds->s|Hiddens->s|Shadowed(s,_i,_s2)->sletmake_stds=Stdsletof_identid=make_std(Ident.nameid)lethidden_of_stringid=Hiddenidlethidden_of_identid=hidden_of_string(Ident.nameid)letshadowed_of_stringid=incrinternal_counter;match!unique_idwith|None->failwith"Unset unique id"|Somes->Shadowed(id,!internal_counter,s)letshadowed_of_identid=shadowed_of_string(Ident.nameid)letequal_modulo_shadowing(x:t)(y:t)=match(x,y)with|Stdx,Stdy->x=y|Hiddenx,Stdy->x=y|Stdx,Hiddeny->x=y|Hiddenx,Hiddeny->x=y|Shadowed(x,i,s),Shadowed(y,j,t)->x=y&&i=j&&s=t|_,_->falseletequal(x:t)(y:t)=x=yletcompare=compareletfmtppfx=Format.fprintfppf"%s"(to_stringx)letis_hidden=function|Std_->false|Hidden_->true|Shadowed_->trueendmoduletypeSimpleName=sigtypetvalto_string:t->stringvalmake_std:string->tvalof_ident:Ident.t->tvalequal:t->t->boolvalcompare:t->t->intvalfmt:Format.formatter->t->unitvalis_hidden:t->boolendmoduleSimpleName:SimpleName=structtypet=stringletto_strings=sletmake_stds=sletof_identid=make_std(Ident.nameid)letequal(x:t)(y:t)=x=yletcomparexy=String.comparexyletfmtppft=Format.pp_print_stringppf(to_stringt)letis_hiddens=contains_double_underscoresendmoduleModuleName=structincludeNameletis_hiddens=is_hiddens||contains_double_underscore(to_strings)endmoduleModuleTypeName=NamemoduleTypeName=NamemoduleConstructorName=SimpleNamemoduleFieldName=SimpleNamemoduleExtensionName=SimpleNamemoduleExceptionName=SimpleNamemoduleValueName=NamemoduleMethodName=SimpleNamemoduleInstanceVariableName=SimpleNamemoduleLabelName=SimpleNamemodulePageName=SimpleNamemoduleDefName=SimpleNamemoduleLocalName=SimpleNamemoduleAssetName=SimpleName