123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147open!ImportmoduleArray=Array0moduleString=String0includeChar0moduleT=structtypet=char[@@deriving_inlinecompare,hash,sexp,sexp_grammar]letcompare=(compare_char:t->t->int)let(hash_fold_t:Ppx_hash_lib.Std.Hash.state->t->Ppx_hash_lib.Std.Hash.state)=hash_fold_charand(hash:t->Ppx_hash_lib.Std.Hash.hash_value)=letfunc=hash_charinfunx->funcx;;lett_of_sexp=(char_of_sexp:Ppx_sexp_conv_lib.Sexp.t->t)letsexp_of_t=(sexp_of_char:t->Ppx_sexp_conv_lib.Sexp.t)let(t_sexp_grammar:Ppx_sexp_conv_lib.Sexp.Private.Raw_grammar.t)=let(_the_generic_group:Ppx_sexp_conv_lib.Sexp.Private.Raw_grammar.generic_group)={implicit_vars=["char"];ggid="\146e\023\249\235eE\139c\132W\195\137\129\235\025";types=["t",Implicit_var0]}inlet(_the_group:Ppx_sexp_conv_lib.Sexp.Private.Raw_grammar.group)={gid=Ppx_sexp_conv_lib.Lazy_group_id.create();apply_implicit=[char_sexp_grammar];generic_group=_the_generic_group;origin="char.ml.T"}inlet(t_sexp_grammar:Ppx_sexp_conv_lib.Sexp.Private.Raw_grammar.t)=Ref("t",_the_group)int_sexp_grammar;;[@@@end]letto_stringt=String.make1tletof_strings=matchString.lengthswith|1->s.[0]|_->failwithf"Char.of_string: %S"s();;endincludeTincludeIdentifiable.Make(structincludeTletmodule_name="Base.Char"end)(* Open replace_polymorphic_compare after including functor instantiations so they do not
shadow its definitions. This is here so that efficient versions of the comparison
functions are available within this module. *)open!Char_replace_polymorphic_compareletinvariant(_:t)=()letall=Array.init256~f:unsafe_of_int|>Array.to_listletis_lowercase=function|'a'..'z'->true|_->false;;letis_uppercase=function|'A'..'Z'->true|_->false;;letis_print=function|' '..'~'->true|_->false;;letis_whitespace=function|'\t'|'\n'|'\011'(* vertical tab *)|'\012'(* form feed *)|'\r'|' '->true|_->false;;letis_digit=function|'0'..'9'->true|_->false;;letis_alpha=function|'a'..'z'|'A'..'Z'->true|_->false;;(* Writing these out, instead of calling [is_alpha] and [is_digit], reduces
runtime by approx. 30% *)letis_alphanum=function|'a'..'z'|'A'..'Z'|'0'..'9'->true|_->false;;letget_digit_unsafet=to_intt-to_int'0'letget_digit_exnt=ifis_digittthenget_digit_unsafetelsefailwithf"Char.get_digit_exn %C: not a digit"t();;letget_digitt=ifis_digittthenSome(get_digit_unsafet)elseNonemoduleO=structlet(>=)=(>=)let(<=)=(<=)let(=)=(=)let(>)=(>)let(<)=(<)let(<>)=(<>)endmoduleCaseless=structmoduleT=structtypet=char[@@deriving_inlinesexp]lett_of_sexp=(char_of_sexp:Ppx_sexp_conv_lib.Sexp.t->t)letsexp_of_t=(sexp_of_char:t->Ppx_sexp_conv_lib.Sexp.t)[@@@end]letcomparec1c2=compare(lowercasec1)(lowercasec2)lethash_fold_tstatet=hash_fold_charstate(lowercaset)lethasht=Hash.runhash_fold_ttendincludeTincludeComparable.Make(T)end(* Include type-specific [Replace_polymorphic_compare] at the end, after
including functor application that could shadow its definitions. This is
here so that efficient versions of the comparison functions are exported by
this module. *)includeChar_replace_polymorphic_compare