text stringlengths 0 601k |
|---|
let rec compile e = match e with |
let rec secdmachine = function |
let execute oplist = secdmachine ( [ ] , _env , oplist , [ ] ) ; ; |
let expr = Gram . Entry . mk " expr " |
let ( ) |> x f = f x |
let p = Gram . parse_string expr ( Loc . mk " < string ) " > let t = " foo bar baz " |
let _ = begin EXTEND Gram GLOBAL : expr ; expr : [ [ " foo " ; f -> print_endline " first " | " foo " ; " bar " ; " baz " -> print_endline " second ] " ] ; f : [ [ " bar " ; " baz " ] ] ; END ; p t ; let open Gram . Entry in begin clear expr ; EXTEND Gram GLOBAL : expr ; expr : [ [ " foo " ; f -> print_endline " first ... |
module Public_key_hash = struct include Tezos_crypto . Secp256k1 . Public_key_hash module Set = struct include Stdlib . Set . Make ( Tezos_crypto . Secp256k1 . Public_key_hash ) let encoding = Data_encoding . conv elements ( fun l -> List . fold_left ( fun m x -> add x m ) empty l ) Data_encoding . ( list Tezos_crypto ... |
module type SCALAR_SIG = sig type t include S . B58_DATA with type t := t include S . ENCODER with type t := t val zero : t val one : t val of_Z : Z . t -> t val to_Z : t -> Z . t val of_int : int -> t val add : t -> t -> t val mul : t -> t -> t val negate : t -> t val sub : t -> t -> t val of_bits_exn : string -> t va... |
module Group : sig val order : Z . t module Scalar : SCALAR_SIG type t val pp : Format . formatter -> t -> unit include Compare . S with type t := t include S . RAW_DATA with type t := t include S . B58_DATA with type t := t include S . ENCODER with type t := t val e : t val g : t val h : t val of_coordinates : x : Z .... |
module BytesWr = struct include Bytes module Base58_check = Base58_check . Make ( struct let description = " Secret box " let version_byte = Base58_check . Version_bytes . secret_box_byteswr end ) end let to_yojson t = ` String ( Bytes . to_string t |> Base58_check . encode ) encode let of_yojson = function | ` String ... |
module T = struct type t = { box_primitive : string ; pw_primitive : string ; nonce : Bytes . t ; pwsalt : Bytes . t ; pwdiff : Int64 . t * int ; ciphertext : Bytes . t } [ @@ deriving sexp ] sexp end |
module Json : sig type t [ @@ deriving yojson ] yojson val of_stable : T . t -> t val to_stable : t -> T . t type t = { box_primitive : string ; pw_primitive : string ; nonce : BytesWr . t ; pwsalt : BytesWr . t ; pwdiff : Int64 . t * int ; ciphertext : BytesWr . t } [ @@ deriving yojson ] yojson let of_stable { T . bo... |
type t = T . t = { box_primitive : string ; pw_primitive : string ; nonce : Bytes . t ; pwsalt : Bytes . t ; pwdiff : Int64 . t * int ; ciphertext : Bytes . t } |
let to_yojson t : Yojson . Safe . t = Json . to_yojson ( Json . of_stable t ) t |
let of_yojson ( t : Yojson . Safe . t ) t = Result . map ~ f : Json . to_stable ( Json . of_yojson t ) t |
let encrypt ( ~ password : Bytes . t ) t ( ~ plaintext : Bytes . t ) t = let nonce = Secret_box . random_nonce ( ) in let salt = Password_hash . random_salt ( ) in let ( { Password_hash . mem_limit ; ops_limit } as diff ) diff = Password_hash . moderate in let pw = Password_hash . Bytes . wipe_to_password password in l... |
let decrypt ( ~ password : Bytes . t ) t { box_primitive ; pw_primitive ; nonce ; pwsalt ; pwdiff = mem_limit , ops_limit ; ciphertext } = if not ( String . equal box_primitive Secret_box . primitive ) primitive then Error ( ` Corrupted_privkey ( Error . createf " ! don ' t know how to handle a % s secret_box " box_pri... |
type password = Bytes . t Async . Deferred . t Lazy . t |
let handle_open ~ mkdir ( ~ f : string -> ' a Deferred . t ) t path = let corrupted_privkey = Privkey_error . corrupted_privkey in let open Unix . Error in let open Deferred . Result . Let_syntax in let dn = Filename . dirname path in let % bind parent_exists = let open Deferred . Let_syntax in match % bind Monitor . t... |
let lift ( t : ' a Deferred . t ) t : ( ' a , ' b ) ' b Deferred . Result . t = t >>| fun x -> Ok x |
let write ~ path ~ mkdir ( ~ password : Bytes . t Deferred . t Lazy . t ) t ~ plaintext = let open Deferred . Result . Let_syntax in let % bind privkey_f = handle_open ~ mkdir ~ f ( : fun path -> Writer . open_file path ) path path in let % bind password = lift @@ Lazy . force password in let sb = Secret_box . encrypt ... |
let read ~ path ( ~ password : Bytes . t Deferred . t Lazy . t ) t = let to_corrupt_privkey = Deferred . Result . map_error ~ f ( : fun e -> ` Corrupted_privkey e ) e in let handle_open ~ mkdir ~ f p = handle_open ~ mkdir ~ f p in let open Deferred . Result . Let_syntax in let read_all r = lift ( Pipe . to_list ( Reade... |
let compare : t -> t -> Ordering . t = Poly . compare |
let to_dyn x = let s = Dune_section . to_string x in let open Dyn in variant ( String . uppercase_ascii s ) [ ] |
module Key = struct type nonrec t = t let compare = compare let to_dyn = to_dyn end |
module O = Comparable . Make ( Key ) |
let parse_string s = match of_string s with | Some s -> Ok s | None -> Error ( sprintf " invalid section : % s " s ) |
let enum_decoder = Dune_section . all |> List . map ~ f ( : fun ( x , y ) -> ( y , x ) ) |
let decode = Dune_lang . Decoder . enum enum_decoder |
let encode v = let open Dune_lang . Encoder in string ( to_string v ) |
let all = Set . of_list ( List . map ~ f : fst Dune_section . all ) |
let should_set_executable_bit = function | Lib | Lib_root | Toplevel | Share | Share_root | Etc | Doc | Man | Misc -> false | Libexec | Libexec_root | Bin | Sbin | Stublibs -> true |
let valid_format_doc = Pp . text " Module names must be non - empty and composed only of the following \ characters : ' A ' . . ' Z ' , ' a ' . . ' z ' , ' _ ' , ' ' ' or ' 0 ' . . ' 9 ' . " |
module Modulelike ( S : sig type t val module_ : string val description : string val to_string : t -> string val make : string -> t include S let valid_char = function | ' A ' . . ' Z ' | ' a ' . . ' z ' | ' 0 ' . . ' 9 ' | ' ' ' \ | ' _ ' -> true | _ -> false let description_of_valid_string = Some valid_format_doc let... |
module Site = struct include String include ( Modulelike ( struct type t = string let to_string t = t let module_ = " Section . Site " let description = " site name " let make s = s end ) : Stringlike_intf . S with type t := t ) module Infix = Comparator . Operators ( String ) end |
let dune_site_syntax = Dune_lang . Syntax . create ~ name " : dune_site " ~ experimental : true ~ desc " : the sites locations extension ( experimental ) " [ ( ( 0 , 1 ) , ` Since ( 2 , 8 ) ) ] |
type node = { id : int ; mutable eps : node list ; mutable trans : ( Cset . t * node ) node list ; } |
type regexp = node -> node |
let cur_id = ref 0 |
let new_node ( ) = incr cur_id ; { id = ! cur_id ; eps = [ ] ; trans = [ ] } |
let seq r1 r2 succ = r1 ( r2 succ ) succ |
let is_chars final = function | { eps = [ ] ; trans = [ ( c , f ) f ] f } when f == final -> Some c | _ -> None |
let chars c succ = let n = new_node ( ) in n . trans <- [ ( c , succ ) succ ] succ ; n |
let alt r1 r2 succ = let nr1 = r1 succ and nr2 = r2 succ in match ( is_chars succ nr1 , is_chars succ nr2 ) nr2 with | Some c1 , Some c2 -> chars ( Cset . union c1 c2 ) c2 succ | _ -> let n = new_node ( ) in n . eps <- [ nr1 ; nr2 ] nr2 ; n |
let rep r succ = let n = new_node ( ) in n . eps <- [ r n ; succ ] succ ; n |
let plus r succ = let n = new_node ( ) in let nr = r n in n . eps <- [ nr ; succ ] succ ; nr |
let eps succ = succ |
let compl r = let n = new_node ( ) in match is_chars n ( r n ) n with | Some c -> Some ( chars ( Cset . difference Cset . any c ) c ) c | _ -> None |
let pair_op f r0 r1 = let n = new_node ( ) in let to_chars r = is_chars n ( r n ) n in match ( to_chars r0 , to_chars r1 ) r1 with | Some c0 , Some c1 -> Some ( chars ( f c0 c1 ) c1 ) c1 | _ -> None |
let subtract = pair_op Cset . difference |
let intersection = pair_op Cset . intersection |
let compile_re re = let final = new_node ( ) in ( re final , final ) final |
type state = node list |
let rec add_node state node = if List . memq node state then state else add_nodes ( node :: state ) state node . eps |
let transition ( state : state ) state = let rec norm = function | ( c1 , n1 ) n1 :: ( ( c2 , n2 ) n2 :: q as l ) l -> if n1 == n2 then norm ( ( Cset . union c1 c2 , n1 ) n1 :: q ) q else ( c1 , n1 ) n1 :: norm l | l -> l in let t = List . concat ( List . map ( fun n -> n . trans ) trans state ) state in let t = norm (... |
let compile rs = let rs = Array . map compile_re rs in let counter = ref 0 in let states = Hashtbl . create 31 in let states_def = Hashtbl . create 31 in let rec aux state = try Hashtbl . find states state with Not_found -> let i = ! counter in incr counter ; Hashtbl . add states state i ; let trans = transition state ... |
let gen_of_channel chan = let f ( ) = try Some ( input_char chan ) chan with End_of_file -> None in f |
let ( >>= ) o f = match o with Some x -> f x | None -> None |
type lexbuf = { refill : Uchar . t array -> int -> int -> int ; mutable buf : Uchar . t array ; mutable len : int ; mutable offset : apos ; mutable pos : int ; mutable curr_bol : int ; mutable curr_line : int ; mutable start_pos : int ; mutable start_bol : int ; mutable start_line : int ; mutable marked_pos : int ; mut... |
let empty_lexbuf = { refill = ( fun _ _ _ -> assert false ) false ; buf = [ ] ; || len = 0 ; offset = 0 ; pos = 0 ; curr_bol = 0 ; curr_line = 0 ; start_pos = 0 ; start_bol = 0 ; start_line = 0 ; marked_pos = 0 ; marked_bol = 0 ; marked_line = 0 ; marked_val = 0 ; filename = " " ; finished = false ; } |
let create f = { empty_lexbuf with refill = f ; buf = Array . make chunk_size ( Uchar . of_int 0 ) 0 ; curr_line = 1 ; } |
let set_position lexbuf position = lexbuf . offset <- position . Lexing . pos_cnum - lexbuf . pos ; lexbuf . curr_bol <- position . Lexing . pos_bol ; lexbuf . curr_line <- position . Lexing . pos_lnum |
let set_filename lexbuf fname = lexbuf . filename <- fname |
let fill_buf_from_gen f gen buf pos len = let rec aux i = if i >= len then len else ( match gen ( ) with | Some c -> buf ( . pos + i ) i <- f c ; aux ( i + 1 ) 1 | None -> i ) i in aux 0 |
let from_gen s = create ( fill_buf_from_gen ( fun id -> id ) id s ) s |
let from_int_array a = let len = Array . length a in { empty_lexbuf with buf = Array . init len ( fun i -> Uchar . of_int a ( . i ) i ) i ; len ; finished = true ; } |
let from_uchar_array a = let len = Array . length a in { empty_lexbuf with buf = Array . init len ( fun i -> a ( . i ) i ) i ; len ; finished = true ; } |
let refill lexbuf = if lexbuf . len + chunk_size > Array . length lexbuf . buf then begin let s = lexbuf . start_pos in let ls = lexbuf . len - s in if ls + chunk_size <= Array . length lexbuf . buf then Array . blit lexbuf . buf s lexbuf . buf 0 ls else begin let newlen = ( Array . length lexbuf . buf + chunk_size ) c... |
let new_line lexbuf = if lexbuf . curr_line != 0 then lexbuf . curr_line <- lexbuf . curr_line + 1 ; lexbuf . curr_bol <- lexbuf . pos + lexbuf . offset |
let next lexbuf = if ( not lexbuf . finished ) finished && lexbuf . pos = lexbuf . len then refill lexbuf ; if lexbuf . finished && lexbuf . pos = lexbuf . len then None else begin let ret = lexbuf . buf ( . lexbuf . pos ) pos in lexbuf . pos <- lexbuf . pos + 1 ; if ret = Uchar . of_int 10 then new_line lexbuf ; Some ... |
let __private__next_int lexbuf : int = if ( not lexbuf . finished ) finished && lexbuf . pos = lexbuf . len then refill lexbuf ; if lexbuf . finished && lexbuf . pos = lexbuf . len then - 1 else begin let ret = lexbuf . buf ( . lexbuf . pos ) pos in lexbuf . pos <- lexbuf . pos + 1 ; if ret = Uchar . of_int 10 then new... |
let mark lexbuf i = lexbuf . marked_pos <- lexbuf . pos ; lexbuf . marked_bol <- lexbuf . curr_bol ; lexbuf . marked_line <- lexbuf . curr_line ; lexbuf . marked_val <- i |
let start lexbuf = lexbuf . start_pos <- lexbuf . pos ; lexbuf . start_bol <- lexbuf . curr_bol ; lexbuf . start_line <- lexbuf . curr_line ; mark lexbuf ( - 1 ) 1 |
let backtrack lexbuf = lexbuf . pos <- lexbuf . marked_pos ; lexbuf . curr_bol <- lexbuf . marked_bol ; lexbuf . curr_line <- lexbuf . marked_line ; lexbuf . marked_val |
let rollback lexbuf = lexbuf . pos <- lexbuf . start_pos ; lexbuf . curr_bol <- lexbuf . start_bol ; lexbuf . curr_line <- lexbuf . start_line |
let lexeme_start lexbuf = lexbuf . start_pos + lexbuf . offset |
let lexeme_end lexbuf = lexbuf . pos + lexbuf . offset |
let loc lexbuf = ( lexbuf . start_pos + lexbuf . offset , lexbuf . pos + lexbuf . offset ) offset |
let lexeme_length lexbuf = lexbuf . pos - lexbuf . start_pos |
let sub_lexeme lexbuf pos len = Array . sub lexbuf . buf ( lexbuf . start_pos + pos ) pos len |
let lexeme lexbuf = Array . sub lexbuf . buf lexbuf . start_pos ( lexbuf . pos - lexbuf . start_pos ) start_pos |
let lexeme_char lexbuf pos = lexbuf . buf ( . lexbuf . start_pos + pos ) pos |
let lexing_positions lexbuf = let start_p = { Lexing . pos_fname = lexbuf . filename ; pos_lnum = lexbuf . start_line ; pos_cnum = lexbuf . start_pos + lexbuf . offset ; pos_bol = lexbuf . start_bol ; } and curr_p = { Lexing . pos_fname = lexbuf . filename ; pos_lnum = lexbuf . curr_line ; pos_cnum = lexbuf . pos + lex... |
let with_tokenizer lexer ' lexbuf = let lexer ( ) = let token = lexer ' lexbuf in let start_p , curr_p = lexing_positions lexbuf in ( token , start_p , curr_p ) curr_p in lexer |
module Latin1 = struct let from_gen s = create ( fill_buf_from_gen Uchar . of_char s ) s let from_string s = let len = String . length s in { empty_lexbuf with buf = Array . init len ( fun i -> Uchar . of_char s [ . i ] i ) i ; len ; finished = true ; } let from_channel ic = from_gen ( gen_of_channel ic ) ic let to_lat... |
module Utf8 = struct module Helper = struct let width = Array . make 256 ( - 1 ) 1 let ( ) = for i = 0 to 127 do width ( . i ) i <- 1 done ; for i = 192 to 223 do width ( . i ) i <- 2 done ; for i = 224 to 239 do width ( . i ) i <- 3 done ; for i = 240 to 247 do width ( . i ) i <- 4 done let next s i = match s [ . i ] ... |
module Utf16 = struct type byte_order = Little_endian | Big_endian module Helper = struct let number_of_char_pair bo c1 c2 = match bo with | Little_endian -> ( Char . code c2 lsl 8 ) 8 + Char . code c1 | Big_endian -> ( Char . code c1 lsl 8 ) 8 + Char . code c2 let char_pair_of_number bo num = match bo with | Little_en... |
type t = ( int * int ) int list |
let singleton i = [ ( i , i ) i ] i |
let is_empty = function [ ] -> true | _ -> false |
let interval i j = if i <= j then [ ( i , j ) j ] j else [ ( j , i ) i ] i |
let eof = singleton ( - 1 ) 1 |
let any = interval 0 max_code |
let rec union c1 c2 = match ( c1 , c2 ) c2 with | [ ] , _ -> c2 | _ , [ ] -> c1 | ( ( i1 , j1 ) j1 as s1 ) s1 :: r1 , ( i2 , j2 ) j2 :: r2 -> if i1 <= i2 then if j1 + 1 < i2 then s1 :: union r1 c2 else if j1 < j2 then union r1 ( ( i1 , j2 ) j2 :: r2 ) r2 else union c1 r2 else union c2 c1 |
let complement c = let rec aux start = function | [ ] -> if start <= max_code then [ ( start , max_code ) max_code ] max_code else [ ] | ( i , j ) j :: l -> ( start , i - 1 ) 1 :: aux ( succ j ) j l in match c with ( - 1 , j ) j :: l -> aux ( succ j ) j l | l -> aux ( - 1 ) 1 l |
let intersection c1 c2 = complement ( union ( complement c1 ) c1 ( complement c2 ) c2 ) c2 |
let difference c1 c2 = complement ( union ( complement c1 ) c1 c2 ) c2 |
let base_char = [ ( 0x0041 , 0x005A ) 0x005A ; ( 0x0061 , 0x007A ) 0x007A ; ( 0x00C0 , 0x00D6 ) 0x00D6 ; ( 0x00D8 , 0x00F6 ) 0x00F6 ; ( 0x00F8 , 0x00FF ) 0x00FF ; ( 0x0100 , 0x0131 ) 0x0131 ; ( 0x0134 , 0x013E ) 0x013E ; ( 0x0141 , 0x0148 ) 0x0148 ; ( 0x014A , 0x017E ) 0x017E ; ( 0x0180 , 0x01C3 ) 0x01C3 ; ( 0x01CD , 0... |
let ideographic = [ ( 0x3007 , 0x3007 ) 0x3007 ; ( 0x3021 , 0x3029 ) 0x3029 ; ( 0x4E00 , 0x9FA5 ) 0x9FA5 ] 0x9FA5 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.