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 . h " ; ` Path " lipe / caisse / val_parse . c " ; ` Path " lipe / caisse / val_lex . c " ; ` Path " lipe / caisse / caisse " ; ` Path " lipe / runtime " ; ` Path " lipe / demo " ; ` Path " unison2 / doc / unison - manual . ps " ; ` Path " unison / doc / unison - mal . ps " ; ` Name " . * ppi " ; ` Path " unison2 / src / unison " ; ` Path " Xduce / xduce / pref . ml " ; ` Path " Xduce / xduce / xduce " ; ` Path " Xduce / xduce / xduce . opt " ; ` Path " unison / src / TAGS " ; ` Path " unison / src / unison " ; ` Name " . * old " ; ` Name " " ; #*# ` Name " . * cmi " ; ` Name " . * cmo " ; ` Name " . * cmx " ; ` Name " . * cma " ; ` Name " . * cmxa " ; ` Name " . * vo " ; ` Name " " ; *~ ` Name " . * aux " ; ` Name " . * bbl " ; ` Name " . * blg " ; ` Name " . * log " ; ` Name " . * toc " ; ` Name " . * o " ; ` Name " . * a " ; ` Name " gmon . out " ; ` Name " ocamlprof . dump " ; ` Name " CVS " ; ` Name " . . * prcs_aux " ; ` Path " icfp2000 / tools / src2tex " ; ` Path " icfp2000 / temp . dvi " ; ` Path " icfp2000 / main . dvi " ; ` Path " icfp2000 / whole . dvi " ; ` Path " icfp2000 / regsub . ps " ; ` Path " Views / main . dvi " ; ` Path " lipe / perso / caisse " ; ` Name " obsolete " ; ` Path " misc / fingerprint / cksum / cksum " ; ` Path " misc / relay / relay " ; ` Path " Xduce / xduce . current / xduce . opt " ; ` Path " Xduce / xduce . current / pref . ml " ; ` Path " Xduce / xduce . new / pref . ml " ; ` Path " Xduce / xduce . new / xduce . opt " ; ` Path " profiler / profiler " ; ` Path " ocaml / boot / Saved " ; ` Path " ocaml / byterun / ocamlrun " ; ` Path " ocaml / config / Makefile " ; ` Path " ocaml / config / m . h " ; ` Path " ocaml / config / s . h " ; ` Path " ocaml / expunge " ; ` Path " ocaml / asmcomp / arch . ml " ; ` Path " ocaml / asmcomp / emit . ml " ; ` Path " ocaml / asmcomp / proc . ml " ; ` Path " ocaml / asmcomp / reload . ml " ; ` Path " ocaml / asmcomp / scheduling . ml " ; ` Path " ocaml / asmcomp / selection . ml " ; ` Path " ocaml / debugger / ocamldebug " ; ` Path " ocaml / lex / ocamllex " ; ` Path " ocaml / ocaml " ; ` Path " ocaml / ocamlc " ; ` Path " ocaml / ocamlopt " ; ` Path " ocaml / otherlibs / dynlink / extract_crc " ; ` Path " ocaml / otherlibs / labltk / browser / ocamlbrowser " ; ` Path " ocaml / otherlibs / labltk / compiler / tkcompiler " ; ` Path " ocaml / otherlibs / str / regex - 0 . 12 / config . status " ; ` Path " ocaml / stdlib / camlheader " ; ` Path " ocaml / tools / cvt_emit " ; ` Path " ocaml / boot / camlheader " ; ` Path " ocaml / boot / ocamlrun " ; ` Path " ocaml / boot / ocamlyacc " ; ` Path " ocaml / otherlibs / labltk / lib . / depend " ; ` Path " ocaml / otherlibs / labltk / lib / labltk " ; ` Path " ocaml / otherlibs / labltk / lib / labltktop " ; ` Path " ocaml / otherlibs / labltk / lib / tk . ml " ; ` Path " ocaml / tools / ocamlcp " ; ` Path " ocaml / tools / ocamldep " ; ` Path " ocaml / tools / ocamlmktop " ; ` Path " ocaml / tools / ocamlprof " ; ` Path " ocaml / utils / config . ml " ; ` Path " ocaml / yacc / ocamlyacc " ; ` Path " Xduce / interleave / tools / src2tex " ; ` Path " xml / parser " ; ` Path " ocaml / ocamlopt . opt " ; ` Path " ocaml / boot / ocamlc " ; ` Path " ocaml / boot / ocamllex " ; ` Path " ocaml / ocamlc . opt " ; ` Path " specs / tools / src2f " ; ` Path " specs / tools / src2tex " ]
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 try List . iter ( fun p -> visit rx p ) paths done
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 -> defns . x_ok | F_OK -> defns . f_ok ) let is_set ~ host t = let bit = _to_code ~ host t in fun code -> ( bit land code ) = bit let set ~ host t = let bit = _to_code ~ host t in fun code -> bit lor code let to_code ~ host = List . fold_left ( fun code t -> set ~ host t code ) 0 let of_code ~ host code = List . filter ( fun t -> is_set ~ host t code ) Unix . ( [ R_OK ; W_OK ; X_OK ; F_OK ] ) end
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 Hashtbl in let h = create 10 in replace h defns . seek_set SEEK_SET ; replace h defns . seek_cur SEEK_CUR ; replace h defns . seek_end SEEK_END ; ( match defns . seek_data with Some i -> replace h i SEEK_DATA | None -> ( ) ) ; ( match defns . seek_hole with Some i -> replace h i SEEK_HOLE | None -> ( ) ) ; h let of_defns d = ( d , index_of_defns d ) and to_defns ( d , _ ) = d end let to_code ~ host = let ( defns , _ ) = host in function | SEEK_SET -> Some defns . seek_set | SEEK_CUR -> Some defns . seek_cur | SEEK_END -> Some defns . seek_end | SEEK_DATA -> defns . seek_data | SEEK_HOLE -> defns . seek_hole let of_code_exn ~ host code = let ( _ , index ) = host in Hashtbl . find index code let of_code ~ host code = try Some ( of_code_exn ~ host code ) with Not_found -> None end
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_int ! sz ) ) ) in while ! len = ! sz do sz := ! sz * 2 ; buf := allocate_n char ~ count :! sz ; len := Ssize . to_int ( c ' path ! buf ( Size . of_int ! sz ) ) done ; CArray . ( set ( from_ptr ! buf ( ! len + 1 ) ) ! len ( Char . chr 0 ) ) ; coerce ( ptr char ) string ! buf
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 . t val pread_lwt : ? blocking : bool -> Unix . file_descr -> unit Ctypes . ptr -> int -> int64 -> int Lwt . t end
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 ) ) . Gen . lwt >>= fun ( rv , errno ) -> if rv < Ssize . zero then Errno_unix . raise_errno ~ call " : pwrite " errno else Lwt . return ( Ssize . to_int rv ) | false -> Lwt_unix . ( wrap_syscall Write ) lwt_fd @@ fun ( ) -> Unistd_unix . pwrite fd p len 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 ) ) . Gen . lwt >>= fun ( rv , errno ) -> if rv < Ssize . zero then Errno_unix . raise_errno ~ call " : pread " errno else Lwt . return ( Ssize . to_int rv ) | false -> Lwt_unix . ( wrap_syscall Read ) lwt_fd @@ fun ( ) -> Unistd_unix . pread fd p len 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 . someclass as v val mutable var : bool = true val mutable virtual var2 : string method private bar1 x ~ y : bool = false method private virtual bar2 : ' a ' b . ( ' a , ' b ) Hashtbl . t constraint ' a = ' b initializer z end
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