text
stringlengths
0
601k
module type Stable_without_comparator = Stable_module_types . S0_without_comparator
module type Stable1 = Stable_module_types . S1
module type Stable2 = Stable_module_types . S2
module type Stable3 = Stable_module_types . S3
module type Stable4 = Stable_module_types . S4
Base : sig type nonrec ' a array = ' a array [ @@ deriving sexp , sexp_grammar ] type nonrec bool = bool [ @@ deriving sexp , sexp_grammar ] type nonrec char = char [ @@ deriving sexp , sexp_grammar ] type nonrec exn = exn [ @@ deriving sexp_of ] type nonrec float = float [ @@ deriving sexp , sexp_grammar ] type nonrec...
type ' a sexp_option = ( ' a Std_internal . sexp_option [ @ ocaml . warning " - 3 " ] )
type ' a sexp_list = ( ' a Std_internal . sexp_list [ @ ocaml . warning " - 3 " ] )
module type S0_without_comparator = sig type t [ @@ deriving bin_io , compare , sexp ] end
module type S0 = sig include S0_without_comparator include Comparator . Stable . V1 . S with type t := t end
module type S1 = sig type ' a t [ @@ deriving bin_io , compare , sexp ] val map : ' a t -> f ( ' : a -> ' b ) -> ' b t end
module type S2 = sig type ( ' a1 , ' a2 ) t [ @@ deriving bin_io , compare , sexp ] val map : ( ' a1 , ' a2 ) t -> f1 ( ' : a1 -> ' b1 ) -> f2 ( ' : a2 -> ' b2 ) -> ( ' b1 , ' b2 ) t end
module type S3 = sig type ( ' a1 , ' a2 , ' a3 ) t [ @@ deriving bin_io , compare , sexp ] val map : ( ' a1 , ' a2 , ' a3 ) t -> f1 ( ' : a1 -> ' b1 ) -> f2 ( ' : a2 -> ' b2 ) -> f3 ( ' : a3 -> ' b3 ) -> ( ' b1 , ' b2 , ' b3 ) t end
module type S4 = sig type ( ' a1 , ' a2 , ' a3 , ' a4 ) t [ @@ deriving bin_io , compare , sexp ] val map : ( ' a1 , ' a2 , ' a3 , ' a4 ) t -> f1 ( ' : a1 -> ' b1 ) -> f2 ( ' : a2 -> ' b2 ) -> f3 ( ' : a3 -> ' b3 ) -> f4 ( ' : a4 -> ' b4 ) -> ( ' b1 , ' b2 , ' b3 , ' b4 ) t end
module Make_sexp_deserialization_test ( T : Stable_unit_test_intf . Arg ) = struct let % test_unit " sexp deserialization " = Or_error . combine_errors_unit ( List . map T . tests ~ f ( : fun ( t , sexp_as_string , _ ) -> match Or_error . try_with ( fun ( ) -> sexp_as_string |> Sexp . of_string |> [ % of_sexp : T . t ]...
module Make_sexp_serialization_test ( T : Stable_unit_test_intf . Arg ) = struct let % test_unit " sexp serialization " = Or_error . combine_errors_unit ( List . map T . tests ~ f ( : fun ( t , sexp_as_string , _ ) -> Or_error . try_with ( fun ( ) -> let sexp = Sexp . of_string sexp_as_string in let serialized_sexp = T...
module Make_bin_io_test ( T : Stable_unit_test_intf . Arg ) = struct let % test_unit " bin_io " = List . iter T . tests ~ f ( : fun ( t , _ , expected_bin_io ) -> let binable_m = ( module T : Binable . S with type t = T . t ) in let to_bin_string t = Binable . to_string binable_m t in let serialized_bin_io = to_bin_str...
module Make ( T : Stable_unit_test_intf . Arg ) = struct include Make_sexp_deserialization_test ( T ) include Make_sexp_serialization_test ( T ) include Make_bin_io_test ( T ) end
module Make_unordered_container ( T : Stable_unit_test_intf . Unordered_container_arg ) = struct module Test = Stable_unit_test_intf . Unordered_container_test let % test_unit " sexp " = List . iter T . tests ~ f ( : fun ( t , { Test . sexps ; _ } ) -> let sexps = List . map sexps ~ f : Sexp . of_string in let serializ...
module type Arg = sig type t [ @@ deriving sexp , bin_io ] val equal : t -> t -> bool val tests : ( t * string * string ) list end
module Unordered_container_test = struct type t = { sexps : string list ; bin_io_header : string ; bin_io_elements : string list } end
module type Unordered_container_arg = sig type t [ @@ deriving sexp , bin_io ] val equal : t -> t -> bool val tests : ( t * Unordered_container_test . t ) list end
type ' a t = { mutable c : ' a list ; mutable len : int ; }
let create ( ) = { c = [ ] ; len = 0 ; }
let clear s = s . c <- [ ] ; s . len <- 0
let copy s = { c = s . c ; len = s . len ; }
let push x s = s . c <- x :: s . c ; s . len <- s . len + 1
let pop s = match s . c with | hd :: tl -> s . c <- tl ; s . len <- s . len - 1 ; hd | [ ] -> raise Empty
let pop_opt s = match s . c with | hd :: tl -> s . c <- tl ; s . len <- s . len - 1 ; Some hd | [ ] -> None
let top s = match s . c with | hd :: _ -> hd | [ ] -> raise Empty
let top_opt s = match s . c with | hd :: _ -> Some hd | [ ] -> None
let is_empty s = ( s . c = [ ] )
let length s = s . len
let iter f s = List . iter f s . c
let fold f acc s = List . fold_left f acc s . c
let to_seq s = List . to_seq s . c
let add_seq q i = Seq . iter ( fun x -> push x q ) i
let of_seq g = let s = create ( ) in add_seq s g ; s
module type S = sig include Lattice . S val push : Basetype . Variables . t -> t -> t end
module Dom1 = struct let n = 3 let rec times x = function 0 -> [ ] | n -> x :: times x ( n - 1 ) let rec map2 f xs ys = match xs , ys with x :: xs , y :: ys -> ( try f x y :: map2 f xs ys with Lattice . Unsupported _ -> [ ] ) | _ -> [ ] let rec fold_left2 f a b xs ys = match xs , ys with | [ ] , _ | _ , [ ] -> a | x ::...
module Dom2 = struct module Var = Basetype . Variables include SetDomain . ToppedSet ( Var ) ( struct let topname = " All functions " end ) let push = add end
module Loc = struct include Printable . Liszt ( CilType . Location ) let dummy = [ ] end
module Dom3 = struct include Lattice . FakeSingleton ( Loc ) let push x ( xs : t ) : t = x :: xs end
let tests : unit Alcotest_lwt . test_case list = [ Alcotest_lwt . test_case " report " ` Quick ( fun _ ( ) -> let open Lwt . Infix in Gcloud . Stackdriver_errors . report { event_time = None ; message = Gcloud . Stackdriver_errors . stackdriver_nodejs_format ~ pos [ :% here ] ~ type_ " : Error " " gcloud error report t...
type ' a t = { mutable elts : ' a list ; mutable length : int ; }
let invariant t = assert ( t . length = List . length t . elts )
let create ( ) = { elts = [ ] ; length = 0 ; }
let set t elts length = begin t . elts <- elts ; t . length <- length end
let push x t = set t ( x :: t . elts ) ( t . length + 1 )
let pop_exn t = match t . elts with | [ ] -> raise Empty | x :: l -> ( set t l ( t . length - 1 ) ; x )
let pop t = try Some ( pop_exn t ) with | Empty -> None
let top_exn t = match t . elts with | [ ] -> raise Empty | x :: _ -> x
let top t = try Some ( top_exn t ) with | Empty -> None
let clear t = set t [ ] 0
let copy t = { elts = t . elts ; length = t . length ; }
let length t = t . length
let is_empty t = t . length = 0
let iter t ~ f = List . iter f t . elts
let fold t ~ init ~ f = List . fold_left f init t . elts
let topn_rev n t = Listf . take_rev n t . elts
let exists t ~ f = List . exists f t . elts
let for_all t ~ f = List . for_all f t . elts
let find_map t ~ f = Listf . find_map f t . elts
let to_list t = t . elts
let of_list l = { elts = l ; length = List . length l }
let to_array t = Array . of_list t . elts
let until_empty t f = let rec loop ( ) = if t . length > 0 then ( f ( pop_exn t ) ; loop ( ) ) in loop ( )
type primitive = | PrimLexerCall of value list | PrimOCamlFieldAccess of value * field | PrimOCamlAction of bindings * production * action string Action . t
type tokpat = | TokSingle of terminal * register | TokMultiple of terminals
type tagpat = | TagSingle of tag
type final = start_nonterminal option
type block_type = { stack : stack ; final : final ; }
type block = | IPush of values * cell * block | IPop of patterns * cell * block | IPeek of patterns * cell * block | IDef of bindings * block | IPrim of pattern * primitive * block | ITrace of trace * block | IComment of string * block | IDead of [ ` Static | ` Dynamic ] | IStop of int | IReturn of start_nonterminal * ...
type cfg = typed_block Label . Map . t
type states = block_type Tag . Map . t
type program = { cfg : cfg ; entry : label StringMap . t ; states : states ; }
let lookup program label : typed_block = try Label . Map . find label program . cfg with Not_found -> Printf . eprintf " Argh ! Cannot find label % s . \ n " %! ( Label . export label ) ; assert false
let invariant program tag : block_type = try Tag . Map . find tag program . states with Not_found -> Printf . eprintf " Argh ! Cannot find tag % s . \ n " %! ( Tag . print tag ) ; assert false
let branch_iter f ( _pat , block ) = f block
let branch_map f ( pat , block ) = ( pat , f block )
let cardinal program = Label . Map . cardinal program . cfg
let covered ( branches : tagbranch list ) : tags = List . fold_left ( fun accu ( tagpat , _body ) -> let TagSingle tag = tagpat in Tag . Set . add tag accu ) Tag . Set . empty branches
let complete program ( branches : tagbranch list ) : tagbranch list = let covered = covered branches in Tag . Map . fold ( fun tag _bty accu -> if Tag . Set . mem tag covered then accu else ( TagSingle tag , IDead ` Dynamic ) :: accu ) program . states branches
let trim branches = let keep ( _ , body ) = match body with IDead ` Dynamic -> false | _ -> true in List . filter keep branches
let tokens tokpat : terminals = match tokpat with | TokSingle ( tok , _ ) -> singleton tok | TokMultiple toks -> toks
let all_tokens ( branches : tokbranch list ) : terminals = let ( ) + = union in List . fold_left ( fun accu ( tokpat , _ ) -> accu + tokens tokpat ) empty branches
let exhaustive ( branches : tokbranch list ) : bool = subset universe ( all_tokens branches )
module Tag : sig type tag val make : Lr1 . node -> tag val lazy_make : Lr1 . node -> tag Lazy . t val print : tag -> string val compare : tag -> tag -> int module Set : Set . S with type elt = tag module Map : Map . S with type key = tag type tag = int let make s = let tag = Lr1 . number s in if not ( Invariant . repre...
type value = | VUnit | VTag of tag | VReg of register
type values = value list
type pattern = | PWildcard | PReg of register
type patterns = pattern list
let identity x = x
let compose f g x = f ( g x )
type state = | Idle | Open of ( block -> block ) | Closed of block
let current : state ref = ref Idle
let exec ( body : unit -> unit ) : block = let saved = ! current in current := Open identity ; body ( ) ; match ! current with | Idle -> assert false | Open _ -> assert false | Closed block -> current := saved ; block
let current_block_type : block_type option ref = ref None
let set_block_type block_type = assert ( ! current_block_type = None ) ; current_block_type := Some block_type
let current_hint : hint ref = ref NoHint