text
stringlengths 0
601k
|
---|
let env_of_pattern expected_k pat = env_of_pattern expected_k Env . empty pat |
let rec pattern h ( { p_desc = desc ; p_loc = loc } as pat ) ty = match desc with | Ewildpat -> pat . p_typ <- ty | Econstpat ( im ) -> unify_pat pat ty ( immediate im ) ; pat . p_typ <- ty | Econstr0pat ( c0 ) -> let qualid , { constr_res = ty_res ; constr_arity = n } = constr loc c0 in if n <> 0 then error loc ( Econstr_arity ( c0 , n , 0 ) ) ; unify_pat pat ty ty_res ; pat . p_desc <- Econstr0pat ( Lident . Modname ( qualid ) ) ; pat . p_typ <- ty | Econstr1pat ( c1 , pat_list ) -> let qualid , { constr_arg = ty_list ; constr_res = ty_res ; constr_arity = n } = constr loc c1 in let actual_n = List . length pat_list in if n <> actual_n then error loc ( Econstr_arity ( c1 , n , actual_n ) ) ; unify_pat pat ty ty_res ; pat . p_desc <- Econstr1pat ( Lident . Modname ( qualid ) , pat_list ) ; pat . p_typ <- ty ; List . iter2 ( pattern h ) pat_list ty_list | Evarpat ( x ) -> unify_pat pat ty ( typ_of_var loc h x ) ; pat . p_typ <- ty | Etuplepat ( pat_list ) -> let ty_list = List . map ( fun _ -> new_var ( ) ) pat_list in unify_pat pat ty ( product ty_list ) ; pat . p_typ <- ty ; List . iter2 ( pattern h ) pat_list ty_list | Etypeconstraintpat ( p , typ_expr ) -> let expected_typ = Ztypes . instance_of_type ( Interface . scheme_of_type typ_expr ) in unify_pat pat expected_typ ty ; pat . p_typ <- ty ; pattern h p ty | Erecordpat ( label_pat_list ) -> pat . p_typ <- ty ; let label_pat_list = List . map ( fun ( lab , pat_label ) -> let qualid , { label_arg = ty_arg ; label_res = ty_res } = label pat . p_loc lab in unify_pat pat_label ty ty_arg ; pattern h pat_label ty_res ; Lident . Modname ( qualid ) , pat_label ) label_pat_list in pat . p_desc <- Erecordpat ( label_pat_list ) | Ealiaspat ( p , x ) -> unify_pat pat ty ( typ_of_var loc h x ) ; pat . p_typ <- ty ; pattern h p ty | Eorpat ( p1 , p2 ) -> pat . p_typ <- ty ; pattern h p1 ty ; pattern h p2 ty |
let pattern_list h pat_list ty_list = List . iter2 ( pattern h ) pat_list ty_list |
let check_total_pattern p = let is_exhaustive = Patternsig . check_activate p . p_loc p in if not is_exhaustive then error p . p_loc Epattern_not_total |
let check_total_pattern_list p_list = List . iter check_total_pattern p_list |
let match_handlers body loc expected_k h total m_handlers pat_ty ty = let handler ( { m_pat = pat ; m_body = b } as mh ) = let h0 = env_of_pattern expected_k pat in pattern h0 pat pat_ty ; mh . m_env <- h0 ; let h = Env . append h0 h in body expected_k h b ty in let defined_names_list = List . map handler m_handlers in let is_exhaustive = ! total || ( Patternsig . check_match_handlers loc m_handlers ) in let defined_names_list = if is_exhaustive then defined_names_list else Deftypes . empty :: defined_names_list in total := is_exhaustive ; Total . merge loc h defined_names_list |
let present_handlers scondpat body loc expected_k h p_h_list b_opt expected_ty = let handler ( { p_cond = scpat ; p_body = b } as ph ) = let h0 = env_of_scondpat expected_k scpat in let h = Env . append h0 h in let is_zero = Ztypes . is_continuous_kind expected_k in scondpat expected_k is_zero h scpat ; ph . p_zero <- is_zero ; ph . p_env <- h0 ; body ( Ztypes . lift_to_discrete expected_k ) h b expected_ty in let defined_names_list = List . map handler p_h_list in let defined_names_list = match b_opt with | None -> Deftypes . empty :: defined_names_list | Some ( b ) -> let defined_names = body expected_k h b expected_ty in defined_names :: defined_names_list in Total . merge loc h defined_names_list |
let rec expression expected_k h ( { e_desc = desc ; e_loc = loc } as e ) = let ty = match desc with | Econst ( i ) -> immediate i | Elocal ( x ) -> let { t_typ = typ ; t_sort = sort } = var loc h x in sort_less_than loc sort expected_k ; typ | Eglobal { lname = lname } -> let qualid , typ_instance , ty = global_with_instance loc expected_k lname in e . e_desc <- Eglobal { lname = Lident . Modname ( qualid ) ; typ_instance = typ_instance } ; ty | Elast ( x ) -> last loc h x | Etuple ( e_list ) -> product ( List . map ( expression expected_k h ) e_list ) | Eop ( Eaccess , [ e1 ; e2 ] ) -> let ty = expression expected_k h e1 in let ty_arg , _ = check_is_vec e1 . e_loc ty in expect expected_k h e2 Initial . typ_int ; ty_arg | Eop ( Eupdate , [ e1 ; i ; e2 ] ) -> let ty = expression expected_k h e1 in let ty_arg , _ = check_is_vec e1 . e_loc ty in expect expected_k h i Initial . typ_int ; expect expected_k h e2 ty_arg ; ty | Eop ( Eslice ( s1 , s2 ) , [ e ] ) -> let s1 = size h s1 in let s2 = size h s2 in let ty = expression expected_k h e in let ty_arg , _ = check_is_vec e . e_loc ty in Ztypes . vec ty_arg ( Ztypes . plus ( Ztypes . minus s2 s1 ) ( Ztypes . const 1 ) ) | Eop ( Econcat , [ e1 ; e2 ] ) -> let ty1 = expression expected_k h e1 in let ty_arg1 , s1 = check_is_vec e1 . e_loc ty1 in let ty2 = expression expected_k h e2 in let ty_arg2 , s2 = check_is_vec e2 . e_loc ty2 in unify_expr e2 ty_arg1 ty_arg2 ; Ztypes . vec ty_arg1 ( Ztypes . plus s1 s2 ) | Eop ( op , e_list ) -> operator expected_k h loc op e_list | Eapp ( { app_statefull = is_statefull } , e , e_list ) -> apply loc is_statefull expected_k h e e_list | Econstr0 ( c0 ) -> let qualid , { constr_res = ty_res ; constr_arity = n } = constr loc c0 in if n <> 0 then error loc ( Econstr_arity ( c0 , n , 0 ) ) ; e . e_desc <- Econstr0 ( Lident . Modname ( qualid ) ) ; ty_res | Econstr1 ( c1 , e_list ) -> let qualid , { constr_arg = ty_list ; constr_res = ty_res ; constr_arity = n } = constr loc c1 in let actual_arity = List . length e_list in if n <> actual_arity then error loc ( Econstr_arity ( c1 , n , actual_arity ) ) ; List . iter2 ( expect expected_k h ) e_list ty_list ; e . e_desc <- Econstr1 ( Lident . Modname ( qualid ) , e_list ) ; ty_res | Erecord_access ( e1 , lab ) -> let qualid , { label_arg = ty_arg ; label_res = ty_res } = label loc lab in expect expected_k h e1 ty_arg ; e . e_desc <- Erecord_access ( e1 , Lident . Modname ( qualid ) ) ; ty_res | Erecord ( label_e_list ) -> let ty = new_var ( ) in let label_e_list = List . map ( fun ( lab , e_label ) -> let qualid , { label_arg = ty_arg ; label_res = ty_res } = label loc lab in unify_expr e ty ty_arg ; expect expected_k h e_label ty_res ; ( Lident . Modname ( qualid ) , e_label ) ) label_e_list in e . e_desc <- Erecord ( label_e_list ) ; let label_desc_list = get_all_labels loc ty in if List . length label_e_list <> List . length label_desc_list then error loc Esome_labels_are_missing ; ty | Erecord_with ( e1 , label_e_list ) -> let ty = new_var ( ) in let label_e_list = List . map ( fun ( lab , e_label ) -> let qualid , { label_arg = ty_arg ; label_res = ty_res } = label loc lab in unify_expr e ty ty_arg ; expect expected_k h e_label ty_res ; ( Lident . Modname ( qualid ) , e_label ) ) label_e_list in e . e_desc <- Erecord_with ( e1 , label_e_list ) ; ty | Etypeconstraint ( exp , typ_expr ) -> let expected_typ = Ztypes . instance_of_type ( Interface . scheme_of_type typ_expr ) in expect expected_k h exp expected_typ ; expected_typ | Elet ( l , e ) -> let h = local expected_k h l in expression expected_k h e | Eblock ( b , e ) -> let h , _ = block_eq_list expected_k h b in expression expected_k h e | Eseq ( e1 , e2 ) -> ignore ( expression expected_k h e1 ) ; expression expected_k h e2 | Eperiod ( p ) -> less_than loc Tcont expected_k ; period ( Tstatic ( true ) ) h p ; Ztypes . zero_type expected_k | Ematch ( total , e , m_h_list ) -> let expected_pat_ty = expression expected_k h e in let expected_ty = new_var ( ) in ignore ( match_handler_exp_list loc expected_k h total m_h_list expected_pat_ty expected_ty ) ; expected_ty | Epresent ( p_h_list , e_opt ) -> let expected_ty = new_var ( ) in ignore ( present_handler_exp_list loc expected_k h p_h_list e_opt expected_ty ) ; expected_ty in type_is_in_kind loc expected_k ty ; e . e_typ <- ty ; ty match desc with | Sconst ( i ) -> Ztypes . const i | Sglobal ( ln ) -> let qualid , _ , typ_body = global_with_instance loc ( Tstatic ( true ) ) ln in unify loc Initial . typ_int typ_body ; Ztypes . global ( qualid ) | Sname ( x ) -> let { t_typ = typ ; t_sort = sort } = var loc h x in sort_less_than loc sort ( Tstatic ( true ) ) ; unify loc Initial . typ_int typ ; Ztypes . name x | Sop ( Splus , s1 , s2 ) -> let s1 = size h s1 in let s2 = size h s2 in Ztypes . plus s1 s2 | Sop ( Sminus , s1 , s2 ) -> let s1 = size h s1 in let s2 = size h s2 in Ztypes . minus s1 s2 match desc with | Econst ( Eint ( i ) ) -> Tconst ( i ) | Elocal ( n ) -> Tname ( n ) | Eglobal { lname = Lident . Modname ( qualid ) } -> Tglobal ( qualid ) | Eapp ( _ , { e_desc = Eglobal { lname = Lident . Modname ( qualid ) } } , [ e1 ; e2 ] ) when qualid = Initial . stdlib_name " " + -> Top ( Tplus , size_of_exp e1 , size_of_exp e2 ) | Eapp ( _ , { e_desc = Eglobal { lname = Lident . Modname ( qualid ) } } , [ e1 ; e2 ] ) when qualid = Initial . stdlib_name " " - -> Top ( Tminus , size_of_exp e1 , size_of_exp e2 ) | _ -> error loc Enot_a_size_expression let actual_k , ty_args , ty_res = match op with | Eifthenelse -> let ty = new_var ( ) in Tany , [ Initial . typ_bool ; ty ; ty ] , ty | Eunarypre -> let ty = new_var ( ) in Tdiscrete ( true ) , [ ty ] , ty | ( Eminusgreater | Efby ) -> let ty = new_var ( ) in Tdiscrete ( true ) , [ ty ; ty ] , ty | ( Eup | Ehorizon ) -> Tcont , [ Initial . typ_float ] , Initial . typ_zero | Etest -> let ty = new_var ( ) in Tany , [ Initial . typ_signal ty ] , Initial . typ_bool | Edisc -> let ty = new_var ( ) in Tcont , [ ty ] , Initial . typ_zero | Einitial -> Tcont , [ ] , Initial . typ_zero | Eatomic -> let ty = new_var ( ) in expected_k , [ ty ] , ty | Eaccess | Eupdate | Eslice _ | Econcat -> assert false in less_than loc actual_k expected_k ; List . iter2 ( expect expected_k h ) e_list ty_args ; ty_res expect expected_k h p2 Initial . typ_float ; match p1_opt with None -> ( ) | Some ( p1 ) -> expect expected_k h p1 Initial . typ_float let actual_ty = expression expected_k h e in unify_expr e expected_ty actual_ty let ty_fct = expression ( Tstatic ( true ) ) h e in if is_statefull then begin check_statefull loc expected_k ; unify_expr e ( Ztypes . run_type expected_k ) ty_fct end ; let intro_k = Ztypes . intro expected_k in let rec args ty_fct = function | [ ] -> ty_fct | arg :: arg_list -> let actual_k , n_opt , ty1 , ty2 = try Ztypes . filter_arrow intro_k ty_fct with Unify -> error loc ( Eapplication_of_non_function ) in let expected_k = lift loc expected_k actual_k in expect expected_k h arg ty1 ; let ty2 = match n_opt with | None -> ty2 | Some ( n ) -> subst_in_type ( Env . singleton n ( size_of_exp arg ) ) ty2 in args ty2 arg_list in args ty_fct arg_list let defnames = match desc with | EQeq ( p , e ) -> let ty_e = expression expected_k h e in pattern h p ty_e ; check_total_pattern p ; let dv = vars p in S . iter ( def loc h ) dv ; { Deftypes . empty with dv = dv } | EQpluseq ( n , e ) -> let actual_ty = expression expected_k h e in let expected_ty = pluseq loc h n in unify loc expected_ty actual_ty ; { Deftypes . empty with mv = S . singleton n } | EQinit ( n , e0 ) -> check_statefull loc expected_k ; let actual_ty = init loc h n in expect ( Ztypes . lift_to_discrete expected_k ) h e0 actual_ty ; { Deftypes . empty with di = S . singleton n } | EQnext ( n , e , e0_opt ) -> less_than loc ( Tdiscrete ( true ) ) expected_k ; let actual_ty = next loc h n in expect expected_k h e actual_ty ; let di = match e0_opt with | None -> S . empty | Some ( e ) -> expect expected_k h e actual_ty ; ignore ( init loc h n ) ; S . singleton n in { Deftypes . empty with nv = S . singleton n ; di = di } | EQder ( n , e , e0_opt , p_h_e_list ) -> less_than loc Tcont expected_k ; let actual_ty = derivative loc h n in unify loc Initial . typ_float actual_ty ; expect expected_k h e actual_ty ; let di = match e0_opt with | None -> S . empty | Some ( e ) -> expect ( Ztypes . lift_to_discrete expected_k ) h e Initial . typ_float ; ignore ( init loc h n ) ; S . singleton n in ignore ( present_handler_exp_list loc expected_k h p_h_e_list None Initial . typ_float ) ; { Deftypes . empty with di = di ; der = S . singleton n } | EQautomaton ( is_weak , s_h_list , se_opt ) -> check_statefull loc expected_k ; automaton_handlers is_weak loc expected_k h s_h_list se_opt | EQmatch ( total , e , m_h_list ) -> let expected_pat_ty = expression expected_k h e in match_handler_block_eq_list loc expected_k h total m_h_list expected_pat_ty | EQpresent ( p_h_list , b_opt ) -> present_handler_block_eq_list loc expected_k h p_h_list b_opt | EQreset ( eq_list , e ) -> expect expected_k h e ( Ztypes . zero_type expected_k ) ; equation_list expected_k h eq_list | EQand ( eq_list ) | EQbefore ( eq_list ) -> equation_list expected_k h eq_list | EQemit ( n , e_opt ) -> less_than loc expected_k ( Ztypes . lift_to_discrete expected_k ) ; let ty_e = new_var ( ) in let ty_name = typ_of_var loc h n in begin match e_opt with | None -> unify loc ( Initial . typ_signal Initial . typ_unit ) ty_name | Some ( e ) -> unify loc ( Initial . typ_signal ty_e ) ty_name ; expect expected_k h e ty_e end ; { Deftypes . empty with dv = S . singleton n } | EQblock ( b_eq_list ) -> snd ( block_eq_list expected_k h b_eq_list ) | EQforall ( { for_index = i_list ; for_init = init_list ; for_body = b_eq_list } as body ) -> let merge ( { dv = dv ; di = di ; der = der ; nv = nv ; mv = mv } as defnames ) h init_h out_h xi_out_x = let out_set = Env . fold ( fun x _ acc -> S . add x acc ) out_h S . empty in let out_not_defined = S . diff out_set ( Deftypes . names S . empty defnames ) in if not ( S . is_empty out_not_defined ) then error loc ( Eequation_is_missing ( S . choose out_not_defined ) ) ; let x_of_xi xi = try Env . find xi xi_out_x with Not_found -> xi in let out xi acc = try S . add ( Env . find xi xi_out_x ) acc with Not_found -> acc in let belong_to_init_out xi = if not ( ( Env . mem xi init_h ) || ( Env . mem xi out_h ) ) then error loc ( Ealready_in_forall ( xi ) ) in let belong_to_out_not_init xi = if not ( Env . mem xi out_h ) || ( Env . mem xi init_h ) then error loc ( Ealready_in_forall ( xi ) ) in S . iter belong_to_init_out dv ; S . iter belong_to_init_out nv ; S . iter belong_to_init_out der ; S . iter belong_to_out_not_init di ; S . iter ( def loc h ) ( S . fold out dv S . empty ) ; S . iter ( fun n -> ignore ( init loc h n ) ) ( S . fold out di S . empty ) ; S . iter ( fun n -> ignore ( derivative loc h n ) ) ( S . fold out der S . empty ) ; { dv = S . map x_of_xi dv ; di = S . map x_of_xi di ; der = S . map x_of_xi der ; nv = S . map x_of_xi nv ; mv = S . map x_of_xi mv } in let sort = if Ztypes . is_statefull_kind expected_k then Deftypes . Smem Deftypes . empty_mem else Deftypes . variable in let index ( in_h , out_h , xi_out_x , size_opt ) { desc = desc ; loc = loc } = let size_of loc size_opt = match size_opt with | None -> error loc Esize_of_vec_is_undetermined | Some ( actual_size ) -> actual_size in match desc with | Einput ( xi , e ) -> let ty = Ztypes . new_var ( ) in let si = size_of loc size_opt in expect Tany h e ( Ztypes . vec ty si ) ; Env . add xi { t_typ = ty ; t_sort = Sval } in_h , out_h , xi_out_x , size_opt | Eoutput ( xi , x ) -> let ty_xi = Ztypes . new_var ( ) in let ty_x = typ_of_var loc h x in let si = size_of loc size_opt in unify loc ( Ztypes . vec ty_xi si ) ty_x ; in_h , Env . add xi { t_typ = ty_xi ; t_sort = sort } out_h , Env . add xi x xi_out_x , size_opt | Eindex ( i , e0 , e1 ) -> expect ( Tstatic ( true ) ) h e0 Initial . typ_int ; expect ( Tstatic ( true ) ) h e1 Initial . typ_int ; let e0 = size_of_exp e0 in let e1 = size_of_exp e1 in let actual_size = Ztypes . plus ( Ztypes . minus e1 e0 ) ( Ztypes . const 1 ) in let size_opt = match size_opt with | None -> Some ( actual_size ) | Some ( expected_size ) -> equal_sizes loc expected_size actual_size ; size_opt in Env . add i { t_typ = Initial . typ_int ; t_sort = Sval } in_h , out_h , xi_out_x , size_opt in let init init_h { desc = desc ; loc = loc } = match desc with | Einit_last ( i , e ) -> let ty = typ_of_var loc h i in expect expected_k h e ty ; Env . add i { t_typ = ty ; t_sort = Deftypes . memory } init_h in let init_h = List . fold_left init Env . empty init_list in let in_h , out_h , xi_out_x , _ = List . fold_left index ( Env . empty , Env . empty , Env . empty , None ) i_list in body . for_in_env <- in_h ; body . for_out_env <- out_h ; let h_eq_list = Env . append in_h ( Env . append out_h ( Env . append init_h h ) ) in let _ , defnames = block_eq_list expected_k h_eq_list b_eq_list in merge defnames h init_h out_h xi_out_x in eq . eq_write <- defnames ; defnames List . fold_left ( fun defined_names eq -> Total . join eq . eq_loc ( equation expected_k h eq ) defined_names ) Deftypes . empty eq_list present_handlers scondpat ( fun expected_k h e expected_ty -> expect expected_k h e expected_ty ; Deftypes . empty ) loc expected_k h p_h_list e0_opt expected_ty present_handlers scondpat ( fun expected_k h b _ -> snd ( block_eq_list expected_k h b ) ) loc expected_k h p_h_list b_opt Initial . typ_unit match_handlers ( fun expected_k h b _ -> snd ( block_eq_list expected_k h b ) ) loc expected_k h total m_h_list pat_ty Initial . typ_unit match_handlers ( fun expected_k h e expected_ty -> expect expected_k h e expected_ty ; Deftypes . empty ) loc expected_k h total m_h_list pat_ty ty ( { b_vars = n_list ; b_locals = l_list ; b_body = eq_list } as b ) = let _ , inames = build_list ( S . empty , S . empty ) eq_list in let h0 = vardec_list expected_k n_list inames in let h = Env . append h0 h in let new_h = List . fold_left ( local expected_k ) h l_list in let defined_names = equation_list expected_k new_h eq_list in let defined_names = check_definitions_for_every_name defined_names n_list in b . b_write <- defined_names ; b . b_env <- h0 ; new_h , defined_names let h0 = env_of_eq_list expected_k eq_list in l . l_env <- h0 ; let new_h = Env . append h0 h in ignore ( equation_list expected_k new_h eq_list ) ; Env . append h0 h let rec typrec expected_k is_zero_type scpat = match scpat . desc with | Econdand ( sc1 , sc2 ) -> typrec expected_k is_zero_type sc1 ; typrec expected_k is_zero_type sc2 | Econdor ( sc1 , sc2 ) -> typrec expected_k is_zero_type sc1 ; typrec expected_k is_zero_type sc2 | Econdexp ( e ) -> let expected_ty = if is_zero_type then Initial . typ_zero else Initial . typ_bool in ignore ( expect expected_k h e expected_ty ) | Econdpat ( e_cond , pat ) -> let ty = new_var ( ) in ignore ( expect expected_k h e_cond ( Initial . typ_signal ty ) ) ; pattern h pat ty | Econdon ( sc1 , e ) -> typrec expected_k is_zero_type sc1 ; ignore ( expect ( Ztypes . on_type expected_k ) h e Initial . typ_bool ) in typrec expected_k is_zero_type scpat match state . desc with | Estate0 ( s ) -> begin try let ( { s_reset = expected_reset ; s_parameters = args } as r ) = Env . find s def_states in if args <> [ ] then error state . loc ( Estate_arity_clash ( s , 0 , List . length args ) ) ; r . s_reset <- check_target_state state . loc expected_reset actual_reset with | Not_found -> error state . loc ( Estate_unbound s ) end | Estate1 ( s , l ) -> let ( { s_reset = expected_reset ; s_parameters = args } as r ) = try Env . find s def_states with | Not_found -> error state . loc ( Estate_unbound s ) in begin try List . iter2 ( fun e expected_ty -> ignore ( expect Tany h e expected_ty ) ) l args ; r . s_reset <- check_target_state state . loc expected_reset actual_reset with | Invalid_argument _ -> error state . loc ( Estate_arity_clash ( s , List . length l , List . length args ) ) end let mark ( { s_state = statepat } as handler ) = let { s_reset = r } = Env . find ( Total . Automaton . statepatname statepat ) def_states in let v = match r with | None | Some ( false ) -> false | Some ( true ) -> true in handler . Zelus . s_reset <- v in List . iter mark state_handlers Total . Automaton . check_all_states_are_accessible loc state_handlers ; let t = Total . Automaton . table state_handlers in let addname acc { s_state = statepat } = match statepat . desc with | Estate0pat ( s ) -> Env . add s { s_reset = None ; s_parameters = [ ] } acc | Estate1pat ( s , l ) -> Env . add s { s_reset = None ; s_parameters = ( List . map ( fun _ -> new_var ( ) ) l ) } acc in let def_states = List . fold_left addname Env . empty state_handlers in let { s_state = statepat } = List . hd state_handlers in begin match se_opt with | None -> begin match statepat . desc with | Estate1pat _ -> error statepat . loc Estate_initial | Estate0pat _ -> ( ) end | Some ( se ) -> typing_state h def_states true se end ; let is_zero_type = Ztypes . is_continuous_kind expected_k in let typing_handler h ( { s_state = statepat ; s_body = b ; s_trans = trans } as s ) = let escape source_state h expected_k ( { e_cond = scpat ; e_reset = r ; e_block = b_opt ; e_next_state = state } as esc ) = let h0 = env_of_scondpat expected_k scpat in let h = Env . append h0 h in scondpat expected_k is_zero_type h scpat ; esc . e_zero <- is_zero_type ; esc . e_env <- h0 ; let h , defined_names = match b_opt with | None -> h , Deftypes . empty | Some ( b ) -> block_eq_list ( Tdiscrete ( true ) ) h b in typing_state h def_states r state ; let statename = if is_weak then source_state else Total . Automaton . statename state in Total . Automaton . add_transition is_weak h statename defined_names t in let h0 = env_of_statepat expected_k statepat in s . s_env <- h0 ; begin match statepat . desc with | Estate0pat _ -> ( ) | Estate1pat ( s , n_list ) -> let { s_parameters = ty_list } = Env . find s def_states in List . iter2 ( fun n ty -> unify statepat . loc ( typ_of_var statepat . loc h0 n ) ty ) n_list ty_list ; end ; let h = Env . append h0 h in let new_h , defined_names = block_eq_list expected_k h b in let source_state = Total . Automaton . statepatname statepat in Total . Automaton . add_state source_state defined_names t ; List . iter ( escape source_state new_h expected_k ) trans ; defined_names in let first_handler = List . hd state_handlers in let remaining_handlers = List . tl state_handlers in let defined_names = typing_handler h first_handler in let first_h , new_h = if is_weak then turn_vars_into_memories h defined_names else Env . empty , h in let defined_names_list = List . map ( typing_handler new_h ) remaining_handlers in let defined_names = Total . Automaton . check loc new_h t in List . iter2 ( fun { s_body = { b_write = _ } as b } defined_names -> b . b_write <- defined_names ) state_handlers ( defined_names :: defined_names_list ) ; incorporate_into_env first_h h ; mark_reset_state def_states state_handlers ; defined_names |
let no_unbounded_name loc free_in_ty ty = if not ( S . is_empty free_in_ty ) then let n = S . choose free_in_ty in error loc ( Esize_parameter_cannot_be_generalized ( n , ty ) ) else ty |
let funtype loc expected_k pat_list ty_list ty_res = let rec arg pat_list ty_list fv_in_ty_res = match pat_list , ty_list with | [ ] , [ ] -> [ ] , fv_in_ty_res | pat :: pat_list , ty_arg :: ty_list -> let ty_res_list , fv_in_ty_res = arg pat_list ty_list fv_in_ty_res in let fv_pat = Vars . fv_pat S . empty S . empty pat in let opt_name , fv_in_ty_res = let fv_inter = S . inter fv_pat fv_in_ty_res in if S . is_empty fv_inter then None , fv_in_ty_res else match pat . p_desc with | Evarpat ( n ) -> Some ( n ) , S . remove n fv_in_ty_res | _ -> error pat . p_loc Esize_parameter_must_be_a_name in ( opt_name , ty_arg ) :: ty_res_list , fv fv_in_ty_res ty_arg | _ -> assert false in let ty_arg_list , fv_in_ty_res = arg pat_list ty_list ( fv S . empty ty_res ) in let ty_res = funtype_list expected_k ty_arg_list ty_res in no_unbounded_name loc fv_in_ty_res ty_res |
let constdecl f is_static e = let expected_k = if is_static then Tstatic ( true ) else Tdiscrete ( false ) in Zmisc . push_binding_level ( ) ; let ty = expression expected_k Env . empty e in Zmisc . pop_binding_level ( ) ; let tys = Ztypes . gen ( not ( expansive e ) ) ty in tys |
let fundecl loc f ( { f_kind = k ; f_atomic = is_atomic ; f_args = pat_list ; f_body = e } as body ) = Zmisc . push_binding_level ( ) ; let expected_k = Interface . kindtype k in let h0 = env_of_pattern_list expected_k Env . empty pat_list in body . f_env <- h0 ; let ty_p_list = List . map ( fun _ -> new_var ( ) ) pat_list in pattern_list h0 pat_list ty_p_list ; check_total_pattern_list pat_list ; let ty_res = expression expected_k h0 e in Zmisc . pop_binding_level ( ) ; let ty_res = funtype loc expected_k pat_list ty_p_list ty_res in let tys = Ztypes . gen true ty_res in tys |
let implementation ff is_first impl = try match impl . desc with | Econstdecl ( f , is_static , e ) -> let tys = constdecl f is_static e in if is_first then Interface . add_type_of_value ff impl . loc f is_static tys else Interface . update_type_of_value ff impl . loc f is_static tys | Efundecl ( f , body ) -> let tys = fundecl impl . loc f body in if is_first then Interface . add_type_of_value ff impl . loc f true tys else Interface . update_type_of_value ff impl . loc f true tys | Eopen ( modname ) -> if is_first then Modules . open_module modname | Etypedecl ( f , params , ty ) -> if is_first then Interface . typedecl ff impl . loc f params ty with | Typerrors . Error ( loc , err ) -> if is_first then Typerrors . message loc err else begin Format . eprintf " [ @ Internal error : type error during the second step \ n \ after static reduction and inlining \ n \ Be carreful , the localisation of errors is misleading . . ] " ; @@@ Typerrors . message loc err end |
let implementation_list ff is_first impl_list = Zmisc . no_warning := not is_first ; List . iter ( implementation ff is_first ) impl_list ; Zmisc . no_warning := not is_first ; impl_list |
let badwords = [ " abandonned " ; " abandonning " ; " abbrevation " ; " abbrevations " ; " abigious " ; " abilties " ; " abilty " ; " abitrate " ; " abolute " ; " abov " ; " absense " ; " absolut " ; " absoulte " ; " acccept " ; " acccepted " ; " acccepting " ; " acccepts " ; " acccess " ; " acceleratoin " ; " accelleration " ; " accesing " ; " accesnt " ; " accessable " ; " accesss " ; " accidentaly " ; " accidently " ; " accidentually " ; " accoding " ; " accodingly " ; " accomodate " ; " accomodates " ; " accompagnied " ; " accompagnies " ; " accompagny " ; " accompagnying " ; " accordint " ; " accoring " ; " accout " ; " accquire " ; " accquired " ; " accquires " ; " accquiring " ; " accross " ; " acessable " ; " acess " ; " achitecture " ; " achitectures " ; " achor " ; " achored " ; " achoring " ; " achors " ; " acient " ; " acknowldegement " ; " ackowledge " ; " ackowledged " ; " acording " ; " acordingly " ; " acqure " ; " acqured " ; " acqures " ; " acquring " ; " actaul " ; " actaully " ; " activete " ; " acually " ; " acumulating " ; " acutally " ; " adapated " ; " adapater " ; " adapaters " ; " addd " ; " addded " ; " addding " ; " addds " ; " addess " ; " addessed " ; " addesses " ; " addessing " ; " addional " ; " additionaly " ; " additonal " ; " additonally " ; " addres " ; " addresed " ; " addreses " ; " addresing " ; " addresss " ; " addresssed " ; " addressses " ; " addresssing " ; " aditional " ; " aditionally " ; " aditionaly " ; " adress " ; " adressed " ; " adresses " ; " adressing " ; " advertisment " ; " advertisments " ; " adviced " ; " afecting " ; " afer " ; " aforementionned " ; " aformentioned " ; " afterall " ; " agains " ; " agaist " ; " agressive " ; " agressively " ; " agrument " ; " agruments " ; " albumns " ; " alegorical " ; " algorith " ; " algorithmical " ; " algoritm " ; " algoritms " ; " algorrithm " ; " algorritm " ; " alignemnt " ; " alignemnts " ; " allign " ; " alligned " ; " alligning " ; " alligns " ; " allpication " ; " allthough " ; " alltogether " ; " allways " ; " alocate " ; " alocated " ; " alocates " ; " alocating " ; " alogirhtms " ; " alogrithm " ; " alogrithms " ; " alot " ; " alow " ; " alows " ; " alpabet " ; " alpabetical " ; " alpabetic " ; " alpabets " ; " alreay " ; " altough " ; " ambigious " ; " ambigous " ; " ammend " ; " ammended " ; " ammending " ; " ammends " ; " ammount " ; " amoung " ; " amout " ; " analagous " ; " analysator " ; " ang " ; " anniversery " ; " annoucement " ; " anomolies " ; " anomoly " ; " anway " ; " anyting " ; " aplication " ; " appearence " ; " appeneded " ; " appliction " ; " applictions " ; " appplication " ; " appplications " ; " appropiate " ; " appropriatly " ; " approproate " ; " appropropriate " ; " approriate " ; " approriately " ; " approximatly " ; " aproximation " ; " aproximations " ; " aqcuire " ; " aqcuired " ; " aqcuires " ; " aqcuiring " ; " aquaint " ; " aquainted " ; " aquainting " ; " aquaints " ; " aquire " ; " aquired " ; " aquisition " ; " arbitary " ; " arbitray " ; " archiecture " ; " archiectures " ; " architechture " ; " architechtures " ; " archvie " ; " archvies " ; " aready " ; " arent " ; " arguement " ; " arguements " ; " arithmatic " ; " aritmetic " ; " arne ' t " ; " aroung " ; " arraival " ; " arround " ; " artifical " ; " artifically " ; " artillary " ; " arugment " ; " arugments " ; " assertation " ; " assgin " ; " assgined " ; " assgining " ; " assginment " ; " assginments " ; " assgins " ; " assigment " ; " assigments " ; " assignement " ; " assignements " ; " assignemnt " ; " assignemnts " ; " assistent " ; " assocate " ; " assocated " ; " assocates " ; " assocating " ; " assocation " ; " associcate " ; " associcated " ; " associcates " ; " associcating " ; " assotiated " ; " asthetic " ; " asuming " ; " asycronous " ; " asynchonous " ; " asynchonously " ; " atomatically " ; " atomicly " ; " attachement " ; " attemps " ; " attemt " ; " attemted " ; " attemting " ; " attemtp " ; " attemtped " ; " attemtping " ; " attemtps " ; " attemts " ; " attibute " ; " attibutes " ; " attirbute " ; " attirbutes " ; " attruibutes " ; " atttribute " ; " atttributes " ; " autenticate " ; " autenticated " ; " autenticates " ; " autenticating " ; " autentication " ; " authenticaiton " ; " authentification " ; " authorative " ; " authoritive " ; " automaticall " ; " automaticaly " ; " automaticly " ; " automatize " ; " automatized " ; " automatizes " ; " autonymous " ; " auxilary " ; " auxillary " ; " auxilliary " ; " avaiable " ; " availabe " ; " availabled " ; " availablity " ; " availale " ; " availavility " ; " availble " ; " availiable " ; " avalable " ; " avaliable " ; " aviable " ; " avilable " ; " backgroud " ; " backslashs " ; " bahavior " ; " bakup " ; " bakups " ; " baloon " ; " baloons " ; " bandwith " ; " basicly " ; " batery " ; " beacause " ; " beacuse " ; " beause " ; " becasue " ; " becomming " ; " becuase " ; " beeing " ; " befor " ; " begining " ; " behavoir " ; " behavoirs " ; " bellow " ; " benifit " ; " betweeen " ; " betwen " ; " bianries " ; " bizzare " ; " blindy " ; " boundry " ; " brige " ; " briges " ; " brighness " ; " brokeness " ; " brower " ; " browers " ; " bufffer " ; " bufffers " ; " bulding " ; " bulid " ; " buliding " ; " bulids " ; " bulit " ; " bulletted " ; " calcualte " ; " calcualted " ; " calcualtes " ; " calcualting " ; " calender " ; " calulate " ; " calulated " ; " calulates " ; " calulating " ; " cancelation " ; " capabilies " ; " capabilites " ; " capatibilities " ; " captial " ; " carefuly " ; " cariage " ; " casue " ; " casued " ; " casues " ; " catagories " ; " catagory " ; " catched " ; " ceate " ; " ceated " ; " ceates " ; " ceating " ; " cehck " ; " cehcked " ; " cehcking " ; " cehcks " ; " certficate " ; " certficates " ; " certian " ; " certicate " ; " certicates " ; " certifcate " ; " certifcates " ; " challange " ; " challanges " ; " changable " ; " channle " ; " channles " ; " channnel " ; " channnels " ; " charachter " ; " charachters " ; " characted " ; " characteds " ; " charactor " ; " charactors " ; " charater " ; " charaters " ; " charcter " ; " chcek " ; " chceked " ; " chceking " ; " chceks " ; " checksuming " ; " childern " ; " childs " ; " chnage " ; " chnages " ; " choise " ; " choosen " ; " chracter " ; " chracters " ; " classs " ; " classses " ; " clearified " ; " clearifies " ; " clearify " ; " clearifying " ; " cleint " ; " cleints " ; " coefficent " ; " coefficents " ; " cofigure " ; " cofigured " ; " cofigures " ; " cofiguring " ; " collapsable " ; " collegue " ; " collegues " ; " colorfull " ; " comand " ; " coment " ; " comented " ; " comenting " ; " coments " ; " comit " ; " commad " ; " commads " ; " commerical " ; " comming " ; " comminucation " ; " commited " ; " commiter " ; " commiters " ; " commiting " ; " committ " ; " commmand " ; " commmands " ; " commment " ; " commmented " ; " commmenting " ; " commments " ; " commoditiy " ; " communcation " ; " compability " ; " comparision " ; " comparisions " ; " comparsion " ; " comparsions " ; " compatability " ; " compatabilty " ; " compatable " ; " compatbility " ; " compatiability " ; " compatibiliy " ; " compatibilty " ; " compatiblity " ; " competion " ; " competions " ; " compilant " ; " compleatly " ; " completly " ; " completness " ; " complient " ; " complier " ; " compliers " ; " complile " ; " compliled " ; " compliles " ; " compliling " ; " compling " ; " compontent " ; " compontents " ; " compres " ; " compresed " ; " compreses " ; " compresing " ; " compresion " ; " comptible " ; " comression " ; " comunication " ; " conatin " ; " conatined " ; " conatining " ; " conatins " ; " conbination " ; " conbinations " ; " concatentate " ; " concatentated " ; " concatentates " ; " concatentating " ; " concatentation " ; " concatentations " ; " concatination " ; " concatinations " ; " concensus " ; " conditionaly " ; " conditionnaly " ; " conection " ; " conections " ; " conent " ; " conents " ; " configuation " ; " configuations " ; " configuratoin " ; " conjuction " ; " conneciton " ; " connecitons " ; " connectinos " ; " connnect " ; " connnected " ; " connnecting " ; " connnection " ; " connnections " ; " connnects " ; " consistancy " ; " consistant " ; " consonent " ; " consonents " ; " constuctor " ; " constuctors " ; " containes " ; " containg " ; " containts " ; " contaisn " ; " contan " ; " contaned " ; " contaning " ; " contans " ; " contein " ; " conteined " ; " conteining " ; " conteins " ; " contence " ; " continous " ; " continously " ; " continueing " ; " contraints " ; " contries " ; " controled " ; " controler " ; " controlers " ; " controll " ; " controlls " ; " contruct " ; " contructed " ; " contructing " ; " contructor " ; " contructors " ; " contructs " ; " contry " ; " converstion " ; " converstions " ; " convertion " ; " convertions " ; " convertor " ; " convet " ; " conveted " ; " conveting " ; " convets " ; " convinient " ; " copyrigth " ; " copyrigthed " ; " copyrigths " ; " corected " ; " corespond " ; " coresponded " ; " corespondence " ; " coresponding " ; " coresponds " ; " correctnes " ; " correponding " ; " correponds " ; " correspoding " ; " correspondance " ; " correspondes " ; " corresponing " ; " corresponsing " ; " corretly " ; " coutner " ; " coutners " ; " coverted " ; " crtical " ; " cryptocraphic " ; " cummulative " ; " curently " ; " cymk " ; " dafault " ; " deafault " ; " deafult " ; " deamon " ; " debain " ; " debians " ; " debuging " ; " decalared " ; " decalare " ; " decalares " ; " decalaring " ; " decendant " ; " decendent " ; " declation " ; " declations " ; " decompres " ; " decompresed " ; " decompreses " ; " decompresing " ; " decribed " ; " decribe " ; " decribes " ; " decribing " ; " decription " ; " decriptions " ; " decriptor " ; " decriptors " ; " decsriptor " ; " decsriptors " ; " defalt " ; " defautl " ; " defered " ; " definate " ; " definately " ; " definining " ; " definitly " ; " defintion " ; " defintions " ; " defualt " ; " deivce " ; " deivces " ; " delared " ; " delare " ; " delares " ; " delaring " ; " delemiter " ; " delimeter " ; " delimeters " ; " demoninator " ; " demoninators " ; " demostrated " ; " demostrate " ; " demostrates " ; " demostrating " ; " depdencies " ; " depdency " ; " depencies " ; " depency " ; " dependancies " ; " dependancy " ; " dependant " ; " dependecies " ; " dependecy " ; " depenencies " ; " depenency " ; " depreacted " ; " depreacte " ; " deprectated " ; " deprectate " ; " deprectates " ; " deprectating " ; " deprected " ; " derefenced " ; " desactivate " ; " descibed " ; " descibe " ; " descibes " ; " descibing " ; " desciptor " ; " desciptors " ; " descriptior " ; " descriptiors " ; " descripton " ; " descriptons " ; " descrition " ; " descritpion " ; " descritpions " ; " desctiptor " ; " desctiptors " ; " desireable " ; " desriptor " ; " desriptors " ; " detabase " ; " detatch " ; " detatched " ; " detatches " ; " detatching " ; " detemined " ; " detemine " ; " detemines " ; " detemining " ; " determing " ; " determinstically " ; " determinstic " ; " detroy " ; " detroyed " ; " detroying " ; " detroys " ; " develoment " ; " develoments " ; " developement " ; " developped " ; " developpement " ; " developper " ; " developpment " ; " deveolpment " ; " devided " ; " diabled " ; " diable " ; " diables " ; " diabling " ; " dictionnary " ; " didnt " ; " didnt ' " ; " diferent " ; " differents " ; " differnet " ; " diffrent " ; " difinition " ; " difinitions " ; " digitial " ; " diplay " ; " directores " ; " directorys " ; " directries " ; " directry " ; " directy " ; " disapear " ; " disapeared " ; " disapearing " ; " disapears " ; " discernable " ; " disconnet " ; " disconneted " ; " disconneting " ; " disconnets " ; " discontinous " ; " discusion " ; " dispath " ; " dispathed " ; " dispathes " ; " dispathing " ; " dispertion " ; " dissapear " ; " dissapeared " ; " dissapearing " ; " dissapears " ; " distibuted " ; " distibute " ; " distibutes " ; " distibuting " ; " distibution " ; " distibutions " ; " distiction " ; " distingush " ; " distingushed " ; " distingushes " ; " distingushing " ; " distribtion " ; " distribtions " ; " divison " ; " divisons " ; " docuentation " ; " documantation " ; " documenation " ; " documentaion " ; " documention " ; " documetation " ; " doens ' t " ; " doesen ' t " ; " doesnt " ; " doesnt ' " ; " doesnt ' t " ; " does ' t " ; " doman " ; " domans " ; " dont " ; " dont ' " ; " dont ' t " ; " donwload " ; " donwloaded " ; " donwloading " ; " donwloads " ; " dosen ' t " ; " downlad " ; " downlads " ; " droppped " ; " dumplicated " ; " dumplicate " ; " dumplicates " ; " dumplicating " ; " dupliate " ; " dupliates " ; " easilly " ; " ecspecially " ; " edditable " ; " editting " ; " effectly " ; " efficency " ; " efficent " ; " efficently " ; " egde " ; " egdes " ; " eletronic " ; " eligable " ; " elliminated " ; " elliminate " ; " elliminates " ; " elliminating " ; " elment " ; " elments " ; " elminated " ; " elminate " ; " elminates " ; " elminating " ; " embeddeding " ; " embeded " ; " emptry " ; " emtpy " ; " enchanced " ; " enconding " ; " encondings " ; " encorporating " ; " encosed " ; " encose " ; " encoses " ; " encosing " ; " encrytion " ; " endianes " ; " endianess " ; " endiannes " ; " enhaced " ; " enhancment " ; " enhancments " ; " enitities " ; " enitity " ; " enlightnment " ; " enocded " ; " enrties " ; " enrty " ; " enterily " ; " entites " ; " envionment " ; " envireonment " ; " enviroiment " ; " enviromental " ; " enviromentally " ; " enviroment " ; " enviroments " ; " environement " ; " environent " ; " eqivalent " ; " equiped " ; " equivelant " ; " equivilant " ; " equvalent " ; " eroneous " ; " eror " ; " erorr " ; " erorrs " ; " erors " ; " erroneus " ; " erroneusly " ; " erronous " ; " erronously " ; " errorneous " ; " errorneously " ; " errror " ; " errrors " ; " esential " ; " esentially " ; " estbalishment " ; " etsablishment " ; " etsbalishment " ; " evalutated " ; " evalutate " ; " evalutates " ; " evalutating " ; " evaluted " ; " evalute " ; " evalutes " ; " evaluting " ; " eventhough " ; " everbody " ; " everone " ; " everthing " ; " everwhere " ; " everyhing " ; " everythings " ; " evironment " ; " evironments " ; " excact " ; " excactly " ; " excecutable " ; " exceded " ; " excellant " ; " excercised " ; " excercise " ; " excercises " ; " excercising " ; " excpected " ; " excpect " ; " excpecting " ; " excpects " ; " excutable " ; " excutables " ; " excuted " ; " excute " ; " excutes " ; " excuting " ; " exeception " ; " execeptions " ; " exectuable " ; " exectuables " ; " executeable " ; " executeables " ; " exension " ; " exensions " ; " exept " ; " exeption " ; " exeptions " ; " exising " ; " exisiting " ; " existance " ; " existant " ; " exlcude " ; " exlcusive " ; " exlicit " ; " exlicitly " ; " exmaple " ; " expecially " ; " expectes " ; " explaination " ; " explainations " ; " explantion " ; " explantions " ; " explicitely " ; " explicitily " ; " explicity " ; " explict " ; " explictly " ; " explit " ; " explitly " ; " expresion " ; " expresions " ; " expresssion " ; " expresssions " ; " exprimental " ; " extensability " ; " extenstion " ; " extenstions " ; " extented " ; " extention " ; " extesion " ; " extesions " ; " extracter " ; " extraenous " ; " faciliated " ; " faciliate " ; " faciliates " ; " faciliating " ; " faild " ; " failue " ; " failuer " ; " failues " ; " falg " ; " falgs " ; " faliure " ; " faliures " ; " familar " ; " fatser " ; " feasable " ; " feauture " ; " feautures " ; " fetaure " ; " fetaures " ; " ficticious " ; " filesytem " ; " filesytems " ; " fileystem " ; " fileystems " ; " findout " ; " finsihed " ; " finsihes " ; " finsih " ; " finsihing " ; " fitler " ; " fitlers " ; " flie " ; " floting " ; " flusing " ; " foget " ; " fogot " ; " fogotten " ; " folloing " ; " follwing " ; " follwoing " ; " folowing " ; " forbiden " ; " foreing " ; " forground " ; " formated " ; " formating " ; " forseeable " ; " forse " ; " fortan " ; " forunate " ; " forunately " ; " forwaded " ; " forwad " ; " forwading " ; " forwads " ; " forwardig " ; " fowarded " ; " foward " ; " fowarding " ; " fowards " ; " framwork " ; " freqencies " ; " freqency " ; " frontent " ; " frontents " ; " fucntion " ; " fucntions " ; " fuction " ; " fuctions " ; " fullfill " ; " funcion " ; " funcions " ; " funciton " ; " funcitons " ; " functionallity " ; " functionaly " ; " functionnality " ; " functiosn " ; " functonality " ; " funtion " ; " funtions " ; " futher " ; " futhermore " ; " gauranteed " ; " gaurantee " ; " gauranteeing " ; " gaurantees " ; " generater " ; " generaters " ; " genereated " ; " genereate " ; " genereates " ; " genereating " ; " generiously " ; " genrated " ; " genrate " ; " genrates " ; " genrating " ; " genreated " ; " genreate " ; " genreates " ; " genreating " ; " genric " ; " geomtry " ; " geting " ; " glpyh " ; " glpyhs " ; " goverment " ; " grabing " ; " grahical " ; " grahpical " ; " gramatically " ; " grammer " ; " grammers " ; " grapic " ; " guage " ; " guarenteed " ; " guarentee " ; " guarenteeing " ; " guarentees " ; " guassian " ; " halfs " ; " hander " ; " handfull " ; " hanshake " ; " hanshakes " ; " hapening " ; " happend " ; " happenned " ; " harcoded " ; " harcode " ; " harcodes " ; " harcoding " ; " harware " ; " havent " ; " heigth " ; " heirarchical " ; " heirarchically " ; " heirarchies " ; " heirarchy " ; " helpfull " ; " hexidecimal " ; " hiearchies " ; " hiearchy " ; " hierachical " ; " hierachies " ; " hierachy " ; " hierarchie " ; " higer " ; " highlighing " ; " highlightning " ; " higlighted " ; " higlight " ; " higlighting " ; " higlights " ; " hilighted " ; " hilight " ; " hilighting " ; " hilights " ; " horzontal " ; " horzontally " ; " howerver " ; " howver " ; " hypenated " ; " hypenate " ; " hypenates " ; " hypenating " ; " hypenation " ; " hypen " ; " hypens " ; " identifer " ; " identifers " ; " idicated " ; " idicate " ; " idicates " ; " idicating " ; " igored " ; " igore " ; " igores " ; " igoring " ; " imediate " ; " imediately " ; " immeadiately " ; " immedate " ; " immedately " ; " immediatelly " ; " immediatly " ; " immidiate " ; " immmediate " ; " immmediately " ; " impementation " ; " impementations " ; " implemantation " ; " implemementation " ; " implemementations " ; " implememented " ; " implemement " ; " implemementing " ; " implemements " ; " implemenation " ; " implemenations " ; " implementaion " ; " implementaions " ; " implementated " ; " implemention " ; " implemetation " ; " implemeted " ; " implemet " ; " implemeting " ; " implemets " ; " implemntation " ; " implemntations " ; " implicitely " ; " implicity " ; " implmentation " ; " implmented " ; " implment " ; " implmenting " ; " implments " ; " improvment " ; " improvments " ; " inadvertant " ; " inadvertantly " ; " inclued " ; " inclue " ; " inclues " ; " incluing " ; " incomming " ; " incompatabilities " ; " incompatability " ; " incompatable " ; " incompatbility " ; " incompatiability " ; " incomptible " ; " inconsistant " ; " incoporated " ; " incoporate " ; " incoporates " ; " incoporating " ; " increas " ; " incuded " ; " incude " ; " incudes " ; " incuding " ; " incure " ; " indeces " ; " indempotent " ; " indendation " ; " indended " ; " indentical " ; " indentified " ; " indentifies " ; " indentify " ; " indentifying " ; " independant " ; " independed " ; " indepenent " ; " indepenently " ; " indiated " ; " indiate " ; " indiates " ; " indiating " ; " indiciated " ; " indiciate " ; " indiciates " ; " indiciating " ; " indipendent " ; " indipendently " ; " indivudual " ; " indivudually " ; " inefficency " ; " inferrence " ; " infomation " ; " informatiom " ; " informations " ; " infromation " ; " ingored " ; " ingore " ; " ingores " ; " ingoring " ; " inheritence " ; " inital " ; " initalisation " ; " initalised " ; " initalise " ; " initalises " ; " initalising " ; " initalization " ; " initalized " ; " initalize " ; " initalizes " ; " initalizing " ; " initators " ; " initializiation " ; " initialsed " ; " initialse " ; " initialses " ; " initialzed " ; " initialze " ; " initialzes " ; " initiliased " ; " initiliase " ; " initiliases " ; " initiliasing " ; " initiliazed " ; " initiliaze " ; " initiliazes " ; " initiliazing " ; " initilized " ; " initilize " ; " initilizes " ; " initilizing " ; " inlcuded " ; " inlcude " ; " inlcudes " ; " inlcuding " ; " inofficial " ; " inproper " ; " inproperly " ; " insensistive " ; " insensistively " ; " instanciated " ; " instanciate " ; " instanciates " ; " instanciating " ; " instanciation " ; " instanciations " ; " intance " ; " intances " ; " intead " ; " inteface " ; " integreated " ; " integrety " ; " integrey " ; " intendet " ; " intentially " ; " intepreted " ; " intepreter " ; " intepreters " ; " intepreting " ; " intepret " ; " inteprets " ; " interace " ; " interaces " ; " interator " ; " interators " ; " interchangable " ; " interchangably " ; " interesected " ; " interesecting " ; " interesect " ; " interesection " ; " interesections " ; " interesects " ; " interferred " ; " interferring " ; " interger " ; " intergers " ; " intermittant " ; " internel " ; " internels " ; " interpeted " ; " interpeter " ; " interpeters " ; " interpeting " ; " interpet " ; " interpets " ; " interpretes " ; " interruped " ; " interupted " ; " interupting " ; " interupt " ; " interupts " ; " intial " ; " intialisation " ; " intialised " ; " intialise " ; " intialises " ; " intialising " ; " intialization " ; " intialized " ; " intialize " ; " intializes " ; " intializing " ; " intially " ; " intregral " ; " intrrupted " ; " intrrupting " ; " intrrupt " ; " intrrupts " ; " intruction " ; " intructions " ; " intrumented " ; " intrumenting " ; " intrument " ; " intruments " ; " intuative " ; " invaid " ; " invalud " ; " invarient " ; " invididual " ; " invokation " ; " invokations " ; " irrelevent " ; " isnt " ; " istead " ; " itialized " ; " itialize " ; " itializes " ; " itializing " ; " itslef " ; " jave " ; " keywork " ; " langage " ; " langauage " ; " langauge " ; " langauges " ; " langugage " ; " languge " ; " languges " ; " laoded " ; " laoding " ; " laod " ; " laods " ; " lauched " ; " laucher " ; " lauches " ; " lauching " ; " lauch " ; " leightweight " ; " lengh " ; " lenghs " ; " lenght " ; " lenghts " ; " lenghty " ; " lengthes " ; " lenth " ; " lesstiff " ; " libaries " ; " libary " ; " librairies " ; " libraris " ; " licenceing " ; " licese " ; " ligth " ; " likelyhood " ; " limted " ; " lintain " ; " loggging " ; " loggin " ; " logile " ; " longers " ; " loosly " ; " machinary " ; " maintainance " ; " maintainence " ; " maintaing " ; " maintance " ; " maintan " ; " makeing " ; " malplaced " ; " malplace " ; " mamory " ; " managable " ; " managment " ; " manoeuvering " ; " mantained " ; " mantainer " ; " mantaining " ; " mantain " ; " mantains " ; " manully " ; " matchin " ; " matcing " ; " mathimatical " ; " mathimatic " ; " mathimatics " ; " maxium " ; " mecanism " ; " mecanisms " ; " mechamism " ; " mechamisms " ; " mentiond " ; " mentionned " ; " ment " ; " mesage " ; " mesages " ; " messags " ; " messge " ; " messges " ; " messsage " ; " messsages " ; " microprocesspr " ; " milisecond " ; " miliseconds " ; " millenium " ; " milliseonds " ; " mimicing " ; " mimick " ; " mimicks " ; " mininum " ; " miniscule " ; " minumum " ; " miscelleneous " ; " misformed " ; " mismached " ; " mismaches " ; " mismaching " ; " mismach " ; " mispelled " ; " mispelt " ; " missconfiguration " ; " missconfigured " ; " missconfigure " ; " missconfigures " ; " missconfiguring " ; " missmatched " ; " missmatches " ; " missmatching " ; " missmatch " ; " mmnemonic " ; " modfied " ; " modfies " ; " modfying " ; " modfy " ; " modifed " ; " modifing " ; " modulues " ; " monochorome " ; " monochromo " ; " monocrome " ; " morever " ; " mroe " ; " mulitple " ; " mulitplied " ; " multidimensionnal " ; " multipled " ; " multple " ; " multplied " ; " multplies " ; " multplying " ; " multply " ; " mumber " ; " mumbers " ; " musn ' t " ; " mutiple " ; " mutliple " ; " nam " ; " nams " ; " navagating " ; " nead " ; " neccecary " ; " neccesarily " ; " neccesary " ; " neccessarily " ; " neccessary " ; " necesarily " ; " necesarrily " ; " necesarry " ; " necesary " ; " necessar " ; " nedded " ; " neeeded " ; " neeeding " ; " neeed " ; " neeeds " ; " negotation " ; " nescessary " ; " nesesarily " ; " nessesary " ; " nessessary " ; " nonexistant " ; " nontheless " ; " noone " ; " normaly " ; " noticable " ; " noticably " ; " notications " ; " notifcation " ; " notifcations " ; " notifed " ; " nubmer " ; " nubmers " ; " numberal " ; " numberals " ; " numebr " ; " numebrs " ; " numner " ; " numners " ; " observered " ; " obsure " ; " o ' caml " ; " occassionally " ; " occationally " ; " occurance " ; " occurances " ; " occured " ; " occurence " ; " occurences " ; " occuring " ; " occurrance " ; " occurrances " ; " ocurrence " ; " ocurrences " ; " offical " ; " officialy " ; " ofthe " ; " omitt " ; " ommiting " ; " ommitted " ; " onself " ; " opague " ; " openened " ; " openned " ; " openning " ; " opertaion " ; " opertaions " ; " opion " ; " opions " ; " optinally " ; " optinal " ; " optionaly " ; " optionnal " ; " optmization " ; " optmizations " ; " orderd " ; " orginally " ; " orginal " ; " orgin " ; " orientatied " ; " orientied " ; " origionally " ; " origional " ; " orignal " ; " otehr " ; " otherwhise " ; " othwerwise " ; " ouptut " ; " ouput " ; " ouputs " ; " ouputted " ; " ouputting " ; " outputing " ; " outut " ; " overaall " ; " overidden " ; " overide " ; " overides " ; " overiding " ; " overlaped " ; " overlaping " ; " overridded " ; " overrided " ; " overriden " ; " overrridden " ; " overrriden " ; " overrride " ; " overrriding " ; " overun " ; " overwite " ; " overwites " ; " overwitten " ; " ovverridden " ; " ovverride " ; " ovverrides " ; " ovverriding " ; " owership " ; " pacakge " ; " pachage " ; " pach " ; " packacge " ; " packege " ; " packge " ; " packges " ; " pakage " ; " palete " ; " pallete " ; " pallette " ; " paniced " ; " panicing " ; " paralellism " ; " paralell " ; " paralel " ; " parallell " ; " parallization " ; " parallized " ; " parallize " ; " parallizes " ; " parallizing " ; " paramameters " ; " paramater " ; " parametes " ; " parametised " ; " paramter " ; " paramters " ; " parantheses " ; " paranthesis " ; " paremeter " ; " paremeters " ; " parenthesed " ; " particularily " ; " partioning " ; " pased " ; " pathes " ; " pecularities " ; " pecularity " ; " peformance " ; " peice " ; " peices " ; " penalities " ; " penality " ; " pendantic " ; " peprocessor " ; " perfomed " ; " perfoming " ; " perfom " ; " perfoms " ; " perfromance " ; " perfromed " ; " perfroming " ; " perfrom " ; " perfroms " ; " peristent " ; " permanantly " ; " permanant " ; " permision " ; " permisions " ; " permissons " ; " permuation " ; " permuations " ; " peroid " ; " peroids " ; " persistance " ; " persistant " ; " personnal " ; " perviously " ; " pervious " ; " pitty " ; " plase " ; " platfrom " ; " platfroms " ; " plattform " ; " pleaes " ; " ploting " ; " poinnter " ; " poiter " ; " poiters " ; " poluted " ; " polute " ; " polutes " ; " poluting " ; " polution " ; " portugese " ; " posible " ; " positionned " ; " positon " ; " positons " ; " positve " ; " positves " ; " possesion " ; " possibe " ; " possibilites " ; " possibilties " ; " possibilty " ; " possiblities " ; " possiblity " ; " postgressql " ; " postion " ; " postions " ; " postive " ; " postives " ; " powerfull " ; " prcesses " ; " prcess " ; " preceeded " ; " preceeding " ; " preceed " ; " preceeds " ; " precendence " ; " precison " ; " precission " ; " prefered " ; " preferrable " ; " preferrably " ; " prefferable " ; " prefferably " ; " prepaired " ; " prepartion " ; " prepartions " ; " prerequsite " ; " prerequsites " ; " prevously " ; " priciple " ; " priciples " ; " primative " ; " princliple " ; " priorty " ; " priveleged " ; " privilaged " ; " privilage " ; " privilages " ; " priviledge " ; " priviledges " ; " privilige " ; " priviliges " ; " probaly " ; " problably " ; " procceed " ; " proccesors " ; " proccesses " ; " proccess " ; " proceded " ; " procede " ; " procedes " ; " proceding " ; " proceeeded " ; " proceeeding " ; " proceeed " ; " proceeeds " ; " procesed " ; " proceses " ; " proces " ; " processessing " ; " processess " ; " processpr " ; " processsed " ; " processses " ; " processsing " ; " processs " ; " proctected " ; " proctecting " ; " proctect " ; " proctects " ; " procude " ; " progams " ; " progess " ; " programers " ; " programm " ; " programms " ; " promiscous " ; " promps " ; " pronnounced " ; " prononciation " ; " pronouce " ; " pronunce " ; " propery " ; " propigate " ; " propigation " ; " propogated " ; " propogate " ; " propogates " ; " propogating " ; " prosess " ; " protable " ; " protcol " ; " protecion " ; " protocoll " ; " psuedo " ; " psychadelic " ; " qouted " ; " qoute " ; " qoutes " ; " qouting " ; " queing " ; " quering " ; " reachs " ; " readabilty " ; " reasearcher " ; " reasearchers " ; " reasearch " ; " reasonble " ; " reasonbly " ; " rebuliding " ; " rebulid " ; " rebulids " ; " rebulit " ; " reccommended " ; " reccommending " ; " reccommend " ; " reccommends " ; " receieved " ; " receieve " ; " receieves " ; " receieving " ; " recepient " ; " recepients " ; " receved " ; " receve " ; " receves " ; " receving " ; " recieved " ; " recieve " ; " reciever " ; " recieves " ; " recieving " ; " recipies " ; " recogized " ; " recogize " ; " recogizes " ; " recogizing " ; " recogniced " ; " recognizeable " ; " recommanded " ; " rectange " ; " rectanges " ; " recurrance " ; " recyled " ; " recyle " ; " recyles " ; " recyling " ; " redefintion " ; " redefintions " ; " redircet " ; " redirectrion " ; " reenabled " ; " reenable " ; " reencode " ; " refected " ; " refecting " ; " refect " ; " refects " ; " refence " ; " refered " ; " refernced " ; " refernce " ; " refernces " ; " referncing " ; " refrenced " ; " refrence " ; " refrences " ; " refrencing " ; " regaring " ; " registed " ; " registeing " ; " registerd " ; " registe " ; " registes " ; " registraration " ; " regulamentations " ; " regularily " ; " reimplmentation " ; " reimplmented " ; " reimplmenting " ; " reimplment " ; " reimplments " ; " releasse " ; " releated " ; " reletively " ; " reletive " ; " relevent " ; " remaing " ; " remoote " ; " removeable " ; " renderering " ; " renegotation " ; " repaced " ; " repace " ; " repaces " ; " repacing " ; " repeatly " ; " repectively " ; " repective " ; " replacable " ; " replacments " ; " replys " ; " reponse " ; " reponses " ; " representaion " ; " representaions " ; " represneted " ; " represneting " ; " represnet " ; " represnets " ; " reproducable " ; " requiered " ; " requiere " ; " requieres " ; " requiering " ; " requred " ; " requrested " ; " requresting " ; " requrest " ; " requrests " ; " requried " ; " requsted " ; " requsting " ; " requst " ; " requsts " ; " resemblence " ; " reserverd " ; " reseted " ; " reseting " ; " resetted " ; " resizeable " ; " resouce " ; " resouces " ; " resoure " ; " resoures " ; " responce " ; " responces " ; " responsabilities " ; " responsability " ; " responsed " ; " responsiblity " ; " responsing " ; " ressize " ; " ressource " ; " ressources " ; " ressurected " ; " ressurecting " ; " ressurect " ; " ressurects " ; " resursively " ; " resursive " ; " retored " ; " retore " ; " retores " ; " retoring " ; " retransmited " ; " retreived " ; " retreive " ; " retrived " ; " retrive " ; " retrives " ; " retriving " ; " retuns " ; " retured " ; " returing " ; " returnd " ; " returnes " ; " retur " ; " returs " ; " reuest " ; " reuests " ; " reuqested " ; " reuqesting " ; " reuqest " ; " reuqests " ; " rewriten " ; " rigth " ; " rigths " ; " rmeoved " ; " rmeove " ; " rmeoves " ; " rougly " ; " rountine " ; " rountines " ; " rquested " ; " rquesting " ; " rquest " ; " rquests " ; " runing " ; " runned " ; " runnning " ; " sacrifying " ; " safly " ; " saftey " ; " safty " ; " santized " ; " santize " ; " santizes " ; " santizing " ; " satisfiabilty " ; " satisified " ; " satisifies " ; " satisifying " ; " satisify " ; " savable " ; " savely " ; " savety " ; " scaned " ; " scaning " ; " seached " ; " seaches " ; " seaching " ; " seach " ; " searchs " ; " secund " ; " securty " ; " sematically " ; " sematical " ; " sematic " ; " sematics " ; " sempahore " ; " sempahores " ; " sensistive " ; " sensistively " ; " sentance " ; " sentances " ; " sentinal " ; " sentinals " ; " separatly " ; " separed " ; " separted " ; " separte " ; " separtes " ; " separting " ; " sepcified " ; " sepcifies " ; " sepcifying " ; " sepcify " ; " seperated " ; " seperately " ; " seperate " ; " seperates " ; " seperating " ; " seperatly " ; " seperator " ; " sepperate " ; " seprator " ; " seprators " ; " sequece " ; " sequeces " ; " sequencial " ; " serie " ; " serivce " ; " serivces " ; " serveral " ; " sesssion " ; " sesssions " ; " setts " ; " settting " ; " setttings " ; " shoud " ; " shouldnt " ; " shoule " ; " siginificantly " ; " siginificant " ; " signficantly " ; " signficant " ; " signle " ; " similarily " ; " similary " ; " similiarly " ; " similiar " ; " simlarlity " ; " simlarly " ; " simlar " ; " simliar " ; " simmilar " ; " simplier " ; " simultanously " ; " simultanous " ; " singal " ; " singed " ; " sitation " ; " sitations " ; " skiped " ; " skiping " ; " slashs " ; " sligthly " ; " sligth " ; " smae " ; " softwares " ; " sofware " ; " somehwere " ; " somes " ; " someting " ; " somthing " ; " souce " ; " souces " ; " spawed " ; " spawing " ; " spaw " ; " spaws " ; " speach " ; " spearator " ; " spearators " ; " specfication " ; " specfications " ; " specfic " ; " specfied " ; " specfies " ; " specfying " ; " specfy " ; " speciefied " ; " specifc " ; " specifed " ; " specificatin " ; " specificaton " ; " specifing " ; " specifiying " ; " specifiy " ; " speficied " ; " spefic " ; " speling " ; " splitted " ; " spported " ; " spporting " ; " spports " ; " spport " ; " spreaded " ; " spurios " ; " sructures " ; " sructure " ; " staically " ; " standardss " ; " standart " ; " staticly " ; " statments " ; " statment " ; " stirngs " ; " stirng " ; " stoped " ; " stoping " ; " stoppped " ; " straigth " ; " straigt " ; " strenghts " ; " strenght " ; " strenth " ; " stucts " ; " stuct " ; " stuctures " ; " stucture " ; " sturctures " ; " sturcture " ; " subdirectoires " ; " subexpresssions " ; " subexpresssion " ; " suble " ; " subseqent " ; " subsequest " ; " substituions " ; " substituion " ; " substracted " ; " substracting " ; " substraction " ; " substracts " ; " substract " ; " subtituted " ; " subtitutes " ; " subtitute " ; " subtituting " ; " subtitutions " ; " subtitution " ; " succeded " ; " succedes " ; " succede " ; " succeding " ; " succeedes " ; " succesfully " ; " succesful " ; " succesive " ; " successfull " ; " successfuly " ; " succint " ; " suceeded " ; " suceeding " ; " suceeds " ; " suceed " ; " sucesses " ; " sucessfully " ; " sucess " ; " sufficently " ; " sufficent " ; " superflous " ; " superseeded " ; " suplied " ; " suported " ; " suporting " ; " suports " ; " suport " ; " suppied " ; " suppies " ; " suppored " ; " supportin " ; " suppoted " ; " suppported " ; " suppporting " ; " suppports " ; " suppport " ; " suppying " ; " suppy " ; " supressed " ; " supresses " ; " supressing " ; " supress " ; " surpressed " ; " surpresses " ; " surpressing " ; " surpress " ; " suspicously " ; " suspicous " ; " sustitutions " ; " sustitution " ; " suuported " ; " suuporting " ; " suuports " ; " suuport " ; " swaping " ; " symetric " ; " synax " ; " synchonized " ; " synchonizes " ; " syncronize " ; " syncronizing " ; " syncronus " ; " synopsys " ; " syste " ; " sytems " ; " sytem " ; " sythesis " ; " taht " ; " targetted " ; " targetting " ; " teached " ; " teh " ; " temorary " ; " terminaters " ; " terminater " ; " thats " ; " theer " ; " theres " ; " therfore " ; " thier " ; " thie " ; " threasholds " ; " threashold " ; " threhold " ; " threshholds " ; " threshhold " ; " throught " ; " thses " ; " thsi " ; " tiggered " ; " tiggering " ; " tiggers " ; " tigger " ; " tigthened " ; " tigthening " ; " tigthens " ; " tigthen " ; " tigth " ; " tihs " ; " timetamps " ; " timetamp " ; " timout " ; " togther " ; " touple " ; " traditionnal " ; " trailling " ; " tranfered " ; " tranfering " ; " tranfers " ; " tranfer " ; " tranformations " ; " tranformation " ; " tranformed " ; " tranforming " ; " tranforms " ; " tranform " ; " tranlations " ; " tranlation " ; " tranparently " ; " tranparent " ; " transfered " ; " transfering " ; " transistions " ; " transistion " ; " transitionned " ; " transmition " ; " transormed " ; " transorming " ; " transorms " ; " transorm " ; " transtions " ; " transtion " ; " transtitions " ; " transtition " ; " trasmission " ; " treshold " ; " trigerring " ; " truely " ; " tupples " ; " tupple " ; " typicaly " ; " typles " ; " typle " ; " uesd " ; " uknown " ; " uncomented " ; " uncomenting " ; " uncoments " ; " uncoment " ; " uncommmented " ; " uncommmenting " ; " uncommments " ; " uncommment " ; " uncomplete " ; " unconditionaly " ; " uncoverted " ; " underuns " ; " underun " ; " undesireable " ; " unecessary " ; " uneeded " ; " unexcpected " ; " unexecpted " ; " unexected " ; " unexepcted " ; " unfortunatelly " ; " unfortunatly " ; " unforunately " ; " unforunate " ; " uninitalized " ; " unintentially " ; " uniqe " ; " unitialized " ; " univerities " ; " univerity " ; " unknonw " ; " unknow " ; " unkown " ; " unles " ; " unneccesarily " ; " unneccesary " ; " unneccessarily " ; " unneccessary " ; " unnecesarily " ; " unnecesary " ; " unnedded " ; " unneedingly " ; " unnesesarily " ; " unnessecary " ; " unnessesary " ; " unoffical " ; " unorderd " ; " unqouted " ; " unqoutes " ; " unqoute " ; " unqouting " ; " unrecogized " ; " unreconized " ; " unsinged " ; " unspported " ; " unsual " ; " unsued " ; " unsuported " ; " untill " ; " unusally " ; " unusal " ; " unuseful " ; " unusuable " ; " unversionned " ; " unversoned " ; " upated " ; " upates " ; " upate " ; " upating " ; " updateing " ; " upsream " ; " upsteam " ; " upstrema " ; " upto " ; " usally " ; " usal " ; " usefule " ; " usefull " ; " usege " ; " usera " ; " userful " ; " usetnet " ; " usuable " ; " usualy " ; " utilites " ; " utillities " ; " utilties " ; " utiltity " ; " utitlty " ; " utlity " ; " vaiables " ; " vaiable " ; " vaild " ; " validing " ; " varables " ; " varable " ; " variabes " ; " variabe " ; " variantions " ; " varibales " ; " varibale " ; " varient " ; " varity " ; " vauled " ; " vaules " ; " vaule " ; " vauling " ; " verbse " ; " verions " ; " verion " ; " verious " ; " verisons " ; " verison " ; " veritical " ; " verry " ; " versionned " ; " versionning " ; " versoned " ; " versons " ; " verson " ; " vicefersa " ; " visiters " ; " vitual " ; " wan ' t " ; " wasnt " ; " weigth " ; " weired " ; " werent " ; " wether " ; " whataver " ; " whenver " ; " wheras " ; " wheter " ; " whish " ; " whithout " ; " wich " ; " widht " ; " wierd " ; " wihout " ; " wiht " ; " wiil " ; " wilcards " ; " wilcard " ; " withing " ; " witin " ; " wnated " ; " wnating " ; " wnats " ; " wnat " ; " wont " ; " workaroung " ; " writeing " ; " writen " ; " writting " ; " xwindows " ; " yeilded " ; " yeilding " ; " yeilds " ; " yeild " ; " yur " ] |
let regexp = let make_regexp word = " \\ b " ^ Str . quote word ^ " \\ b " in Str . regexp @@ String . concat " " \\| @@ List . map make_regexp badwords |
let string_search re s start = try ignore ( Str . search_forward re s start ) ; true with Not_found -> false |
let find s = if string_search regexp s 0 then Some ( Str . matched_string s ) else None |
module Seq = struct include Seq let of_list l = let rec aux l ( ) = match l with | [ ] -> Seq . Nil | x :: tail -> Seq . Cons ( x , aux tail ) in aux l let to_rev_list gen = fold_left ( fun acc x -> x :: acc ) [ ] gen let to_list gen = List . rev ( to_rev_list gen ) end |
let map_3 f ( x , y , z ) = ( x , y , f z ) |
module T = struct type ( ' a , ' b ) conv = { to_ : ' a -> ' b ; from_ : ' b -> ' a ; } type ' a raw = | Regexp : Re . t * Re . re Lazy . t -> string raw | Conv : ' a raw * ( ' a , ' b ) conv -> ' b raw | Opt : ' a raw -> ( ' a option ) raw | Alt : ' a raw * ' b raw -> [ ` Left of ' a | ` Right of ' b ] raw | Seq : ' a raw * ' b raw -> ( ' a * ' b ) raw | Prefix : ' b raw * ' a raw -> ' a raw | Suffix : ' a raw * ' b raw -> ' a raw | Rep : ' a raw -> ' a Seq . t raw | Mod : ( Re . t -> Re . t ) * ' a raw -> ' a raw type _ wit = | Lit : int -> string wit | Conv : ' a wit * ( ' a , ' b ) conv -> ' b wit | Opt : Re . Mark . t * ' a wit -> ' a option wit | Alt : Re . Mark . t * ' a wit * ' b wit -> [ ` Left of ' a | ` Right of ' b ] wit | Seq : ' a wit * ' b wit -> ( ' a * ' b ) wit | Rep : int * ' a wit * Re . re -> ' a Seq . t wit end |
type ' a t = ' a T . raw |
let regex x : _ t = let re = lazy Re . ( compile @@ whole_string @@ no_group x ) in Regexp ( x , re ) |
let pcre s = regex @@ Re . Pcre . re s |
let conv to_ from_ x : _ t = Conv ( x , { to_ ; from_ } ) |
let seq a b : _ t = Seq ( a , b ) |
let alt a b : _ t = Alt ( a , b ) |
let prefix x a : _ t = Prefix ( x , a ) |
let suffix a x : _ t = Suffix ( a , x ) |
let opt a : _ t = Opt a |
module Infix = struct let ( ) <|> = alt let ( ) <&> = seq let ( ) *> = prefix let ( <* ) = suffix end |
let rep x : _ t = Rep x |
let rep1 x = x <&> rep x |
let modifier f re : _ t = Mod ( f , re ) |
let word re = modifier Re . word re |
let whole_string re = modifier Re . whole_string re |
let longest re = modifier Re . longest re |
let shortest re = modifier Re . shortest re |
let first re = modifier Re . first re |
let greedy re = modifier Re . greedy re |
let non_greedy re = modifier Re . non_greedy re |
let nest re = modifier Re . nest re |
module Regex = struct open ! Re let pos_int = rep1 digit let int = seq [ opt ( char ' ' ) - ; pos_int ] let float = seq [ opt ( char ' ' ) - ; rep1 digit ; opt ( seq [ char ' . ' ; rep digit ] ) ] let bool = alt [ str " true " ; str " false " ] end |
let unit s re = conv ( fun _ -> ( ) ) ( fun ( ) -> s ) ( regex re ) |
let start = unit " " Re . start |
let stop = unit " " Re . stop |
let str s = unit s ( Re . str s ) |
let char c = let s = String . make 1 c in unit s ( Re . char c ) |
let blanks = unit " " ( Re . rep Re . blank ) |
let pos_int = conv int_of_string string_of_int ( regex Regex . pos_int ) |
let int = conv int_of_string string_of_int ( regex Regex . int ) |
let float = conv float_of_string string_of_float ( regex Regex . float ) |
let bool = conv bool_of_string string_of_bool ( regex Regex . bool ) |
let list e = conv Seq . to_list Seq . of_list ( rep e ) |
let terminated_list ~ sep e = list ( e <* sep ) |
let separated_list ~ sep e = let e = opt ( e <&> list ( sep *> e ) ) in let to_ = function None -> [ ] | Some ( h , t ) -> ( h :: t ) and from_ = function [ ] -> None | h :: t -> Some ( h , t ) in conv to_ from_ e |
let rec witnesspp : type a . Format . formatter -> a t -> unit = fun ppf tre -> let open T in match tre with | Regexp ( re , _ ) -> Format . pp_print_string ppf @@ Re . witness re | Conv ( tre , _ ) -> witnesspp ppf tre | Opt _ -> ( ) | Alt ( tre1 , _ ) -> witnesspp ppf tre1 | Seq ( tre1 , tre2 ) -> witnesspp ppf tre1 ; witnesspp ppf tre2 | Prefix ( tre1 , tre2 ) -> witnesspp ppf tre1 ; witnesspp ppf tre2 | Suffix ( tre1 , tre2 ) -> witnesspp ppf tre1 ; witnesspp ppf tre2 | Rep _ -> ( ) | Mod ( _ , tre ) -> witnesspp ppf tre |
let rec pprep f ppf seq = match seq ( ) with | Seq . Nil -> ( ) | Cons ( x , seq ) -> f ppf x ; pprep f ppf seq |
let rec evalpp : type a . a t -> Format . formatter -> a -> unit = fun tre ppf -> let open T in match tre with | Regexp ( _ , lazy cre ) -> begin function v -> if not @@ Re . execp cre v then invalid_arg @@ Printf . sprintf " Tyre . eval : regexp not respected by " \% s " . " \ v ; pstr ppf v end | Conv ( tre , conv ) -> fun v -> evalpp tre ppf ( conv . from_ v ) | Opt p -> begin function | None -> pstr ppf " " | Some x -> evalpp p ppf x end | Seq ( tre1 , tre2 ) -> fun ( x1 , x2 ) -> evalpp tre1 ppf x1 ; evalpp tre2 ppf x2 ; | Prefix ( tre_l , tre ) -> fun v -> witnesspp ppf tre_l ; evalpp tre ppf v | Suffix ( tre , tre_g ) -> fun v -> evalpp tre ppf v ; witnesspp ppf tre_g | Alt ( treL , treR ) -> begin function | ` Left x -> evalpp treL ppf x | ` Right x -> evalpp treR ppf x end | Rep tre -> pprep ( evalpp tre ) ppf | Mod ( _ , tre ) -> evalpp tre ppf |
let eval tre = Format . asprintf " % a " ( evalpp tre ) |
let rec build : type a . int -> a t -> int * a T . wit * Re . t = let open ! Re in let open T in fun i -> function | Regexp ( re , _ ) -> ( i + 1 ) , Lit i , group @@ no_group re | Conv ( e , conv ) -> let i ' , w , re = build i e in i ' , Conv ( w , conv ) , re | Opt e -> let i ' , w , ( id , re ) = map_3 mark @@ build i e in i ' , Opt ( id , w ) , opt re | Alt ( e1 , e2 ) -> let i ' , w1 , ( id1 , re1 ) = map_3 mark @@ build i e1 in let i ' ' , w2 , re2 = build i ' e2 in i ' ' , Alt ( id1 , w1 , w2 ) , alt [ re1 ; re2 ] | Prefix ( e_ign , e ) -> let i ' , w , re = build i e in let _ , _ , re_ign = build 1 e_ign in i ' , w , seq [ no_group re_ign ; re ] | Suffix ( e , e_ign ) -> let i ' , w , re = build i e in let _ , _ , re_ign = build 1 e_ign in i ' , w , seq [ re ; no_group re_ign ] | Seq ( e1 , e2 ) -> let i ' , w1 , re1 = build i e1 in let i ' ' , w2 , re2 = build i ' e2 in i ' ' , Seq ( w1 , w2 ) , seq [ re1 ; re2 ] | Rep e -> let _ , w , re = build 1 e in ( i + 1 ) , Rep ( i , w , Re . compile re ) , group @@ rep @@ no_group re | Mod ( f , e ) -> let i ' , w , re = build i e in i ' , w , f re : type a . original : string -> a T . wit -> Re . Group . t -> a = fun ~ original rea s -> let open T in match rea with | Lit i -> Re . Group . get s i | Conv ( w , conv ) -> let v = extract ~ original w s in conv . to_ v | Opt ( id , w ) -> if not @@ Re . Mark . test s id then None else Some ( extract ~ original w s ) | Alt ( i1 , w1 , w2 ) -> if Re . Mark . test s i1 then ` Left ( extract ~ original w1 s ) else ` Right ( extract ~ original w2 s ) | Seq ( e1 , e2 ) -> let v1 = extract ~ original e1 s in let v2 = extract ~ original e2 s in ( v1 , v2 ) | Rep ( i , e , re ) -> extract_list ~ original e re i s : type a . original : string -> a T . wit -> Re . re -> int -> Re . Group . t -> a Seq . t = fun ~ original e re i s -> let aux = extract ~ original e in let ( pos , pos ' ) = Re . Group . offset s i in let len = pos ' - pos in Seq . map aux @@ Re . Seq . all ~ pos ~ len re original |
type ' + r route = Route : ' a t * ( ' a -> ' r ) -> ' r route |
let route re f = Route ( re , f ) |
type ' r wit_route = WRoute : Re . Mark . t * ' a T . wit * ( ' a -> ' r ) -> ' r wit_route |
let rec build_route_aux i rel wl = function | [ ] -> List . rev rel , List . rev wl | Route ( tre , f ) :: l -> let i ' , wit , re = build i tre in let id , re = Re . mark re in let w = WRoute ( id , wit , f ) in build_route_aux i ' ( re :: rel ) ( w :: wl ) l |
let build_route l = build_route_aux 1 [ ] [ ] l |
let rec extract_route ~ original wl subs = match wl with | [ ] -> assert false | WRoute ( id , wit , f ) :: wl -> if Re . Mark . test subs id then f ( extract ~ original wit subs ) else extract_route ~ original wl subs |
type ' r info = | One of ' r T . wit | Routes of ' r wit_route list |
type ' a re = { info : ' a info ; cre : Re . re } |
let compile tre = let _ , wit , re = build 1 tre in let cre = Re . compile re in { info = One wit ; cre } |
let route l = let rel , wl = build_route l in let cre = Re . compile @@ Re . alt rel in { info = Routes wl ; cre } |
type ' a error = [ | ` NoMatch of ' a re * string | ` ConverterFailure of exn ] |
let extract_with_info ~ info ~ original subs = match info with | One w -> extract ~ original w subs | Routes wl -> extract_route ~ original wl subs match Re . exec_opt ? pos ? len cre original with | None -> Result . Error ( ` NoMatch ( tcre , original ) ) | Some subs -> try Result . Ok ( extract_with_info ~ info ~ original subs ) with exn -> Result . Error ( ` ConverterFailure exn ) |
let execp ? pos ? len { cre ; _ } original = Re . execp ? pos ? len cre original |
let all_seq ? pos ? len { info ; cre } original = let seq = Re . Seq . all ? pos ? len cre original in let get_res subs = extract_with_info ~ info ~ original subs in Seq . map get_res seq |
let all ? pos ? len tcre original = try Result . Ok ( Seq . to_list @@ all_seq ? pos ? len tcre original ) with exn -> Result . Error ( ` ConverterFailure exn ) |
let sexp ppf s fmt = Format . fprintf ppf ( " [ @< 3 ( >% s @ " ^^ fmt " ) ] " ) ^^@ s |
let rec pp_list pp ppf = function | [ ] -> ( ) | [ v ] -> pp ppf v | v :: vs -> pp ppf v ; Format . pp_print_space ppf ( ) ; pp_list pp ppf vs |
let rec pp : type a . _ -> a t -> unit = fun ppf -> let open T in function | Regexp ( re , _ ) -> sexp ppf " Re " " % a " Re . pp re | Conv ( tre , _ ) -> sexp ppf " Conv " " % a " pp tre | Opt tre -> sexp ppf " Opt " " % a " pp tre | Alt ( tre1 , tre2 ) -> sexp ppf " Alt " " % a @ % a " pp tre1 pp tre2 | Seq ( tre1 , tre2 ) -> sexp ppf " Seq " " % a @ % a " pp tre1 pp tre2 | Prefix ( tre1 , tre2 ) -> sexp ppf " Prefix " " % a @ % a " pp tre1 pp tre2 | Suffix ( tre1 , tre2 ) -> sexp ppf " Suffix " " % a @ % a " pp tre1 pp tre2 | Rep tre -> sexp ppf " Rep " " % a " pp tre | Mod ( _ , tre ) -> sexp ppf " Mod " " % a " pp tre |
let rec pp_wit : type a . _ -> a T . wit -> unit = fun ppf -> let open T in function | Lit i -> sexp ppf " Lit " " % i " i | Conv ( tre , _ ) -> sexp ppf " Conv " " % a " pp_wit tre | Opt ( _ , tre ) -> sexp ppf " Opt " " % a " pp_wit tre | Alt ( _ , tre1 , tre2 ) -> sexp ppf " Alt " " % a @ % a " pp_wit tre1 pp_wit tre2 | Seq ( tre1 , tre2 ) -> sexp ppf " Seq " " % a @ % a " pp_wit tre1 pp_wit tre2 | Rep ( i , w , re ) -> sexp ppf " Rep " " % i @ % a @ % a " i pp_wit w Re . pp_re re |
let pp_wit_route : type a . _ -> a wit_route -> unit = fun ppf ( WRoute ( _ , w , _ ) ) -> pp_wit ppf w |
let pp_re ppf = function | { info = One w ; cre } -> sexp ppf " One " " % a @ % a " Re . pp_re cre pp_wit w | { info = Routes wl ; cre } -> sexp ppf " Route " " % a @ % a " Re . pp_re cre ( pp_list pp_wit_route ) wl |
let pp_error ppf : _ error -> unit = function | ` NoMatch ( re , s ) -> Format . fprintf ppf " ` NoMatch ( % a , % s ) " pp_re re s | ` ConverterFailure exn -> Format . pp_print_string ppf @@ Printexc . to_string exn |
module Internal = struct include T let to_t x = x let from_t x = x let build = build let extract = extract end |
module MakeTo ( C : sig type ' a elt val elt : ' a elt -> Dom . node Js . t type ' a elt = ' a C . elt let rebuild_node _ x = Js . Unsafe . coerce ( C . elt x ) let of_element elt = rebuild_node " of_element " elt let of_node elt = rebuild_node " of_node " elt let of_pcdata elt = rebuild_node " of_pcdata " elt let of_html elt = rebuild_node " of_html " elt let of_head elt = rebuild_node " of_head " elt let of_link elt = rebuild_node " of_link " elt let of_title elt = rebuild_node " of_title " elt let of_meta elt = rebuild_node " of_meta " elt let of_base elt = rebuild_node " of_base " elt let of_style elt = rebuild_node " of_style " elt let of_body elt = rebuild_node " of_body " elt let of_form elt = rebuild_node " of_form " elt let of_optgroup elt = rebuild_node " of_optgroup " elt let of_option elt = rebuild_node " of_option " elt let of_select elt = rebuild_node " of_select " elt let of_input elt = rebuild_node " of_input " elt let of_textarea elt = rebuild_node " of_textarea " elt let of_button elt = rebuild_node " of_button " elt let of_label elt = rebuild_node " of_label " elt let of_fieldset elt = rebuild_node " of_fieldset " elt let of_legend elt = rebuild_node " of_legend " elt let of_ul elt = rebuild_node " of_ul " elt let of_ol elt = rebuild_node " of_ol " elt let of_dl elt = rebuild_node " of_dl " elt let of_li elt = rebuild_node " of_li " elt let of_div elt = rebuild_node " of_div " elt let of_p elt = rebuild_node " of_p " elt let of_heading elt = rebuild_node " of_heading " elt let of_blockquote elt = rebuild_node " of_blockquote " elt let of_pre elt = rebuild_node " of_pre " elt let of_br elt = rebuild_node " of_br " elt let of_hr elt = rebuild_node " of_hr " elt let of_ins elt = rebuild_node " of_ins " elt let of_del elt = rebuild_node " of_del " elt let of_a elt = rebuild_node " of_a " elt let of_img elt = rebuild_node " of_img " elt let of_object elt = rebuild_node " of_object " elt let of_param elt = rebuild_node " of_param " elt let of_area elt = rebuild_node " of_area " elt let of_map elt = rebuild_node " of_map " elt let of_script elt = rebuild_node " of_script " elt let of_td elt = rebuild_node " of_td " elt let of_tr elt = rebuild_node " of_tr " elt let of_col elt = rebuild_node " of_col " elt let of_tfoot elt = rebuild_node " of_tfoot " elt let of_thead elt = rebuild_node " of_thead " elt let of_tbody elt = rebuild_node " of_tbody " elt let of_caption elt = rebuild_node " of_caption " elt let of_table elt = rebuild_node " of_table " elt let of_canvas elt = rebuild_node " of_canvas " elt let of_iframe elt = rebuild_node " of_iframe " elt let of_audio elt = rebuild_node " of_audio " elt let of_video elt = rebuild_node " of_video " elt let of_h1 elt = rebuild_node " of_h1 " elt let of_h2 elt = rebuild_node " of_h2 " elt let of_h3 elt = rebuild_node " of_h3 " elt let of_h4 elt = rebuild_node " of_h4 " elt let of_h5 elt = rebuild_node " of_h5 " elt let of_h6 elt = rebuild_node " of_h6 " elt let of_abbr elt = rebuild_node " of_abbr " elt let of_address elt = rebuild_node " of_address " elt let of_article elt = rebuild_node " of_article " elt let of_aside elt = rebuild_node " of_aside " elt let of_b elt = rebuild_node " of_b " elt let of_bdo elt = rebuild_node " of_bdo " elt let of_cite elt = rebuild_node " of_cite " elt let of_code elt = rebuild_node " of_code " elt let of_colgroup elt = rebuild_node " of_colgroup " elt let of_command elt = rebuild_node " of_command " elt let of_datalist elt = rebuild_node " of_datalist " elt let of_dd elt = rebuild_node " of_dd " elt let of_details elt = rebuild_node " of_details " elt let of_dfn elt = rebuild_node " of_dfn " elt let of_dt elt = rebuild_node " of_dt " elt let of_em elt = rebuild_node " of_em " elt let of_embed elt = rebuild_node " of_embed " elt let of_figcaption elt = rebuild_node " of_figcaption " elt let of_figure elt = rebuild_node " of_figure " elt let of_footer elt = rebuild_node " of_footer " elt let of_header elt = rebuild_node " of_header " elt let of_hgroup elt = rebuild_node " of_hgroup " elt let of_i elt = rebuild_node " of_i " elt let of_kbd elt = rebuild_node " of_kbd " elt let of_keygen elt = rebuild_node " of_keygen " elt let of_main elt = rebuild_node " of_main " elt let of_mark elt = rebuild_node " of_mark " elt let of_menu elt = rebuild_node " of_menu " elt let of_meter elt = rebuild_node " of_meter " elt let of_nav elt = rebuild_node " of_nav " elt let of_noscript elt = rebuild_node " of_noscript " elt let of_output elt = rebuild_node " of_output " elt let of_progress elt = rebuild_node " of_progress " elt let of_q elt = rebuild_node " of_q " elt let of_rp elt = rebuild_node " of_rp " elt let of_rt elt = rebuild_node " of_rt " elt let of_ruby elt = rebuild_node " of_ruby " elt let of_samp elt = rebuild_node " of_samp " elt let of_section elt = rebuild_node " of_section " elt let of_small elt = rebuild_node " of_small " elt let of_source elt = rebuild_node " of_source " elt let of_span elt = rebuild_node " of_span " elt let of_strong elt = rebuild_node " of_strong " elt let of_sub elt = rebuild_node " of_sub " elt let of_summary elt = rebuild_node " of_summary " elt let of_sup elt = rebuild_node " of_sup " elt let of_th elt = rebuild_node " of_th " elt let of_time elt = rebuild_node " of_time " elt let of_u elt = rebuild_node " of_u " elt let of_var elt = rebuild_node " of_var " elt let of_wbr elt = rebuild_node " of_wbr " elt end |
module MakeOf ( C : sig type ' a elt val elt : Dom . node Js . t -> ' a elt type ' a elt = ' a C . elt let rebuild_node _ x = C . elt ( Js . Unsafe . coerce x ) let of_element elt = rebuild_node " of_element " elt let of_html elt = rebuild_node " of_html " elt let of_head elt = rebuild_node " of_head " elt let of_link elt = rebuild_node " of_link " elt let of_title elt = rebuild_node " of_title " elt let of_meta elt = rebuild_node " of_meta " elt let of_base elt = rebuild_node " of_base " elt let of_style elt = rebuild_node " of_style " elt let of_body elt = rebuild_node " of_body " elt let of_form elt = rebuild_node " of_form " elt let of_optGroup elt = rebuild_node " of_optGroup " elt let of_option elt = rebuild_node " of_option " elt let of_select elt = rebuild_node " of_select " elt let of_input elt = rebuild_node " of_input " elt let of_textArea elt = rebuild_node " of_textArea " elt let of_button elt = rebuild_node " of_button " elt let of_label elt = rebuild_node " of_label " elt let of_fieldSet elt = rebuild_node " of_fieldSet " elt let of_legend elt = rebuild_node " of_legend " elt let of_uList elt = rebuild_node " of_uList " elt let of_oList elt = rebuild_node " of_oList " elt let of_dList elt = rebuild_node " of_dList " elt let of_li elt = rebuild_node " of_li " elt let of_div elt = rebuild_node " of_div " elt let of_paragraph elt = rebuild_node " of_paragraph " elt let of_heading elt = rebuild_node " of_heading " elt let of_quote elt = rebuild_node " of_quote " elt let of_pre elt = rebuild_node " of_pre " elt let of_br elt = rebuild_node " of_br " elt let of_hr elt = rebuild_node " of_hr " elt let of_mod elt = rebuild_node " of_mod " elt let of_anchor elt = rebuild_node " of_anchor " elt let of_image elt = rebuild_node " of_image " elt let of_object elt = rebuild_node " of_object " elt let of_param elt = rebuild_node " of_param " elt let of_area elt = rebuild_node " of_area " elt let of_map elt = rebuild_node " of_map " elt let of_script elt = rebuild_node " of_script " elt let of_embed elt = rebuild_node " of_embed " elt let of_tableCell elt = rebuild_node " of_tableCell " elt let of_tableRow elt = rebuild_node " of_tableRow " elt let of_tableCol elt = rebuild_node " of_tableCol " elt let of_tableSection elt = rebuild_node " of_tableSection " elt let of_tableCaption elt = rebuild_node " of_tableCaption " elt let of_table elt = rebuild_node " of_table " elt let of_canvas elt = rebuild_node " of_canvas " elt let of_iFrame elt = rebuild_node " of_iFrame " elt let of_audio elt = rebuild_node " of_audio " elt let of_video elt = rebuild_node " of_video " elt end |
module type OF = sig type ' a elt val of_element : Dom_html . element Js . t -> ' a elt val of_html : Dom_html . htmlElement Js . t -> [ > Html_types . html ] elt val of_head : Dom_html . headElement Js . t -> [ > Html_types . head ] elt val of_link : Dom_html . linkElement Js . t -> [ > Html_types . link ] elt val of_title : Dom_html . titleElement Js . t -> [ > Html_types . title ] elt val of_meta : Dom_html . metaElement Js . t -> [ > Html_types . meta ] elt val of_base : Dom_html . baseElement Js . t -> [ > Html_types . base ] elt val of_style : Dom_html . styleElement Js . t -> [ > Html_types . style ] elt val of_body : Dom_html . bodyElement Js . t -> [ > Html_types . body ] elt val of_form : Dom_html . formElement Js . t -> [ > Html_types . form ] elt val of_optGroup : Dom_html . optGroupElement Js . t -> [ > Html_types . optgroup ] elt val of_option : Dom_html . optionElement Js . t -> [ > Html_types . selectoption ] elt val of_select : Dom_html . selectElement Js . t -> [ > Html_types . select ] elt val of_input : Dom_html . inputElement Js . t -> [ > Html_types . input ] elt val of_textArea : Dom_html . textAreaElement Js . t -> [ > Html_types . textarea ] elt val of_button : Dom_html . buttonElement Js . t -> [ > Html_types . button ] elt val of_label : Dom_html . labelElement Js . t -> [ > Html_types . label ] elt val of_fieldSet : Dom_html . fieldSetElement Js . t -> [ > Html_types . fieldset ] elt val of_legend : Dom_html . legendElement Js . t -> [ > Html_types . legend ] elt val of_uList : Dom_html . uListElement Js . t -> [ > Html_types . ul ] elt val of_oList : Dom_html . oListElement Js . t -> [ > Html_types . ol ] elt val of_dList : Dom_html . dListElement Js . t -> [ > Html_types . dl ] elt val of_li : Dom_html . liElement Js . t -> [ > Html_types . li ] elt val of_div : Dom_html . divElement Js . t -> [ > Html_types . div ] elt val of_paragraph : Dom_html . paragraphElement Js . t -> [ > Html_types . p ] elt val of_heading : Dom_html . headingElement Js . t -> [ > Html_types . heading ] elt val of_quote : Dom_html . quoteElement Js . t -> [ > Html_types . blockquote ] elt val of_pre : Dom_html . preElement Js . t -> [ > Html_types . pre ] elt val of_br : Dom_html . brElement Js . t -> [ > Html_types . br ] elt val of_hr : Dom_html . hrElement Js . t -> [ > Html_types . hr ] elt val of_mod : Dom_html . modElement Js . t -> [ > ' a Html_types . del | ' a Html_types . ins ] elt val of_anchor : Dom_html . anchorElement Js . t -> [ > ' a Html_types . a ] elt val of_image : Dom_html . imageElement Js . t -> [ > Html_types . img ] elt val of_object : Dom_html . objectElement Js . t -> [ > ' a Html_types . object_ ] elt val of_param : Dom_html . paramElement Js . t -> [ > Html_types . param ] elt val of_area : Dom_html . areaElement Js . t -> [ > Html_types . area ] elt val of_map : Dom_html . mapElement Js . t -> [ > ' a Html_types . map ] elt val of_script : Dom_html . scriptElement Js . t -> [ > Html_types . script ] elt val of_embed : Dom_html . embedElement Js . t -> [ > Html_types . embed ] elt val of_tableCell : Dom_html . tableCellElement Js . t -> [ > Html_types . td | Html_types . th ] elt val of_tableRow : Dom_html . tableRowElement Js . t -> [ > Html_types . tr ] elt val of_tableCol : Dom_html . tableColElement Js . t -> [ > Html_types . col ] elt val of_tableSection : Dom_html . tableSectionElement Js . t -> [ > Html_types . tfoot | Html_types . thead | Html_types . tbody ] elt val of_tableCaption : Dom_html . tableCaptionElement Js . t -> [ > Html_types . caption ] elt val of_table : Dom_html . tableElement Js . t -> [ > Html_types . table ] elt val of_canvas : Dom_html . canvasElement Js . t -> [ > ' a Html_types . canvas ] elt val of_iFrame : Dom_html . iFrameElement Js . t -> [ > Html_types . iframe ] elt val of_audio : Dom_html . audioElement Js . t -> [ > ' a Html_types . audio ] elt val of_video : Dom_html . videoElement Js . t -> [ > ' a Html_types . video ] elt end |
module type TO = sig type ' a elt val of_element : ' a elt -> Dom_html . element Js . t val of_node : ' a elt -> Dom . node Js . t val of_pcdata : [ < Html_types . pcdata ] elt -> Dom . text Js . t val of_html : [ < Html_types . html ] elt -> Dom_html . htmlElement Js . t val of_head : [ < Html_types . head ] elt -> Dom_html . headElement Js . t val of_link : [ < Html_types . link ] elt -> Dom_html . linkElement Js . t val of_title : [ < Html_types . title ] elt -> Dom_html . titleElement Js . t val of_meta : [ < Html_types . meta ] elt -> Dom_html . metaElement Js . t val of_base : [ < Html_types . base ] elt -> Dom_html . baseElement Js . t val of_style : [ < Html_types . style ] elt -> Dom_html . styleElement Js . t val of_body : [ < Html_types . body ] elt -> Dom_html . bodyElement Js . t val of_form : [ < Html_types . form ] elt -> Dom_html . formElement Js . t val of_optgroup : [ < Html_types . optgroup ] elt -> Dom_html . optGroupElement Js . t val of_option : [ < Html_types . selectoption ] elt -> Dom_html . optionElement Js . t val of_select : [ < Html_types . select ] elt -> Dom_html . selectElement Js . t val of_input : [ < Html_types . input ] elt -> Dom_html . inputElement Js . t val of_textarea : [ < Html_types . textarea ] elt -> Dom_html . textAreaElement Js . t val of_button : [ < Html_types . button ] elt -> Dom_html . buttonElement Js . t val of_label : [ < Html_types . label ] elt -> Dom_html . labelElement Js . t val of_fieldset : [ < Html_types . fieldset ] elt -> Dom_html . fieldSetElement Js . t val of_legend : [ < Html_types . legend ] elt -> Dom_html . legendElement Js . t val of_ul : [ < Html_types . ul ] elt -> Dom_html . uListElement Js . t val of_ol : [ < Html_types . ol ] elt -> Dom_html . oListElement Js . t val of_dl : [ < Html_types . dl ] elt -> Dom_html . dListElement Js . t val of_li : [ < Html_types . li ] elt -> Dom_html . liElement Js . t val of_div : [ < Html_types . div ] elt -> Dom_html . divElement Js . t val of_p : [ < Html_types . p ] elt -> Dom_html . paragraphElement Js . t val of_heading : [ < Html_types . heading ] elt -> Dom_html . headingElement Js . t val of_blockquote : [ < Html_types . blockquote ] elt -> Dom_html . quoteElement Js . t val of_pre : [ < Html_types . pre ] elt -> Dom_html . preElement Js . t val of_br : [ < Html_types . br ] elt -> Dom_html . brElement Js . t val of_hr : [ < Html_types . hr ] elt -> Dom_html . hrElement Js . t val of_del : [ < ' a Html_types . del ] elt -> Dom_html . modElement Js . t val of_ins : [ < ' a Html_types . ins ] elt -> Dom_html . modElement Js . t val of_a : [ < ' a Html_types . a ] elt -> Dom_html . anchorElement Js . t val of_img : [ < Html_types . img_interactive ] elt -> Dom_html . imageElement Js . t val of_object : [ < ' a Html_types . object_ ] elt -> Dom_html . objectElement Js . t val of_param : [ < Html_types . param ] elt -> Dom_html . paramElement Js . t val of_area : [ < Html_types . area ] elt -> Dom_html . areaElement Js . t val of_map : [ < ' a Html_types . map ] elt -> Dom_html . mapElement Js . t val of_script : [ < Html_types . script ] elt -> Dom_html . scriptElement Js . t val of_td : [ < Html_types . td | Html_types . td ] elt -> Dom_html . tableCellElement Js . t val of_tr : [ < Html_types . tr ] elt -> Dom_html . tableRowElement Js . t val of_col : [ < Html_types . col ] elt -> Dom_html . tableColElement Js . t val of_tfoot : [ < Html_types . tfoot ] elt -> Dom_html . tableSectionElement Js . t val of_thead : [ < Html_types . thead ] elt -> Dom_html . tableSectionElement Js . t val of_tbody : [ < Html_types . tbody ] elt -> Dom_html . tableSectionElement Js . t val of_caption : [ < Html_types . caption ] elt -> Dom_html . tableCaptionElement Js . t val of_table : [ < Html_types . table ] elt -> Dom_html . tableElement Js . t val of_canvas : [ < ' a Html_types . canvas ] elt -> Dom_html . canvasElement Js . t val of_iframe : [ < Html_types . iframe ] elt -> Dom_html . iFrameElement Js . t val of_audio : [ < ' a Html_types . audio_interactive ] elt -> Dom_html . audioElement Js . t val of_video : [ < ' a Html_types . video_interactive ] elt -> Dom_html . videoElement Js . t val of_h1 : Html_types . heading elt -> Dom_html . headingElement Js . t val of_h2 : Html_types . heading elt -> Dom_html . headingElement Js . t val of_h3 : Html_types . heading elt -> Dom_html . headingElement Js . t val of_h4 : Html_types . heading elt -> Dom_html . headingElement Js . t val of_h5 : Html_types . heading elt -> Dom_html . headingElement Js . t val of_h6 : Html_types . heading elt -> Dom_html . headingElement Js . t val of_abbr : [ > Html_types . abbr ] elt -> Dom_html . element Js . t val of_address : [ > Html_types . address ] elt -> Dom_html . element Js . t val of_article : [ > Html_types . article ] elt -> Dom_html . element Js . t val of_aside : [ > Html_types . aside ] elt -> Dom_html . element Js . t val of_b : [ > Html_types . b ] elt -> Dom_html . element Js . t val of_bdo : [ > Html_types . bdo ] elt -> Dom_html . element Js . t val of_cite : [ > Html_types . cite ] elt -> Dom_html . element Js . t val of_code : [ > Html_types . code ] elt -> Dom_html . element Js . t val of_colgroup : [ > Html_types . colgroup ] elt -> Dom_html . element Js . t val of_command : [ > Html_types . command ] elt -> Dom_html . element Js . t val of_datalist : [ > Html_types . datalist ] elt -> Dom_html . element Js . t val of_dd : [ > Html_types . dd ] elt -> Dom_html . element Js . t val of_details : [ > Html_types . details ] elt -> Dom_html . element Js . t val of_dfn : [ > Html_types . dfn ] elt -> Dom_html . element Js . t val of_dt : [ > Html_types . dt ] elt -> Dom_html . element Js . t val of_em : [ > Html_types . em ] elt -> Dom_html . element Js . t val of_embed : [ > Html_types . embed ] elt -> Dom_html . element Js . t val of_figcaption : [ > Html_types . figcaption ] elt -> Dom_html . element Js . t val of_figure : [ > Html_types . figure ] elt -> Dom_html . element Js . t val of_footer : [ > Html_types . footer ] elt -> Dom_html . element Js . t val of_header : [ > Html_types . header ] elt -> Dom_html . element Js . t val of_hgroup : [ > Html_types . hgroup ] elt -> Dom_html . element Js . t val of_i : [ > Html_types . i ] elt -> Dom_html . element Js . t val of_kbd : [ > Html_types . kbd ] elt -> Dom_html . element Js . t val of_keygen : [ > Html_types . keygen ] elt -> Dom_html . element Js . t val of_main : [ > Html_types . main ] elt -> Dom_html . element Js . t val of_mark : [ > Html_types . mark ] elt -> Dom_html . element Js . t val of_menu : [ > Html_types . menu ] elt -> Dom_html . element Js . t val of_meter : [ > Html_types . meter ] elt -> Dom_html . element Js . t val of_nav : [ > Html_types . nav ] elt -> Dom_html . element Js . t val of_noscript : [ > Html_types . noscript ] elt -> Dom_html . element Js . t val of_output : [ > Html_types . output_elt ] elt -> Dom_html . element Js . t val of_progress : [ > Html_types . progress ] elt -> Dom_html . element Js . t val of_q : [ > Html_types . q ] elt -> Dom_html . element Js . t val of_rp : [ > Html_types . rp ] elt -> Dom_html . element Js . t val of_rt : [ > Html_types . rt ] elt -> Dom_html . element Js . t val of_ruby : [ > Html_types . ruby ] elt -> Dom_html . element Js . t val of_samp : [ > Html_types . samp ] elt -> Dom_html . element Js . t val of_section : [ > Html_types . section ] elt -> Dom_html . element Js . t val of_small : [ > Html_types . small ] elt -> Dom_html . element Js . t val of_source : [ > Html_types . source ] elt -> Dom_html . element Js . t val of_span : [ > Html_types . span ] elt -> Dom_html . element Js . t val of_strong : [ > Html_types . strong ] elt -> Dom_html . element Js . t val of_sub : [ > Html_types . sub ] elt -> Dom_html . element Js . t val of_summary : [ > Html_types . summary ] elt -> Dom_html . element Js . t val of_sup : [ > Html_types . sup ] elt -> Dom_html . element Js . t val of_th : [ > Html_types . th ] elt -> Dom_html . element Js . t val of_time : [ > Html_types . time ] elt -> Dom_html . element Js . t val of_u : [ > Html_types . u ] elt -> Dom_html . element Js . t val of_var : [ > Html_types . var ] elt -> Dom_html . element Js . t val of_wbr : [ > Html_types . wbr ] elt -> Dom_html . element Js . t end |
let js_string_of_float f = ( Js . number_of_float f ) ## toString |
let js_string_of_int i = ( Js . number_of_float ( float_of_int i ) ) ## toString |
module type XML = Xml_sigs . T with type uri = string and type event_handler = Dom_html . event Js . t -> bool and type mouse_event_handler = Dom_html . mouseEvent Js . t -> bool and type keyboard_event_handler = Dom_html . keyboardEvent Js . t -> bool and type elt = Dom . node Js . t |
module Xml = struct module W = Xml_wrap . NoWrap type ' a wrap = ' a type ' a list_wrap = ' a list type uri = string let uri_of_string s = s let string_of_uri s = s type aname = string type event_handler = Dom_html . event Js . t -> bool type mouse_event_handler = Dom_html . mouseEvent Js . t -> bool type keyboard_event_handler = Dom_html . keyboardEvent Js . t -> bool type touch_event_handler = Dom_html . touchEvent Js . t -> bool type attrib_k = | Event of event_handler | MouseEvent of mouse_event_handler | KeyboardEvent of keyboard_event_handler | TouchEvent of touch_event_handler | Attr of Js . js_string Js . t option React . S . t type attrib = aname * attrib_k let attr name v = name , Attr ( React . S . const ( Some v ) ) let float_attrib name value : attrib = attr name ( js_string_of_float value ) let int_attrib name value = attr name ( js_string_of_int value ) let string_attrib name value = attr name ( Js . string value ) let space_sep_attrib name values = attr name ( Js . string ( String . concat " " values ) ) let comma_sep_attrib name values = attr name ( Js . string ( String . concat " , " values ) ) let event_handler_attrib name ( value : event_handler ) = name , Event value let mouse_event_handler_attrib name ( value : mouse_event_handler ) = name , MouseEvent value let keyboard_event_handler_attrib name ( value : keyboard_event_handler ) = name , KeyboardEvent value let touch_event_handler_attrib name ( value : touch_event_handler ) = name , TouchEvent value let uri_attrib name value = attr name ( Js . string value ) let uris_attrib name values = attr name ( Js . string ( String . concat " " values ) ) type elt = Dom . node Js . t type ename = string let empty ( ) = ( Dom_html . document ## createDocumentFragment :> Dom . node Js . t ) let comment c = ( Dom_html . document ## createComment ( Js . string c ) :> Dom . node Js . t ) let pcdata s = ( Dom_html . document ## createTextNode ( Js . string s ) :> Dom . node Js . t ) let encodedpcdata s = ( Dom_html . document ## createTextNode ( Js . string s ) :> Dom . node Js . t ) let entity = let string_fold s ~ pos ~ init ~ f = let r = ref init in for i = pos to String . length s - 1 do let c = s . [ i ] in r := f ! r c done ; ! r in let invalid_entity e = failwith ( Printf . sprintf " Invalid entity % S " e ) in let int_of_char = function | ' 0 ' . . ' 9 ' as x -> Some ( Char . code x - Char . code ' 0 ' ) | ' a ' . . ' f ' as x -> Some ( Char . code x - Char . code ' a ' + 10 ) | ' A ' . . ' F ' as x -> Some ( Char . code x - Char . code ' A ' + 10 ) | _ -> None in let parse_int ~ pos ~ base e = string_fold e ~ pos ~ init : 0 ~ f ( : fun acc x -> match int_of_char x with | Some d when d < base -> ( acc * base ) + d | Some _ | None -> invalid_entity e ) in let is_alpha_num = function | ' 0 ' . . ' 9 ' | ' a ' . . ' z ' | ' A ' . . ' Z ' -> true | _ -> false in fun e -> let len = String . length e in let str = if len >= 1 && Char . equal e . [ 0 ] ' ' # then let i = if len >= 2 && ( Char . equal e . [ 1 ] ' x ' || Char . equal e . [ 1 ] ' X ' ) then parse_int ~ pos : 2 ~ base : 16 e else parse_int ~ pos : 1 ~ base : 10 e in Js . string_constr ## fromCharCode i else if string_fold e ~ pos : 0 ~ init : true ~ f ( : fun acc x -> acc && is_alpha_num x ) then match e with | " quot " -> Js . string " " " \ | " amp " -> Js . string " " & | " apos " -> Js . string " ' " | " lt " -> Js . string " " < | " gt " -> Js . string " " > | " " -> invalid_entity e | _ -> Dom_html . decode_html_entities ( Js . string ( " " & ^ e ^ " ; " ) ) else invalid_entity e in ( Dom_html . document ## createTextNode str :> Dom . node Js . t ) let get_prop node name = if Js . Optdef . test ( Js . Unsafe . get node name ) then Some name else None let iter_prop_protected node name f = match get_prop node name with | Some n -> ( try f n with _ -> ( ) ) | None -> ( ) let attach_attribs node l = List . iter ( fun ( n ' , att ) -> let n = Js . string n ' in match att with | Attr a -> let ( _ : unit React . S . t ) = React . S . map ( function | Some v -> ( ignore ( node ## setAttribute n v ) ; match n ' with | " style " -> node . ## style . ## cssText := v | _ -> iter_prop_protected node n ( fun name -> Js . Unsafe . set node name v ) ) | None -> ( ignore ( node ## removeAttribute n ) ; match n ' with | " style " -> node . ## style . ## cssText := Js . string " " | _ -> iter_prop_protected node n ( fun name -> Js . Unsafe . set node name Js . null ) ) ) a in ( ) | Event h -> Js . Unsafe . set node n ( fun ev -> Js . bool ( h ev ) ) | MouseEvent h -> Js . Unsafe . set node n ( fun ev -> Js . bool ( h ev ) ) | KeyboardEvent h -> Js . Unsafe . set node n ( fun ev -> Js . bool ( h ev ) ) | TouchEvent h -> Js . Unsafe . set node n ( fun ev -> Js . bool ( h ev ) ) ) l let leaf ( ? a = [ ] ) name = let e = Dom_html . document ## createElement ( Js . string name ) in attach_attribs e a ; ( e :> Dom . node Js . t ) let node ( ? a = [ ] ) name children = let e = Dom_html . document ## createElement ( Js . string name ) in attach_attribs e a ; List . iter ( fun c -> ignore ( e ## appendChild c ) ) children ; ( e :> Dom . node Js . t ) let cdata s = pcdata s let cdata_script s = cdata s let cdata_style s = cdata s end |
module Xml_Svg = struct include Xml let leaf ( ? a = [ ] ) name = let e = Dom_html . document ## createElementNS Dom_svg . xmlns ( Js . string name ) in attach_attribs e a ; ( e :> Dom . node Js . t ) let node ( ? a = [ ] ) name children = let e = Dom_html . document ## createElementNS Dom_svg . xmlns ( Js . string name ) in attach_attribs e a ; List . iter ( fun c -> ignore ( e ## appendChild c ) ) children ; ( e :> Dom . node Js . t ) end |
module Svg = Svg_f . Make ( Xml_Svg ) |
module Html = Html_f . Make ( Xml ) ( Svg ) |
module To_dom = Tyxml_cast . MakeTo ( struct type ' a elt = ' a Html . elt let elt = Html . toelt end ) |
module Of_dom = Tyxml_cast . MakeOf ( struct type ' a elt = ' a Html . elt let elt = Html . tot end ) |
module Register = struct let removeChildren ( node : # Dom . element Js . t ) = let l = node . ## childNodes in for i = 0 to l . ## length - 1 do Js . Opt . iter ( l ## item i ) ( fun x -> ignore ( node ## removeChild x ) ) done let add_to ( ? keep = true ) node content = if not keep then removeChildren node ; List . iter ( fun x -> Dom . appendChild node ( To_dom . of_element x ) ) content let id ? keep id content = let node = Dom_html . getElementById id in add_to ? keep node content let body ? keep content = add_to ? keep Dom_html . document . ## body content let head ? keep content = add_to ? keep Dom_html . document . ## head content let html ? head body = ( match head with | Some h -> Dom_html . document . ## head := To_dom . of_head h | None -> ( ) ) ; Dom_html . document . ## body := To_dom . of_body body ; ( ) end |
module Wrap = struct type ' a t = ' a React . signal type ' a tlist = ' a ReactiveData . RList . t type ( ' a , ' b ) ft = ' a -> ' b let return = React . S . const let fmap f = React . S . map f let nil ( ) = ReactiveData . RList . empty let singleton = ReactiveData . RList . singleton_s let cons x xs = ReactiveData . RList . concat ( singleton x ) xs let map f = ReactiveData . RList . map f let append x y = ReactiveData . RList . concat x y end |
module Util = struct open ReactiveData open RList let insertAt dom i x = let nodes = dom . ## childNodes in assert ( i <= nodes . ## length ) ; if i = nodes . ## length then ignore ( dom ## appendChild ( x :> Dom . node Js . t ) ) else ignore ( dom ## insertBefore x ( nodes ## item i ) ) let merge_one_patch ( dom : Dom . node Js . t ) ( p : Dom . node Js . t p ) = match p with | I ( i , x ) -> let i = if i < 0 then dom . ## childNodes . ## length + 1 + i else i in insertAt dom i x | R i -> let i = if i < 0 then dom . ## childNodes . ## length + i else i in let nodes = dom . ## childNodes in assert ( i >= 0 && i < nodes . ## length ) ; Js . Opt . iter ( nodes ## item i ) ( fun n -> Dom . removeChild dom n ) | U ( i , x ) -> ( let i = if i < 0 then dom . ## childNodes . ## length + i else i in match Js . Opt . to_option ( dom . ## childNodes ## item i ) with | Some old -> ignore ( dom ## replaceChild x old ) | _ -> assert false ) | X ( i , move ) -> ( let i = if i < 0 then dom . ## childNodes . ## length + i else i in if move = 0 then ( ) else match Js . Opt . to_option ( dom . ## childNodes ## item i ) with | Some i ' -> insertAt dom ( i + if move > 0 then move + 1 else move ) i ' | _ -> assert false ) let rec removeChildren dom = match Js . Opt . to_option dom . ## lastChild with | None -> ( ) | Some c -> ignore ( dom ## removeChild c ) ; removeChildren dom let merge_msg ( dom : Dom . node Js . t ) ( msg : Dom . node Js . t msg ) = match msg with | Set l -> removeChildren dom ; List . iter ( fun l -> ignore ( dom ## appendChild l ) ) l | Patch p -> List . iter ( merge_one_patch dom ) p let update_children ( dom : Dom . node Js . t ) ( nodes : Dom . node Js . t t ) = removeChildren dom ; let _s : unit React . S . t = fold ( fun ( ) msg -> merge_msg dom msg ) nodes ( ) in ( ) end |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.