text stringlengths 0 601k |
|---|
let rec visit rx p = if Rx . match_string rx p then ( ) let fp = prefix ^ p in if is_dir fp then List . iter ( fun n -> visit rx ( p ^ " " / ^ n ) ) ( children fp ) end |
let _ = let rx = Rx . alt ( List . map ( fun p -> match p with ` Path s -> Rx . globx s | ` Name s -> Rx . seq [ Rx . rx " ( . ) " ; */? Rx . globx s ] ) desc ) ; in List . iter ( fun p -> visit rx p ) paths |
let desc = [ ` Path " lablgtk - 1 . 00 / config . make " ; ` Path " lablgtk - 1 . 00 / lablgtktop_t " ; ` Path " lablgtk - 1 . 00 / lablgtktop " ; ` Path " lablgtk - 1 . 00 / lablgtkrun " ; ` Path " lablgtk - 1 . 00 / lablgtk " ; ` Path " unison3 / src / unison " ; ` Name " core " ; ` Path " lipe / caisse / val_parse .... |
let translate_char c = match c with ' . ' -> " . " \ | ' ' * -> " [ ] " ^/* | _ -> String . make 1 c |
let translate_str s = let res = ref " " in for i = 0 to String . length s - 1 do res := ! res ^ translate_char s . [ i ] done ; ! res |
let paths = [ " These " ; " Xduce " ; " unison " ; " unison2 " ; " unison3 " ; " tinkertype " ; " lipe " ; " icfp2000 " ; " Views " ; " sync " ; " misc " ; " lablgtk - 1 . 00 " ; " mydb " ; " yacc " ; " db - papers " ; " submissions " ; " xml " ; " profiler " ; " specs " ; " ocaml " ; " rx " ] |
let rec children p = let rec loop ch dir = try let file = Unix . readdir dir in let ch ' = if file = " . " || file = " . . " then ch else file :: ch in loop ch ' dir with End_of_file -> ch in let dir = Unix . opendir p in let result = loop [ ] dir in Unix . closedir dir ; result |
let is_dir p = try ( Unix . lstat p ) . Unix . st_kind = Unix . S_DIR with Unix . Unix_error _ -> false |
let count = ref 0 |
let rec visit rx p = try ignore ( Re_pcre . exec ~ rex : rx p ) ; with Not_found -> let fp = prefix ^ p in if is_dir fp then List . iter ( fun n -> visit rx ( p ^ " " / ^ n ) ) ( children fp ) |
let _ = let l = List . map ( fun p -> match p with ` Path s -> translate_str s | ` Name s -> " ( . ) " ?:*/? ^ translate_str s ) desc in let rx = " ( " ^?: ^ begin match l with x :: r -> x ^ List . fold_right ( fun x rem -> " " | ^ x ^ rem ) r " " | [ ] -> assert false end ^ " ) " $ in let rx = Re_pcre . regexp rx in t... |
module Access = struct type t = Unix . access_permission type defns = { r_ok : int ; w_ok : int ; x_ok : int ; f_ok : int ; } module Host = struct type t = defns let of_defns d = d and to_defns d = d end let _to_code ~ host = let defns = host in Unix . ( function | R_OK -> defns . r_ok | W_OK -> defns . w_ok | X_OK -> ... |
module Seek = struct type t = SEEK_SET | SEEK_CUR | SEEK_END | SEEK_DATA | SEEK_HOLE type defns = { seek_set : int ; seek_cur : int ; seek_end : int ; seek_data : int option ; seek_hole : int option ; } type index = ( int , t ) Hashtbl . t module Host = struct type t = defns * index let index_of_defns defns = let open ... |
module Sysconf = struct type defns = { pagesize : int ; } module Host = struct type t = defns let of_defns d = d and to_defns d = d end let pagesize ~ host = host . pagesize end |
type host = { access : Access . Host . t ; seek : Seek . Host . t ; sysconf : Sysconf . Host . t ; } |
module Access = struct open Unistd . Access let host = Host . of_defns Type . Access . ( { r_ok ; w_ok ; x_ok ; f_ok } ) let view ~ host = Ctypes . ( view ~ read ( : of_code ~ host ) ~ write ( : to_code ~ host ) int ) end |
module Seek = struct open Unistd . Seek let host = Host . of_defns Type . Seek . ( { seek_set ; seek_cur ; seek_end ; seek_data = if seek_data = - 1 then None else Some seek_data ; seek_hole = if seek_hole = - 1 then None else Some seek_hole ; } ) end |
module Sysconf = struct open Unistd . Sysconf let host = Host . of_defns Type . Sysconf . ( { pagesize = _sc_pagesize } ) end |
let host = { Unistd . access = Access . host ; seek = Seek . host ; sysconf = Sysconf . host ; } |
let handle_error ? label call zero ( rv , errno ) = if rv < zero then Errno_unix . raise_errno ~ call ? label errno else rv |
let seek_code cmd = match Unistd . Seek . to_code ~ host : Seek . host cmd with | Some code -> code | None -> raise Unix . ( Unix_error ( EINVAL , " lseek " , " " ) ) |
let lseek fd offset whence = Off . to_int64 ( handle_error " lseek " Off . zero ( C . lseek fd ( Off . of_int64 offset ) ( seek_code whence ) ) ) |
let unlink path = ignore ( handle_error " unlink " 0 ~ label : path ( C . unlink path ) ) |
let rmdir path = ignore ( handle_error " rmdir " 0 ~ label : path ( C . rmdir path ) ) |
let write fd buf count = Ssize . to_int ( handle_error " write " Ssize . zero ( C . write fd buf ( Size . of_int count ) ) ) |
let pwrite fd buf count offset = Ssize . to_int ( handle_error " pwrite " Ssize . zero ( C . pwrite fd buf ( Size . of_int count ) ( Off . of_int64 offset ) ) ) |
let read fd buf count = Ssize . to_int ( handle_error " read " Ssize . zero ( C . read fd buf ( Size . of_int count ) ) ) |
let pread fd buf count offset = Ssize . to_int ( handle_error " pread " Ssize . zero ( C . pread fd buf ( Size . of_int count ) ( Off . of_int64 offset ) ) ) |
let close fd = ignore ( handle_error " close " 0 ( C . close fd ) ) |
let access pathname mode = ignore ( handle_error " access " 0 ~ label : pathname ( C . access pathname ( Unistd . Access . to_code ~ host : Access . host mode ) ) ) |
let readlink = let c ' path buf sz = handle_error " readlink " Ssize . zero ~ label : path ( C . readlink path buf sz ) in fun path -> let sz = ref ( Unistd . Sysconf . pagesize ~ host : Sysconf . host ) in let buf = ref ( allocate_n char ~ count :! sz ) in let len = ref ( Ssize . to_int ( c ' path ! buf ( Size . of_in... |
let symlink target linkpath = ignore ( handle_error ~ label : linkpath " symlink " 0 ( C . symlink target linkpath ) ) |
let truncate path length = ignore ( handle_error " truncate " ~ label : path 0 ( C . truncate path ( Off . of_int64 length ) ) ) |
let ftruncate fd length = ignore ( handle_error " truncate " 0 ( C . ftruncate fd ( Off . of_int64 length ) ) ) |
let chown path owner group = ignore ( handle_error " chown " 0 ~ label : path ( C . chown path ( Uid . of_int owner ) ( Gid . of_int group ) ) ) |
let fchown fd owner group = ignore ( handle_error " fchown " 0 ( C . fchown fd ( Uid . of_int owner ) ( Gid . of_int group ) ) ) |
let seteuid euid = ignore ( handle_error " seteuid " 0 ( C . seteuid ( Posix_types . Uid . of_int euid ) ) ) |
let setegid egid = ignore ( handle_error " setguid " 0 ( C . setegid ( Posix_types . Gid . of_int egid ) ) ) |
module type S = sig val write_lwt : ? blocking : bool -> Unix . file_descr -> unit Ctypes . ptr -> int -> int Lwt . t val pwrite_lwt : ? blocking : bool -> Unix . file_descr -> unit Ctypes . ptr -> int -> int64 -> int Lwt . t val read_lwt : ? blocking : bool -> Unix . file_descr -> unit Ctypes . ptr -> int -> int Lwt .... |
let char_bigarray_of_unit_ptr p len = let open Ctypes in bigarray_of_ptr array1 len Bigarray . char ( coerce ( ptr void ) ( ptr char ) p ) |
let write ? blocking ? set_flags fd ptr len = let lwt_fd = Lwt_unix . of_unix_file_descr ? blocking ? set_flags fd in Lwt_bytes . write lwt_fd ( char_bigarray_of_unit_ptr ptr len ) 0 len |
let pwrite ? blocking ? set_flags fd ( Ctypes_static . CPointer ptr as p ) len offset = let lwt_fd = Lwt_unix . of_unix_file_descr ? blocking ? set_flags fd in Lwt_unix . blocking lwt_fd >>= function | true -> Lwt_unix . wait_write lwt_fd >>= fun ( ) -> ( C . pwrite fd p ( Size . of_int len ) ( Off . of_int64 offset ) ... |
let read ? blocking ? set_flags fd ptr len = let lwt_fd = Lwt_unix . of_unix_file_descr ? blocking ? set_flags fd in Lwt_bytes . read lwt_fd ( char_bigarray_of_unit_ptr ptr len ) 0 len |
let pread ? blocking ? set_flags fd ( Ctypes_static . CPointer ptr as p ) len offset = let lwt_fd = Lwt_unix . of_unix_file_descr ? blocking ? set_flags fd in Lwt_unix . blocking lwt_fd >>= function | true -> Lwt_unix . wait_read lwt_fd >>= fun ( ) -> ( C . pread fd p ( Size . of_int len ) ( Off . of_int64 offset ) ) .... |
object end M . cl [ ' a , ' b ] M . cl object ( ' ty ) inherit cl val mutable virtual var : bool method private bar1 x ~ y : bool method private virtual bar2 : ' a ' b . ( ' a , ' b ) Hashtbl . t constraint ' a = ' b end [ ' a , ' b ] M . cl fun a b -> object end val x = true end object ( _ : ' a ) inherit Something . ... |
let e = var <- true |
let e = { < var = false ; var2 = true ; } > object val x = true end and virtual [ ' a , ' b ] cl2 x y : object val x : bool end = fun x y -> object val x : bool = true end : object end method x : int end < > |
let ( ) = ( ) < . . > |
let ( ) = ( ) < meth : int option ; meth2 : ' a . ' a option ; meth3 : ' a ' b . ( ' a , ' b ) Hashtbl . t > |
let ( ) = ( ) < meth : int option ; meth2 : ' a . ' a option ; meth3 : ' a ' b . ( ' a , ' b ) Hashtbl . t ; . . > |
let ( ) = ( ) # M . meth ' a # M . meth ( ' a , ' b ' * c ) # M . meth |
type a = < > |
type a = < . . > |
type a = < meth : int option ; meth2 : ' a . ' a option ; meth3 : ' a ' b . ( ' a , ' b ) Hashtbl . t > |
type a = < meth : int option ; meth2 : ' a . ' a option ; meth3 : ' a ' b . ( ' a , ' b ) Hashtbl . t ; . . > |
type t = < a : int ; b : < a : int ; b : < c : int > > > |
type t = < a : int ; b : < a : int ; b : < c : int -> int > ; > c : int > |
type ' a t = | Bla : < x : int > t | Blo : < y : int > t |
let e = begin true end |
let e = ( true : bool ) |
let e = true , false , true |
let e = Some true |
let e = ` _ true |
let e = true :: false :: true |
let e = [ true ; false ; true ; ] |
let e = [ | true ; false ; true ] | |
let e = { f1 = true ; f2 = false ; f3 = true ; } |
let e = { e with f1 = true ; f2 = false ; } |
let e = f true false true |
let e = !? true |
let e = true || false && true |
let e = 1 mod 1 land 1 lor 1 lxor 1 lsl 1 lsr 1 asr 1 |
let e = re . f1 <- true |
let e = a . ( 0 ) <- true |
let e = a . [ 0 ] <- true |
let e = if true then false else true |
let e = while true do ( ) done |
let e = for x = a to b do ( ) done |
let e = true ; false ; true |
let e = match true with | true -> false | false -> true |
let e = match true with | true -> false | false -> true |
let e = function | true -> false | false -> true |
let e = fun x ~ lbl1 ~ ( lbl2 : int ) ~ lbl3 : _a ? olbl1 ? ( olbl2 : ' a list = [ ] ) ? olbl3 : _c ? olbl4 : ( _d : bool = false ) ( ) when true -> true |
let e = fun x -> fun ~ lbl1 -> fun ~ ( lbl2 : int ) -> fun ~ lbl3 : _a -> fun ? olbl1 -> fun ? ( olbl2 : ' a list = [ ] ) -> fun ? olbl3 : _c when true -> fun ? olbl4 : ( _d : bool = false ) -> fun ( ) when true -> true |
let e x ~ lbl1 ~ ( lbl2 : int ) ~ lbl3 : _a ? olbl1 ? ( olbl2 : ' a list = [ ] ) ? olbl3 : _c ? olbl4 : ( _d : bool = false ) ( ) = true |
let e = try true with | Exit -> true | _ -> false |
let e = let rec a = true and _b = false in true |
let e = new foo |
let foo = object end |
let e = foo # bar1 |
let e = ( true :> bool ) |
let e = ( true : bool :> bool ) |
let e = assert true |
let e = lazy true |
let i = 12l + 0l |
let i = 12L + 0l |
let i = 12n + 0n |
let f = function | ' a ' . . ' z ' -> e1 | ' A ' . . ' Z ' | ' 0 ' . . ' 9 ' -> e2 |
let f = let module M = F ( struct end ) in M . f x |
module rec M : S = struct ; ; end struct ; ; end |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.