text
stringlengths
0
601k
let string_of_bool b = if b then " true " else " false "
let bool_of_string = function | " true " -> true | " false " -> false | _ -> invalid_arg " bool_of_string "
let bool_of_string_opt = function | " true " -> Some true | " false " -> Some false | _ -> None # else
let string_of_int n = format_int " % d " n # end
let int_of_string_opt s = try Some ( int_of_string s ) with Failure _ -> None
let valid_float_lexem s = let l = string_length s in let rec loop i = if i >= l then s ^ " . " else match string_get s i with | ' 0 ' . . ' 9 ' | ' ' - -> loop ( i + 1 ) | _ -> s in loop 0
let string_of_float f = valid_float_lexem ( format_float " . % 12g " f )
let float_of_string_opt s = try Some ( float_of_string s ) with Failure _ -> None
let rec ( @ ) l1 l2 = match l1 with [ ] -> l2 | hd :: tl -> hd :: ( tl @ l2 )
let stdin = open_descriptor_in 0
let stdout = open_descriptor_out 1
let stderr = open_descriptor_out 2
type open_flag = Open_rdonly | Open_wronly | Open_append | Open_creat | Open_trunc | Open_excl | Open_binary | Open_text | Open_nonblock " caml_ml_set_channel_name "
let open_out_gen mode perm name = let c = open_descriptor_out ( open_desc name mode perm ) in set_out_channel_name c name ; c
let open_out name = open_out_gen [ Open_wronly ; Open_creat ; Open_trunc ; Open_text ] 0o666 name
let open_out_bin name = open_out_gen [ Open_wronly ; Open_creat ; Open_trunc ; Open_binary ] 0o666 name = " caml_ml_out_channels_list "
let flush_all ( ) = let rec iter = function [ ] -> ( ) | a :: l -> begin try flush a with Sys_error _ -> ( ) end ; iter l in iter ( out_channels_list ( ) ) = " caml_ml_output_bytes " = " caml_ml_output "
let output_bytes oc s = unsafe_output oc s 0 ( bytes_length s )
let output_string oc s = unsafe_output_string oc s 0 ( string_length s )
let output oc s ofs len = if ofs < 0 || len < 0 || ofs > bytes_length s - len then invalid_arg " output " else unsafe_output oc s ofs len
let output_substring oc s ofs len = if ofs < 0 || len < 0 || ofs > string_length s - len then invalid_arg " output_substring " else unsafe_output_string oc s ofs len = " caml_output_value "
let output_value chan v = marshal_to_channel chan v [ ]
let close_out oc = flush oc ; close_out_channel oc
let close_out_noerr oc = ( try flush oc with _ -> ( ) ) ; ( try close_out_channel oc with _ -> ( ) ) = " caml_ml_set_binary_mode " " caml_ml_set_channel_name "
let open_in_gen mode perm name = let c = open_descriptor_in ( open_desc name mode perm ) in set_in_channel_name c name ; c
let open_in name = open_in_gen [ Open_rdonly ; Open_text ] 0 name
let open_in_bin name = open_in_gen [ Open_rdonly ; Open_binary ] 0 name = " caml_ml_input "
let input ic s ofs len = if ofs < 0 || len < 0 || ofs > bytes_length s - len then invalid_arg " input " else unsafe_input ic s ofs len
let rec unsafe_really_input ic s ofs len = if len <= 0 then ( ) else begin let r = unsafe_input ic s ofs len in if r = 0 then raise End_of_file else unsafe_really_input ic s ( ofs + r ) ( len - r ) end
let really_input ic s ofs len = if ofs < 0 || len < 0 || ofs > bytes_length s - len then invalid_arg " really_input " else unsafe_really_input ic s ofs len
let really_input_string ic len = let s = bytes_create len in really_input ic s 0 len ; bytes_unsafe_to_string s
let input_line chan = let rec build_result buf pos = function [ ] -> buf | hd :: tl -> let len = bytes_length hd in bytes_blit hd 0 buf ( pos - len ) len ; build_result buf ( pos - len ) tl in let rec scan accu len = let n = input_scan_line chan in if n = 0 then begin match accu with [ ] -> raise End_of_file | _ -> bui...
let close_in_noerr ic = ( try close_in ic with _ -> ( ) ) = " caml_ml_set_binary_mode "
let print_char c = output_char stdout c
let print_string s = output_string stdout s
let print_bytes s = output_bytes stdout s
let print_int i = output_string stdout ( string_of_int i )
let print_float f = output_string stdout ( string_of_float f ) # else
let print_endline s = output_string stdout s ; output_char stdout ' \ n ' ; flush stdout # end
let print_newline ( ) = output_char stdout ' \ n ' ; flush stdout
let prerr_char c = output_char stderr c
let prerr_string s = output_string stderr s
let prerr_bytes s = output_bytes stderr s
let prerr_int i = output_string stderr ( string_of_int i )
let prerr_float f = output_string stderr ( string_of_float f ) # else
let prerr_endline s = output_string stderr s ; output_char stderr ' \ n ' ; flush stderr # end
let prerr_newline ( ) = output_char stderr ' \ n ' ; flush stderr
let read_line ( ) = flush stdout ; input_line stdin
let read_int ( ) = int_of_string ( read_line ( ) )
let read_int_opt ( ) = int_of_string_opt ( read_line ( ) )
let read_float ( ) = float_of_string ( read_line ( ) )
let read_float_opt ( ) = float_of_string_opt ( read_line ( ) )
module LargeFile = struct external seek_out : out_channel -> int64 -> unit = " caml_ml_seek_out_64 " external pos_out : out_channel -> int64 = " caml_ml_pos_out_64 " external out_channel_length : out_channel -> int64 = " caml_ml_channel_size_64 " external seek_in : in_channel -> int64 -> unit = " caml_ml_seek_in_64 " e...
type ( ' a , ' b , ' c , ' d , ' e , ' f ) format6 = ( ' a , ' b , ' c , ' d , ' e , ' f ) CamlinternalFormatBasics . format6 = Format of ( ' a , ' b , ' c , ' d , ' e , ' f ) CamlinternalFormatBasics . fmt * string
type ( ' a , ' b , ' c , ' d ) format4 = ( ' a , ' b , ' c , ' c , ' c , ' d ) format6
type ( ' a , ' b , ' c ) format = ( ' a , ' b , ' c , ' c ) format4
let string_of_format ( Format ( _fmt , str ) ) = str ( ' a , ' b , ' c , ' d , ' e , ' f ) format6 -> ( ' a , ' b , ' c , ' d , ' e , ' f ) format6 = " % identity "
let ( ^^ ) ( Format ( fmt1 , str1 ) ) ( Format ( fmt2 , str2 ) ) = Format ( CamlinternalFormatBasics . concat_fmt fmt1 fmt2 , str1 ^ " , " % ^ str2 )
let exit_function = CamlinternalAtomic . make flush_all
let rec at_exit f = let module Atomic = CamlinternalAtomic in let f_yet_to_run = Atomic . make true in let old_exit = Atomic . get exit_function in let new_exit ( ) = if Atomic . compare_and_set f_yet_to_run true false then f ( ) ; old_exit ( ) in let success = Atomic . compare_and_set exit_function old_exit new_exit i...
let do_at_exit ( ) = ( CamlinternalAtomic . get exit_function ) ( )
let exit retcode = do_at_exit ( ) ; sys_exit retcode # else
let _ = register_named_value " Pervasives . do_at_exit " do_at_exit = " caml_sys_const_naked_pointers_checked "
let ( ) = if naked_pointers_checked ( ) then at_exit major # end end
module type Comparisons = sig type t val compare : t -> t -> int val equal : t -> t -> bool val ( = ) : t -> t -> bool val ( < ) : t -> t -> bool val ( > ) : t -> t -> bool val ( <> ) : t -> t -> bool val ( <= ) : t -> t -> bool val ( >= ) : t -> t -> bool val min : t -> t -> t val max : t -> t -> t end
module Poly = struct let compare = compare let equal = ( = ) let ( = ) = ( = ) let ( < ) = ( < ) let ( > ) = ( > ) let ( <> ) = ( <> ) let ( <= ) = ( <= ) let ( >= ) = ( >= ) let min = min let max = max end
module Bool = struct let to_string = string_of_bool include ( Poly : Comparisons with type t := bool ) end
module Bytes = struct include Bytes let sub_string t ~ pos ~ len = Stdlib . Bytes . sub_string t pos len let blit_string ~ src ~ src_pos ~ dst ~ dst_pos ~ len = Stdlib . Bytes . blit_string src src_pos dst dst_pos len end
module Char = struct include Char include ( Poly : Comparisons with type t := char ) end
module Exn = struct let protectx x ~ f ~ finally = match f x with | y -> finally x ; y | exception exn -> finally x ; raise exn end
module Float = struct let to_string = string_of_float include ( Poly : Comparisons with type t := float ) end
module Fn = struct let id x = x end
module Hashtbl = struct include Hashtbl let set t ~ key ~ data = while mem t key do remove t key done ; add t key data let add t ~ key ~ data = if mem t key then Error ( Invalid_argument " Hashtbl . add_exn " ) else ( add t key data ; Ok ( ) ) let add_exn t ~ key ~ data = match add t ~ key ~ data with Ok ( ) -> ( ) | E...
module In_channel = struct let create ( ? binary = true ) file = let flags = [ Open_rdonly ] in let flags = if binary then Open_binary :: flags else flags in open_in_gen flags 0o000 file let with_file ? binary filename ~ f = let t = create ? binary filename in Exn . protectx t ~ f ~ finally : close_in let input_all t =...
module Int = struct let max_int = max_int let to_string = string_of_int include ( Poly : Comparisons with type t := int ) end
module List = struct include List include struct let merge = ` not_tail_recursive let remove_assoc = ` not_tail_recursive let remove_assq = ` not_tail_recursive let rev_mapi list ~ f = let rec rev_mapi_at list i ~ f ~ acc = match list with | [ ] -> acc | head :: tail -> rev_mapi_at tail ( i + 1 ) ~ f ~ acc ( : f i head...
module Option = struct let is_some = function None -> false | Some _ -> true let iter t ~ f = match t with None -> ( ) | Some x -> f x let map t ~ f = match t with None -> None | Some x -> Some ( f x ) let value t ~ default = match t with None -> default | Some x -> x end
module Out_channel = struct let create ( ? binary = true ) ( ? append = false ) ( ? fail_if_exists = false ) ( ? perm = 0o666 ) file = let flags = [ Open_wronly ; Open_creat ] in let flags = ( if binary then Open_binary else Open_text ) :: flags in let flags = ( if append then Open_append else Open_trunc ) :: flags in ...
module String = struct include String let is_empty ( t : t ) = length t = 0 let prefix t len = sub t ~ pos : 0 ~ len let suffix t len = sub t ~ pos ( : length t - len ) ~ len let drop_prefix t len = sub t ~ pos : len ~ len ( : length t - len ) let drop_suffix t len = sub t ~ pos : 0 ~ len ( : length t - len ) let is_pr...
let ( @ ) = List . append
let output oc bytes ~ pos ~ len = output oc bytes pos len
let output_substring oc string ~ pos ~ len = output_substring oc string pos len
let compare _ _ = ` Use_Poly_compare
type ( ' a , ' error ) result = ( ' a , ' error ) Result . t = | Ok of ' a | Error of ' error
type ( ' a , ' b ) either = ( ' a , ' b ) Either . t = | Left of ' a | Right of ' b
type ordering = Ordering . t = | Lt | Eq | Gt
type use_file = toplevel_phrase list
type ' a t = | Structure : structure t | Signature : signature t | Use_file : use_file t | Core_type : core_type t | Module_type : module_type t | Expression : expression t | Repl_file : unit t
let equal ( type a ) ( _ : a t ) : a -> a -> bool = Poly . equal
let map ( type a ) ( x : a t ) ( m : Ast_mapper . mapper ) : a -> a = match x with | Structure -> m . structure m | Signature -> m . signature m | Use_file -> List . map ~ f ( : m . toplevel_phrase m ) | Core_type -> m . typ m | Module_type -> m . module_type m | Expression -> m . expr m | Repl_file -> Fn . id
module Parse = struct let ast ( type a ) ( fg : a t ) lexbuf : a = match fg with | Structure -> Parse . implementation lexbuf | Signature -> Parse . interface lexbuf | Use_file -> Parse . use_file lexbuf | Core_type -> Parse . core_type lexbuf | Module_type -> Parse . module_type lexbuf | Expression -> Parse . expressi...
module Printast = struct include Printast let use_file = Format . pp_print_list top_phrase let ast ( type a ) : a t -> _ -> a -> _ = function | Structure -> implementation | Signature -> interface | Use_file -> use_file | Core_type -> core_type 0 | Module_type -> module_type 0 | Expression -> expression 0 | Repl_file -...
module Name_of = struct let typename_of_int = let module M = Typename . Make0 ( struct type t = int let name = " int " end ) in M . typename_of_t ; ; let typename_of_int32 = let module M = Typename . Make0 ( struct type t = int32 let name = " int32 " end ) in M . typename_of_t ; ; let typename_of_int64 = let module M =...
module rec Typerep : sig type _ t = | Int : int t | Int32 : int32 t | Int64 : int64 t | Nativeint : nativeint t | Char : char t | Float : float t | String : string t | Bytes : bytes t | Bool : bool t | Unit : unit t | Option : ' a t -> ' a option t | List : ' a t -> ' a list t | Array : ' a t -> ' a array t | Lazy : ' ...
let typerep_of_option rep = Typerep . Option rep
let typerep_of_list rep = Typerep . List rep
let typerep_of_array rep = Typerep . Array rep
let typerep_of_lazy_t rep = Typerep . Lazy rep
let typerep_of_ref rep = Typerep . Ref rep
let typerep_of_function dom rng = Typerep . Function ( dom , rng )