1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859(* [String0] defines string functions that are primitives or can be simply defined in
terms of [Stdlib.String]. [String0] is intended to completely express the part of
[Stdlib.String] that [Base] uses -- no other file in Base other than string0.ml should
use [Stdlib.String]. [String0] has few dependencies, and so is available early in Base's
build order.
All Base files that need to use strings, including the subscript syntax [x.[i]] which
the OCaml parser desugars into calls to [String], and come before [Base.String] in
build order should do
{[
module String = String0
]}
Defining [module String = String0] is also necessary because it prevents
ocamldep from mistakenly causing a file to depend on [Base.String]. *)open!Import0moduleSys=Sys0moduleString=structexternalget:(string[@local_opt])->(int[@local_opt])->char="%string_safe_get"externallength:(string[@local_opt])->int="%string_length"externalunsafe_get:(string[@local_opt])->(int[@local_opt])->char="%string_unsafe_get"endincludeStringletmax_length=Sys.max_string_lengthlet(^)=(^)letcapitalize=Stdlib.String.capitalize_asciiletcompare=Stdlib.String.compareletescaped=Stdlib.String.escapedletlowercase=Stdlib.String.lowercase_asciiletmake=Stdlib.String.makeletsub=Stdlib.String.subletuncapitalize=Stdlib.String.uncapitalize_asciiletunsafe_blit=Stdlib.String.unsafe_blitletuppercase=Stdlib.String.uppercase_asciiletsplit_on_char=Stdlib.String.split_on_charletconcat?(sep="")l=matchlwith|[]->""(* The stdlib does not specialize this case because it could break existing projects. *)|[x]->x|l->Stdlib.String.concat~sepl;;letitert~f:(f[@local])=fori=0tolengtht-1dof(unsafe_getti)done;;