text stringlengths 12 786k |
|---|
let repl_actns ( id : int ) new_x r = Cnl2cnl . rule_dp_map_over_nodes { Cnl2cnl . id_map_over_node_fun with Cnl2cnl . actns_map_fun = ( replace_desc id new_x ) } r |
let repl_actns_closed ( id : int ) closed r = let repl_closed actns = begin match actns . actns_node with | N_undefined actns_id | N_rejected ( actns_id , _ ) -> let node = if closed then { list_elems = [ ] ; list_closed = N_filled ( Some id , ( ) ) ; } else { list_elems =... |
let replace id cnl r = begin match cnl with | Cnl_expr expr -> let map_fun node = if Some id = node_id node then expr . expr_node else node in Cnl2cnl . rule_dp_map_over_nodes { Cnl2cnl . id_map_over_node_fun with Cnl2cnl . expr_map_fun = map_fun ; } r | Cnl_actn actn -> let map_fun node = if Som... |
let confirm ( id : int ) b r = begin match rule_get_cnl ( Some id ) r with | Some cnl -> let cnl = if b then cnl_f_to_a cnl else cnl_f_to_r cnl in replace ( Some id ) cnl r | None -> r end |
let insert_action r = let r = Cnl2cnl . rule_sh_map ( fun x -> x ) ( fun x -> x ) ( fun actns -> let node = Cnl2cnl . node_sh_map ( fun desc -> { list_elems = desc . list_elems @ [ Cnl_builder . mk_actn_undefined ( ) ] ; list_closed = desc . list_closed ; } ) actns . ... |
let cnl_instr_apply instr ( r : cnl_rule ) : cnl_rule = let r_applied = begin match instr with | I_repl_expr ( id , e ) -> repl_expr id e r | I_repl_actn ( id , a ) -> repl_actn id a r | I_repl_evnt ( id , w ) -> repl_evnt id w r | I_repl_cond ( id , c ) -> repl_cond id c r | I_... |
let ( ) >>= x f = match x with Ok x -> f x | ( Error _ ) as x -> x |
let ( ) >|= x f = x >>= fun x -> Ok ( f x ) |
let rec map_bind f acc xs = match xs with | x :: xs -> f x >>= fun x -> map_bind f ( x :: acc ) xs | [ ] -> Ok ( List . rev acc ) |
type ' a error_or = ( ' a , string ) result |
type cnl_instr = | I_repl_expr of int * cnl_expr_desc | I_repl_actn of int * cnl_actn_desc | I_repl_evnt of int * cnl_evnt_desc | I_repl_cond of int * cnl_cond_desc | I_repl_actns of int * cnl_actns_desc | I_repl_actns_closed of int * bool | I_conf_expr of int * bool | I_conf_actn of int * bool | I_co... |
let rec ( cnl_instr_to_yojson : cnl_instr -> Yojson . Safe . json ) = ( ( function | I_repl_expr ( arg0 , arg1 ) -> ` List [ ` String " I_repl_expr " ; ( ( fun x -> ` Int x ) ) arg0 ; ( ( fun x -> cnl_expr_desc_to_yojson x ) ) arg1 ] | I_repl_actn ( arg0 , ... |
type cnl_program = cnl_instr list |
let rec ( cnl_program_to_yojson : cnl_program -> Yojson . Safe . json ) = ( ( fun x -> ` List ( List . map ( fun x -> cnl_instr_to_yojson x ) x ) ) [ @ ocaml . warning " - A " ] ) Yojson . Safe . json -> cnl_program error_or ) = ( ( function | ` List xs -> ma... |
let focus_of_instr instr = match instr with | I_repl_expr ( focus , _ ) -> focus | I_repl_actn ( focus , _ ) -> focus | I_repl_evnt ( focus , _ ) -> focus | I_repl_cond ( focus , _ ) -> focus | I_repl_actns ( focus , _ ) -> focus | I_repl_actns_closed ( focus , _ ) ... |
let cnl_print_literal prec ff l = begin match l with | L_string s -> fprintf ff " " \% s " " \ s | L_int i -> fprintf ff " % i " i | L_int_as_string i -> fprintf ff " % s " i | L_real f -> fprintf ff " % f " f | L_real_as_string f -> fprintf ff " % s " f | L_boolean true -> fp... |
let cnl_binop_precedence op = begin match op with | Op_eq -> 3 | Op_ne -> 3 | Op_lt -> 3 | Op_le -> 3 | Op_gt -> 3 | Op_ge -> 3 | Op_and -> 2 | Op_or -> 1 | Op_plus -> 4 | Op_minus -> 4 | Op_mult -> 5 | Op_div -> 5 | Op_mod -> 5 | Op_pow -> 5 | Op_concat -> 5 | Op_during ... |
let variable_has_whitespace ( n : string ) : bool = String . contains n ' ' || String . contains n ' \ t ' |
let cnl_print_variable ff n = if ( variable_has_whitespace n ) then fprintf ff " ' % s ' " n else fprintf ff " % s " n |
let cnl_print_kind kind = begin match kind with | K_expr _ -> " expr " | K_actn -> " action " | K_evnt -> " event " | K_cond -> " condition " | K_actns -> " actions " | K_actns_closed -> " actions_closed " | K_rule -> " rule " end |
let cnl_print_id kind ff ( i : id ) = begin match i with | None -> ( ) | Some i -> fprintf ff " { % s % i } " ( cnl_print_kind kind ) i end |
let cnl_print_node fpart kind ff part = begin match part with | N_undefined i -> fprintf ff " [ UNDEFINED % a ] " ( cnl_print_id kind ) i | N_filled ( i , x ) -> fprintf ff " [ % a % a ] " ( cnl_print_id kind ) i fpart x | N_rejected ( i , x ) -> fprintf ff " [ REJECTED... |
let rec cnl_print_expr prec ff e = cnl_print_expr_desc prec ff e . expr_node let printer ff x = begin match x with | E_lit l -> cnl_print_literal prec ff l | E_var n -> cnl_print_variable ff n | E_get ( e , fname ) -> fprintf ff " the % s of % a " fname ( cnl_print_expr prec ) e | E_agg ( a... |
let cnl_print_expr_top = cnl_print_expr 0 |
let cnl_print_evnt ff evnt = let printer ff w = let ( ename , ovname ) = w in begin match ovname with | None -> fprintf ff " a % s occurs " ename | Some vname -> fprintf ff " a % s occurs , called ' % s ' " ename vname end in fprintf ff " [ @< hv 2 > when % a ; @< 0 - 2 ] "... |
let cnl_print_cond ff cond = begin match cond . cond_node with | N_undefined _ -> let printer ff i = ( ) in fprintf ff " [ @< hv 2 > if % a ; @< 0 - 2 ] " >@ ( cnl_print_node printer K_cond ) cond . cond_node | _ -> let printer ff i = begin match i with | C_condition i -> fprin... |
let cnl_print_actn ff a = let printer ff ad = begin match ad with | A_print e -> fprintf ff " print % a " ( cnl_print_expr 0 ) e | A_emit e -> fprintf ff " emit % a " ( cnl_print_expr 0 ) e | A_define ( vname , e ) -> fprintf ff " define ' % s ' as @ % a " vname ( cnl_prin... |
let rec cnl_print_actns_desc ff al = begin match al with | [ ] -> ( ) | [ a ] -> fprintf ff " % a ; " cnl_print_actn a | a :: al ' -> fprintf ff " % a ; @ % a " cnl_print_actn a cnl_print_actns_desc al ' end |
let cnl_print_actns ff actns = let printer ff t = fprintf ff " % a " cnl_print_actns_desc t . list_elems in fprintf ff " [ @< hv 2 > then % a ; @< 0 - 2 ] " >@ ( cnl_print_node printer K_actns ) actns . actns_node |
let cnl_print_rule_desc ff r = fprintf ff " % a @ % a @ % a " cnl_print_evnt r . rule_evnt cnl_print_cond r . rule_cond cnl_print_actns r . rule_actns |
let cnl_print_rule ff r = cnl_print_node cnl_print_rule_desc K_rule ff r . rule_node |
let cnl_print_rule_top r = let ff = str_formatter in begin fprintf ff " [ @% a ] . " @@ cnl_print_rule r ; flush_str_formatter ( ) end |
let empty_init ( ) = let evnt = mk_evnt_undefined ( ) in let cond = mk_cond_undefined ( ) in let actns = mk_actns_undefined ( ) in let r0 = mk_rule_f evnt cond actns in index_rule r0 |
let rule_init = ref None |
let set_rule_init r = rule_init := Some r |
let rule_init ( ) = begin match ! rule_init with | None -> empty_init ( ) | Some r -> r end |
let cond_init ( ) : cnl_cond_desc = C_condition ( mk_expr_undefined ( ) ) |
let actns_init ( ) : cnl_actns_desc = { list_elems = [ mk_actn_undefined ( ) ] ; list_closed = N_undefined None ; } |
let print_init ( ) : cnl_actn_desc = A_print ( mk_expr_undefined ( ) ) |
let emit_init ( ) : cnl_actn_desc = A_emit ( mk_expr_undefined ( ) ) |
let define_init vname : cnl_actn_desc = A_define ( vname , mk_expr_undefined ( ) ) |
let set_init vname fname : cnl_actn_desc = A_set ( vname , fname , mk_expr_undefined ( ) ) |
let define1 = mk_define_f " the exception " ( mk_new_event_f " exception " [ ( " reason " , mk_concat_list_f [ mk_string_f " The account for " ; mk_get_f ( mk_get_var_f " customer " " the account " ) " email " ; mk_string_f " is risky and below the average balance for ri... |
let emit1 = mk_emit_f ( mk_new_event_f " authorization response " [ ( " account " , mk_var_f " the account " ) ; ( " message " , mk_concat_list_f [ mk_string_f " R04 : the account for " ; mk_get_f ( mk_get_var_f " the account " " customer " ) " email " ; mk_st... |
let when1 = ( " transaction " , Some " the transaction " ) |
let cond1 = C_condition ( mk_lt_f ( mk_get_var_f " balance " " the account " ) ( mk_expr_f ( E_var " Average Risky Account Balance " ) ) ) |
let then1 = { list_elems = [ mk_print_f ( mk_concat_f ( mk_string_f " aggregate " ) ( mk_var_f " Average Risky Account Balance " ) ) ; mk_print_f ( mk_concat_f ( mk_string_f " balance " ) ( mk_get_var_f " balance " " the account " ) ) ; define1 ; emit1 ; ] ; ... |
let rule1 = mk_rule_init when1 cond1 then1 |
let define21 = mk_define_f " rpmAverage " ( mk_div_f ( mk_plus_f ( mk_get_var_f " average engine rpm " " the airplane " ) ( mk_get_f ( mk_get_f ( mk_this_f " airplane " ) " engine " ) " rpm " ) ) ( mk_int_f 2 ) ) |
let define22 = mk_define_f " pressureAverage " ( mk_div_f ( mk_plus_f ( mk_get_var_f " average engine pressure ratio " " the airplane " ) ( mk_get_f ( mk_get_f ( mk_this_f " airplane " ) " engine " ) " pressure ratio " ) ) ( mk_int_f 2 ) ) |
let setdesc21 = mk_set_desc_f " average engine rpm " " the airplane " ( mk_var_f " rpmAverage " ) |
let setdesc22 = mk_set_desc_f " average engine pressure ratio " " the airplane " ( mk_var_f " pressureAverage " ) |
let set21 = mk_set_f " average engine rpm " " the airplane " ( mk_var_f " rpmAverage " ) |
let set22 = mk_set_f " average engine pressure ratio " " the airplane " ( mk_var_f " pressureAverage " ) |
let rule2 = mk_rule_init ( " airplane " , None ) C_no_condition { list_elems = [ define21 ; define22 ; set21 ; set22 ; ] ; list_closed = N_filled ( None , ( ) ) ; } |
let cnl_samples = [ ( " rule_init " , rule_init ( ) ) ; ( " rule1un1 " , index_rule rule1 ) ; ( " rule1 " , rule_f_to_a rule1 ) ; ( " rule2 " , rule2 ) ; ] |
let expr1 = mk_expr_undefined ( ) |
let expr2 = mk_expr_undefined ( ) |
let ( ) >>= x f = match x with Ok x -> f x | ( Error _ ) as x -> x |
let ( ) >|= x f = x >>= fun x -> Ok ( f x ) |
let rec map_bind f acc xs = match xs with | x :: xs -> f x >>= fun x -> map_bind f ( x :: acc ) xs | [ ] -> Ok ( List . rev acc ) |
type ' a error_or = ( ' a , string ) result |
type location = ( Lexing . position * Lexing . position ) |
let location_to_yojson pos = ` Null |
let location_of_yojson j = Ok ( { Lexing . pos_fname = " " ; Lexing . pos_lnum = 0 ; Lexing . pos_bol = 0 ; Lexing . pos_cnum = 0 } , { Lexing . pos_fname = " " ; Lexing . pos_lnum = 0 ; Lexing . pos_bol = 0 ; Lexing . pos_cnum = 0 } ) |
let default_loc = ( ( Parsing . symbol_start_pos ( ) ) , ( Parsing . symbol_end_pos ( ) ) ) |
type id = int option |
let rec ( id_to_yojson : id -> Yojson . Safe . json ) = ( ( function | None -> ` Null | Some x -> ( ( fun x -> ` Int x ) ) x ) [ @ ocaml . warning " - A " ] ) Yojson . Safe . json -> id error_or ) = ( ( function | ` Null -> Ok None | x -> ( ( functio... |
type ' a node = | N_undefined of id | N_filled of id * ' a | N_rejected of id * ' a | N_accepted of ' a |
let rec node_to_yojson : ' a . ( ' a -> Yojson . Safe . json ) -> ' a node -> Yojson . Safe . json = fun poly_a -> ( ( function | N_undefined arg0 -> ` List [ ` String " N_undefined " ; ( ( fun x -> id_to_yojson x ) ) arg0 ] | N_filled ( arg0 , arg1 ) -> ` ... |
type ' a node_list = { list_elems : ' a list ; list_closed : unit node ; } |
let rec node_list_to_yojson : ' a . ( ' a -> Yojson . Safe . json ) -> ' a node_list -> Yojson . Safe . json = fun poly_a -> ( ( fun x -> let fields = [ ] in let fields = ( " list_closed " , ( ( fun x -> ( node_to_yojson ( fun x -> ` Null ) ) x ) x . list... |
type cnl_rule = { rule_node : cnl_rule_desc node ; rule_loc : ( ( location ) [ @ default default_loc ] ) ; } { rule_evnt : cnl_event ; rule_cond : cnl_cond ; rule_actns : cnl_actions ; } { evnt_node : cnl_evnt_desc node ; evnt_loc : ( ( location ) [ @ default default_... |
let rec ( cnl_rule_to_yojson : cnl_rule -> Yojson . Safe . json ) = ( ( fun x -> let fields = [ ] in let fields = if x . rule_loc = default_loc then fields else ( " rule_loc " , ( ( ( fun x -> location_to_yojson x ) ) x . rule_loc ) ) :: fields in let fields = ( " ... |
type cnl_kind = | K_expr of ( event_name * field_name ) option | K_actn | K_evnt | K_cond | K_actns | K_actns_closed | K_rule |
type cnl_ast = | Cnl_expr of cnl_expr | Cnl_actn of cnl_action | Cnl_evnt of cnl_event | Cnl_cond of cnl_cond | Cnl_actns of cnl_actions | Cnl_rule of cnl_rule |
let string_of_cnl_agg agg = begin match agg with | A_total -> " total " | A_avg -> " average " end |
let string_of_cnl_unop op = begin match op with | Op_not -> " not " | Op_toString -> " toString " end |
let string_of_cnl_binop op = begin match op with | Op_eq -> " is " | Op_ne -> " is not " | Op_lt -> " is less than " | Op_le -> " is under " | Op_gt -> " is more than " | Op_ge -> " is over " | Op_and -> " and " | Op_or -> " or " | Op_plus -> " " + | Op_minus ->... |
let node_desc node = begin match node with | N_undefined _ -> None | N_filled ( _ , desc ) | N_rejected ( _ , desc ) | N_accepted desc -> Some desc end |
let node_id node = begin match node with | N_undefined id | N_filled ( id , _ ) | N_rejected ( id , _ ) -> Some id | N_accepted _ -> None end |
let find_node_kind ( id : id ) ( kind : cnl_kind ) ( node : ' a node ) ( acc : cnl_kind option ) : cnl_kind option = begin match node with | N_undefined id ' | N_filled ( id ' , _ ) | N_rejected ( id ' , _ ) -> if id = id ' then begin match acc with | None -> Some ki... |
let find_node_kind_fold_fun ( id : id ) = let f kind node acc = find_node_kind id kind node acc in { Cnl2cnl . id_fold_over_node_fun with Cnl2cnl . poly_fold_fun = f } |
let rule_find_node_kind ( id : id ) ( rule : cnl_rule ) : cnl_kind option = Cnl2cnl . rule_dp_fold_over_nodes ( find_node_kind_fold_fun id ) rule None |
let get_node_ids ( kind : cnl_kind ) ( node : ' a node ) ( acc : ( id * cnl_kind * unit node ) list ) : ( id * cnl_kind * unit node ) list = begin match node with | N_undefined id -> ( id , kind , N_undefined id ) :: acc | N_filled ( id , _ ) -> ( id , kind , N_f... |
let get_node_ids_fold_fun = { Cnl2cnl . id_fold_over_node_fun with Cnl2cnl . poly_fold_fun = get_node_ids } |
let rule_get_node_ids ( rule : cnl_rule ) : ( id * cnl_kind * unit node ) list = Cnl2cnl . rule_dp_fold_over_nodes get_node_ids_fold_fun rule [ ] |
let get_undefined ( kind : cnl_kind ) ( node : ' a node ) ( acc : ( id * cnl_kind ) list ) : ( id * cnl_kind ) list = begin match node with | N_undefined id -> ( id , kind ) :: acc | N_filled ( _ , _ ) | N_rejected ( _ , _ ) | N_accepted _ -> acc end |
let get_undefined_fold_fun = { Cnl2cnl . id_fold_over_node_fun with Cnl2cnl . poly_fold_fun = get_undefined } |
let rule_get_undefined ( rule : cnl_rule ) : ( id * cnl_kind ) list = Cnl2cnl . rule_dp_fold_over_nodes get_undefined_fold_fun rule [ ] |
let evnt_get_undefined ( evnt : cnl_event ) : ( id * cnl_kind ) list = Cnl2cnl . evnt_dp_fold_over_nodes get_undefined_fold_fun evnt [ ] |
let cond_get_undefined ( cond : cnl_cond ) : ( id * cnl_kind ) list = Cnl2cnl . cond_dp_fold_over_nodes get_undefined_fold_fun cond [ ] |
let actns_get_undefined ( actns : cnl_actions ) : ( id * cnl_kind ) list = Cnl2cnl . actns_dp_fold_over_nodes get_undefined_fold_fun actns [ ] |
let actn_get_undefined ( actn : cnl_action ) : ( id * cnl_kind ) list = Cnl2cnl . actn_dp_fold_over_nodes get_undefined_fold_fun actn [ ] |
let expr_get_undefined ( expr : cnl_expr ) : ( id * cnl_kind ) list = Cnl2cnl . expr_dp_fold_over_nodes get_undefined_fold_fun expr [ ] |
let get_filled ( kind : cnl_kind ) ( node : ' a node ) ( acc : ( id * cnl_kind ) list ) : ( id * cnl_kind ) list = begin match node with | N_filled ( id , _ ) -> ( id , kind ) :: acc | N_undefined _ | N_rejected ( _ , _ ) | N_accepted _ -> acc end |
let get_filled_fold_fun = { Cnl2cnl . id_fold_over_node_fun with Cnl2cnl . poly_fold_fun = get_filled } |
let rule_get_filled ( rule : cnl_rule ) : ( id * cnl_kind ) list = Cnl2cnl . rule_dp_fold_over_nodes get_filled_fold_fun rule [ ] |
let evnt_get_filled ( evnt : cnl_event ) : ( id * cnl_kind ) list = Cnl2cnl . evnt_dp_fold_over_nodes get_filled_fold_fun evnt [ ] |
let cond_get_filled ( cond : cnl_cond ) : ( id * cnl_kind ) list = Cnl2cnl . cond_dp_fold_over_nodes get_filled_fold_fun cond [ ] |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.