text stringlengths 0 601k |
|---|
let name_ts_rule_body ( body : Tree_sitter_t . rule_body ) = let open Tree_sitter_t in let rec name_rule_body body = match body with | SYMBOL ident -> ident | STRING s -> Punct . to_alphanum s | BLANK -> " blank " | PATTERN pat -> " pat_ " ^ hash_string_hex pat | REPEAT x -> " rep_ " ^ name_rule_body x | REPEAT1 x -> "... |
let name_rule_body body = let rec name_rule_body body = match body with | Symbol ident -> ident | Token token -> name_of_token token | Blank -> " blank " | Repeat body -> " rep_ " ^ name_rule_body body | Repeat1 body -> " rep1_ " ^ name_rule_body body | Choice ( ( _name , body ) :: _ ) -> " choice_ " ^ name_rule_body b... |
let hash_rule_body body = let buf = Buffer . create 100 in let rec aux = function | Symbol ident | Alias ( ident , _ ) -> Buffer . add_string buf ident | Token token -> Buffer . add_string buf token . name | Blank -> Buffer . add_string buf " blank " | Repeat body -> Buffer . add_string buf " repeat ( " ; aux body ; Bu... |
let assign_case_names ? rule_name : opt_rule_name cases = let initial_naming = List . mapi ( fun pos rule_body -> let case_name = name_rule_body rule_body in let name = force_capitalize case_name in ( name , ( pos , rule_body ) ) ) cases in let grouped = Util_list . group_by_key initial_naming in let disambiguated_nami... |
let again = ref false |
let rec signature : Env . t -> Signature . t -> Signature . t = fun env sg -> let env = Env . open_signature sg env in signature_items env sg fun env s -> let open Signature in let items = List . map ( fun item -> match item with | Module ( r , m ) -> Module ( r , module_ env m ) | ModuleType mt -> ModuleType ( module_... |
let signature env = let rec loop sg = again := false ; let sg ' = signature env sg in Tools . reset_caches ( ) ; if ! again then if sg ' = sg then sg else loop sg ' else sg ' in loop |
module Variant_kind = struct type t = Polymorphic | Non_polymorphic let to_string_prefix = function | Polymorphic -> " ` " | Non_polymorphic -> " " end |
module Result = struct type t = | Obj_boxed_traversable | Obj_boxed_not_traversable | Obj_immediate | Obj_immediate_but_should_be_boxed | Unit | Abstract of Path . t | Array of Types . type_expr * Env . t | List of Types . type_expr * Env . t | Tuple of Types . type_expr list * Env . t | Char | Int | Float | Float_arra... |
module Make ( D : Debugger . S ) ( Cmt_cache : Cmt_cache_intf . S ) = struct module V = D . Value module Abstraction_breaker = Abstraction_breaker . Make ( D ) ( Cmt_cache ) type maybe_boxed = Unboxed of V . t | Boxed of V . t | Absent type t = { abstraction_breaker : Abstraction_breaker . t ; cmt_cache : Cmt_cache . t... |
module type TYPE = sig val _type : env -> ( Loc . t , Loc . t ) Ast . Type . t val type_identifier : env -> ( Loc . t , Loc . t ) Ast . Identifier . t val type_params : env -> ( Loc . t , Loc . t ) Ast . Type . TypeParams . t option val type_args : env -> ( Loc . t , Loc . t ) Ast . Type . TypeArgs . t option val gener... |
module Type ( Parse : Parser_common . PARSER ) : TYPE = struct type param_list_or_type = | ParamList of ( Loc . t , Loc . t ) Type . Function . Params . t ' | Type of ( Loc . t , Loc . t ) Type . t let maybe_variance env = let loc = Peek . loc env in match Peek . token env with | T_PLUS -> let leading = Peek . comments... |
module Make ( D : Debugger . S ) ( Cmt_cache : Cmt_cache_intf . S ) ( Type_helper : Type_helper_intf . S with module Cmt_cache := Cmt_cache with module D := D ) = struct type t = { cmt_cache : Cmt_cache . t ; } let create cmt_cache = { cmt_cache ; } let print_given_type_and_env ? variable_name ? always_print formatter ... |
module type S = sig module Cmt_cache : Cmt_cache_intf . S type t val create : Cmt_cache . t -> t val print_given_type_and_env : ? variable_name : string -> ? always_print : unit -> Format . formatter -> ( Cmt_file . core_or_module_type * Env . t * Is_parameter . t ) option -> bool val print : ? variable_name : string -... |
let var ( n : int ) int = Var ( Var " v " ^ string_of_int n ) n |
let const c = Term ( c [ ] ) , |
let new_int , reset_new_int = let c = ref ( - 1 ) 1 in ( fun ( ) -> incr c ; ! c ) c , ( fun ( ) -> c := - 1 ) |
let unop_type k = match k with | Ml_fst -> let a = var ( new_int ( new_int ) new_int ) new_int and b = var ( new_int ( new_int ) new_int ) new_int in pair ( paira , b ) b , a | Ml_snd -> let a = var ( new_int ( new_int ) new_int ) new_int and b = var ( new_int ( new_int ) new_int ) new_int in pair ( paira , b ) b , b |
let binop_type k = match k with | Ml_add | Ml_sub | Ml_mult -> ( const " int " , const " int " , const " int ) " | Ml_eq | Ml_gt | Ml_less -> ( const " int " , const " int " , const " bool ) " |
let generate_type_constraints e = begin reset_new_int ( reset_new_int ) reset_new_int ; let rec gen n tenv = function | <: me < $ int : _ $ >> -> [ var n , const " int ] " | <: me < $ bool : _ $ >> -> [ var n , const " bool ] " | <: me < fst $ _ $ >> -> let t1 , t2 = unop_type Ml_fst and ne = new_int ( ) in [ ( var n ,... |
type simple = A of int |
type u = A of int |
type u = [ ` a | ` b ] ; ; |
type u = v = A of int ; ; |
type u = v = private A of int ; ; |
type ' a ab = [ < ` a ` | b ] as ' a |
type ' a ac = ' a constraint ' a = [ < ` a | ` c ] |
type ( ' a , ' b ) m = [ < ` m of ' a ab & ' a ac ] as ' b |
type _ a = A : int -> int a |
type _ a = A : int -> int a | B : int -> float a |
type ( ' u , ' v ) a = | A of int list * bool | B of bool |
type gram = { gfilter : filter ; gkeywords ( : string , int ref ) Hashtbl . t ; glexer : ( FanLoc . t -> ( char Stream . t -> ( token * FanLoc . t ) Stream . t ) ) ; warning_verbose : bool ref ; error_verbose : bool ref } [ ` Smeta of ( string * symbol list * Action . t ) | ` Snterm of internal_entry | ` Snterml of ( i... |
type ' + a my = H of ' a | D ; ; |
type ( ' + a , ' - b ) u = H of ' a | D of ( ' b -> int ) |
type ' a item_or_def = | SdStr of ' a | SdDef of string ( * string list * Ast . expr ) option | SdUnd of string | SdITE of bool ' * a item_or_def list ' * a item_or_def list | SdLazy of ' a Lazy . t |
type s = ? u : int -> int -> int |
let parse_expr ( ? keywords = Lexer_raw . keywords [ ] ) expr = let lexbuf = Lexing . from_string expr in let state = Lexer_raw . make keywords in let rec lexer = function | Lexer_raw . Fail ( e , l ) -> raise ( Lexer_raw . Error ( e , l ) ) | Lexer_raw . Return token -> token | Lexer_raw . Refill k -> lexer ( k ( ) ) ... |
let lookup_module name env = let path , md = Env . find_module_by_name name env in path , md . Types . md_type , md . Types . md_attributes |
let verbosity = ref 0 |
module Printtyp = struct include Printtyp let expand_type env ty = Env . with_cmis @@ fun ( ) -> if ! verbosity = 0 then ty else let ty = Subst . type_expr Subst . identity ty in let marks = Hashtbl . create 7 in let mark ty = if Hashtbl . mem marks ty . Types . id then false else ( Hashtbl . add marks ty . Types . id ... |
let rec mod_smallerthan n m = if n < 0 then None else let open Types in match m with | Mty_ident _ -> Some 1 | Mty_signature s -> begin match List . length_lessthan n s with | None -> None | Some _ -> List . fold_left s ~ init ( : Some 0 ) ~ f : begin fun acc item -> let sub n1 m = match mod_smallerthan ( n - n1 ) m wi... |
let print_short_modtype verbosity env ppf md = match mod_smallerthan 1000 md with | None when verbosity = 0 -> Format . pp_print_string ppf " " ; | _ -> Printtyp . modtype env ppf md |
let print_type_with_decl ~ verbosity env ppf typ = if verbosity > 0 then match ( Ctype . repr typ ) . Types . desc with | Types . Tconstr ( path , params , _ ) -> let decl = Env . with_cmis @@ fun ( ) -> Env . find_type path env in let is_abstract = match decl . Types . type_kind with | Types . Type_abstract -> true | ... |
let print_exn ppf exn = match Location . error_of_exn exn with | None | Some ` Already_displayed -> Format . pp_print_string ppf ( Printexc . to_string exn ) | Some ( ` Ok report ) -> Location . print_main ppf report |
let print_type ppf env lid = let p , t = Env . find_type_by_name lid . Asttypes . txt env in Printtyp . type_declaration env ( Ident . create_persistent ( Path . last p ) ) ppf t |
let print_modtype ppf verbosity env lid = let _p , mtd = Env . find_modtype_by_name lid . Asttypes . txt env in match mtd . mtd_type with | Some mt -> print_short_modtype verbosity env ppf mt | None -> Format . pp_print_string ppf " " |
let print_modpath ppf verbosity env lid = let _path , md = Env . find_module_by_name lid . Asttypes . txt env in print_short_modtype verbosity env ppf ( md . md_type ) |
let print_constr ppf env lid = let cstr_desc = Env . find_constructor_by_name lid . Asttypes . txt env in ! Oprint . out_type ppf ( Browse_misc . print_constructor cstr_desc ) |
let type_in_env ( ? verbosity = 0 ) ? keywords ~ context env ppf expr = let print_expr expression = let ( str , _sg , _ ) = Env . with_cmis @@ fun ( ) -> Typemod . type_toplevel_phrase env [ Ast_helper . Str . eval expression ] in let open Typedtree in let exp = Raw_compat . dest_tstr_eval str in print_type_with_decl ~... |
let read_doc_attributes attrs = let rec loop = function | ( { Location . txt = ( " doc " | " ocaml . doc " ) ; loc = _ } , payload ) :: _ -> Ast_helper . extract_str_payload payload | _ :: rest -> loop rest | [ ] -> None in loop ( List . map ~ f : Ast_helper . Attr . as_tuple attrs ) |
let is_deprecated = List . exists ~ f ( : fun ( attr : Parsetree . attribute ) -> match Ast_helper . Attr . as_tuple attr with | { Location . txt = ( " deprecated " | " ocaml . deprecated " ) ; loc = _ } , _ -> true | _ -> false ) |
module List = struct let map t ~ f = List . rev ( List . rev_map f t ) end |
module Make ( Pos : sig type t val sexp_of_t : t -> Type . t end ) = struct module T = struct type t = | Atom of Pos . t * string * string option | List of Pos . t * t_or_comment list * Pos . t and t_or_comment = | Sexp of t | Comment of comment and comment = | Plain_comment of Pos . t * string | Sexp_comment of Pos . ... |
module Parsed = Make ( Src_pos . Absolute ) |
let relativize = let rel ~ outer_p p = Src_pos . Absolute . diff p outer_p in let rec aux_t ~ outer_p = function | Parsed . Atom ( pos , s , sopt ) -> Atom ( rel pos ~ outer_p , s , sopt ) | Parsed . List ( start_pos , tocs , end_pos ) -> List ( rel start_pos ~ outer_p , List . map tocs ~ f ( : fun toc -> aux_toc ~ out... |
let find_value loc f = try find_value f with Not_found -> error loc ( Eglobal_undefined ( Value , f ) ) |
let find_type loc f = try find_type f with Not_found -> error loc ( Eglobal_undefined ( Type , f ) ) |
let find_constr loc c = try find_constr c with Not_found -> error loc ( Eglobal_undefined ( Constr , c ) ) |
let find_label loc l = try find_label l with Not_found -> error loc ( Eglobal_undefined ( Label , l ) ) |
let unify loc expected_ty actual_ty = try Ztypes . unify expected_ty actual_ty with | Ztypes . Unify -> error loc ( Etype_clash ( actual_ty , expected_ty ) ) |
let equal_sizes loc expected_size actual_size = try Ztypes . equal_sizes expected_size actual_size with | Ztypes . Unify -> error loc ( Esize_clash ( actual_size , expected_size ) ) |
let unify_expr expr expected_ty actual_ty = try Ztypes . unify expected_ty actual_ty with | Ztypes . Unify -> error expr . e_loc ( Etype_clash ( actual_ty , expected_ty ) ) |
let unify_pat pat expected_ty actual_ty = try Ztypes . unify expected_ty actual_ty with | Ztypes . Unify -> error pat . p_loc ( Etype_clash ( actual_ty , expected_ty ) ) |
let less_than loc actual_k expected_k = try Ztypes . less_than actual_k expected_k with | Ztypes . Unify -> error loc ( Ekind_clash ( actual_k , expected_k ) ) |
let type_is_in_kind loc expected_k ty = try Ztypes . kind expected_k ty with | Ztypes . Unify -> error loc ( Etype_kind_clash ( expected_k , ty ) ) |
let lift loc left_k right_k = try Ztypes . lift left_k right_k with | Ztypes . Unify -> error loc ( Ekind_clash ( right_k , left_k ) ) |
let sort_less_than loc sort expected_k = match expected_k , sort with | Tstatic _ , Sstatic -> ( ) | Tstatic _ , _ -> error loc ( Ekind_clash ( Deftypes . Tany , expected_k ) ) | _ -> ( ) |
let check_is_vec loc actual_ty = try let ty_arg , size = Ztypes . filter_vec actual_ty in ty_arg , size with | Ztypes . Unify -> error loc Esize_of_vec_is_undetermined |
let rec expansive { e_desc = desc } = match desc with | Elocal _ | Eglobal _ | Econst _ | Econstr0 _ -> false | Etuple ( e_list ) -> List . exists expansive e_list | Erecord ( l_e_list ) -> List . exists ( fun ( _ , e ) -> expansive e ) l_e_list | Erecord_access ( e , _ ) | Etypeconstraint ( e , _ ) -> expansive e | Er... |
let check_statefull loc expected_k = if not ( Ztypes . is_statefull_kind expected_k ) then error loc Ekind_not_combinatorial |
type state = { mutable s_reset : bool option ; s_parameters : typ list } |
let check_target_state loc expected_reset actual_reset = match expected_reset with | None -> Some ( actual_reset ) | Some ( expected_reset ) -> if expected_reset <> actual_reset then warning loc ( Wreset_target_state ( actual_reset , expected_reset ) ) ; Some ( expected_reset ) |
let turn_vars_into_memories h { dv = dv } = let add n acc = let ( { t_sort = sort ; t_typ = typ } as tentry ) = Env . find n h in match sort with | Smem ( { m_init = Noinit } as m ) -> Env . add n { tentry with t_sort = Smem { m with m_init = InitEq } } acc | Sstatic | Sval | Svar _ | Smem _ -> acc in let first_h = S .... |
let immediate = function | Ebool _ -> Initial . typ_bool | Eint ( i ) -> Initial . typ_int | Efloat ( i ) -> Initial . typ_float | Echar ( c ) -> Initial . typ_char | Estring ( c ) -> Initial . typ_string | Evoid -> Initial . typ_unit |
let incorporate_into_env first_h h = let mark n { t_sort = sort } = let tentry = Env . find n h in match sort with | Smem ( { m_init = InitEq } as m ) -> tentry . t_sort <- Smem { m with m_init = Noinit } | _ -> ( ) in Env . iter mark first_h |
let vars pat = Vars . fv_pat S . empty S . empty pat |
let var loc h n = try Env . find n h with Not_found -> error loc ( Evar_undefined ( n ) ) |
let typ_of_var loc h n = let { t_typ = typ } = var loc h n in typ |
let last loc h n = let { t_sort = sort ; t_typ = typ } as entry = var loc h n in begin match sort with | Sstatic | Sval | Svar _ | Smem { m_next = Some ( true ) } -> | Smem ( m ) -> entry . t_sort <- Smem { m with m_previous = true } end ; typ |
let derivative loc h n = let { t_typ = typ ; t_sort = sort } as entry = var loc h n in match sort with | Sstatic | Sval | Svar _ -> | Smem ( m ) -> entry . t_sort <- Smem { m with m_kind = Some ( Cont ) } ; typ |
let pluseq loc h n = let ( { t_typ = typ ; t_sort = sort } as entry ) = var loc h n in match sort with | Svar { v_combine = Some _ } -> typ | Sstatic | Sval | Svar { v_combine = None } | Smem { m_combine = None } -> error loc ( Ecombination_function ( n ) ) | Smem ( { m_next = n_opt } as m ) -> match n_opt with | None ... |
let init loc h n = let { t_typ = typ ; t_sort = sort } as entry = var loc h n in match sort with | Sstatic | Sval | Svar _ -> assert false | Smem ( { m_init = i } as m ) -> match i with | Noinit -> entry . t_sort <- Smem { m with m_init = InitEq } ; typ | InitEq -> typ | InitDecl _ -> error loc ( Ealready ( Initial , n... |
let next loc h n = let { t_typ = typ ; t_sort = sort } as entry = var loc h n in match sort with | Sstatic | Sval | Svar _ -> assert false | Smem { m_previous = true } -> error loc ( Enext_forbidden ( n ) ) | Smem ( { m_next = n_opt } as m ) -> match n_opt with | None -> entry . t_sort <- Smem { m with m_next = Some ( ... |
let def loc h n = let { t_sort = sort } as entry = var loc h n in match sort with | Sstatic | Sval | Svar _ -> ( ) | Smem ( { m_next = n_opt } as m ) -> match n_opt with | None -> entry . t_sort <- Smem { m with m_next = Some ( false ) } | Some ( false ) -> ( ) | Some ( true ) -> error loc ( Ealready_with_different_kin... |
let global loc expected_k lname = let { qualid = qualid ; info = { value_static = is_static ; value_typ = tys } } = find_value loc lname in less_than loc ( if is_static then Tstatic true else expected_k ) expected_k ; qualid , Ztypes . instance_of_type tys |
let global_with_instance loc expected_k lname = let { qualid = qualid ; info = { value_static = is_static ; value_typ = tys } } = find_value loc lname in less_than loc ( if is_static then Tstatic true else expected_k ) expected_k ; let typ_instance , typ_body = Ztypes . instance_and_vars_of_type tys in qualid , typ_ins... |
let label loc l = let { qualid = qualid ; info = tys_label } = find_label loc l in qualid , Ztypes . label_instance tys_label |
let constr loc c = let { qualid = qualid ; info = tys_c } = find_constr loc c in qualid , Ztypes . constr_instance tys_c |
let rec get_all_labels loc ty = match ty . t_desc with | Tconstr ( qual , _ , _ ) -> let { info = { type_desc = ty_c } } = find_type loc ( Lident . Modname ( qual ) ) in begin match ty_c with Record_type ( l ) -> l | _ -> assert false end | Tlink ( link ) -> get_all_labels loc link | _ -> assert false |
let check_definitions_for_every_name defined_names n_list = List . fold_left ( fun { dv = dv ; di = di ; der = der ; nv = nv ; mv = mv } { vardec_name = n ; vardec_default = d_opt ; vardec_loc = loc } -> let in_dv = S . mem n dv in let in_di = S . mem n di in let in_der = S . mem n der in let in_nv = S . mem n nv in le... |
let combine loc expected_ty lname = let { qualid = qualid ; info = { value_typ = tys } } = find_value loc lname in let ty = Ztypes . instance_of_type tys in let ty_combine = Ztypes . type_of_combine ( ) in unify loc ty_combine ty |
let constant loc expected_k expected_ty = function | Cimmediate ( i ) -> let actual_ty = immediate ( i ) in unify loc expected_ty actual_ty | Cglobal ( lname ) -> let qualid , actual_ty = global loc expected_k lname in unify loc expected_ty actual_ty |
let vardec_list expected_k n_list inames = let default loc expected_ty c_opt = function | Init ( v ) -> if not ( Ztypes . is_statefull_kind expected_k ) then error loc Ekind_not_combinatorial ; constant loc expected_k expected_ty v ; Deftypes . Smem ( Deftypes . cmem c_opt { empty_mem with m_init = InitDecl ( v ) } ) |... |
let rec build ( names , inames ) { eq_desc = desc } = let block_with_bounded ( names , inames ) let vardec acc { vardec_name = n } = S . add n acc in let bounded = List . fold_left vardec S . empty b_vars in let ( local_names , local_inames ) = build_list ( S . empty , S . empty ) eq_list in bounded , ( S . union names... |
let env_of_eq_list expected_k eq_list = let names , inames = build_list ( S . empty , S . empty ) eq_list in S . fold ( fun n acc -> let sort = match expected_k with | Deftypes . Tstatic _ -> Deftypes . static | Deftypes . Tany | Deftypes . Tdiscrete false -> Deftypes . variable | Deftypes . Tcont | Deftypes . Tdiscret... |
let intro_sort_of_var expected_k = match expected_k with | Deftypes . Tstatic _ -> Deftypes . static | Deftypes . Tany | Deftypes . Tdiscrete false -> Deftypes . Sval | Deftypes . Tcont | Deftypes . Tdiscrete true | Deftypes . Tproba -> Deftypes . Smem ( Deftypes . empty_mem ) |
let env_of_scondpat expected_k scpat = let rec env_of acc { desc = desc } = match desc with | Econdand ( sc1 , sc2 ) -> env_of ( env_of acc sc1 ) sc2 | Econdor ( sc , _ ) | Econdon ( sc , _ ) -> env_of acc sc | Econdexp _ -> acc | Econdpat ( _ , pat ) -> Vars . fv_pat S . empty acc pat in let acc = env_of S . empty scp... |
let env_of_statepat expected_k spat = let rec env_of acc { desc = desc } = match desc with | Estate0pat _ -> acc | Estate1pat ( _ , l ) -> List . fold_left ( fun acc n -> S . add n acc ) acc l in let acc = env_of S . empty spat in S . fold ( fun n acc -> Env . add n { t_typ = Ztypes . new_var ( ) ; t_sort = intro_sort_... |
let env_of_pattern expected_k h0 pat = let acc = Vars . fv_pat S . empty S . empty pat in S . fold ( fun n acc -> Env . add n { t_typ = Ztypes . new_var ( ) ; t_sort = intro_sort_of_var expected_k } acc ) acc h0 |
let env_of_pattern_list expected_k env p_list = let p_list , p = Zmisc . firsts p_list in let env = List . fold_left ( env_of_pattern ( Deftypes . Tstatic true ) ) env p_list in env_of_pattern expected_k env p |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.