text stringlengths 12 786k |
|---|
let rcut ~ sep ( : sep , sep_start , sep_stop ) ( s , start , stop ) = let sep_len = sep_stop - sep_start in if sep_len = 0 then invalid_arg Astring_base . err_empty_sep else let max_sep_zidx = sep_len - 1 in let max_s_idx = stop - 1 in let rec check_sep i k = if k > max_sep_zidx then S... |
let cut ( ? rev = false ) ~ sep s = match rev with |
let add_sub ~ no_empty s ~ start ~ stop acc = if start = stop then ( if no_empty then acc else ( s , start , start ) :: acc ) else ( s , start , stop ) :: acc |
let fcuts ~ no_empty ~ sep ( : sep , sep_start , sep_stop ) ( s , start , stop as sub ) = let sep_len = sep_stop - sep_start in if sep_len = 0 then invalid_arg Astring_base . err_empty_sep else let s_len = stop - start in let max_sep_zidx = sep_len - 1 in let max_s_idx = stop - sep_len ... |
let rcuts ~ no_empty ~ sep ( : sep , sep_start , sep_stop ) ( s , start , stop as sub ) = let sep_len = sep_stop - sep_start in if sep_len = 0 then invalid_arg Astring_base . err_empty_sep else let s_len = stop - start in let max_sep_zidx = sep_len - 1 in let max_s_idx = stop - 1 in le... |
let cuts ( ? rev = false ) ( ? empty = true ) ~ sep s = match rev with |
let fields ( ? empty = false ) ( ? is_sep = Astring_char . Ascii . is_white ) ( s , start , stop as sub ) = let no_empty = not empty in let max_pos = stop in let rec loop i end_pos acc = if i < start then begin if end_pos = max_pos then ( if no_empty && max_pos = start then [ ] els... |
let ffind sat ( s , start , stop ) = let max_idx = stop - 1 in let rec loop i = if i > max_idx then None else if sat ( sunsafe_get s i ) then Some ( s , i , i + 1 ) else loop ( i + 1 ) in loop start |
let rfind sat ( s , start , stop ) = let rec loop i = if i < start then None else if sat ( sunsafe_get s i ) then Some ( s , i , i + 1 ) else loop ( i - 1 ) in loop ( stop - 1 ) |
let find ( ? rev = false ) sat sub = match rev with |
let ffind_sub ~ sub ( : sub , sub_start , sub_stop ) ( s , start , stop ) = let len_sub = sub_stop - sub_start in let len_s = stop - start in if len_sub > len_s then None else let max_zidx_sub = len_sub - 1 in let max_idx_s = start + len_s - len_sub in let rec loop i k = if i > max_idx_s... |
let rfind_sub ~ sub ( : sub , sub_start , sub_stop ) ( s , start , stop ) = let len_sub = sub_stop - sub_start in let len_s = stop - start in if len_sub > len_s then None else let max_zidx_sub = len_sub - 1 in let rec loop i k = if i < start then None else if k > max_zidx_sub then Some ( ... |
let find_sub ( ? rev = false ) ~ sub start = match rev with |
let filter sat ( s , start , stop ) = let len = stop - start in if len = 0 then empty else let b = Bytes . create len in let max_idx = stop - 1 in let rec loop b k i = if i > max_idx then ( ( if k = len then bytes_unsafe_to_string b else Bytes . sub_string b 0 k ) , 0 , k ) else le... |
let filter_map f ( s , start , stop ) = let len = stop - start in if len = 0 then empty else let b = Bytes . create len in let max_idx = stop - 1 in let rec loop b k i = if i > max_idx then ( ( if k = len then bytes_unsafe_to_string b else Bytes . sub_string b 0 k ) , 0 , k ) else ... |
let map f ( s , start , stop ) = let len = stop - start in if len = 0 then empty else let b = Bytes . create len in for i = 0 to len - 1 do bytes_unsafe_set b i ( f ( sunsafe_get s ( start + i ) ) ) done ; ( bytes_unsafe_to_string b , 0 , len ) |
let mapi f ( s , start , stop ) = let len = stop - start in if len = 0 then empty else let b = Bytes . create len in for i = 0 to len - 1 do bytes_unsafe_set b i ( f i ( sunsafe_get s ( start + i ) ) ) done ; ( bytes_unsafe_to_string b , 0 , len ) |
let fold_left f acc ( s , start , stop ) = Astring_base . fold_left f acc s ~ first : start ~ last ( : stop - 1 ) |
let fold_right f ( s , start , stop ) acc = Astring_base . fold_right f s acc ~ first : start ~ last ( : stop - 1 ) |
let iter f ( s , start , stop ) = for i = start to stop - 1 do f ( sunsafe_get s i ) done |
let iteri f ( s , start , stop ) = for i = start to stop - 1 do f ( i - start ) ( sunsafe_get s i ) done |
let pp ppf s = Format . pp_print_string ppf ( to_string s ) |
let dump ppf s = Format . pp_print_char ppf ' " ' ; Format . pp_print_string ppf ( Astring_escape . escape_string ( to_string s ) ) ; Format . pp_print_char ppf ' " ' ; ( ) |
let dump_raw ppf ( s , start , stop ) = Format . fprintf ppf " [ @< 1 ( [ >@< 1 ( > base @ " \% s " ) ] \@@ [ @< 1 ( > start @ % d ) ] @@ \ [ ( @ stop @ % d ) ] ) ] " @@ ( Astring_escape . escape_string s ) start stop |
let of_char c = v ( Astring_base . of_char c ) |
let to_char s = Astring_base . to_char ( to_string s ) |
let of_bool b = v ( Astring_base . of_bool b ) |
let to_bool s = Astring_base . to_bool ( to_string s ) |
let of_int i = v ( Astring_base . of_int i ) |
let to_int s = Astring_base . to_int ( to_string s ) |
let of_nativeint i = v ( Astring_base . of_nativeint i ) |
let to_nativeint s = Astring_base . to_nativeint ( to_string s ) |
let of_int32 i = v ( Astring_base . of_int32 i ) |
let to_int32 s = Astring_base . to_int32 ( to_string s ) |
let of_int64 i = v ( Astring_base . of_int64 i ) |
let to_int64 s = Astring_base . to_int64 ( to_string s ) |
let of_float f = v ( Astring_base . of_float f ) |
let to_float s = Astring_base . to_float ( to_string s ) |
type ' a with_loc = ' a Location . loc |
type lid = Longident . t with_loc |
type str = string with_loc |
type str_opt = string option with_loc |
type attrs = attribute list |
let default_loc = ref Location . none |
let with_default_loc l f = Misc . protect_refs [ Misc . R ( default_loc , l ) ] f |
module Const = struct let integer ? suffix i = Pconst_integer ( i , suffix ) let int ? suffix i = integer ? suffix ( Int . to_string i ) let int32 ( ? suffix ' = l ' ) i = integer ~ suffix ( Int32 . to_string i ) let int64 ( ? suffix ' = L ' ) i = integer ~ suffix ( Int... |
module Attr = struct let mk ( ? loc = ! default_loc ) name payload = { attr_name = name ; attr_payload = payload ; attr_loc = loc } end |
module Typ = struct let mk ( ? loc = ! default_loc ) ( ? attrs = [ ] ) d = { ptyp_desc = d ; ptyp_loc = loc ; ptyp_loc_stack = [ ] ; ptyp_attributes = attrs } let attr d a = { d with ptyp_attributes = d . ptyp_attributes @ [ a ] } let any ? loc ? attrs ( ) = mk ... |
module Pat = struct let mk ( ? loc = ! default_loc ) ( ? attrs = [ ] ) d = { ppat_desc = d ; ppat_loc = loc ; ppat_loc_stack = [ ] ; ppat_attributes = attrs } let attr d a = { d with ppat_attributes = d . ppat_attributes @ [ a ] } let any ? loc ? attrs ( ) = mk ... |
module Exp = struct let mk ( ? loc = ! default_loc ) ( ? attrs = [ ] ) d = { pexp_desc = d ; pexp_loc = loc ; pexp_loc_stack = [ ] ; pexp_attributes = attrs } let attr d a = { d with pexp_attributes = d . pexp_attributes @ [ a ] } let ident ? loc ? attrs a = mk ? lo... |
module Mty = struct let mk ( ? loc = ! default_loc ) ( ? attrs = [ ] ) d = { pmty_desc = d ; pmty_loc = loc ; pmty_attributes = attrs } let attr d a = { d with pmty_attributes = d . pmty_attributes @ [ a ] } let ident ? loc ? attrs a = mk ? loc ? attrs ( Pmty_ident a ) ... |
let mk ( ? loc = ! default_loc ) ( ? attrs = [ ] ) d = { pmod_desc = d ; pmod_loc = loc ; pmod_attributes = attrs } let attr d a = { d with pmod_attributes = d . pmod_attributes @ [ a ] } let ident ? loc ? attrs x = mk ? loc ? attrs ( Pmod_ident x ) let structure ? lo... |
module Sig = struct let mk ( ? loc = ! default_loc ) d = { psig_desc = d ; psig_loc = loc } let value ? loc a = mk ? loc ( Psig_value a ) let type_ ? loc rec_flag a = mk ? loc ( Psig_type ( rec_flag , a ) ) let type_subst ? loc a = mk ? loc ( Psig_typesubst a ) let type_exten... |
module Str = struct let mk ( ? loc = ! default_loc ) d = { pstr_desc = d ; pstr_loc = loc } let eval ? loc ( ? attrs = [ ] ) a = mk ? loc ( Pstr_eval ( a , attrs ) ) let value ? loc a b = mk ? loc ( Pstr_value ( a , b ) ) let primitive ? loc a = mk ? loc ( Pstr_... |
module Cl = struct let mk ( ? loc = ! default_loc ) ( ? attrs = [ ] ) d = { pcl_desc = d ; pcl_loc = loc ; pcl_attributes = attrs ; } let attr d a = { d with pcl_attributes = d . pcl_attributes @ [ a ] } let constr ? loc ? attrs a b = mk ? loc ? attrs ( Pcl_constr ( ... |
module Cty = struct let mk ( ? loc = ! default_loc ) ( ? attrs = [ ] ) d = { pcty_desc = d ; pcty_loc = loc ; pcty_attributes = attrs ; } let attr d a = { d with pcty_attributes = d . pcty_attributes @ [ a ] } let constr ? loc ? attrs a b = mk ? loc ? attrs ( Pcty_con... |
module Ctf = struct let mk ( ? loc = ! default_loc ) ( ? attrs = [ ] ) ( ? docs = empty_docs ) d = { pctf_desc = d ; pctf_loc = loc ; pctf_attributes = add_docs_attrs docs attrs ; } let inherit_ ? loc ? attrs a = mk ? loc ? attrs ( Pctf_inherit a ) let val_ ? loc ? attrs... |
module Cf = struct let mk ( ? loc = ! default_loc ) ( ? attrs = [ ] ) ( ? docs = empty_docs ) d = { pcf_desc = d ; pcf_loc = loc ; pcf_attributes = add_docs_attrs docs attrs ; } let inherit_ ? loc ? attrs a b c = mk ? loc ? attrs ( Pcf_inherit ( a , b , c ) ) let v... |
module Val = struct let mk ( ? loc = ! default_loc ) ( ? attrs = [ ] ) ( ? docs = empty_docs ) ( ? prim = [ ] ) name typ = { pval_name = name ; pval_type = typ ; pval_attributes = add_docs_attrs docs attrs ; pval_loc = loc ; pval_prim = prim ; } end |
module Md = struct let mk ( ? loc = ! default_loc ) ( ? attrs = [ ] ) ( ? docs = empty_docs ) ( ? text = [ ] ) name typ = { pmd_name = name ; pmd_type = typ ; pmd_attributes = add_text_attrs text ( add_docs_attrs docs attrs ) ; pmd_loc = loc ; } end |
module Ms = struct let mk ( ? loc = ! default_loc ) ( ? attrs = [ ] ) ( ? docs = empty_docs ) ( ? text = [ ] ) name syn = { pms_name = name ; pms_manifest = syn ; pms_attributes = add_text_attrs text ( add_docs_attrs docs attrs ) ; pms_loc = loc ; } end |
module Mtd = struct let mk ( ? loc = ! default_loc ) ( ? attrs = [ ] ) ( ? docs = empty_docs ) ( ? text = [ ] ) ? typ name = { pmtd_name = name ; pmtd_type = typ ; pmtd_attributes = add_text_attrs text ( add_docs_attrs docs attrs ) ; pmtd_loc = loc ; } end |
module Mb = struct let mk ( ? loc = ! default_loc ) ( ? attrs = [ ] ) ( ? docs = empty_docs ) ( ? text = [ ] ) name expr = { pmb_name = name ; pmb_expr = expr ; pmb_attributes = add_text_attrs text ( add_docs_attrs docs attrs ) ; pmb_loc = loc ; } end |
module Opn = struct let mk ( ? loc = ! default_loc ) ( ? attrs = [ ] ) ( ? docs = empty_docs ) ( ? override = Fresh ) expr = { popen_expr = expr ; popen_override = override ; popen_loc = loc ; popen_attributes = add_docs_attrs docs attrs ; } end |
module Incl = struct let mk ( ? loc = ! default_loc ) ( ? attrs = [ ] ) ( ? docs = empty_docs ) mexpr = { pincl_mod = mexpr ; pincl_loc = loc ; pincl_attributes = add_docs_attrs docs attrs ; } end |
module Vb = struct let mk ( ? loc = ! default_loc ) ( ? attrs = [ ] ) ( ? docs = empty_docs ) ( ? text = [ ] ) pat expr = { pvb_pat = pat ; pvb_expr = expr ; pvb_attributes = add_text_attrs text ( add_docs_attrs docs attrs ) ; pvb_loc = loc ; } end |
module Ci = struct let mk ( ? loc = ! default_loc ) ( ? attrs = [ ] ) ( ? docs = empty_docs ) ( ? text = [ ] ) ( ? virt = Concrete ) ( ? params = [ ] ) name expr = { pci_virt = virt ; pci_params = params ; pci_name = name ; pci_expr = expr ; pci_attribute... |
module Type = struct let mk ( ? loc = ! default_loc ) ( ? attrs = [ ] ) ( ? docs = empty_docs ) ( ? text = [ ] ) ( ? params = [ ] ) ( ? cstrs = [ ] ) ( ? kind = Ptype_abstract ) ( ? priv = Public ) ? manifest name = { ptype_name = name ; ptype_par... |
module Te = struct let mk ( ? loc = ! default_loc ) ( ? attrs = [ ] ) ( ? docs = empty_docs ) ( ? params = [ ] ) ( ? priv = Public ) path constructors = { ptyext_path = path ; ptyext_params = params ; ptyext_constructors = constructors ; ptyext_private = priv ; pty... |
module Csig = struct let mk self fields = { pcsig_self = self ; pcsig_fields = fields ; } end |
module Cstr = struct let mk self fields = { pcstr_self = self ; pcstr_fields = fields ; } end |
module Rf = struct let mk ( ? loc = ! default_loc ) ( ? attrs = [ ] ) desc = { prf_desc = desc ; prf_loc = loc ; prf_attributes = attrs ; } let tag ? loc ? attrs label const tys = mk ? loc ? attrs ( Rtag ( label , const , tys ) ) let inherit_ ? loc ty = mk ? loc ( R... |
module Of = struct let mk ( ? loc = ! default_loc ) ( ? attrs [ ] ) = desc = { pof_desc = desc ; pof_loc = loc ; pof_attributes = attrs ; } let tag ? loc ? attrs label ty = mk ? loc ? attrs ( Otag ( label , ty ) ) let inherit_ ? loc ty = mk ? loc ( Oinherit ty ) end |
let empty_record loc = err loc " Records cannot be empty . " |
let invalid_tuple loc = err loc " Tuples must have at least 2 components . " |
let no_args loc = err loc " Function application with no argument . " |
let empty_let loc = err loc " Let with no bindings . " |
let empty_type loc = err loc " Type declarations cannot be empty . " |
let complex_id loc = err loc " Functor application not allowed here . " |
let simple_longident id = let rec is_simple = function | Longident . Lident _ -> true | Longident . Ldot ( id , _ ) -> is_simple id | Longident . Lapply _ -> false in if not ( is_simple id . txt ) then complex_id id . loc |
let iterator = let super = Ast_iterator . default_iterator in let type_declaration self td = super . type_declaration self td ; let loc = td . ptype_loc in match td . ptype_kind with | Ptype_record [ ] -> empty_record loc | _ -> ( ) in let typ self ty = super . typ self ty ; let loc = t... |
let structure st = iterator . structure iterator st |
let signature sg = iterator . signature iterator sg |
type iterator = { attribute : iterator -> attribute -> unit ; attributes : iterator -> attribute list -> unit ; binding_op : iterator -> binding_op -> unit ; case : iterator -> case -> unit ; cases : iterator -> case list -> unit ; class_declaration : iterator -> class_declaration -> unit... |
let iter_fst f ( x , _ ) = f x |
let iter_snd f ( _ , y ) = f y |
let iter_tuple f1 f2 ( x , y ) = f1 x ; f2 y |
let iter_tuple3 f1 f2 f3 ( x , y , z ) = f1 x ; f2 y ; f3 z |
let iter_opt f = function None -> ( ) | Some x -> f x |
let iter_loc sub { loc ; txt = _ } = sub . location sub loc |
module T = struct let row_field sub { prf_desc ; prf_loc ; prf_attributes ; } = sub . location sub prf_loc ; sub . attributes sub prf_attributes ; match prf_desc with | Rtag ( _ , _ , tl ) -> List . iter ( sub . typ sub ) tl | Rinherit t -> sub . typ sub t let object_field su... |
module CT = struct let iter sub { pcty_loc = loc ; pcty_desc = desc ; pcty_attributes = attrs } = sub . location sub loc ; sub . attributes sub attrs ; match desc with | Pcty_constr ( lid , tys ) -> iter_loc sub lid ; List . iter ( sub . typ sub ) tys | Pcty_signature x -> sub .... |
let iter_functor_param sub = function | Unit -> ( ) | Named ( name , mty ) -> iter_loc sub name ; sub . module_type sub mty |
module MT = struct let iter sub { pmty_desc = desc ; pmty_loc = loc ; pmty_attributes = attrs } = sub . location sub loc ; sub . attributes sub attrs ; match desc with | Pmty_ident s -> iter_loc sub s | Pmty_alias s -> iter_loc sub s | Pmty_signature sg -> sub . signature sub sg | Pmty_fun... |
module M = struct let iter sub { pmod_loc = loc ; pmod_desc = desc ; pmod_attributes = attrs } = sub . location sub loc ; sub . attributes sub attrs ; match desc with | Pmod_ident x -> iter_loc sub x | Pmod_structure str -> sub . structure sub str | Pmod_functor ( param , body ) -> it... |
module E = struct let iter sub { pexp_loc = loc ; pexp_desc = desc ; pexp_attributes = attrs } = sub . location sub loc ; sub . attributes sub attrs ; match desc with | Pexp_ident x -> iter_loc sub x | Pexp_constant _ -> ( ) | Pexp_let ( _r , vbs , e ) -> List . iter ( sub .... |
module P = struct let iter sub { ppat_desc = desc ; ppat_loc = loc ; ppat_attributes = attrs } = sub . location sub loc ; sub . attributes sub attrs ; match desc with | Ppat_any -> ( ) | Ppat_var s -> iter_loc sub s | Ppat_alias ( p , s ) -> sub . pat sub p ; iter_loc sub s | P... |
module CE = struct let iter sub { pcl_loc = loc ; pcl_desc = desc ; pcl_attributes = attrs } = sub . location sub loc ; sub . attributes sub attrs ; match desc with | Pcl_constr ( lid , tys ) -> iter_loc sub lid ; List . iter ( sub . typ sub ) tys | Pcl_structure s -> sub . cl... |
let default_iterator = { structure = ( fun this l -> List . iter ( this . structure_item this ) l ) ; structure_item = M . iter_structure_item ; module_expr = M . iter ; signature = ( fun this l -> List . iter ( this . signature_item this ) l ) ; signature_item = MT . ite... |
type mapper = { attribute : mapper -> attribute -> attribute ; attributes : mapper -> attribute list -> attribute list ; binding_op : mapper -> binding_op -> binding_op ; case : mapper -> case -> case ; cases : mapper -> case list -> case list ; class_declaration : mapper -> class_declarat... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.