text
stringlengths
12
786k
let sec_part ~ regexp line = Str . string_match ( Str . regexp regexp ) line 0
let sec_start = sec_part ~ regexp " : " *=+
let sec_end = sec_part ~ regexp " ( :-+\\|\\ Nothing else to report in this section ) " \\
let errors = ref 0
let error ~ why ~ where ( ) = incr errors ; prerr_string " \ x1b [ 0 ; 31m " ; prerr_string where ; prerr_string " : \ x1b [ 0 ; 37 ; 41m " ; prerr_string why ; prerr_string " \ x1b [ 0m " |> prerr_newline
let total = ref 0
let comp = ref " "
let nextl = ref " "
let fnames = ref [ ]
let dir = ref " "
let res = ref ( open_in_gen [ Open_creat ] 777 " trash . out " )
let fn = ref None
let in_file = ref ! res
let old_fn = ref None
let extend = ref " "
let normalize fname = let rec block fname pos len = if pos = String . length fname || fname . [ pos ] = ' ' / then String . sub fname ( pos - len ) len else block fname ( pos + 1 ) ( len + 1 ) in let rec normalize acc fname pos = if pos = String . length fname then acc else let ...
let rec empty file = try let where = input_line file in if where <> " " then ( error ~ why " : Not detected " ~ where ( ) ; incr total ) ; empty file with _ -> close_in file
let rec empty_fnames ( ? regexp = " . " ) * threshold = function | e :: l -> let extension s = let tmp = Filename . chop_extension s in String . sub s ( String . length tmp ) ( String . length s - String . length tmp ) in if ( try extension e <= extension threshold with _ -> t...
let is_trash diff eq = let tmp = open_in " trash . out " in if ! in_file <> tmp then ( close_in tmp ; diff ( ) ) else eq
let rec check_fn name line = let ok = match ! fn with | None -> begin match ! old_fn with | Some str when str = name -> decr total ; error ~ why " : Should not be detected " ~ where : line ( ) ; nextl := " " ; false | _ -> fn := Some name ; let name = normalize ( ! dir ^ name ...
let check_elt ~ f line x = compare x @@ f line
let check_aux line status = if status > 0 then ( error ~ why ( " : Not detected " ) ~ where : line ( ) ; comp := " " ; false ) else if status < 0 then ( decr total ; error ~ why ( " : Should not be detected " ) ~ where :! nextl ( ) ; nextl := " " ; false ) ...
let check_value line x = check_elt ~ f : get_info line x |> check_aux line
let check_pos line pos = check_elt ~ f : get_pos line pos |> check_aux line
let check_info line info = if ( check_elt ~ f : get_info line info ) <> 0 then ( error ~ why ( " : Expected " : ^ ( get_info line ) ) ~ where :! nextl ( ) ; nextl := " " ; comp := " " ; false ) else true
let rec section ( ? path = true ) ( ? pos = true ) ( ? value = false ) ( ? info = true ) ( ) = try if ! nextl = " " then ( nextl := input_line ! res ; section ~ path ~ pos ~ value ~ info ( ) ) else if sec_start ! nextl then ( nextl := " " ; comp := " " ;...
let rec sel_section ( ) = fn := None ; old_fn := None ; nextl := " " ; comp := " " ; try match ( input_line ! res ) with | " . > UNUSED EXPORTED VALUES " : as s -> ( try fnames := empty_fnames ~ regexp " . :\\ ml [ a - z0 - 9 ] " *$ " . mli " ! fnames wi...
let result ( ) = print_string " Total : \ x1b [ 0 ; 34m " ; print_int ! total ; print_string " \ x1b [ 0m \ nFailed : \ x1b [ 0 ; 31m " ; print_int ! errors ; let ratio = ( . - ) 100 . @@ ( . * ) 100 . @@ ( float_of_int ! total |> ( . / ) @@...
let rec get_fnames ( ? acc = [ ] ) dir = try if Sys . is_directory dir then acc @ Array . fold_left ( fun l s -> get_fnames ~ acc : l ( normalize ( dir ^ " " / ^ s ) ) ) [ ] @@ Sys . readdir dir else if dir <> " . / check . ml " && Str . string_match ( Str . ...
let ( ) = dir := if ( Array . length Sys . argv ) < 2 then " . " else Sys . argv . ( 1 ) ; res := if ( Array . length Sys . argv ) < 3 then open_in " res . out " else open_in Sys . argv . ( 2 ) ; fnames := List . fast_sort ( fun x y -> let req s = get_...
type checkpoint_state = C_stopped | C_running of int64
type checkpoint = { mutable c_time : int64 ; mutable c_pid : int ; mutable c_fd : io_channel ; mutable c_valid : bool ; mutable c_report : report option ; mutable c_state : checkpoint_state ; mutable c_parent : checkpoint ; mutable c_breakpoint_version : int ; mutable c_breakpoints : ( pc ...
let rec root = { c_time = _0 ; c_pid = - 2 ; c_fd = std_io ; c_valid = false ; c_report = None ; c_state = C_stopped ; c_parent = root ; c_breakpoint_version = 0 ; c_breakpoints = [ ] ; c_trap_barrier = 0 ; c_code_fragments = [ 0 ] }
let checkpoints = ref ( [ ] : checkpoint list )
let current_checkpoint = ref root
let current_time ( ) = ! current_checkpoint . c_time
let current_report ( ) = ! current_checkpoint . c_report
let current_pc_sp ( ) = match current_report ( ) with | Some { rep_type = Event | Breakpoint ; rep_program_pointer = pc ; rep_stack_pointer = sp } -> Some ( pc , sp ) | _ -> None
let current_pc ( ) = Option . map fst ( current_pc_sp ( ) )
module Stdlib = struct external register_named_value : string -> ' a -> unit = " caml_register_named_value " let ( ) = register_named_value " Pervasives . array_bound_error " ( Invalid_argument " index out of bounds " ) external raise : exn -> ' a = " % raise " external raise_not...
let create_char_set ( ) = Bytes . make 32 ' \ 000 '
let add_in_char_set char_set c = let ind = int_of_char c in let str_ind = ind lsr 3 and mask = 1 lsl ( ind land 0b111 ) in Bytes . set char_set str_ind ( char_of_int ( int_of_char ( Bytes . get char_set str_ind ) lor mask ) )
let freeze_char_set char_set = Bytes . to_string char_set
let rev_char_set char_set = let char_set ' = create_char_set ( ) in for i = 0 to 31 do Bytes . set char_set ' i ( char_of_int ( int_of_char ( String . get char_set i ) lxor 0xFF ) ) done ; Bytes . unsafe_to_string char_set '
let is_in_char_set char_set c = let ind = int_of_char c in let str_ind = ind lsr 3 and mask = 1 lsl ( ind land 0b111 ) in int_of_char ( String . get char_set str_ind ) land mask <> 0
type ( ' a , ' b , ' c , ' d , ' e , ' f ) param_format_ebb = | Param_format_EBB : ( ' x -> ' a , ' b , ' c , ' d , ' e , ' f ) fmt -> ( ' a , ' b , ' c , ' d , ' e , ' f ) param_format_ebb
let pad_of_pad_opt pad_opt = match pad_opt with | None -> No_padding | Some width -> Lit_padding ( Right , width )
let prec_of_prec_opt prec_opt = match prec_opt with None -> No_precision | Some ndec -> Lit_precision ndec
let param_format_of_ignored_format : type a b c d e f x y . ( a , b , c , d , y , x ) ignored -> ( x , b , c , y , e , f ) fmt -> ( a , b , c , d , e , f ) param_format_ebb = fun ign fmt -> match ign with | Ignored_char -> Param_format_EBB ( Char fmt ) | Ignored_c...
type ( ' b , ' c ) acc_formatting_gen = | Acc_open_tag of ( ' b , ' c ) acc | Acc_open_box of ( ' b , ' c ) acc | Acc_formatting_lit of ( ' b , ' c ) acc * formatting_lit | Acc_formatting_gen of ( ' b , ' c ) acc * ( ' b , ' c ) acc_formatting_gen | Ac...
type ( ' a , ' b ) heter_list = | Cons : ' c * ( ' a , ' b ) heter_list -> ( ' c -> ' a , ' b ) heter_list | Nil : ( ' b , ' b ) heter_list
type ( ' a , ' b , ' c , ' d , ' e , ' f ) padding_fmtty_ebb = | Padding_fmtty_EBB : ( ' x , ' y ) padding * ( ' y , ' b , ' c , ' d , ' e , ' f ) fmtty -> ( ' x , ' b , ' c , ' d , ' e , ' f ) padding_fmtty_ebb
type ( ' a , ' b , ' c , ' d , ' e , ' f ) padprec_fmtty_ebb = | Padprec_fmtty_EBB : ( ' x , ' y ) padding * ( ' y , ' z ) precision * ( ' z , ' b , ' c , ' d , ' e , ' f ) fmtty -> ( ' x , ' b , ' c , ' d , ' e , ' f ...
type ( ' a , ' b , ' c , ' e , ' f ) padding_fmt_ebb = | Padding_fmt_EBB : ( _ , ' x -> ' a ) padding * ( ' a , ' b , ' c , ' d , ' e , ' f ) fmt -> ( ' x , ' b , ' c , ' e , ' f ) padding_fmt_ebb
type ( ' a , ' b , ' c , ' e , ' f ) precision_fmt_ebb = | Precision_fmt_EBB : ( _ , ' x -> ' a ) precision * ( ' a , ' b , ' c , ' d , ' e , ' f ) fmt -> ( ' x , ' b , ' c , ' e , ' f ) precision_fmt_ebb
type ( ' p , ' b , ' c , ' e , ' f ) padprec_fmt_ebb = | Padprec_fmt_EBB : ( ' x , ' y ) padding * ( ' y , ' p -> ' a ) precision * ( ' a , ' b , ' c , ' d , ' e , ' f ) fmt -> ( ' p , ' b , ' c , ' e , ' f ) padprec_fmt_...
type ( ' b , ' c , ' e , ' f ) fmt_ebb = | Fmt_EBB : ( ' a , ' b , ' c , ' d , ' e , ' f ) fmt -> ( ' b , ' c , ' e , ' f ) fmt_ebb
type ( ' a , ' b , ' c , ' d , ' e , ' f ) fmt_fmtty_ebb = | Fmt_fmtty_EBB : ( ' a , ' b , ' c , ' d , ' y , ' x ) fmt * ( ' x , ' b , ' c , ' y , ' e , ' f ) fmtty -> ( ' a , ' b , ' c , ' d , ' e , ' f ) fmt_f...
type ( ' a , ' b , ' c , ' d , ' e , ' f ) fmtty_fmt_ebb = | Fmtty_fmt_EBB : ( ' a , ' b , ' c , ' d , ' y , ' x ) fmtty * ( ' x , ' b , ' c , ' y , ' e , ' f ) fmt_fmtty_ebb -> ( ' a , ' b , ' c , ' d , ' e , ' f...
type fmtty_ebb = Fmtty_EBB : ( ' a , ' b , ' c , ' d , ' e , ' f ) fmtty -> fmtty_ebb
type padding_ebb = Padding_EBB : ( ' a , ' b ) padding -> padding_ebb
type precision_ebb = Precision_EBB : ( ' a , ' b ) precision -> precision_ebb
let default_float_precision fconv = match snd fconv with | Float_f | Float_e | Float_E | Float_g | Float_G | Float_h | Float_H -> - 6 | Float_F -> 12 = " caml_nativeint_format " = " caml_hexstring_of_float "
type buffer = { mutable ind : int ; mutable bytes : bytes }
let buffer_create init_size = { ind = 0 ; bytes = Bytes . create init_size }
let buffer_check_size buf overhead = let len = Bytes . length buf . bytes in let min_len = buf . ind + overhead in if min_len > len then ( let new_len = max ( len * 2 ) min_len in let new_str = Bytes . create new_len in Bytes . blit buf . bytes 0 new_str 0 len ; buf . bytes <- new_str ...
let buffer_add_char buf c = buffer_check_size buf 1 ; Bytes . set buf . bytes buf . ind c ; buf . ind <- buf . ind + 1
let buffer_add_string buf s = let str_len = String . length s in buffer_check_size buf str_len ; String . blit s 0 buf . bytes buf . ind str_len ; buf . ind <- buf . ind + str_len
let buffer_contents buf = Bytes . sub_string buf . bytes 0 buf . ind
let char_of_iconv iconv = match iconv with | Int_d | Int_pd | Int_sd | Int_Cd -> ' d ' | Int_i | Int_pi | Int_si | Int_Ci -> ' i ' | Int_x | Int_Cx -> ' x ' | Int_X | Int_CX -> ' X ' | Int_o | Int_Co -> ' o ' | Int_u | Int_Cu -> ' u '
let char_of_fconv ( ? cF = ' F ' ) fconv = match snd fconv with | Float_f -> ' f ' | Float_e -> ' e ' | Float_E -> ' E ' | Float_g -> ' g ' | Float_G -> ' G ' | Float_F -> cF | Float_h -> ' h ' | Float_H -> ' H '
let char_of_counter counter = match counter with | Line_counter -> ' l ' | Char_counter -> ' n ' | Token_counter -> ' N '
let bprint_char_set buf char_set = let rec print_start set = let is_alone c = let before , after = Char . ( chr ( code c - 1 ) , chr ( code c + 1 ) ) in is_in_char_set set c && not ( is_in_char_set set before && is_in_char_set set after ) in if is_alone ' ] ' then buffer_add_char b...
let bprint_padty buf padty = match padty with | Left -> buffer_add_char buf ' ' - | Right -> ( ) | Zeros -> buffer_add_char buf ' 0 '
let bprint_ignored_flag buf ign_flag = if ign_flag then buffer_add_char buf ' _ '
let bprint_pad_opt buf pad_opt = match pad_opt with | None -> ( ) | Some width -> buffer_add_string buf ( Int . to_string width )
let bprint_padding : type a b . buffer -> ( a , b ) padding -> unit = fun buf pad -> match pad with | No_padding -> ( ) | Lit_padding ( padty , n ) -> bprint_padty buf padty ; buffer_add_string buf ( Int . to_string n ) | Arg_padding padty -> bprint_padty buf padty ; buffer_add_ch...
let bprint_precision : type a b . buffer -> ( a , b ) precision -> unit = fun buf prec -> match prec with | No_precision -> ( ) | Lit_precision n -> buffer_add_char buf ' . ' ; buffer_add_string buf ( Int . to_string n ) | Arg_precision -> buffer_add_string buf " . " *
let bprint_iconv_flag buf iconv = match iconv with | Int_pd | Int_pi -> buffer_add_char buf ' ' + | Int_sd | Int_si -> buffer_add_char buf ' ' | Int_Cx | Int_CX | Int_Co | Int_Cd | Int_Ci | Int_Cu -> buffer_add_char buf ' ' # | Int_d | Int_i | Int_x | Int_X | Int_o | Int_u -> ( )
let bprint_int_fmt buf ign_flag iconv pad prec = buffer_add_char buf ' ' ; % bprint_ignored_flag buf ign_flag ; bprint_iconv_flag buf iconv ; bprint_padding buf pad ; bprint_precision buf prec ; buffer_add_char buf ( char_of_iconv iconv )
let bprint_altint_fmt buf ign_flag iconv pad prec c = buffer_add_char buf ' ' ; % bprint_ignored_flag buf ign_flag ; bprint_iconv_flag buf iconv ; bprint_padding buf pad ; bprint_precision buf prec ; buffer_add_char buf c ; buffer_add_char buf ( char_of_iconv iconv )
let bprint_fconv_flag buf fconv = match fst fconv with | Float_flag_p -> buffer_add_char buf ' ' + | Float_flag_s -> buffer_add_char buf ' ' | Float_flag_ -> ( )
let bprint_float_fmt buf ign_flag fconv pad prec = buffer_add_char buf ' ' ; % bprint_ignored_flag buf ign_flag ; bprint_fconv_flag buf fconv ; bprint_padding buf pad ; bprint_precision buf prec ; buffer_add_char buf ( char_of_fconv fconv )
let string_of_formatting_lit formatting_lit = match formatting_lit with | Close_box -> " ] " @ | Close_tag -> " } " @ | Break ( str , _ , _ ) -> str | FFlush -> " " @? | Force_newline -> " @\ n " | Flush_newline -> " . " @ | Magic_size ( str , _ ) -> str |...
let string_of_formatting_gen : type a b c d e f . ( a , b , c , d , e , f ) formatting_gen -> string = fun formatting_gen -> match formatting_gen with | Open_tag ( Format ( _ , str ) ) -> str | Open_box ( Format ( _ , str ) ) -> str
let bprint_char_literal buf chr = match chr with | ' ' % -> buffer_add_string buf " " %% | _ -> buffer_add_char buf chr
let bprint_string_literal buf str = for i = 0 to String . length str - 1 do bprint_char_literal buf str . [ i ] done
let rec bprint_fmtty : type a b c d e f g h i j k l . buffer -> ( a , b , c , d , e , f , g , h , i , j , k , l ) fmtty_rel -> unit = fun buf fmtty -> match fmtty with | Char_ty rest -> buffer_add_string buf " % c " ; bprint_fmtty buf rest | String_ty rest -> buffer_add_strin...
let rec int_of_custom_arity : type a b c . ( a , b , c ) custom_arity -> int = function | Custom_zero -> 0 | Custom_succ x -> 1 + int_of_custom_arity x
let bprint_fmt buf fmt = let rec fmtiter : type a b c d e f . ( a , b , c , d , e , f ) fmt -> bool -> unit = fun fmt ign_flag -> match fmt with | String ( pad , rest ) -> buffer_add_char buf ' ' ; % bprint_ignored_flag buf ign_flag ; bprint_padding buf pad ; buffer_add_char buf...
let string_of_fmt fmt = let buf = buffer_create 16 in bprint_fmt buf fmt ; buffer_contents buf
type ( _ , _ ) eq = Refl : ( ' a , ' a ) eq
let rec symm : type a1 b1 c1 d1 e1 f1 a2 b2 c2 d2 e2 f2 . ( a1 , b1 , c1 , d1 , e1 , f1 , a2 , b2 , c2 , d2 , e2 , f2 ) fmtty_rel -> ( a2 , b2 , c2 , d2 , e2 , f2 , a1 , b1 , c1 , d1 , e1 , f1 ) fmtty_rel = function | Char_ty rest -> Char_ty ( symm rest ) ...
let rec fmtty_rel_det : type a1 b c d1 e1 f1 a2 d2 e2 f2 . ( a1 , b , c , d1 , e1 , f1 , a2 , b , c , d2 , e2 , f2 ) fmtty_rel -> ( ( f1 , f2 ) eq -> ( a1 , a2 ) eq ) * ( ( a1 , a2 ) eq -> ( f1 , f2 ) eq ) * ( ( e1 , e2 ) eq -> ( d1 , d2 ) ...
let rec fmtty_of_formatting_gen : type a b c d e f . ( a , b , c , d , e , f ) formatting_gen -> ( a , b , c , d , e , f ) fmtty = fun formatting_gen -> match formatting_gen with | Open_tag ( Format ( fmt , _ ) ) -> fmtty_of_fmt fmt | Open_box ( Format ( fmt , _ ) ...
let type_padding : type a b c d e f x y . ( x , y ) padding -> ( a , b , c , d , e , f ) fmtty -> ( a , b , c , d , e , f ) padding_fmtty_ebb = fun pad fmtty -> match pad , fmtty with | No_padding , _ -> Padding_fmtty_EBB ( No_padding , fmtty ) | Lit_padding ( pa...
let type_padprec : type a b c d e f x y z . ( x , y ) padding -> ( y , z ) precision -> ( a , b , c , d , e , f ) fmtty -> ( a , b , c , d , e , f ) padprec_fmtty_ebb = fun pad prec fmtty -> match prec , type_padding pad fmtty with | No_precision , Padding_fmtty_EBB ...
let rec type_format : type a1 b1 c1 d1 e1 f1 a2 b2 c2 d2 e2 f2 . ( a1 , b1 , c1 , d1 , e1 , f1 ) fmt -> ( a2 , b2 , c2 , d2 , e2 , f2 ) fmtty -> ( a2 , b2 , c2 , d2 , e2 , f2 ) fmt = fun fmt fmtty -> match type_format_gen fmt fmtty with | Fmt_fmtty_EBB ( fmt ' , E...
let recast : type a1 b1 c1 d1 e1 f1 a2 b2 c2 d2 e2 f2 . ( a1 , b1 , c1 , d1 , e1 , f1 ) fmt -> ( a1 , b1 , c1 , d1 , e1 , f1 , a2 , b2 , c2 , d2 , e2 , f2 ) fmtty_rel -> ( a2 , b2 , c2 , d2 , e2 , f2 ) fmt = fun fmt fmtty -> type_format fmt ( erase_rel ( ...
let fix_padding padty width str = let len = String . length str in let width , padty = ( abs width , if width < 0 then Left else padty ) in if width <= len then str else let res = Bytes . make width ( if padty = Zeros then ' 0 ' else ' ' ) in begin match padty with | Left -> String . ...