text
stringlengths
0
601k
let interface lexbuf = parse_and_filter_doc_comments ( fun it -> it . Ast_mapper . signature it ) ( fun lexbuf -> From_current . copy_signature ( Parser . interface Lexer . token lexbuf ) ) lexbuf
let filter_toplevel_phrase it = function | Parsetree . Ptop_def str -> ignore ( it . Ast_mapper . structure it str ) | Parsetree . Ptop_dir _ -> ( )
let toplevel_phrase lexbuf = parse_and_filter_doc_comments filter_toplevel_phrase ( fun lexbuf -> From_current . copy_toplevel_phrase ( Parser . toplevel_phrase Lexer . token lexbuf ) ) lexbuf
let use_file lexbuf = parse_and_filter_doc_comments ( fun it result -> List . map ( filter_toplevel_phrase it ) result ) ( fun lexbuf -> List . map From_current . copy_toplevel_phrase ( Parser . use_file Lexer . token lexbuf ) ) lexbuf
let rec skip_phrase lexbuf = try match Lexer . token lexbuf with OCaml_parser . SEMISEMI | OCaml_parser . EOF -> ( ) | _ -> skip_phrase lexbuf with | Lexer . Error ( Lexer . Unterminated_comment _ , _ ) | Lexer . Error ( Lexer . Unterminated_string , _ ) | Lexer . Error ( Lexer . Unterminated_string_in_comment _ , _ ) ...
let maybe_skip_phrase lexbuf = if Parsing . is_current_lookahead OCaml_parser . SEMISEMI || Parsing . is_current_lookahead OCaml_parser . EOF then ( ) else skip_phrase lexbuf
let safeguard_parsing lexbuf fn = try fn ( ) with | Lexer . Error ( Lexer . Illegal_character _ , _ ) as err when ! Location . input_name = " // toplevel " //-> skip_phrase lexbuf ; raise err | Syntaxerr . Error _ as err when ! Location . input_name = " // toplevel " // -> maybe_skip_phrase lexbuf ; raise err | Parsing...
let format_interface_with_comments ( signature , _ ) formatter = Pprintast . signature formatter ( To_current . copy_signature signature )
let format_implementation_with_comments ( structure , _ ) formatter = let structure = Reason_syntax_util . ( apply_mapper_to_structure structure ( backport_letopt_mapper remove_stylistic_attrs_mapper ) ) in Pprintast . structure formatter ( To_current . copy_structure structure )
let rec loop lexer parser = let token = Lexer . token lexer in match P . step parser token with | P . Intermediate parser ' -> loop lexer parser ' | P . Error -> let _ , loc_start , loc_end = token in let loc = { Location . loc_start ; loc_end ; loc_ghost = false } in raise_fatal_error ( Parsing_error " Syntax error " ...
let initial_run entry_point lexer = loop lexer ( P . initial entry_point ( Lexer . lexbuf lexer ) . Lexing . lex_curr_p )
let implementation lexer = initial_run Reason_parser . Incremental . implementation lexer
let interface lexer = initial_run Reason_parser . Incremental . interface lexer
let core_type lexer = initial_run Reason_parser . Incremental . parse_core_type lexer
let toplevel_phrase lexer = initial_run Reason_parser . Incremental . toplevel_phrase lexer
let use_file lexer = initial_run Reason_parser . Incremental . use_file lexer
let rec skip_phrase lexer = try match Lexer . token lexer with | ( Reason_parser . SEMI | Reason_parser . EOF ) , _ , _ -> ( ) | _ -> skip_phrase lexer with Reason_error ( Lexing_error ( Unterminated_comment _ | Unterminated_string | Unterminated_string_in_comment _ | Illegal_character _ ) , _ ) -> skip_phrase lexer
let safeguard_parsing lexbuf fn = try fn ( ) with | Reason_error _ as err when ! Location . input_name = " // toplevel " //-> skip_phrase ( Lexer . init lexbuf ) ; raise err | Location . Error _ as x -> let loc = Location . curr lexbuf in if ! Location . input_name = " // toplevel " // then let _ = skip_phrase ( Lexer ...
let format_interface_with_comments ( signature , comments ) formatter = let reason_formatter = Reason_pprint_ast . createFormatter ( ) in reason_formatter # signature comments formatter signature
let format_implementation_with_comments ( implementation , comments ) formatter = let reason_formatter = Reason_pprint_ast . createFormatter ( ) in reason_formatter # structure comments formatter implementation
let setup_lexbuf ~ parser source_file = let ic = open_in source_file in try seek_in ic 0 ; let lexbuf = Lexing . from_channel ic in Location . init lexbuf source_file ; parser lexbuf with e -> Format . fprintf Format . std_formatter " Reason parser error : % s " ( Printexc . to_string e ) ; close_in_noerr ic ; exit 1
let read_signature info = let module_name = info . module_name in let cmi_file = module_name ^ " . cmi " in try let intf_file = Load_path . find_uncap cmi_file in let sign = Env . read_signature module_name intf_file in Some sign with Not_found -> None
let parse_implementation source_file = let implementation lexbuf = lexbuf |> Reason_toolchain . RE . implementation |> Reason_toolchain . To_current . copy_structure in setup_lexbuf ~ parser : implementation source_file
let parse_interface source_file = let interface lexbuf = lexbuf |> Reason_toolchain . RE . interface |> Reason_toolchain . To_current . copy_signature in setup_lexbuf ~ parser : interface source_file
let interface ~ source_file ~ output_prefix ~ opts : _ = Compile_common . with_info ~ native : false ~ tool_name ~ source_file ~ output_prefix ~ dump_ext " : cmo " @@ fun info -> Profile . record_call source_file @@ fun ( ) -> let parsetree = parse_interface source_file in if Clflags . ( should_stop_after Compiler_pass...
let compile ~ source_file ~ output_prefix ~ opts : _ = Compile_common . with_info ~ native : false ~ tool_name ~ source_file ~ output_prefix ~ dump_ext " : cmo " @@ fun info -> let parsetree = parse_implementation source_file in let typed , _coercion = parsetree |> Profile . ( record typing ) ( Typemod . type_implement...
let ( ) = Reason_pprint_ast . configure ~ width : 80 ~ assumeExplicitArity : false ~ constructorLists [ ] :
let reasonFormatter = Reason_pprint_ast . createFormatter ( )
let parseAsCoreType str formatter = Lexing . from_string str |> Reason_toolchain . ML . core_type |> reasonFormatter # core_type formatter
let parseAsImplementation str formatter = Lexing . from_string str |> Reason_toolchain . ML . implementation |> reasonFormatter # structure [ ] formatter
let parseAsInterface str formatter = Lexing . from_string str |> Reason_toolchain . ML . interface |> reasonFormatter # signature [ ] formatter
let parseAsCoreModuleType str formatter = Lexing . from_string ( " module X : " ^ str ) |> Reason_toolchain . ML . interface |> reasonFormatter # signature [ ] formatter
let parseAsWeirdListSyntax str a = if str = " type ' a list = [ ] | :: of ' a * ' a list " then " type list ' a = [ ] | :: of list ' a ' a " else raise ( Syntaxerr . Error a )
let convert str = let formatter = Format . str_formatter in try ( parseAsCoreType str formatter ; Format . flush_str_formatter ( ) ) with Syntaxerr . Error _ -> try ( parseAsImplementation str formatter ; Format . flush_str_formatter ( ) ) with Syntaxerr . Error _ -> try ( parseAsInterface str formatter ; Format . flus...
module ToploopBackup = struct let print_out_value = ! Toploop . print_out_value let print_out_type = ! Toploop . print_out_type let print_out_class_type = ! Toploop . print_out_class_type let print_out_module_type = ! Toploop . print_out_module_type let print_out_type_extension = ! Toploop . print_out_type_extension le...
let rec lident_operator_map mapper li = let open Longident in match li with | Lident s -> Lident ( mapper s ) | Ldot ( x , s ) -> Ldot ( x , mapper s ) | Lapply ( x , y ) -> Lapply ( lident_operator_map mapper x , lident_operator_map mapper y )
type top_kind = RTop | UTop
let current_top = ref RTop
let init_reason ( ) = if List . exists ( ( ) = " camlp4o " ) ! Topfind . predicates || List . exists ( ( ) = " camlp4r " ) ! Topfind . predicates then print_endline " Reason is incompatible with camlp4 " ! else begin let use_file x = List . map Reason_toolchain . To_current . copy_toplevel_phrase ( Reason_toolchain . R...
let init_ocaml ( ) = current_top := UTop ; UTop . set_phrase_terminator " ; ; " ; UTop . prompt := fst ( React . S . create LTerm_text . ( eval [ B_fg ( LTerm_style . green ) ; S " OCaml # " ] ) ) ; UTop . parse_toplevel_phrase := UTop . parse_toplevel_phrase_default ; UTop . parse_use_file := UTop . parse_use_file_def...
let toggle_syntax ( ) = match ! current_top with | RTop -> init_ocaml ( ) | UTop -> init_reason ( )
let _ = Hashtbl . add ( Toploop . directive_table [ @ ocaml . warning " - 3 " ] ) " toggle_syntax " ( Toploop . Directive_none toggle_syntax ) ; init_reason ( )
let to_http service region req = let uri = Uri . add_query_params ( Uri . of_string ( Aws . Util . of_option_exn ( Endpoints . url_of service region ) ) ) ( List . append [ ( " Version " , [ " 2015 - 02 - 02 " ] ) ; ( " Action " , [ " RebalanceSlotsInGlobalReplicationGroup " ] ) ] ( Util . drop_empty ( Uri . query_of_e...
let of_http body = try let xml = Ezxmlm . from_string body in let resp = Util . option_bind ( Xml . member " RebalanceSlotsInGlobalReplicationGroupResponse " ( snd xml ) ) ( Xml . member " RebalanceSlotsInGlobalReplicationGroupResult " ) in try Util . or_error ( Util . option_bind resp RebalanceSlotsInGlobalReplication...
let parse_error code err = let errors = [ ] @ Errors_internal . common in match Errors_internal . of_string err with | Some var -> if ( List . mem var errors ) && ( ( match Errors_internal . to_http_code var with | Some var -> var = code | None -> true ) ) then Some var else None | None -> None
let to_http service region req = let uri = Uri . add_query_params ( Uri . of_string ( Aws . Util . of_option_exn ( Endpoints . url_of service region ) ) ) ( List . append [ ( " Version " , [ " 2015 - 02 - 02 " ] ) ; ( " Action " , [ " RebootCacheCluster " ] ) ] ( Util . drop_empty ( Uri . query_of_encoded ( Query . ren...
let of_http body = try let xml = Ezxmlm . from_string body in let resp = Util . option_bind ( Xml . member " RebootCacheClusterResponse " ( snd xml ) ) ( Xml . member " RebootCacheClusterResult " ) in try Util . or_error ( Util . option_bind resp RebootCacheClusterResult . parse ) ( let open Error in BadResponse { body...
let parse_error code err = let errors = [ ] @ Errors_internal . common in match Errors_internal . of_string err with | Some var -> if ( List . mem var errors ) && ( ( match Errors_internal . to_http_code var with | Some var -> var = code | None -> true ) ) then Some var else None | None -> None
let to_http service region req = let uri = Uri . add_query_params ( Uri . of_string ( Aws . Util . of_option_exn ( Endpoints . url_of service region ) ) ) ( List . append [ ( " Version " , [ " 2014 - 10 - 31 " ] ) ; ( " Action " , [ " RebootDBInstance " ] ) ] ( Util . drop_empty ( Uri . query_of_encoded ( Query . rende...
let of_http body = try let xml = Ezxmlm . from_string body in let resp = Util . option_bind ( Xml . member " RebootDBInstanceResponse " ( snd xml ) ) ( Xml . member " RebootDBInstanceResult " ) in try Util . or_error ( Util . option_bind resp RebootDBInstanceResult . parse ) ( let open Error in BadResponse { body ; mes...
let parse_error code err = let errors = [ ] @ Errors_internal . common in match Errors_internal . of_string err with | Some var -> if ( List . mem var errors ) && ( ( match Errors_internal . to_http_code var with | Some var -> var = code | None -> true ) ) then Some var else None | None -> None
module Elt = struct type t = | Signed_command of Signed_command . Payload . t | Parties of Random_oracle . Digest . t end
module Chain_hash = struct include Data_hash . Make_full_size ( struct let description = " Receipt chain hash " let version_byte = Base58_check . Version_bytes . receipt_chain_hash end ) end [ %% versioned module Stable = struct [ @@@ no_toplevel_latest_type ] no_toplevel_latest_type module V1 = struct module T = struc...
type balance = | Contract of Contract_repr . t | Legacy_rewards of Signature . Public_key_hash . t * Cycle_repr . t | Block_fees | Legacy_deposits of Signature . Public_key_hash . t * Cycle_repr . t | Deposits of Signature . Public_key_hash . t | Nonce_revelation_rewards | Double_signing_evidence_rewards | Endorsing_re...
let balance_encoding = let open Data_encoding in def " operation_metadata . alpha . balance " @@ union [ case ( Tag 0 ) ~ title " : Contract " ( obj2 ( req " kind " ( constant " contract " ) ) ( req " contract " Contract_repr . encoding ) ) ( function Contract c -> Some ( ( ) , c ) | _ -> None ) ( fun ( ( ) , c ) -> Co...
let is_not_zero c = not ( Compare . Int . equal c 0 )
let compare_balance ba bb = match ( ba , bb ) with | ( Contract ca , Contract cb ) -> Contract_repr . compare ca cb | ( Legacy_rewards ( pkha , ca ) , Legacy_rewards ( pkhb , cb ) ) -> let c = Signature . Public_key_hash . compare pkha pkhb in if is_not_zero c then c else Cycle_repr . compare ca cb | ( Legacy_deposits ...
type balance_update = Debited of Tez_repr . t | Credited of Tez_repr . t
let balance_update_encoding = let open Data_encoding in def " operation_metadata . alpha . balance_update " @@ obj1 ( req " change " ( conv ( function | Credited v -> Tez_repr . to_mutez v | Debited v -> Int64 . neg ( Tez_repr . to_mutez v ) ) ( Json . wrap_error @@ fun v -> if Compare . Int64 . ( v < 0L ) then match T...
type update_origin = | Block_application | Protocol_migration | Subsidy | Simulation
let compare_update_origin oa ob = let index o = match o with | Block_application -> 0 | Protocol_migration -> 1 | Subsidy -> 2 | Simulation -> 3 in Compare . Int . compare ( index oa ) ( index ob )
let update_origin_encoding = let open Data_encoding in def " operation_metadata . alpha . update_origin " @@ obj1 @@ req " origin " @@ union [ case ( Tag 0 ) ~ title " : Block_application " ( constant " block " ) ( function Block_application -> Some ( ) | _ -> None ) ( fun ( ) -> Block_application ) ; case ( Tag 1 ) ~ ...
type balance_updates = ( balance * balance_update * update_origin ) list
let balance_updates_encoding = let open Data_encoding in def " operation_metadata . alpha . balance_updates " @@ list ( conv ( function | ( balance , balance_update , update_origin ) -> ( ( balance , balance_update ) , update_origin ) ) ( fun ( ( balance , balance_update ) , update_origin ) -> ( balance , balance_updat...
module BalanceMap = Map . Make ( struct type t = balance * update_origin let compare ( ba , ua ) ( bb , ub ) = let c = compare_balance ba bb in if is_not_zero c then c else compare_update_origin ua ub end )
let group_balance_updates balance_updates = List . fold_left_e ( fun acc ( b , update , o ) -> ( match BalanceMap . find ( b , o ) acc with | None -> ok update | Some present -> ( match ( present , update ) with | ( Credited a , Debited b ) | ( Debited b , Credited a ) -> if Tez_repr . ( a >= b ) then Tez_repr . ( a -?...
module Option = struct let map f = function Some x -> Some ( f x ) | None -> None end
type ' a stream = unit -> ' a option
type protocol = [ ` ESMTP | ` SMTP | ` Atom of string ]
type link = [ ` TCP | ` Atom of string ]
type ' a with_info = Only of ' a | With of ' a * info
type t = { from : Domain . t with_info option ; by : Domain . t with_info option ; via : link option ; _with : protocol option ; id : [ ` Local of Emile . local | ` MsgID of Mrmime . MessageID . t | ` Atom of string ] option ; _for : Path . t option ; date_time : Mrmime . Date . t ; }
let received_with { _with ; _ } = _with
let received_via { via ; _ } = via
let id { id ; _ } = id
let date_time { date_time ; _ } = date_time
let map_domain = function | Domain . IPv4 v -> ` Addr ( Emile . IPv4 v ) | Domain . IPv6 v -> ` Addr ( Emile . IPv6 v ) | Domain . Extension ( ldh , v ) -> ` Addr ( Emile . Ext ( ldh , v ) ) | Domain . Domain v -> ` Domain v
let msg_id t = let domain = match t . by with | Some ( Only domain ) -> Some domain | Some ( With ( domain , _ ) ) -> Some domain | None -> None in let domain = Option . map map_domain domain in match ( t . id , domain ) with | Some ( ` Local local ) , Some domain -> Some ( local , domain ) | Some ( ` Atom atom ) , Som...
let equal t0 t1 = let msg_id0 = msg_id t0 in let msg_id1 = msg_id t1 in match ( msg_id0 , msg_id1 ) with | Some ( local0 , domain0 ) , Some ( local1 , domain1 ) -> Emile . equal_local local0 local1 && Emile . equal_domain domain0 domain1 | Some _ , None | None , Some _ | None , None -> false
let compare t0 t1 = let sup = 1 and inf = - 1 in let msg_id0 = msg_id t0 in let msg_id1 = msg_id t1 in match ( msg_id0 , msg_id1 ) with | Some ( local0 , domain0 ) , Some ( local1 , domain1 ) -> let res = Emile . compare_local local0 local1 in if res = 0 then Emile . compare_domain domain0 domain1 else res | Some _ , N...
let received_by { by ; _ } = by
let received_from { from ; _ } = from
let received_for { _for ; _ } = _for
let link v = ` Atom v
let protocol v = ` Atom v
let make ? from ? by ? via ? protocol ? id _for ~ zone ptime = let date_time = Date . of_ptime ~ zone ptime in let id = match id with Some id -> Some ( ` MsgID id ) | None -> None in { from ; by ; via ; id ; _with = protocol ; _for ; date_time }
let ( . <> ) f g x = f ( g x )
let pp_extended_domain ppf = function | Only v -> Domain . pp ppf v | With ( v , ` Address addr ) -> Fmt . pf ppf " % a ( % a ) " Domain . pp v Domain . pp addr | With ( v , ` Domain_and_address ( domain , addr ) ) -> Fmt . pf ppf " % a ( % a % a ) " Domain . pp v Domain . pp domain Domain . pp addr
let pp_via ppf = function | ` Atom v -> Fmt . string ppf v | ` TCP -> Fmt . string ppf " tcp "
let pp_with ppf = function | ` ESMTP -> Fmt . string ppf " esmtp " | ` SMTP -> Fmt . string ppf " smtp " | ` Atom v -> Fmt . string ppf v
let pp_id ppf = function | ` MsgID v -> MessageID . pp ppf v | ` Local v -> Emile . pp_local ppf v | ` Atom v -> Fmt . string ppf v
let pp ppf t = let ptime , tz_offset_s = ( Rresult . R . get_ok . <> Date . to_ptime ) t . date_time in Fmt . pf ppf " from : % a @\ n \ by : % a @\ n \ via : % a @\ n \ with : % a @\ n \ id : % a @\ n \ for : % a @\ n \ date : % a @\ n " Fmt . ( option pp_extended_domain ) t . from Fmt . ( option pp_extended_domain ) ...
let some x : _ option = Some x
module Decoder = struct open Angstrom let is_wsp = function ' ' | ' \ t ' -> true | _ -> false let domain = Domain . Decoder . ipv4_address_literal >>| ( fun v -> Domain . IPv4 v ) <|> ( Domain . Decoder . ipv6_addr >>| fun v -> Domain . IPv6 v ) <|> Domain . Decoder . domain let address_literal = Domain . Decoder . ad...
module Encoder = struct open Prettym let extended_domain ppf = function | Only domain -> string ppf ( Domain . to_string domain ) | With ( domain , ` Address addr ) -> eval ppf [ !! string ; spaces 1 ; char $ ' ( ' ; !! string ; char $ ' ) ' ] ( Domain . to_string domain ) ( Domain . to_string addr ) | With ( domain , ...
let received = Field_name . v " Received "
let of_unstructured v = let v = List . fold_left ( fun a -> function # Unstrctrd . elt as x -> x :: a | _ -> a ) [ ] v in let v = List . rev v in match Unstrctrd . of_list v with | Ok v -> let v = Unstrctrd . fold_fws v in Unstrctrd . to_utf_8_string v | Error _ -> assert false
let of_stream stream = let decoder = Hd . decoder Field_name . Map . empty in let rec go acc = match Hd . decode decoder with | ` Field field -> ( let ( Field . Field ( field_name , w , v ) ) = Location . prj field in match w with | Field . Unstructured -> if Field_name . equal field_name received then let v = of_unstr...
let to_http service region req = let uri = Uri . add_query_params ( Uri . of_string ( Aws . Util . of_option_exn ( Endpoints . url_of service region ) ) ) ( List . append [ ( " Version " , [ " 2012 - 11 - 05 " ] ) ; ( " Action " , [ " ReceiveMessage " ] ) ] ( Util . drop_empty ( Uri . query_of_encoded ( Query . render ...
let of_http body = try let xml = Ezxmlm . from_string body in let resp = Util . option_bind ( Xml . member " ReceiveMessageResponse " ( snd xml ) ) ( Xml . member " ReceiveMessageResult " ) in try Util . or_error ( Util . option_bind resp ReceiveMessageResult . parse ) ( let open Error in BadResponse { body ; message =...